Пример #1
0
        static void DoHeader(
            string conflictName,
            IncomingChangeInfo conflict,
            Action <IncomingChangeInfo> resolveConflictAction,
            bool isResolveButtonEnabled,
            ref ConflictResolutionState state)
        {
            EditorGUILayout.BeginHorizontal();

            GUILayout.Label(conflictName,
                            UnityStyles.DirectoryConflicts.TitleLabel);

            GUI.enabled = isResolveButtonEnabled;

            GUILayout.Space(5);

            if (GUILayout.Button(PlasticLocalization.GetString(
                                     PlasticLocalization.Name.ResolveDirectoryConflict)))
            {
                resolveConflictAction(conflict);
            }

            GUI.enabled = true;

            GUILayout.FlexibleSpace();
            EditorGUILayout.EndHorizontal();
        }
Пример #2
0
        static void DoApplyActionsForNextConflictsCheck(
            int pendingConflictsCount,
            ref ConflictResolutionState state)
        {
            if (pendingConflictsCount == 0)
            {
                return;
            }

            GUILayout.Space(5);

            bool isCheckEnabled = state.ResolveAction != DirectoryConflictResolveActions.Rename;
            bool isChecked      = state.IsApplyActionsForNextConflictsChecked & isCheckEnabled;

            GUI.enabled = isCheckEnabled;
            EditorGUILayout.BeginHorizontal();

            state.IsApplyActionsForNextConflictsChecked = !GUILayout.Toggle(
                isChecked,
                GetApplyActionCheckButtonText(pendingConflictsCount));

            if (!isCheckEnabled)
            {
                state.IsApplyActionsForNextConflictsChecked = false;
            }

            GUILayout.FlexibleSpace();
            EditorGUILayout.EndHorizontal();
            GUI.enabled = true;
        }
Пример #3
0
        internal static void ForConflict(
            IncomingChangeInfo conflict,
            int pendingConflictsCount,
            DirectoryConflictUserInfo conflictUserInfo,
            DirectoryConflictAction[] actions,
            Action <IncomingChangeInfo> resolveConflictAction,
            ref ConflictResolutionState state)
        {
            bool   isResolveButtonEnabled;
            string validationMessage = null;

            GetValidationData(
                conflict,
                state,
                out isResolveButtonEnabled,
                out validationMessage);

            GUILayout.Space(2);
            DoHeader(
                conflictUserInfo.ConflictTitle,
                conflict,
                resolveConflictAction,
                isResolveButtonEnabled,
                ref state);
            DoConflictExplanation(conflictUserInfo.ConflictExplanation);
            DoSourceAndDestinationLabels(
                conflictUserInfo.SourceOperation,
                conflictUserInfo.DestinationOperation);
            DoResolutionOptions(
                actions,
                validationMessage,
                ref state);
            DoApplyActionsForNextConflictsCheck(pendingConflictsCount, ref state);
            GUILayout.Space(10);
        }
Пример #4
0
        internal static ConflictResolutionState Build(
            DirectoryConflict directoryConflict,
            DirectoryConflictAction[] conflictActions)
        {
            bool hasRenameOption = DirectoryConflictResolutionInfo.HasRenameOption(
                conflictActions);

            ConflictResolutionState result = new ConflictResolutionState()
            {
                IsApplyActionsForNextConflictsChecked = false,
                ResolveAction = (hasRenameOption) ?
                                DirectoryConflictResolveActions.Rename :
                                DirectoryConflictResolveActions.KeepSource,
            };

            if (!hasRenameOption)
            {
                return(result);
            }


            result.RenameValue = DirectoryConflictResolutionInfo.GetProposeNewItemName(
                directoryConflict, "dst");

            return(result);
        }
Пример #5
0
        static void GetValidationData(
            IncomingChangeInfo conflict,
            ConflictResolutionState state,
            out bool isResolveButtonEnabled,
            out string renameWarningMessage)
        {
            if (state.ResolveAction != DirectoryConflictResolveActions.Rename)
            {
                renameWarningMessage   = string.Empty;
                isResolveButtonEnabled = true;
                return;
            }

            isResolveButtonEnabled = IsValidName(
                state.RenameValue,
                conflict.DirectoryConflict,
                out renameWarningMessage);
        }
Пример #6
0
        static void DoResolutionOptions(
            DirectoryConflictAction[] actions,
            string validationMessage,
            ref ConflictResolutionState state)
        {
            GUILayout.Space(10);
            GUILayout.Label(PlasticLocalization.GetString(
                                PlasticLocalization.Name.ResolveDirectoryConflictChooseOption));

            foreach (DirectoryConflictAction action in actions)
            {
                EditorGUILayout.BeginHorizontal();
                GUILayout.Space(25);
                if (GUILayout.Toggle(
                        state.ResolveAction == action.ActionKind,
                        action.ActionText,
                        EditorStyles.radioButton))
                {
                    state.ResolveAction = action.ActionKind;
                }

                if (action.ActionKind == DirectoryConflictResolveActions.Rename)
                {
                    GUI.enabled       = state.ResolveAction == DirectoryConflictResolveActions.Rename;
                    state.RenameValue = GUILayout.TextField(
                        state.RenameValue,
                        UnityStyles.DirectoryConflicts.FileNameTextField,
                        GUILayout.Width(250));
                    GUI.enabled = true;

                    if (!string.IsNullOrEmpty(validationMessage))
                    {
                        GUILayout.Label(new GUIContent(
                                            validationMessage,
                                            Images.GetWarnIcon()),
                                        UnityStyles.DirectoryConflictResolution.WarningLabel,
                                        GUILayout.Height(UnityConstants.DIR_CONFLICT_VALIDATION_WARNING_LABEL_HEIGHT));
                    }
                }

                GUILayout.FlexibleSpace();
                EditorGUILayout.EndHorizontal();
            }
        }