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.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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. waiter.Exception is CmClientUpdateMergeNeededException)
  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. });
  66. }
  67. internal static void CheckinPathsPartial(
  68. WorkspaceInfo wkInfo,
  69. List<string> paths,
  70. string comment,
  71. ViewHost viewHost,
  72. CheckinDialog dialog,
  73. GuiMessage.IGuiMessage guiMessage,
  74. IProgressControls progressControls,
  75. IGluonViewSwitcher gluonViewSwitcher)
  76. {
  77. BaseCommandsImpl baseCommands = new BaseCommandsImpl();
  78. progressControls.ShowProgress(PlasticLocalization.GetString(
  79. PlasticLocalization.Name.CheckinInFilesProgress));
  80. IThreadWaiter waiter = ThreadWaiter.GetWaiter(50);
  81. waiter.Execute(
  82. /*threadOperationDelegate*/ delegate
  83. {
  84. baseCommands.PartialCheckin(wkInfo, paths, comment);
  85. },
  86. /*afterOperationDelegate*/ delegate
  87. {
  88. progressControls.HideProgress();
  89. ((IPlasticDialogCloser)dialog).CloseDialog();
  90. if (waiter.Exception is CheckinConflictsException)
  91. {
  92. // we need to explicitly call EditorWindow.Close() to ensure
  93. // that the dialog is closed before asking the user
  94. dialog.Close();
  95. if (!UserWantsToShowIncomingView(guiMessage))
  96. return;
  97. gluonViewSwitcher.ShowIncomingChangesView();
  98. return;
  99. }
  100. if (waiter.Exception != null)
  101. {
  102. ExceptionsHandler.DisplayException(waiter.Exception);
  103. return;
  104. }
  105. viewHost.RefreshView(ViewType.CheckinView);
  106. viewHost.RefreshView(ViewType.HistoryView);
  107. });
  108. }
  109. static bool UserWantsToShowIncomingView(GuiMessage.IGuiMessage guiMessage)
  110. {
  111. GuiMessage.GuiMessageResponseButton result = guiMessage.ShowQuestion(
  112. PlasticLocalization.GetString(PlasticLocalization.Name.CheckinConflictsTitle),
  113. PlasticLocalization.GetString(PlasticLocalization.Name.UnityCheckinConflictsExplanation),
  114. PlasticLocalization.GetString(PlasticLocalization.Name.CheckinShowIncomingChangesView),
  115. PlasticLocalization.GetString(PlasticLocalization.Name.CancelButton),
  116. null);
  117. return result == GuiMessage.GuiMessageResponseButton.Positive;
  118. }
  119. }
  120. }