Exemplo n.º 1
0
        static void DoRadioButtonsArea(
            ref CreateWorkspaceViewState state)
        {
            EditorGUILayout.BeginHorizontal();
            DoLabel("I'm a");

            EditorGUILayout.BeginVertical();
            if (DoRadioButton(
                    "Developer, I use branches, merges and maybe push/pull",
                    state.WorkspaceMode == CreateWorkspaceViewState.WorkspaceModes.Developer,
                    !state.ProgressData.IsOperationRunning,
                    LABEL_WIDTH))
            {
                state.WorkspaceMode = CreateWorkspaceViewState.WorkspaceModes.Developer;
            }

            if (DoRadioButton(
                    "Artist, I simply want to checkin and forget",
                    state.WorkspaceMode == CreateWorkspaceViewState.WorkspaceModes.Gluon,
                    !state.ProgressData.IsOperationRunning,
                    LABEL_WIDTH))
            {
                state.WorkspaceMode = CreateWorkspaceViewState.WorkspaceModes.Gluon;
            }

            EditorGUILayout.EndVertical();

            EditorGUILayout.EndHorizontal();
        }
Exemplo n.º 2
0
 static WorkspaceCreationData BuildCreationDataFromState(
     CreateWorkspaceViewState state)
 {
     return(new WorkspaceCreationData(
                state.WorkspaceName,
                state.WorkspacePath,
                state.RepositoryName,
                state.WorkspaceMode ==
                CreateWorkspaceViewState.WorkspaceModes.Gluon));
 }
Exemplo n.º 3
0
        void ValidateAndCreateWorkspace(
            CreateWorkspaceViewState state)
        {
            mWkCreationData = BuildCreationDataFromState(state);

            WorkspaceCreationValidation.AsyncValidation(
                mWkCreationData, this, mProgressControls);
            // validation calls IPlasticDialogCloser.CloseDialog()
            // when the validation is ok
        }
Exemplo n.º 4
0
        internal CreateWorkspaceView(
            EditorWindow parentWindow,
            ICreateWorkspaceListener listener,
            PlasticAPI plasticApi)
        {
            mParentWindow            = parentWindow;
            mCreateWorkspaceListener = listener;
            mProgressControls        = new ProgressControlsForViews();
            mWorkspaceOperations     = new WorkspaceOperations(this, mProgressControls);
            mCreateWorkspaceState    = CreateWorkspaceViewState.BuildForProjectDefaults();

            Initialize(plasticApi);
        }
Exemplo n.º 5
0
        static void DoBrowseRepositoryButton(
            EditorWindow parentWindow,
            string defaultServer,
            ref CreateWorkspaceViewState state)
        {
            string result = RepositoryExplorerDialog.BrowseRepository(
                parentWindow, defaultServer);

            if (string.IsNullOrEmpty(result))
            {
                return;
            }

            state.RepositoryName = result;
        }
Exemplo n.º 6
0
        static void DoOpenFolderPanel(
            ref CreateWorkspaceViewState state)
        {
            string result = EditorUtility.OpenFolderPanel(
                "Create workspace",
                state.WorkspacePath,
                string.Empty);

            if (string.IsNullOrEmpty(result))
            {
                return;
            }

            state.WorkspacePath = Path.GetFullPath(result);
        }
Exemplo n.º 7
0
        static void DoFieldsArea(
            Action <RepositoryCreationData> createRepositoryAction,
            EditorWindow parentWindow,
            string defaultServer,
            string projectPath,
            ref CreateWorkspaceViewState state)
        {
            DoRepositoryField(
                createRepositoryAction,
                parentWindow,
                defaultServer,
                ref state);

            DoWorkspaceField(ref state);

            DoPathOnDiskField(projectPath, ref state);
        }
Exemplo n.º 8
0
        static void OnRepositoryChanged(
            CreateWorkspaceDialogUserAssistant dialogUserAssistant,
            CreateWorkspaceViewState createWorkspaceState)
        {
            if (dialogUserAssistant == null)
            {
                return;
            }

            dialogUserAssistant.RepositoryChanged(
                createWorkspaceState.RepositoryName,
                createWorkspaceState.WorkspaceName,
                createWorkspaceState.WorkspacePath);

            createWorkspaceState.WorkspaceName =
                dialogUserAssistant.GetProposedWorkspaceName();
        }
Exemplo n.º 9
0
        static void DoPathOnDiskField(
            string projectPath,
            ref CreateWorkspaceViewState state)
        {
            EditorGUILayout.BeginHorizontal();

            DoLabel("Path on disk");

            state.WorkspacePath = DoTextField(
                state.WorkspacePath,
                !state.ProgressData.IsOperationRunning,
                LABEL_WIDTH,
                TEXTBOX_WIDTH - BROWSE_BUTTON_WIDTH);

            float buttonX =
                LABEL_WIDTH + TEXTBOX_WIDTH + BUTTON_MARGIN -
                BROWSE_BUTTON_WIDTH;
            float buttonWidth =
                BROWSE_BUTTON_WIDTH - BUTTON_MARGIN;

            if (DoButton(
                    "...",
                    !state.ProgressData.IsOperationRunning,
                    buttonX,
                    buttonWidth))
            {
                DoOpenFolderPanel(ref state);
            }

            ValidationResult validationResult = ValidateWorkspacePath(
                state.WorkspacePath, projectPath);

            if (!validationResult.IsValid)
            {
                DoWarningLabel(
                    validationResult.ErrorMessage,
                    LABEL_WIDTH + TEXTBOX_WIDTH + LABEL_MARGIN);
            }

            EditorGUILayout.EndHorizontal();
        }
