Exemplo n.º 1
0
        /// <summary>
        /// ブランチ切り替え
        /// </summary>
        private void SwitchBranch(GitTreeViewItem item)
        {
            if (_current == item.displayName)
            {
                return;
            }

            // 差分がある
            if (GetStatus().Any())
            {
                if (!EditorUtility.DisplayDialog(
                        "Warning",
                        "There is a diff, want to switch branch?",
                        "Yes",
                        "No"))
                {
                    return;
                }

                var output = Stash();
                EditorUtility.DisplayDialog("Info", output, "Ok");
            }
            else
            {
                if (!EditorUtility.DisplayDialog("Info", $"Switch {item.displayName}?", "Yes", "No"))
                {
                    return;
                }
            }

            Switch(item.displayName);
            OnEnter(null);
        }
Exemplo n.º 2
0
 private string GetPath(GitTreeViewItem item)
 {
     // 0なら子供を全部変更する
     return(item.depth == 0 && item.children != null
                         ? string.Join(" ", item.children.Select(i => (i as GitTreeViewItem).StatusFilePath))
                         : item.StatusFilePath);
 }
Exemplo n.º 3
0
 private void RowAction(Rect rect, GitTreeViewItem item)
 {
     for (var i = 0; i < MaxWidth.Length; i++)
     {
         rect.width = MaxWidth[i] + EditorGUIUtility.standardVerticalSpacing * 4;
         EditorGUI.LabelField(rect, item[i], ColorLabel.Get(colors[i]));
         rect.xMin += rect.width;
     }
 }
Exemplo n.º 4
0
        private void Jump(GitTreeViewItem item)
        {
            if (string.IsNullOrEmpty(item.FilePath))
            {
                return;
            }

            // TODO 存在しないファイルの場合
            InternalEditorUtility.OpenFileAtLineExternal(item.FilePath, item.FileLine);
        }
Exemplo n.º 5
0
        private GUIStyle GetStyle(GitTreeViewItem item)
        {
            if (item.displayName == _current)
            {
                return(EditorStyles.boldLabel);
            }

            if (item.displayName.StartsWith("origin/"))
            {
                return(ColorLabel.Get(Color.yellow));
            }

            return(ColorLabel.Get(Color.blue));
        }
Exemplo n.º 6
0
        private TreeViewItem GetUnStageFiles(IEnumerable <string> output, int startIndex)
        {
            var cns = new GitTreeViewItem(GitStatusType.UnStage)
            {
                displayName = "Changes not staged for commit",
                id          = -3,
                depth       = 0
            };

            foreach (var i in GetUnStage(output, 1, startIndex))
            {
                cns.AddChild(i);
            }

            return(cns);
        }
Exemplo n.º 7
0
        private TreeViewItem GetStageFiles(IEnumerable <string> output, int startIndex)
        {
            var ctc = new GitTreeViewItem(GitStatusType.Stage)
            {
                displayName = "Changes to be committed",
                id          = -2,
                depth       = 0
            };

            foreach (var i in GetStage(output, 1, startIndex))
            {
                ctc.AddChild(i);
            }

            return(ctc);
        }
Exemplo n.º 8
0
        private void ChangeUndo(GitTreeViewItem item)
        {
            var path = GetPath(item);

            if (item.Status == GitStatusType.UnStage)
            {
                Checkout(path);
                Refresh(TreeView.GetSelectionIndex());
            }

            if (item.Status == GitStatusType.UnTrack)
            {
                Clean(path);
                Refresh(TreeView.GetSelectionIndex());
            }
        }
Exemplo n.º 9
0
        internal void KeyEvent(GitTreeViewItem item, KeyCode keyCode)
        {
            var index = KeyDic.FindIndex(k => k.KeyCode == keyCode);

            if (index < 0)
            {
                return;
            }

            if (KeyDic[index].Action == null)
            {
                return;
            }

            KeyDic[index].Action.Invoke(item);
        }
Exemplo n.º 10
0
        private void Row(Rect rect, GitTreeViewItem item)
        {
            EditorGUI.LabelField(
                new Rect(4, rect.y, 12, rect.height),
                $"{item.GetStatusText()}",
                ColorLabel.Get(Color.magenta));

            rect.xMin += (item.depth + 1) * TreeView.DepthIndentWidth;

            EditorGUI.LabelField(
                rect,
                item.displayName,
                item.depth == 0 ?
                EditorStyles.boldLabel :
                EditorStyles.label
                );
        }
Exemplo n.º 11
0
        private void ChangeStage(GitTreeViewItem item)
        {
            var path = GetPath(item);

            switch (item.Status)
            {
            case GitStatusType.UnStage:
            case GitStatusType.UnTrack:
                Add(path);
                break;

            case GitStatusType.Stage:
                Reset(path);
                break;
            }

            Refresh(TreeView.GetSelectionIndex());
        }
Exemplo n.º 12
0
        private TreeViewItem UntrackFiles(IEnumerable <string> output, int startIndex)
        {
            var uf = new GitTreeViewItem(GitStatusType.UnTrack)
            {
                displayName = "Untracked files",
                id          = -4,
                depth       = 0
            };
            var items = output
                        .Where(l => l[0] == '?')
                        .Select((l, i) => new GitTreeViewItem(l, GitStatusType.UnTrack)
            {
                id    = startIndex + i,
                depth = 1,
            })
                        .Cast <TreeViewItem>();

            foreach (var i in items)
            {
                uf.AddChild(i);
            }

            return(uf);
        }
Exemplo n.º 13
0
 internal virtual void SingleClick(GitTreeViewItem item)
 {
 }
Exemplo n.º 14
0
 private void RowAction(Rect rect, GitTreeViewItem item)
 {
     rect.x = 0;
     EditorGUI.LabelField(rect, item.displayName, GetStyle(item.displayName));
 }
Exemplo n.º 15
0
        private void DoubleClick(GitTreeViewItem item)
        {
            var index = _hasSub && _subTreeView.HasFocus() ? _sub : _main;

            _modules[index].DoubleClick(item);
        }
Exemplo n.º 16
0
 internal override void DoubleClick(GitTreeViewItem item)
 {
     KeyEvent(item, KeyCode.U);
 }
Exemplo n.º 17
0
 internal virtual void DoubleClick(GitTreeViewItem item)
 {
     KeyEvent(item, KeyCode.Return);
 }
Exemplo n.º 18
0
 private void RowAction(Rect rect, GitTreeViewItem item)
 {
     rect.xMin += TreeView.DepthIndentWidth;
     EditorGUI.LabelField(rect, item.displayName, GetStyle(item));
 }