internal static void ForWorkspace( WorkspaceInfo wkInfo, IPlasticAPI plasticApi) { RepositoryInfo repInfo = null; IThreadWaiter waiter = ThreadWaiter.GetWaiter(10); waiter.Execute( /*threadOperationDelegate*/ delegate { RepositorySpec repSpec = plasticApi.GetRepositorySpec(wkInfo); repInfo = plasticApi.GetRepositoryInfo(repSpec); }, /*afterOperationDelegate*/ delegate { if (waiter.Exception != null) { ExceptionsHandler.LogException( "SetupCloudProjectId", waiter.Exception); return; } SetupCloudProjectId.ForRepository(repInfo); }); }
void ExchangeTokensAndJoinOrganization(string unityAccessToken) { int ini = Environment.TickCount; TokenExchangeResponse response = null; IThreadWaiter waiter = ThreadWaiter.GetWaiter(10); waiter.Execute( /*threadOperationDelegate*/ delegate { mPlasticWindow.GetWelcomeView().autoLoginState = AutoLogin.State.ResponseInit; response = PlasticScmRestApiClient.TokenExchange(unityAccessToken); }, /*afterOperationDelegate*/ delegate { mLog.DebugFormat( "TokenExchange time {0} ms", Environment.TickCount - ini); if (waiter.Exception != null) { mPlasticWindow.GetWelcomeView().autoLoginState = AutoLogin.State.ErrorTokenException; ExceptionsHandler.LogException( "TokenExchangeSetting", waiter.Exception); return; } if (response == null) { mPlasticWindow.GetWelcomeView().autoLoginState = AutoLogin.State.ErrorResponseNull; Debug.Log("response null"); return; } if (response.Error != null) { mPlasticWindow.GetWelcomeView().autoLoginState = AutoLogin.State.ErrorResponseError; mLog.ErrorFormat( "Unable to exchange token: {0} [code {1}]", response.Error.Message, response.Error.ErrorCode); return; } if (string.IsNullOrEmpty(response.AccessToken)) { mPlasticWindow.GetWelcomeView().autoLoginState = AutoLogin.State.ErrorTokenEmpty; mLog.InfoFormat( "Access token is empty for user: {0}", response.User); return; } mPlasticWindow.GetWelcomeView().autoLoginState = AutoLogin.State.ResponseEnd; sAccessToken = response.AccessToken; sUserName = response.User; GetOrganizationList(); }); }
static void InviteMemberButton_clicked(object obj) { WorkspaceInfo wkInfo = (WorkspaceInfo)obj; CurrentUserAdminCheckResponse response = null; IThreadWaiter waiter = ThreadWaiter.GetWaiter(50); waiter.Execute( /*threadOperationDelegate*/ delegate { RepositorySpec repSpec = PlasticGui.Plastic.API.GetRepositorySpec(wkInfo); ServerProfile serverProfile = CmConnection.Get().GetProfileManager().GetProfileForServer(repSpec.Server) ?? ClientConfig.Get().GetDefaultProfile(); string authToken = CmConnection.Get() .BuildWebApiTokenForCloudEditionForProfileAndOrg( serverProfile); response = WebRestApiClient.PlasticScm.IsUserAdmin( ServerOrganizationParser.GetOrganizationFromServer(repSpec.Server), authToken); }, /*afterOperationDelegate*/ delegate { if (waiter.Exception != null) { ExceptionsHandler.LogException( "IsUserAdmin", waiter.Exception); return; } if (response.Error != null) { Debug.LogErrorFormat( "Error checking if the user is the organization admin: {0}", string.Format("Unable to get IsUserAdminResponse: {0} [code {1}]", response.Error.Message, response.Error.ErrorCode)); return; } if (response.IsCurrentUserAdmin) { Application.OpenURL("https://www.plasticscm.com/dashboard/cloud/" + response.OrganizationName + "/users-and-groups"); return; } GuiMessage.ShowInformation( PlasticLocalization.GetString(PlasticLocalization.Name.InviteMembersTitle), PlasticLocalization.GetString(PlasticLocalization.Name.InviteMembersMessage)); }); }
internal static void ForWorkspace( WorkspaceInfo wkInfo, IPlasticAPI plasticApi) { if (HasCloudProjectId()) { return; } string repGuid = null; IThreadWaiter waiter = ThreadWaiter.GetWaiter(10); waiter.Execute( /*threadOperationDelegate*/ delegate { RepositorySpec repSpec = plasticApi.GetRepositorySpec(wkInfo); RepositoryInfo repInfo = plasticApi.GetRepositoryInfo(repSpec); repGuid = repInfo.GUID.ToString(); }, /*afterOperationDelegate*/ delegate { if (waiter.Exception != null) { ExceptionsHandler.LogException( "SetupCloudProjectId", waiter.Exception); } ConfigureCloudProjectId(repGuid); }); }
static void DisplayException( ProgressControlsForMigration progressControls, Exception ex) { ExceptionsHandler.LogException( "MigrationDialog", ex); progressControls.ShowError( ExceptionsHandler.GetCorrectExceptionMessage(ex)); }
static void DisplayException( IProgressControls progressControls, Exception ex) { ExceptionsHandler.LogException( "CreateWorkspaceView", ex); progressControls.ShowError( ExceptionsHandler.GetCorrectExceptionMessage(ex)); }
internal void ExchangeTokens(string unityAccessToken) { int ini = Environment.TickCount; TokenExchangeResponse response = null; IThreadWaiter waiter = ThreadWaiter.GetWaiter(10); waiter.Execute( /*threadOperationDelegate*/ delegate { response = PlasticScmRestApiClient.TokenExchange(unityAccessToken); }, /*afterOperationDelegate*/ delegate { mLog.DebugFormat( "TokenExchange time {0} ms", Environment.TickCount - ini); if (waiter.Exception != null) { ExceptionsHandler.LogException( "TokenExchangeSetting", waiter.Exception); return; } if (response == null) { Debug.Log("response null"); return; } if (response.Error != null) { mLog.ErrorFormat( "Unable to exchange token: {0} [code {1}]", response.Error.Message, response.Error.ErrorCode); return; } if (string.IsNullOrEmpty(response.AccessToken)) { mLog.InfoFormat( "Access token is empty for user: {0}", response.User); return; } sAccessToken = response.AccessToken; sUserName = response.User; }); }
void AsyncCalculateStatus(CancelToken cancelToken) { Dictionary <string, LockStatusData> statusByPathCache = null; IThreadWaiter waiter = ThreadWaiter.GetWaiter(50); waiter.Execute( /*threadOperationDelegate*/ delegate { Dictionary <RepositorySpec, List <WorkspaceTreeNode> > lockCandidates = new Dictionary <RepositorySpec, List <WorkspaceTreeNode> >(); FillLockCandidates.ForTree(mWkInfo, lockCandidates); if (cancelToken.IsCancelled()) { return; } Dictionary <WorkspaceTreeNode, LockInfo> lockInfoByNode = SearchLocks.GetLocksInfo(mWkInfo, lockCandidates); if (cancelToken.IsCancelled()) { return; } statusByPathCache = BuildStatusByNodeCache. ForLocks(mWkInfo.ClientPath, lockInfoByNode); }, /*afterOperationDelegate*/ delegate { if (waiter.Exception != null) { ExceptionsHandler.LogException( "LockStatusCache", waiter.Exception); return; } if (cancelToken.IsCancelled()) { return; } lock (mLock) { mStatusByPathCache = statusByPathCache; } mRepaintProjectWindow(); }); }
static void EnableUserBetaProgramIfNeeded(string unityAccessToken) { int ini = Environment.TickCount; UnityPackageBetaEnrollResponse response = null; IThreadWaiter waiter = ThreadWaiter.GetWaiter(10); waiter.Execute( /*threadOperationDelegate*/ delegate { response = PlasticScmRestApiClient.IsBetaEnabled(unityAccessToken); }, /*afterOperationDelegate*/ delegate { mLog.DebugFormat( "IsBetaEnabled time {0} ms", Environment.TickCount - ini); if (waiter.Exception != null) { ExceptionsHandler.LogException( "CalculateUserBetaProgramSetting", waiter.Exception); return; } if (response == null) { return; } if (response.Error != null) { mLog.ErrorFormat( "Unable to retrieve is beta enabled: {0} [code {1}]", response.Error.Message, response.Error.ErrorCode); return; } if (!response.IsBetaEnabled) { mLog.InfoFormat( "Beta is disabled for accessToken: {0}", unityAccessToken); return; } PlasticMenuItem.Add(); }); }
void AsyncCalculateStatus(CancelToken cancelToken) { Dictionary <string, AssetStatus> statusByPathCache = null; IThreadWaiter waiter = ThreadWaiter.GetWaiter(50); waiter.Execute( /*threadOperationDelegate*/ delegate { OutOfDateItems outOfDateItems = OutOfDateUpdater.CalculateOutOfDateItems( mWkInfo, new List <ErrorMessage>(), OutOfDateCalculator.Options.IsIncomingChanges); if (cancelToken.IsCancelled()) { return; } statusByPathCache = BuildStatusByPathCache. ForOutOfDateItems(outOfDateItems, mWkInfo.ClientPath); }, /*afterOperationDelegate*/ delegate { if (waiter.Exception != null) { ExceptionsHandler.LogException( "RemoteStatusCache", waiter.Exception); return; } if (cancelToken.IsCancelled()) { return; } lock (mLock) { mStatusByPathCache = statusByPathCache; } mRepaintProjectWindow(); }); }
void OnGUI() { if (mException != null) { DoExceptionErrorArea(); return; } try { // IMPORTANT: disable collab (if needed) // must be executed before the next if statement // where we check if collab is enabled if (mDisableCollabIfEnabledWhenLoaded) { mDisableCollabIfEnabledWhenLoaded = false; DisableCollabIfEnabled(ProjectPath.FromApplicationDataPath( Application.dataPath)); } if (CollabPlugin.IsEnabled()) { // execute Close() once after all inspectors update // to avoid our window to be drawn in back color EditorApplication.delayCall = Close; return; } bool isPlasticExeAvailable = IsExeAvailable.ForMode(mIsGluonMode); bool clientNeedsConfiguration = UnityConfigurationChecker.NeedsConfiguration(); var welcomeView = GetWelcomeView(); if (clientNeedsConfiguration && welcomeView.autoLoginState == AutoLogin.State.Off) { welcomeView.autoLoginState = AutoLogin.State.Started; } if (welcomeView.autoLoginState == AutoLogin.State.OrganizationChoosed) { OnEnable(); welcomeView.autoLoginState = AutoLogin.State.InitializingPlastic; } if (NeedsToDisplayWelcomeView(clientNeedsConfiguration, mWkInfo)) { welcomeView.OnGUI(clientNeedsConfiguration); return; } //TODO: Codice - beta: hide the switcher until the update dialog is implemented //DrawGuiModeSwitcher.ForMode( // isGluonMode, plasticClient, changesTreeView, editorWindow); DoTabToolbar( isPlasticExeAvailable, mWkInfo, mViewSwitcher, mIsGluonMode); mViewSwitcher.TabViewGUI(); if (mWorkspaceWindow.IsOperationInProgress()) { DrawProgressForOperations.For( mWorkspaceWindow, mWorkspaceWindow.Progress, position.width); } mStatusBar.OnGUI( mWkInfo, mWorkspaceWindow, mViewSwitcher, mViewSwitcher, mIncomingChangesNotifier, mIsGluonMode); } catch (Exception ex) { if (IsExitGUIException(ex)) { throw; } GUI.enabled = true; if (IsIMGUIPaintException(ex)) { ExceptionsHandler.LogException("PlasticWindow", ex); return; } mException = ex; DoExceptionErrorArea(); ExceptionsHandler.HandleException("OnGUI", ex); } }
static void InviteMemberButton_clicked(object obj) { RepositorySpec repSpec = (RepositorySpec)obj; string organizationName = ServerOrganizationParser. GetOrganizationFromServer(repSpec.Server); CurrentUserAdminCheckResponse response = null; IThreadWaiter waiter = ThreadWaiter.GetWaiter(50); waiter.Execute( /*threadOperationDelegate*/ delegate { ServerProfile serverProfile = CmConnection.Get(). GetProfileManager().GetProfileForServer(repSpec.Server); string authToken = serverProfile != null ? CmConnection.Get(). BuildWebApiTokenForCloudEditionForUser( serverProfile.Server, serverProfile.GetSEIDWorkingMode(), serverProfile.SecurityConfig): CmConnection.Get(). BuildWebApiTokenForCloudEditionForUser( repSpec.Server, ClientConfig.Get().GetSEIDWorkingMode(), ClientConfig.Get().GetSecurityConfig()); if (string.IsNullOrEmpty(authToken)) { authToken = CmConnection.Get(). BuildWebApiTokenForCloudEditionDefaultUser(); } if (string.IsNullOrEmpty(authToken)) { return; } response = WebRestApiClient.PlasticScm.IsUserAdmin( organizationName, authToken); }, /*afterOperationDelegate*/ delegate { if (waiter.Exception != null) { ExceptionsHandler.LogException( "IsUserAdmin", waiter.Exception); OpenCloudDashboardUsersGroupsUrl(organizationName); return; } if (response == null) { mLog.DebugFormat( "Error checking if the user is the organization admin for {0}", organizationName); OpenCloudDashboardUsersGroupsUrl(organizationName); return; } if (response.Error != null) { mLog.DebugFormat( "Error checking if the user is the organization admin: {0}", string.Format("Unable to get IsUserAdminResponse: {0} [code {1}]", response.Error.Message, response.Error.ErrorCode)); OpenCloudDashboardUsersGroupsUrl(organizationName); return; } if (response.IsCurrentUserAdmin) { OpenCloudDashboardUsersGroupsUrl(response.OrganizationName); return; } GuiMessage.ShowInformation( PlasticLocalization.GetString(PlasticLocalization.Name.InviteMembersTitle), PlasticLocalization.GetString(PlasticLocalization.Name.InviteMembersMessage)); }); }
void OnGUI() { if (mException != null) { DoExceptionErrorArea(); return; } try { bool isPlasticExeAvailable = IsExeAvailable.ForMode(mIsGluonMode); bool clientNeedsConfiguration = UnityConfigurationChecker.NeedsConfiguration(); if (NeedsToDisplayWelcomeView( isPlasticExeAvailable, clientNeedsConfiguration, mWkInfo)) { GetWelcomeView().OnGUI( isPlasticExeAvailable, clientNeedsConfiguration, mIsGluonMode); return; } DoHeader( mWkInfo, mPlasticClient, mViewSwitcher, mViewSwitcher, mIsGluonMode, mIncomingChangesNotificationPanel, mIncomingChangesFromMainNotificationPanel); DoTabToolbar( mWkInfo, mPlasticClient, mViewSwitcher, mIsGluonMode); mViewSwitcher.TabViewGUI(); if (mPlasticClient.IsOperationInProgress()) { DrawProgressForOperations.For( mPlasticClient, mPlasticClient.Progress, position.width); } } catch (Exception ex) { if (IsExitGUIException(ex)) { throw; } GUI.enabled = true; if (IsIMGUIPaintException(ex)) { ExceptionsHandler.LogException("PlasticWindow", ex); return; } mException = ex; DoExceptionErrorArea(); ExceptionsHandler.HandleException("OnGUI", ex); } }
static void LaunchMigrationIfProjectIsArchivedAndMigrated( string unityAccessToken, string projectPath, string projectGuid, string headCommitSha) { IsCollabProjectMigratedResponse isMigratedResponse = null; ChangesetFromCollabCommitResponse changesetResponse = null; IThreadWaiter waiter = ThreadWaiter.GetWaiter(10); waiter.Execute( /*threadOperationDelegate*/ delegate { isMigratedResponse = WebRestApiClient.PlasticScm. IsCollabProjectMigrated(unityAccessToken, projectGuid); if (isMigratedResponse.Error != null) { return; } if (!isMigratedResponse.IsMigrated) { return; } OrganizationCredentials credentials = new OrganizationCredentials(); credentials.User = isMigratedResponse.Credentials.Email; credentials.Password = isMigratedResponse.Credentials.Token; string webLoginAccessToken = WebRestApiClient.CloudServer.WebLogin( isMigratedResponse.WebServerUri, isMigratedResponse.PlasticCloudOrganizationName, credentials); changesetResponse = WebRestApiClient.CloudServer. GetChangesetFromCollabCommit( isMigratedResponse.WebServerUri, isMigratedResponse.PlasticCloudOrganizationName, webLoginAccessToken, projectGuid, headCommitSha); }, /*afterOperationDelegate*/ delegate { if (waiter.Exception != null) { ExceptionsHandler.LogException( "IsCollabProjectArchivedAndMigrated", waiter.Exception); return; } if (isMigratedResponse.Error != null) { mLog.ErrorFormat( "Unable to get IsCollabProjectMigratedResponse: {0} [code {1}]", isMigratedResponse.Error.Message, isMigratedResponse.Error.ErrorCode); return; } if (!isMigratedResponse.IsMigrated) { SessionState.SetInt( IS_PROJECT_MIGRATED_ALREADY_CALCULATED_KEY, MIGRATED_NOTHING_TO_DO); return; } if (changesetResponse.Error != null) { mLog.ErrorFormat( "Unable to get ChangesetFromCollabCommitResponse: {0} [code {1}]", changesetResponse.Error.Message, changesetResponse.Error.ErrorCode); return; } DeletePlasticDirectoryIfExists(projectPath); MigrationDialog.Show( null, unityAccessToken, projectPath, isMigratedResponse.PlasticCloudOrganizationName, new RepId( changesetResponse.RepId, changesetResponse.RepModuleId), changesetResponse.ChangesetId, changesetResponse.BranchId, AfterWorkspaceMigrated); }); }
void OnGUI() { if (mException != null) { DoExceptionErrorArea(); return; } try { // IMPORTANT: disable collab (if needed) // must be executed before the next if statement // where we check if collab is enabled if (mDisableCollabIfEnabledWhenLoaded) { mDisableCollabIfEnabledWhenLoaded = false; DisableCollabIfEnabled(ProjectPath.FromApplicationDataPath( Application.dataPath)); } if (CollabPlugin.IsEnabled()) { // execute Close() once after all inspectors update // to avoid our window to be drawn in back color EditorApplication.delayCall = Close; return; } bool isPlasticExeAvailable = IsExeAvailable.ForMode(mIsGluonMode); bool clientNeedsConfiguration = UnityConfigurationChecker.NeedsConfiguration(); if (NeedsToDisplayWelcomeView( isPlasticExeAvailable, clientNeedsConfiguration, mWkInfo)) { GetWelcomeView().OnGUI( isPlasticExeAvailable, clientNeedsConfiguration, mIsGluonMode); return; } DoHeader( mWkInfo, mPlasticClient, mViewSwitcher, mViewSwitcher, mIsGluonMode, mIncomingChangesNotificationPanel); DoTabToolbar( mWkInfo, mPlasticClient, mViewSwitcher, mIsGluonMode); mViewSwitcher.TabViewGUI(); if (mPlasticClient.IsOperationInProgress()) { DrawProgressForOperations.For( mPlasticClient, mPlasticClient.Progress, position.width); } } catch (Exception ex) { if (IsExitGUIException(ex)) { throw; } GUI.enabled = true; if (IsIMGUIPaintException(ex)) { ExceptionsHandler.LogException("PlasticWindow", ex); return; } mException = ex; DoExceptionErrorArea(); ExceptionsHandler.HandleException("OnGUI", ex); } }