A game about forced loneliness, made by TACStudios
1using System;
2using System.Collections.Generic;
3
4using Codice.Client.BaseCommands;
5using Codice.Client.Commands.CheckIn;
6using Codice.Client.Common;
7using Codice.Client.Common.Threading;
8using Codice.Client.GameUI.Checkin;
9using Codice.CM.Common;
10using Codice.CM.Common.Checkin.Partial;
11
12using GluonGui;
13
14using PlasticGui;
15using PlasticGui.Gluon;
16using PlasticGui.WorkspaceWindow.PendingChanges;
17
18namespace Unity.PlasticSCM.Editor.AssetMenu.Dialogs
19{
20 internal static class CheckinDialogOperations
21 {
22 internal static void CheckinPaths(
23 WorkspaceInfo wkInfo,
24 List<string> paths,
25 string comment,
26 IWorkspaceWindow workspaceWindow,
27 CheckinDialog dialog,
28 GuiMessage.IGuiMessage guiMessage,
29 IProgressControls progressControls,
30 IMergeViewLauncher mergeViewLauncher)
31 {
32 BaseCommandsImpl baseCommands = new BaseCommandsImpl();
33
34 progressControls.ShowProgress("Checkin in files");
35
36 IThreadWaiter waiter = ThreadWaiter.GetWaiter(50);
37 waiter.Execute(
38 /*threadOperationDelegate*/ delegate
39 {
40 CheckinParams ciParams = new CheckinParams();
41 ciParams.paths = paths.ToArray();
42 ciParams.comment = comment;
43 ciParams.time = DateTime.MinValue;
44 ciParams.flags = CheckinFlags.Recurse | CheckinFlags.ProcessSymlinks;
45
46 baseCommands.CheckIn(ciParams);
47 },
48 /*afterOperationDelegate*/ delegate
49 {
50 progressControls.HideProgress();
51 ((IPlasticDialogCloser)dialog).CloseDialog();
52
53 if (waiter.Exception is CmClientMergeNeededException)
54 {
55 // we need to explicitly call EditorWindow.Close() to ensure
56 // that the dialog is closed before asking the user
57 dialog.Close();
58
59 if (!UserWantsToShowIncomingView(guiMessage))
60 return;
61
62 ShowIncomingChanges.FromCheckin(
63 wkInfo,
64 mergeViewLauncher,
65 progressControls);
66
67 return;
68 }
69
70 if (waiter.Exception != null)
71 {
72 ExceptionsHandler.DisplayException(waiter.Exception);
73 return;
74 }
75
76 workspaceWindow.RefreshView(ViewType.PendingChangesView);
77 workspaceWindow.RefreshView(ViewType.HistoryView);
78 workspaceWindow.RefreshView(ViewType.BranchesView);
79 workspaceWindow.RefreshView(ViewType.ChangesetsView);
80 workspaceWindow.RefreshView(ViewType.LocksView);
81 });
82 }
83
84 internal static void CheckinPathsPartial(
85 WorkspaceInfo wkInfo,
86 List<string> paths,
87 string comment,
88 ViewHost viewHost,
89 CheckinDialog dialog,
90 GuiMessage.IGuiMessage guiMessage,
91 IProgressControls progressControls,
92 IGluonViewSwitcher gluonViewSwitcher)
93 {
94 BaseCommandsImpl baseCommands = new BaseCommandsImpl();
95
96 progressControls.ShowProgress(PlasticLocalization.GetString(
97 PlasticLocalization.Name.CheckinInFilesProgress));
98
99 IThreadWaiter waiter = ThreadWaiter.GetWaiter(50);
100 waiter.Execute(
101 /*threadOperationDelegate*/ delegate
102 {
103 baseCommands.PartialCheckin(wkInfo, paths, comment);
104 },
105 /*afterOperationDelegate*/ delegate
106 {
107 progressControls.HideProgress();
108
109 ((IPlasticDialogCloser)dialog).CloseDialog();
110
111 if (waiter.Exception is CheckinConflictsException)
112 {
113 // we need to explicitly call EditorWindow.Close() to ensure
114 // that the dialog is closed before asking the user
115 dialog.Close();
116
117 if (!UserWantsToShowIncomingView(guiMessage))
118 return;
119
120 gluonViewSwitcher.ShowIncomingChangesView();
121 return;
122 }
123
124 if (waiter.Exception != null)
125 {
126 ExceptionsHandler.DisplayException(waiter.Exception);
127 return;
128 }
129
130 viewHost.RefreshView(ViewType.CheckinView);
131 viewHost.RefreshView(ViewType.HistoryView);
132 viewHost.RefreshView(ViewType.LocksView);
133 });
134 }
135
136 static bool UserWantsToShowIncomingView(GuiMessage.IGuiMessage guiMessage)
137 {
138 GuiMessage.GuiMessageResponseButton result = guiMessage.ShowQuestion(
139 PlasticLocalization.GetString(PlasticLocalization.Name.CheckinConflictsTitle),
140 PlasticLocalization.GetString(PlasticLocalization.Name.UnityCheckinConflictsExplanation),
141 PlasticLocalization.GetString(PlasticLocalization.Name.CheckinShowIncomingChangesView),
142 PlasticLocalization.GetString(PlasticLocalization.Name.CancelButton),
143 null);
144
145 return result == GuiMessage.GuiMessageResponseButton.Positive;
146 }
147 }
148}