ProgressOperationHandler.cs
3.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
using Codice.Client.BaseCommands;
using Codice.Client.Commands.CheckIn;
using Codice.Client.Common;
using Codice.CM.Common;
using PlasticGui;
using PlasticGui.WorkspaceWindow;
namespace Unity.PlasticSCM.Editor.Developer
{
internal class ProgressOperationHandler
{
internal ProgressOperationHandler(WorkspaceInfo wkInfo, WorkspaceWindow workspaceWindow)
{
mWkInfo = wkInfo;
mWorkspaceWindow = workspaceWindow;
}
internal void Update(double elapsedSeconds)
{
if (mUpdateProgress == null)
return;
mSecondsSinceLastProgressUpdate += elapsedSeconds;
if (mSecondsSinceLastProgressUpdate > UPDATE_INTERVAL_SECONDS)
{
mUpdateProgress.OnUpdateProgress();
mSecondsSinceLastProgressUpdate -= UPDATE_INTERVAL_SECONDS;
}
}
internal bool CheckOperationInProgress()
{
if (IsOperationInProgress())
{
GuiMessage.ShowInformation(
PlasticLocalization.GetString(PlasticLocalization.Name.OperationRunning),
PlasticLocalization.GetString(PlasticLocalization.Name.OperationInProgress));
return true;
}
return false;
}
internal bool IsOperationInProgress()
{
return mProgress != null
|| mUpdateProgress != null
|| mCheckinProgress != null;
}
internal void ShowProgress()
{
mProgress = new GenericProgress(mWorkspaceWindow);
}
internal void RefreshProgress(ProgressData progressData)
{
mProgress.RefreshProgress(progressData);
}
internal void EndProgress()
{
mProgress = null;
mWorkspaceWindow.Progress.ResetProgress();
mWorkspaceWindow.RequestRepaint();
}
internal void ShowUpdateProgress(string title, UpdateNotifier notifier)
{
mUpdateProgress = new UpdateProgress(
notifier, mWkInfo.ClientPath, title, mWorkspaceWindow);
mUpdateProgress.OnUpdateProgress();
mSecondsSinceLastProgressUpdate = 0;
}
internal void ShowCheckinProgress()
{
mCheckinProgress = new CheckinProgress(mWkInfo, mWorkspaceWindow);
}
internal void RefreshCheckinProgress(
CheckinStatus checkinStatus,
BuildProgressSpeedAndRemainingTime.ProgressData progressData)
{
mCheckinProgress.Refresh(checkinStatus, progressData);
}
internal void CancelCheckinProgress()
{
mCheckinProgress.CancelPressed = true;
}
internal void EndUpdateProgress()
{
mUpdateProgress = null;
mWorkspaceWindow.Progress.ResetProgress();
mWorkspaceWindow.RequestRepaint();
}
internal void EndCheckinProgress()
{
mCheckinProgress = null;
mWorkspaceWindow.Progress.ResetProgress();
mWorkspaceWindow.RequestRepaint();
}
internal bool HasCheckinCancelled()
{
return mCheckinProgress.CancelPressed;
}
double mSecondsSinceLastProgressUpdate = 0;
GenericProgress mProgress;
UpdateProgress mUpdateProgress;
CheckinProgress mCheckinProgress;
WorkspaceInfo mWkInfo;
WorkspaceWindow mWorkspaceWindow;
const double UPDATE_INTERVAL_SECONDS = 0.5;
}
}