Example #1
0
        private void OnGUI()
        {
            using (GUILayoutHelper.Vertical())
            {
                username = EditorGUILayout.TextField("Username", username);
                Color passwordColor = Color.grey;
                if (hasVerified && !success)
                {
                    passwordColor = Color.red;
                }
                if (hasVerified && success)
                {
                    passwordColor = Color.green;
                }
                using (GUILayoutHelper.BackgroundColor(passwordColor))
                {
                    password = EditorGUILayout.TextField("Password", password);
                }

                allowCacheCredentials = GUILayout.Toggle(allowCacheCredentials, new GUIContent("Allow Credentials to be cached"));

                using (GUILayoutHelper.Horizontal())
                {
                    if (GUILayout.Button("Cancel"))
                    {
                        Close();
                    }
                    if (!success)
                    {
                        if (GUILayout.Button("Verify"))
                        {
                            hasVerified = true;
                            success     = VCCommands.Instance.SetUserCredentials(username, password, allowCacheCredentials);
                        }
                    }
                    else
                    {
                        if (GUILayout.Button("Close"))
                        {
                            Close();
                        }
                    }
                }
            }
        }
Example #2
0
        private void DrawButtons()
        {
            EditorGUILayout.BeginHorizontal();

            using (GUILayoutHelper.BackgroundColor(CommitMessage.Length < 10 ? new Color(1, 0, 0) : new Color(0, 1, 0)))
            {
                statusScroll = EditorGUILayout.BeginScrollView(statusScroll, false, false);
                string strCommitMessageOld = CommitMessage;

                GUI.SetNextControlName("Message");
                CommitMessage = EditorGUILayout.TextArea(CommitMessage, GUILayout.MinWidth(100), GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true));

                if (CommitMessage.Length > strCommitMessageOld.Length)
                {
                    if (!string.IsNullOrEmpty(VCSettings.strCommitAutoComplete))
                    {
                        string[] arSuggestions = VCSettings.strCommitAutoComplete.Split(';');
                        for (int i = 0; i < arSuggestions.Length; i++)
                        {
                            string   strSuggestion      = arSuggestions[i].Trim(new[] { ' ' });
                            string[] strSuggestionParts = strSuggestion.Split(new string[] { "->" }, System.StringSplitOptions.RemoveEmptyEntries);

                            if (CommitMessage.EndsWith(strSuggestionParts[0]))
                            {
                                TextEditor editor = (TextEditor)GUIUtility.GetStateObject(typeof(TextEditor), GUIUtility.keyboardControl);

                                CommitAutoCompleteSuggestion suggestion = new CommitAutoCompleteSuggestion(strSuggestionParts[0].Length, strSuggestionParts[1], this);

                                editor.DetectFocusChange();
                                editor.OnLostFocus();

                                PopupWindow.Show(new Rect((editor.graphicalSelectCursorPos), suggestion.GetWindowSize()), suggestion);
                            }
                        }
                    }
                }
                EditorGUILayout.EndScrollView();
            }
            if (firstTime)
            {
                EditorGUI.FocusTextInControl("CommitMessage");
                firstTime = false;
            }


            using (new PushState <bool>(GUI.enabled, VCCommands.Instance.Ready, v => GUI.enabled = v))
            {
                if (GUILayout.Button(Terminology.commit, GUILayout.Width(100)))
                {
                    var selection = //VCSettings.SelectiveCommit ? vcMultiColumnAssetList.GetMasterSelection() : vcMultiColumnAssetList.GetSelection();
                                    vcMultiColumnAssetList.GetCommitSelection(VCSettings.SelectiveCommit);
                    if (selection.Count() != 0)
                    {
                        var selectedAssets = selection.Select(status => status.assetPath).Select(cstr => cstr.Compose()).ToList();
                        VCCommands.Instance.ProgressInformation += s =>
                        {
                            commitProgress = commitProgress + s;
                            if (commitProgress.Length > maxProgressSize)
                            {
                                commitProgress = commitProgress.Substring(commitProgress.Length - maxProgressSize);
                            }
                            statusScroll.y = Mathf.Infinity;
                            Repaint();
                        };
                        //foreach (string str in selectedAssets)
                        //    Debug.Log("Committing: " + str);
                        var commitTask = VCCommands.Instance.CommitTask(selectedAssets, CommitMessage, VCSettings.NonRecursiveAdd);
                        commitTask.ContinueWithOnNextUpdate(result =>
                        {
                            if (result)
                            {
                                commitedFiles = selectedAssets;
                                CommitMessage = "";
                                Repaint();
                                if (VCSettings.AutoCloseAfterSuccess)
                                {
                                    Close();
                                }
                            }
                            commitCompleted = true;
                        });
                        commitInProgress = true;
                    }
                    else
                    {
                        ShowNotification(new GUIContent("No files selected"));
                    }
                }
                if (GUILayout.Button("Cancel", GUILayout.Width(100)))
                {
                    Close();
                }
            }
            EditorGUILayout.EndHorizontal();
            if (vcMultiColumnAssetList.GetSelection().Any())
            {
                RemoveNotification();
            }

            GUI.SetNextControlName("unfocus");
        }
Example #3
0
        private void DrawButtons()
        {
            EditorGUILayout.BeginHorizontal();

            GUI.SetNextControlName("CommitMessage");
            using (GUILayoutHelper.BackgroundColor(CommitMessage.Length < 10 ? new Color(1, 0, 0) : new Color(0, 1, 0)))
            {
                statusScroll  = EditorGUILayout.BeginScrollView(statusScroll, false, false);
                CommitMessage = EditorGUILayout.TextArea(CommitMessage, GUILayout.MinWidth(100), GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true));
                EditorGUILayout.EndScrollView();
            }
            if (firstTime)
            {
                GUI.FocusControl("CommitMessage");
                firstTime = false;
            }

            using (new PushState <bool>(GUI.enabled, VCCommands.Instance.Ready, v => GUI.enabled = v))
            {
                if (GUILayout.Button(Terminology.commit, GUILayout.Width(100)))
                {
                    var selection = VCSettings.SelectiveCommit ? vcMultiColumnAssetList.GetMasterSelection() : vcMultiColumnAssetList.GetSelection();
                    if (selection.Count() != 0)
                    {
                        var selectedAssets = selection.Select(status => status.assetPath).Select(cstr => cstr.Compose()).ToList();
                        VCCommands.Instance.ProgressInformation += s =>
                        {
                            commitProgress = commitProgress + s;
                            if (commitProgress.Length > maxProgressSize)
                            {
                                commitProgress = commitProgress.Substring(commitProgress.Length - maxProgressSize);
                            }
                            statusScroll.y = Mathf.Infinity;
                            Repaint();
                        };
                        var commitTask = VCCommands.Instance.CommitTask(selectedAssets, CommitMessage);
                        commitTask.ContinueWithOnNextUpdate(result =>
                        {
                            if (result)
                            {
                                commitedFiles = selectedAssets;
                                CommitMessage = "";
                                Repaint();
                                if (VCSettings.AutoCloseAfterSuccess)
                                {
                                    Close();
                                }
                            }
                            commitCompleted = true;
                        });
                        commitInProgress = true;
                    }
                    else
                    {
                        ShowNotification(new GUIContent("No files selected"));
                    }
                }
                if (GUILayout.Button("Cancel", GUILayout.Width(100)))
                {
                    Close();
                }
            }
            EditorGUILayout.EndHorizontal();
            if (vcMultiColumnAssetList.GetSelection().Any())
            {
                RemoveNotification();
            }
        }