/// <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); }
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); }
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; } }
private void Jump(GitTreeViewItem item) { if (string.IsNullOrEmpty(item.FilePath)) { return; } // TODO 存在しないファイルの場合 InternalEditorUtility.OpenFileAtLineExternal(item.FilePath, item.FileLine); }
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)); }
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); }
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); }
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()); } }
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); }
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 ); }
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()); }
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); }
internal virtual void SingleClick(GitTreeViewItem item) { }
private void RowAction(Rect rect, GitTreeViewItem item) { rect.x = 0; EditorGUI.LabelField(rect, item.displayName, GetStyle(item.displayName)); }
private void DoubleClick(GitTreeViewItem item) { var index = _hasSub && _subTreeView.HasFocus() ? _sub : _main; _modules[index].DoubleClick(item); }
internal override void DoubleClick(GitTreeViewItem item) { KeyEvent(item, KeyCode.U); }
internal virtual void DoubleClick(GitTreeViewItem item) { KeyEvent(item, KeyCode.Return); }
private void RowAction(Rect rect, GitTreeViewItem item) { rect.xMin += TreeView.DepthIndentWidth; EditorGUI.LabelField(rect, item.displayName, GetStyle(item)); }