暫無描述
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CheckinDialogOperations.cs 5.5KB

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