Exemplo n.º 10
0
        static bool IsValidState(
            CreateWorkspaceViewState state,
            string projectPath)
        {
            if (!ValidateRepositoryName(state.RepositoryName).IsValid)
            {
                return(false);
            }

            if (!ValidateWorkspaceName(state.WorkspaceName).IsValid)
            {
                return(false);
            }

            if (!ValidateWorkspacePath(state.WorkspacePath, projectPath).IsValid)
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 11
0
        static void DoCreateWorkspaceButton(
            Action <CreateWorkspaceViewState> createWorkspaceAction,
            string projectPath,
            ref CreateWorkspaceViewState state)
        {
            EditorGUILayout.BeginHorizontal();

            bool isButtonEnabled =
                IsValidState(state, projectPath) &&
                !state.ProgressData.IsOperationRunning;

            if (DoButton("Create workspace", isButtonEnabled, LABEL_WIDTH, CREATE_WORKSPACE_BUTTON_WIDTH))
            {
                createWorkspaceAction(state);
                return;
            }

            GUI.enabled = true;

            EditorGUILayout.EndHorizontal();
        }
Exemplo n.º 12
0
        internal static void ForState(
            Action <RepositoryCreationData> createRepositoryAction,
            Action <CreateWorkspaceViewState> createWorkspaceAction,
            EditorWindow parentWindow,
            string defaultServer,
            string projectPath,
            ref CreateWorkspaceViewState state)
        {
            GUILayout.Space(10);

            DoTitle();

            GUILayout.Space(15);

            DoFieldsArea(
                createRepositoryAction,
                parentWindow,
                defaultServer,
                projectPath,
                ref state);

            GUILayout.Space(10);

            DoRadioButtonsArea(ref state);

            GUILayout.Space(3);

            DoHelpLabel();

            GUILayout.Space(10);

            DoCreateWorkspaceButton(
                createWorkspaceAction,
                projectPath,
                ref state);

            GUILayout.Space(5);

            DoNotificationArea(state.ProgressData);
        }
Exemplo n.º 13
0
        static void DoWorkspaceField(
            ref CreateWorkspaceViewState state)
        {
            EditorGUILayout.BeginHorizontal();

            DoLabel("Workspace name");

            state.WorkspaceName = DoTextField(
                state.WorkspaceName,
                !state.ProgressData.IsOperationRunning,
                LABEL_WIDTH,
                TEXTBOX_WIDTH - BROWSE_BUTTON_WIDTH);

            ValidationResult validationResult = ValidateWorkspaceName(
                state.WorkspaceName);

            if (!validationResult.IsValid)
            {
                DoWarningLabel(validationResult.ErrorMessage,
                               LABEL_WIDTH + TEXTBOX_WIDTH - BROWSE_BUTTON_WIDTH + LABEL_MARGIN);
            }

            EditorGUILayout.EndHorizontal();
        }
Exemplo n.º 14
0
        static void DoRepositoryField(
            Action <RepositoryCreationData> createRepositoryAction,
            EditorWindow parentWindow,
            string defaultServer,
            ref CreateWorkspaceViewState state)
        {
            EditorGUILayout.BeginHorizontal();

            DoLabel("Repository name");

            state.RepositoryName = DoTextField(
                state.RepositoryName,
                !state.ProgressData.IsOperationRunning,
                LABEL_WIDTH,
                TEXTBOX_WIDTH - BROWSE_BUTTON_WIDTH);

            float browseButtonX =
                LABEL_WIDTH + TEXTBOX_WIDTH + BUTTON_MARGIN -
                BROWSE_BUTTON_WIDTH;
            float browseButtonWidth =
                BROWSE_BUTTON_WIDTH - BUTTON_MARGIN;

            if (DoButton(
                    "...",
                    !state.ProgressData.IsOperationRunning,
                    browseButtonX,
                    browseButtonWidth))
            {
                DoBrowseRepositoryButton(
                    parentWindow,
                    defaultServer,
                    ref state);
                EditorGUIUtility.ExitGUI();
            }

            float newButtonX =
                LABEL_WIDTH + TEXTBOX_WIDTH + BUTTON_MARGIN;
            float newButtonWidth =
                NEW_BUTTON_WIDTH - BUTTON_MARGIN;

            if (DoButton(
                    "New ...",
                    !state.ProgressData.IsOperationRunning,
                    newButtonX, newButtonWidth))
            {
                DoNewRepositoryButton(
                    createRepositoryAction,
                    parentWindow,
                    state.RepositoryName,
                    defaultServer);
                EditorGUIUtility.ExitGUI();
            }

            ValidationResult validationResult = ValidateRepositoryName(
                state.RepositoryName);

            if (!validationResult.IsValid)
            {
                DoWarningLabel(validationResult.ErrorMessage,
                               LABEL_WIDTH + TEXTBOX_WIDTH + NEW_BUTTON_WIDTH + LABEL_MARGIN);
            }

            EditorGUILayout.EndHorizontal();
        }