Example #1
0
        public static unsafe void CalculateImageDiff(
            IImageDiffView diffView, IProgressControls progressControls,
            byte *leftBitmapData, byte *rightBitmapData, int leftLen, int rightLen)
        {
            if (leftLen != rightLen)
            {
                progressControls.ShowInformation(DIFF_SIZE_INFO_MESSSAGE);
                return;
            }

            byte[] resultDiffImage = null;

            progressControls.ShowProgress();

            IThreadWaiter waiter = ThreadWaiter.GetWaiter();

            waiter.Execute(
                /*threadOperationDelegate*/ delegate
            {
                resultDiffImage = PixelDiff(leftBitmapData, rightBitmapData, leftLen);
            },
                /*afterOperationDelegate*/ delegate
            {
                progressControls.HideProgress();

                if (waiter.Exception != null)
                {
                    progressControls.ShowError(waiter.Exception.Message);
                    return;
                }

                diffView.SetDiffImageBytes(resultDiffImage);
            });
        }
Example #2
0
            internal static void IfRepositoryIsEmpty(
                WorkspaceInfo wkInfo,
                string repository,
                bool isGluonWorkspace,
                IPlasticAPI plasticApi,
                IProgressControls progressControls,
                ICreateWorkspaceListener createWorkspaceListener,
                PlasticWindow plasticWindow)
            {
                RepositoryInfo repInfo           = null;
                bool           isEmptyRepository = false;

                progressControls.ShowProgress(string.Empty);

                IThreadWaiter waiter = ThreadWaiter.GetWaiter(10);

                waiter.Execute(
                    /*threadOperationDelegate*/ delegate
                {
                    RepositorySpec repSpec = new SpecGenerator().
                                             GenRepositorySpec(false, repository);

                    repInfo = plasticApi.GetRepositoryInfo(repSpec);

                    isEmptyRepository = IsEmptyRepositoryCondition.
                                        Evaluate(wkInfo, repSpec, plasticApi);
                },
                    /*afterOperationDelegate*/ delegate
                {
                    progressControls.HideProgress();

                    if (waiter.Exception != null)
                    {
                        DisplayException(progressControls, waiter.Exception);
                        return;
                    }

                    if (!SetupCloudProjectId.HasCloudProjectId())
                    {
                        SetupCloudProjectId.ForRepository(repInfo);
                    }

                    if (!isEmptyRepository)
                    {
                        plasticWindow.RefreshWorkspaceUI();
                        AssetMenu.AssetMenuItems.Enable();
                        return;
                    }

                    CheckinPackagesAndProjectSettingsFolders(
                        wkInfo, isGluonWorkspace, plasticApi,
                        progressControls, createWorkspaceListener);
                });
            }
