CheckinDialogOperations.cs
5.3 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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
using System;
using System.Collections.Generic;
using Codice.Client.BaseCommands;
using Codice.Client.Commands.CheckIn;
using Codice.Client.Common;
using Codice.Client.Common.Threading;
using Codice.Client.GameUI.Checkin;
using Codice.CM.Common;
using GluonGui;
using PlasticGui;
using PlasticGui.Gluon;
using PlasticGui.WorkspaceWindow.PendingChanges;
namespace Unity.PlasticSCM.Editor.AssetMenu.Dialogs
{
internal static class CheckinDialogOperations
{
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);
});
}
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);
});
}
static bool UserWantsToShowIncomingView(GuiMessage.IGuiMessage guiMessage)
{
GuiMessage.GuiMessageResponseButton result = guiMessage.ShowQuestion(
PlasticLocalization.GetString(PlasticLocalization.Name.CheckinConflictsTitle),
PlasticLocalization.GetString(PlasticLocalization.Name.UnityCheckinConflictsExplanation),
"",
PlasticLocalization.GetString(PlasticLocalization.Name.CheckinShowIncomingChangesView),
PlasticLocalization.GetString(PlasticLocalization.Name.CancelButton),
false);
return result == GuiMessage.GuiMessageResponseButton.Second;
}
}
}