No Description
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

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