Example #3
0
        internal static void CheckinPathsPartial(
            WorkspaceInfo wkInfo,
            List <string> paths,
            string comment,
            ViewHost viewHost,
            CheckinDialog dialog,
            GuiMessage.IGuiMessage guiMessage,
            IProgressControls progressControls,
            IGluonViewSwitcher gluonViewSwitcher)
        {
            BaseCommandsImpl baseCommands = new BaseCommandsImpl();

            progressControls.ShowProgress(PlasticLocalization.GetString(
                                              PlasticLocalization.Name.CheckinInFilesProgress));

            IThreadWaiter waiter = ThreadWaiter.GetWaiter(50);

            waiter.Execute(
                /*threadOperationDelegate*/ delegate
            {
                baseCommands.PartialCheckin(wkInfo, paths, comment);
            },
                /*afterOperationDelegate*/ delegate
            {
                progressControls.HideProgress();

                ((IPlasticDialogCloser)dialog).CloseDialog();

                if (waiter.Exception is CheckinConflictsException)
                {
                    // we need to explicitly call EditorWindow.Close() to ensure
                    // that the dialog is closed before asking the user
                    dialog.Close();

                    if (!UserWantsToShowIncomingView(guiMessage))
                    {
                        return;
                    }

                    gluonViewSwitcher.ShowIncomingChangesView();
                    return;
                }

                if (waiter.Exception != null)
                {
                    ExceptionsHandler.DisplayException(waiter.Exception);
                    return;
                }

                viewHost.RefreshView(ViewType.CheckinView);
                viewHost.RefreshView(ViewType.HistoryView);
            });
        }
        public void AddElement(
            string element,
            IApplicationWindow window,
            IProgressControls progressControls)
        {
            if (string.IsNullOrEmpty(element))
            {
                progressControls.ShowError(
                    Localization.GetText(
                        Localization.Name.ElementCantBeEmptyErrorMessage));
                return;
            }

            progressControls.ShowProgress(
                Localization.GetText(
                    Localization.Name.AddingElementProgressText,
                    element));

            IThreadWaiter waiter = ThreadWaiter.GetWaiter();

            waiter.Execute(
                threadOperationDelegate: () =>
            {
                DoHeavyWork();

                if (mModel.Contains(element))
                {
                    throw new Exception(
                        Localization.GetText(
                            Localization.Name.ElementInTheListErrorMessage, element));
                }

                mModel.Add(element);
                mModel.Sort(StringComparer.Ordinal);
            },
                afterOperationDelegate: () =>
            {
                progressControls.HideProgress();

                if (waiter.Exception != null)
                {
                    GuiMessage.ShowError(
                        Localization.GetText(Localization.Name.ErrorTitle),
                        waiter.Exception.Message);
                    return;
                }

                window.UpdateItems(mModel);
                window.ClearInput();
            });
        }
            static void CheckinPackagesAndProjectSettingsFolders(
                WorkspaceInfo wkInfo,
                bool isGluonWorkspace,
                IPlasticAPI plasticApi,
                IProgressControls progressControls,
                ICreateWorkspaceListener createWorkspaceListener)
            {
                List <string> paths = new List <string> {
                    Path.Combine(wkInfo.ClientPath, "Packages"),
                    Path.Combine(wkInfo.ClientPath, "ProjectSettings")
                };

                string comment = PlasticLocalization.GetString(
                    PlasticLocalization.Name.UnityInitialCheckinComment);

                progressControls.ShowProgress(PlasticLocalization.GetString(
                                                  PlasticLocalization.Name.UnityInitialCheckinProgress));

                IThreadWaiter waiter = ThreadWaiter.GetWaiter(10);

                waiter.Execute(
                    /*threadOperationDelegate*/ delegate
                {
                    PerformAdd(paths, plasticApi);

                    PerformCheckinForMode(
                        wkInfo, paths, comment, isGluonWorkspace);
                },
                    /*afterOperationDelegate*/ delegate
                {
                    progressControls.HideProgress();

                    if (waiter.Exception != null &&
                        !IsMergeNeededException(waiter.Exception))
                    {
                        DisplayException(progressControls, waiter.Exception);
                        return;
                    }

                    createWorkspaceListener.OnWorkspaceCreated(
                        wkInfo, isGluonWorkspace);
                });
            }
Example #6
0
        void PartialUpdateWorkspace()
        {
            mProgressControls.ShowProgress(PlasticLocalization.GetString(
                                               PlasticLocalization.Name.UpdatingWorkspace));

            ((IUpdateProgress)mGluonProgressOperationHandler).ShowCancelableProgress();

            OutOfDateUpdater outOfDateUpdater = new OutOfDateUpdater(mWkInfo);

            BuildProgressSpeedAndRemainingTime.ProgressData progressData =
                new BuildProgressSpeedAndRemainingTime.ProgressData(DateTime.Now);

            IThreadWaiter waiter = ThreadWaiter.GetWaiter();

            waiter.Execute(
                /*threadOperationDelegate*/ delegate
            {
                outOfDateUpdater.Execute();
            },
                /*afterOperationDelegate*/ delegate
            {
                mProgressControls.HideProgress();

                ((IUpdateProgress)mGluonProgressOperationHandler).EndProgress();

                mViewHost.RefreshView(ViewType.CheckinView);
                mViewHost.RefreshView(ViewType.IncomingChangesView);

                RefreshAsset.UnityAssetDatabase();

                if (waiter.Exception != null)
                {
                    ExceptionsHandler.DisplayException(waiter.Exception);
                    return;
                }

                ShowUpdateReportDialog(
                    mWkInfo, mViewHost, outOfDateUpdater.Progress, mProgressControls,
                    mGuiMessage, mGluonProgressOperationHandler, this);
            },
                /*timerTickDelegate*/ delegate
            {
                UpdateProgress progress = outOfDateUpdater.Progress;

                if (progress == null)
                {
                    return;
                }

                if (progress.IsCanceled)
                {
                    mProgressControls.ShowNotification(
                        PlasticLocalization.GetString(PlasticLocalization.Name.Canceling));
                }

                ((IUpdateProgress)mGluonProgressOperationHandler).RefreshProgress(
                    progress,
                    UpdateProgressDataCalculator.CalculateProgressForWorkspaceUpdate(
                        mWkInfo.ClientPath, progress, progressData));
            });
        }
