123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
-
- using UnityEditor;
-
- using Codice.Client.BaseCommands;
- using Codice.Client.Commands.CheckIn;
- using Codice.Client.Common;
- using Codice.Client.Common.Threading;
- using Codice.CM.Common;
- using Codice.CM.Common.Replication;
- using GluonGui.WorkspaceWindow.Views;
- using GluonGui;
- using GluonGui.WorkspaceWindow.Views.WorkspaceExplorer.Explorer;
- using PlasticGui;
- using PlasticGui.WorkspaceWindow;
- using PlasticGui.WorkspaceWindow.Topbar;
- using PlasticGui.WorkspaceWindow.Replication;
- using PlasticGui.WorkspaceWindow.Update;
- using Unity.PlasticSCM.Editor.AssetUtils;
- using Unity.PlasticSCM.Editor.Configuration;
- using Unity.PlasticSCM.Editor.Developer.UpdateReport;
- using Unity.PlasticSCM.Editor.UI;
- using Unity.PlasticSCM.Editor.UI.Progress;
-
- using IGluonUpdateReport = PlasticGui.Gluon.IUpdateReport;
- using IGluonWorkspaceStatusChangeListener = PlasticGui.Gluon.IWorkspaceStatusChangeListener;
- using GluonUpdateReportDialog = Unity.PlasticSCM.Editor.Gluon.UpdateReport.UpdateReportDialog;
-
- namespace Unity.PlasticSCM.Editor
- {
- internal class WorkspaceWindow :
- IWorkspaceWindow,
- IRefreshView,
- IUpdateReport,
- IGluonUpdateReport,
- IGluonWorkspaceStatusChangeListener
- {
- internal void SetUpdateNotifierForTesting(UpdateNotifier updateNotifier)
- {
- mUpdateNotifierForTesting = updateNotifier;
- }
- internal WorkspaceStatusString.Data WorkspaceStatus { get; private set; }
- internal OperationProgressData Progress { get { return mOperationProgressData; } }
-
- internal Gluon.ProgressOperationHandler GluonProgressOperationHandler
- {
- get { return mGluonProgressOperationHandler; }
- }
-
- internal WorkspaceWindow(
- WorkspaceInfo wkInfo,
- ViewHost viewHost,
- ViewSwitcher switcher,
- IMergeViewLauncher mergeViewLauncher,
- NewIncomingChangesUpdater developerNewIncomingChangesUpdater,
- EditorWindow parentWindow)
- {
- mWkInfo = wkInfo;
- mViewHost = viewHost;
- mSwitcher = switcher;
- mMergeViewLauncher = mergeViewLauncher;
- mDeveloperNewIncomingChangesUpdater = developerNewIncomingChangesUpdater;
- mPlasticWindow = parentWindow;
- mGuiMessage = new UnityPlasticGuiMessage();
-
- mDeveloperProgressOperationHandler = new Developer.ProgressOperationHandler(mWkInfo, this);
- mGluonProgressOperationHandler = new Gluon.ProgressOperationHandler(this);
- mOperationProgressData = new OperationProgressData();
-
- ((IWorkspaceWindow)this).UpdateTitle();
- }
-
- internal bool IsOperationInProgress()
- {
- return mDeveloperProgressOperationHandler.IsOperationInProgress()
- || mGluonProgressOperationHandler.IsOperationInProgress();
- }
-
- internal void CancelCurrentOperation()
- {
- if (mDeveloperProgressOperationHandler.IsOperationInProgress())
- {
- mDeveloperProgressOperationHandler.CancelCheckinProgress();
- return;
- }
-
- if (mGluonProgressOperationHandler.IsOperationInProgress())
- {
- mGluonProgressOperationHandler.CancelUpdateProgress();
- return;
- }
- }
-
- internal void OnParentUpdated(double elapsedSeconds)
- {
- if (IsOperationInProgress() || mRequestedRepaint)
- {
- if (mDeveloperProgressOperationHandler.IsOperationInProgress())
- mDeveloperProgressOperationHandler.Update(elapsedSeconds);
-
- mPlasticWindow.Repaint();
-
- mRequestedRepaint = false;
- }
- }
-
- internal void RequestRepaint()
- {
- mRequestedRepaint = true;
- }
-
- internal void UpdateWorkspace()
- {
- UpdateWorkspaceOperation update = new UpdateWorkspaceOperation(
- mWkInfo, this, mSwitcher, mMergeViewLauncher, this,
- mDeveloperNewIncomingChangesUpdater,
- null);
-
- update.Run(
- UpdateWorkspaceOperation.UpdateType.UpdateToLatest,
- RefreshAsset.UnityAssetDatabase,
- null);
- }
-
- void IWorkspaceWindow.RefreshView(ViewType viewType)
- {
- mSwitcher.RefreshView(viewType);
- }
-
- void IWorkspaceWindow.RefreshWorkingObjectViews(
- ViewType viewType,
- WorkingObjectInfo workingObjectInfo)
- {
- mSwitcher.RefreshWorkingObjectInfoForSelectedView(
- viewType,
- workingObjectInfo);
- }
-
- void IWorkspaceWindow.UpdateTitle()
- {
- UpdateWorkspaceTitle();
- }
-
- bool IWorkspaceWindow.CheckOperationInProgress()
- {
- return mDeveloperProgressOperationHandler.CheckOperationInProgress();
- }
-
- void IWorkspaceWindow.ShowUpdateProgress(string title, UpdateNotifier notifier)
- {
- mDeveloperProgressOperationHandler.ShowUpdateProgress(title, mUpdateNotifierForTesting ?? notifier);
- }
-
- void IWorkspaceWindow.EndUpdateProgress()
- {
- mDeveloperProgressOperationHandler.EndUpdateProgress();
- }
-
- void IWorkspaceWindow.ShowCheckinProgress()
- {
- mDeveloperProgressOperationHandler.ShowCheckinProgress();
- }
-
- void IWorkspaceWindow.EndCheckinProgress()
- {
- mDeveloperProgressOperationHandler.EndCheckinProgress();
- }
-
- void IWorkspaceWindow.RefreshCheckinProgress(
- CheckinStatus checkinStatus,
- BuildProgressSpeedAndRemainingTime.ProgressData progressData)
- {
- mDeveloperProgressOperationHandler.
- RefreshCheckinProgress(checkinStatus, progressData);
- }
-
- bool IWorkspaceWindow.HasCheckinCancelled()
- {
- return mDeveloperProgressOperationHandler.HasCheckinCancelled();
- }
-
- void IWorkspaceWindow.ShowReplicationProgress(IReplicationOperation replicationOperation)
- {
- throw new NotImplementedException();
- }
-
- void IWorkspaceWindow.RefreshReplicationProgress(BranchReplicationData replicationData, ReplicationStatus replicationStatus, int current, int total)
- {
- throw new NotImplementedException();
- }
-
- void IWorkspaceWindow.EndReplicationProgress(ReplicationStatus replicationStatus)
- {
- throw new NotImplementedException();
- }
-
- void IWorkspaceWindow.ShowProgress()
- {
- mDeveloperProgressOperationHandler.ShowProgress();
- }
-
- void IWorkspaceWindow.ShowProgress(IProgressOperation progressOperation)
- {
- throw new NotImplementedException();
- }
-
- void IWorkspaceWindow.RefreshProgress(ProgressData progressData)
- {
- mDeveloperProgressOperationHandler.RefreshProgress(progressData);
- }
-
- void IWorkspaceWindow.EndProgress()
- {
- mDeveloperProgressOperationHandler.EndProgress();
- }
-
- EncryptionConfigurationDialogData IWorkspaceWindow.RequestEncryptionPassword(string server)
- {
- return EncryptionConfigurationDialog.RequestEncryptionPassword(server, mPlasticWindow);
- }
-
- void IRefreshView.ForType(ViewType viewType)
- {
- mSwitcher.RefreshView(viewType);
- }
-
- void IUpdateReport.Show(WorkspaceInfo wkInfo, IList reportLines)
- {
- UpdateReportDialog.ShowReportDialog(
- wkInfo,
- reportLines,
- mPlasticWindow);
- }
-
- void IGluonUpdateReport.AppendReport(string updateReport)
- {
- }
-
- void IGluonWorkspaceStatusChangeListener.OnWorkspaceStatusChanged()
- {
- UpdateWorkspaceTitle();
- }
-
- void UpdateWorkspaceTitle()
- {
- WorkspaceStatusString.Data status = null;
-
- IThreadWaiter waiter = ThreadWaiter.GetWaiter();
- waiter.Execute(
- /*threadOperationDelegate*/ delegate
- {
- status = WorkspaceStatusString.GetSelectorData(mWkInfo);
- },
- /*afterOperationDelegate*/ delegate
- {
- if (waiter.Exception != null)
- return;
-
- WorkspaceStatus = status;
-
- RequestRepaint();
- });
- }
-
- bool mRequestedRepaint;
-
- UpdateNotifier mUpdateNotifierForTesting;
- IProgressControls mProgressControls;
-
- readonly OperationProgressData mOperationProgressData;
- readonly Developer.ProgressOperationHandler mDeveloperProgressOperationHandler;
- readonly Gluon.ProgressOperationHandler mGluonProgressOperationHandler;
- readonly GuiMessage.IGuiMessage mGuiMessage;
- readonly EditorWindow mPlasticWindow;
- readonly NewIncomingChangesUpdater mDeveloperNewIncomingChangesUpdater;
- readonly IMergeViewLauncher mMergeViewLauncher;
- readonly ViewSwitcher mSwitcher;
- readonly ViewHost mViewHost;
- readonly WorkspaceInfo mWkInfo;
-
- internal void RegisterPendingChangesProgressControls(
- ProgressControlsForViews progressControls)
- {
- mProgressControls = progressControls;
- }
-
- internal void UpdateWorkspaceForMode(
- bool isGluonMode,
- WorkspaceWindow workspaceWindow)
- {
- if (isGluonMode)
- {
- PartialUpdateWorkspace();
- return;
- }
-
- UpdateWorkspace();
- }
-
- UpdateReportResult IGluonUpdateReport.ShowUpdateReport(
- WorkspaceInfo wkInfo, List<ErrorMessage> errors)
- {
- return GluonUpdateReportDialog.ShowUpdateReport(
- wkInfo, errors, mPlasticWindow);
- }
-
- void PartialUpdateWorkspace()
- {
- mProgressControls.ShowProgress(PlasticLocalization.GetString(
- PlasticLocalization.Name.UpdatingWorkspace));
-
- ((IUpdateProgress)mGluonProgressOperationHandler).ShowCancelableProgress();
-
- OutOfDateUpdater outOfDateUpdater = new OutOfDateUpdater(mWkInfo, null);
-
- 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));
- });
- }
-
- static void ShowUpdateReportDialog(
- WorkspaceInfo wkInfo,
- ViewHost viewHost,
- UpdateProgress progress,
- IProgressControls progressControls,
- GuiMessage.IGuiMessage guiMessage,
- IUpdateProgress updateProgress,
- IGluonUpdateReport updateReport)
- {
- if (progress.ErrorMessages.Count == 0)
- return;
-
- UpdateReportResult updateReportResult =
- updateReport.ShowUpdateReport(wkInfo, progress.ErrorMessages);
-
- if (!updateReportResult.IsUpdateForcedRequested())
- return;
-
- UpdateForcedOperation updateForced = new UpdateForcedOperation(
- wkInfo, viewHost, progress, progressControls,
- guiMessage, updateProgress, updateReport);
-
- updateForced.UpdateForced(
- updateReportResult.UpdateForcedPaths,
- updateReportResult.UnaffectedErrors);
- }
- }
- }
|