| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223 |
- using System.Collections.Generic;
- using Codice.Client.BaseCommands;
- using Codice.Client.BaseCommands.EventTracking;
- using Codice.CM.Common;
- using GluonGui.WorkspaceWindow.Views.Checkin.Operations;
- using PlasticGui;
- using Unity.PlasticSCM.Editor.AssetUtils;
- using Unity.PlasticSCM.Editor.UI;
- using Unity.PlasticSCM.Editor.Views.PendingChanges.Dialogs;
- namespace Unity.PlasticSCM.Editor.Views.PendingChanges
- {
- internal partial class PendingChangesTab
- {
- void CheckinForMode(WorkspaceInfo wkInfo, bool isGluonMode, bool keepItemsLocked)
- {
- TrackFeatureUseEvent.For(
- PlasticGui.Plastic.API.GetRepositorySpec(wkInfo),
- isGluonMode ?
- TrackFeatureUseEvent.Features.PartialCheckin :
- TrackFeatureUseEvent.Features.Checkin);
- if (isGluonMode)
- {
- PartialCheckin(keepItemsLocked);
- return;
- }
- Checkin();
- }
- void UndoForMode(WorkspaceInfo wkInfo, bool isGluonMode)
- {
- TrackFeatureUseEvent.For(
- PlasticGui.Plastic.API.GetRepositorySpec(wkInfo),
- isGluonMode ?
- TrackFeatureUseEvent.Features.PartialUndo :
- TrackFeatureUseEvent.Features.Undo);
- if (isGluonMode)
- {
- PartialUndo();
- return;
- }
- Undo();
- }
- void UndoChangesForMode(
- bool isGluonMode,
- List<ChangeInfo> changesToUndo,
- List<ChangeInfo> dependenciesCandidates)
- {
- if (isGluonMode)
- {
- PartialUndoChanges(changesToUndo, dependenciesCandidates);
- return;
- }
- UndoChanges(changesToUndo, dependenciesCandidates);
- }
- void PartialCheckin(bool keepItemsLocked)
- {
- List<ChangeInfo> changesToCheckin;
- List<ChangeInfo> dependenciesCandidates;
- mPendingChangesTreeView.GetCheckedChanges(
- false,
- out changesToCheckin,
- out dependenciesCandidates);
- if (CheckEmptyOperation(changesToCheckin))
- {
- ((IProgressControls)mProgressControls).ShowWarning(
- PlasticLocalization.GetString(PlasticLocalization.Name.NoItemsAreSelected));
- return;
- }
- bool isCancelled;
- SaveAssets.ForChangesWithConfirmation(changesToCheckin, out isCancelled);
- if (isCancelled)
- return;
- CheckinUIOperation ciOperation = new CheckinUIOperation(
- mWkInfo, mViewHost, mProgressControls, mGuiMessage,
- new LaunchCheckinConflictsDialog(mParentWindow),
- new LaunchDependenciesDialog(
- PlasticLocalization.GetString(PlasticLocalization.Name.CheckinButton),
- mParentWindow),
- this, mWorkspaceWindow.GluonProgressOperationHandler);
- ciOperation.Checkin(
- changesToCheckin,
- dependenciesCandidates,
- CommentText,
- keepItemsLocked,
- RefreshAsset.UnityAssetDatabase);
- }
- void Checkin()
- {
- List<ChangeInfo> changesToCheckin;
- List<ChangeInfo> dependenciesCandidates;
- mPendingChangesTreeView.GetCheckedChanges(
- false, out changesToCheckin, out dependenciesCandidates);
- if (CheckEmptyOperation(changesToCheckin, HasPendingMergeLinks()))
- {
- ((IProgressControls)mProgressControls).ShowWarning(
- PlasticLocalization.GetString(PlasticLocalization.Name.NoItemsAreSelected));
- return;
- }
- bool isCancelled;
- SaveAssets.ForChangesWithConfirmation(changesToCheckin, out isCancelled);
- if (isCancelled)
- return;
- mPendingChangesOperations.Checkin(
- changesToCheckin,
- dependenciesCandidates,
- CommentText,
- null,
- EndCheckin);
- }
- void PartialUndo()
- {
- List<ChangeInfo> changesToUndo;
- List<ChangeInfo> dependenciesCandidates;
- mPendingChangesTreeView.GetCheckedChanges(
- true, out changesToUndo, out dependenciesCandidates);
- PartialUndoChanges(changesToUndo, dependenciesCandidates);
- }
- void Undo()
- {
- List<ChangeInfo> changesToUndo;
- List<ChangeInfo> dependenciesCandidates;
- mPendingChangesTreeView.GetCheckedChanges(
- true, out changesToUndo, out dependenciesCandidates);
- UndoChanges(changesToUndo, dependenciesCandidates);
- }
- void PartialUndoChanges(
- List<ChangeInfo> changesToUndo,
- List<ChangeInfo> dependenciesCandidates)
- {
- if (CheckEmptyOperation(changesToUndo))
- {
- ((IProgressControls)mProgressControls).ShowWarning(
- PlasticLocalization.GetString(PlasticLocalization.Name.NoItemsToUndo));
- return;
- }
- SaveAssets.ForChangesWithoutConfirmation(changesToUndo);
- UndoUIOperation undoOperation = new UndoUIOperation(
- mWkInfo, mViewHost,
- new LaunchDependenciesDialog(
- PlasticLocalization.GetString(PlasticLocalization.Name.UndoButton),
- mParentWindow),
- mProgressControls, mGuiMessage);
- undoOperation.Undo(
- changesToUndo,
- dependenciesCandidates,
- RefreshAsset.UnityAssetDatabase);
- }
- void UndoChanges(
- List<ChangeInfo> changesToUndo,
- List<ChangeInfo> dependenciesCandidates)
- {
- if (CheckEmptyOperation(changesToUndo, HasPendingMergeLinks()))
- {
- ((IProgressControls)mProgressControls).ShowWarning(
- PlasticLocalization.GetString(PlasticLocalization.Name.NoItemsToUndo));
- return;
- }
- SaveAssets.ForChangesWithoutConfirmation(changesToUndo);
- mPendingChangesOperations.Undo(
- changesToUndo,
- dependenciesCandidates,
- mPendingMergeLinks.Count,
- RefreshAsset.UnityAssetDatabase);
- }
- void EndCheckin()
- {
- // TODO: Localization
- mNotificationDrawer.Notify("Checkin successfully completed", UnityEditor.MessageType.None, Images.Name.StepOk);
- RefreshAsset.UnityAssetDatabase();
- }
- static bool CheckEmptyOperation(List<ChangeInfo> elements)
- {
- return elements == null || elements.Count == 0;
- }
- static bool CheckEmptyOperation(List<ChangeInfo> elements, bool bHasPendingMergeLinks)
- {
- if (bHasPendingMergeLinks)
- return false;
- if (elements != null && elements.Count > 0)
- return false;
- return true;
- }
- }
- }
|