Example #7
0
        internal static void CheckinPaths(
            WorkspaceInfo wkInfo,
            List <string> paths,
            string comment,
            IWorkspaceWindow workspaceWindow,
            CheckinDialog dialog,
            GuiMessage.IGuiMessage guiMessage,
            IProgressControls progressControls,
            IMergeViewLauncher mergeViewLauncher)
        {
            BaseCommandsImpl baseCommands = new BaseCommandsImpl();

            progressControls.ShowProgress("Checkin in files");

            IThreadWaiter waiter = ThreadWaiter.GetWaiter(50);

            waiter.Execute(
                /*threadOperationDelegate*/ delegate
            {
                CheckinParams ciParams = new CheckinParams();
                ciParams.paths         = paths.ToArray();
                ciParams.comment       = comment;
                ciParams.time          = DateTime.MinValue;
                ciParams.flags         = CheckinFlags.Recurse | CheckinFlags.ProcessSymlinks;

                baseCommands.CheckIn(ciParams);
            },
                /*afterOperationDelegate*/ delegate
            {
                progressControls.HideProgress();
                ((IPlasticDialogCloser)dialog).CloseDialog();

                if (waiter.Exception is CmClientMergeNeededException ||
                    waiter.Exception is CmClientUpdateMergeNeededException)
                {
                    // we need to explicitly call EditorWindow.Close() to ensure
                    // that the dialog is closed before asking the user
                    dialog.Close();

                    if (!UserWantsToShowIncomingView(guiMessage))
                    {
                        return;
                    }

                    ShowIncomingChanges.FromCheckin(
                        wkInfo,
                        mergeViewLauncher,
                        progressControls);

                    return;
                }

                if (waiter.Exception != null)
                {
                    ExceptionsHandler.DisplayException(waiter.Exception);
                    return;
                }

                workspaceWindow.RefreshView(ViewType.PendingChangesView);
                workspaceWindow.RefreshView(ViewType.HistoryView);
            });
        }
Example #8
0
        void LaunchMigration(
            string unityAccessToken,
            string projectPath,
            string organizationName,
            RepId repId,
            long changesetId,
            long branchId,
            Action afterWorkspaceMigratedAction,
            IProgressControls progressControls)
        {
            string serverName = string.Format(
                "{0}@cloud", organizationName);

            progressControls.ShowProgress(
                "Migrating project to Plastic SCM...");

            TokenExchangeResponse tokenExchangeResponse = null;
            WorkspaceInfo         workspaceInfo         = null;

            IThreadWaiter waiter = ThreadWaiter.GetWaiter(10);

            waiter.Execute(
                /*threadOperationDelegate*/
                delegate
            {
                // we just migrate a cloud project,
                // so let's assume we're going to use Cloud Edition
                SetupUnityEditionToken.CreateCloudEditionTokenIfNeeded();

                if (!ClientConfig.IsConfigured())
                {
                    AutoConfigClientConf.FromUnityAccessToken(
                        unityAccessToken, serverName, projectPath);
                }

                tokenExchangeResponse = WebRestApiClient.
                                        PlasticScm.TokenExchange(unityAccessToken);

                if (tokenExchangeResponse.Error != null)
                {
                    return;
                }

                CloudEditionWelcomeWindow.JoinCloudServer(
                    serverName,
                    tokenExchangeResponse.User,
                    tokenExchangeResponse.AccessToken);

                RepositoryInfo repInfo = new BaseCommandsImpl().
                                         GetRepositoryInfo(repId, serverName);

                if (repInfo == null)
                {
                    return;
                }

                repInfo.SetExplicitServer(serverName);

                workspaceInfo = CreateWorkspaceFromCollab.Create(
                    projectPath, repInfo.Name, repInfo,
                    changesetId, branchId,
                    new CreateWorkspaceFromCollab.Progress());
            },
                /*afterOperationDelegate*/
                delegate
            {
                progressControls.HideProgress();

                if (waiter.Exception != null)
                {
                    DisplayException(progressControls, waiter.Exception);
                    return;
                }

                if (tokenExchangeResponse.Error != null)
                {
                    mLog.ErrorFormat(
                        "Unable to get TokenExchangeResponse: {0} [code {1}]",
                        tokenExchangeResponse.Error.Message,
                        tokenExchangeResponse.Error.ErrorCode);
                }

                if (tokenExchangeResponse.Error != null ||
                    workspaceInfo == null)
                {
                    progressControls.ShowError(
                        "Failed to migrate the project to Plastic SCM");
                    return;
                }

                progressControls.ShowSuccess(
                    "The project migration to Plastic SCM is completed successfully");

                mIsMigrationCompleted = true;

                afterWorkspaceMigratedAction();
            });
        }