private static SmartListView GetListView(BaseCommandEventArgs e) { if (e == null) throw new ArgumentNullException("e"); return e.Selection.GetActiveControl<SmartListView>(); }
private static GitItem GetRoot(BaseCommandEventArgs e) { GitItem item = null; switch (e.Command) { case VisualGitCommand.SolutionBranch: case VisualGitCommand.SolutionTag: IVisualGitSolutionSettings ss = e.GetService<IVisualGitSolutionSettings>(); if (ss == null) return null; string root = ss.ProjectRoot; if (string.IsNullOrEmpty(root)) return null; item = e.GetService<IFileStatusCache>()[root]; break; case VisualGitCommand.ProjectBranch: case VisualGitCommand.ProjectTag: GitProject p = EnumTools.GetSingle(e.Selection.GetSelectedProjects(false)); if(p == null) break; IGitProjectInfo info = e.GetService<IProjectFileMapper>().GetProjectInfo(p); if (info == null || info.ProjectDirectory == null) break; item = e.GetService<IFileStatusCache>()[info.ProjectDirectory]; break; } return item; }
/// <summary> /// Gets the "project root" /// </summary> /// <param name="e"></param> /// <returns></returns> private static SvnItem GetRoot(BaseCommandEventArgs e) { SvnItem item = null; switch (e.Command) { case AnkhCommand.SolutionIssueTrackerSetup: IAnkhSolutionSettings ss = e.GetService <IAnkhSolutionSettings>(); if (ss == null) { return(null); } string root = ss.ProjectRoot; if (string.IsNullOrEmpty(root)) { return(null); } item = e.GetService <ISvnStatusCache>()[root]; break; } return(item); }
public void OnError(Exception ex, BaseCommandEventArgs commandArgs) { if (ex == null) return; else if (commandArgs == null) OnError(ex); else Handle(ex, commandArgs); }
private PendingChangesPage GetPage(BaseCommandEventArgs e) { PendingChangesPage page = e.Context.GetService<PendingCommitsPage>(); if (page != null && page.Visible) return page; return null; }
private static SmartListView GetListView(BaseCommandEventArgs e) { if (e == null) { throw new ArgumentNullException("e"); } return(e.Selection.GetActiveControl <SmartListView>()); }
IEnumerable<SvnItem> GetSelection(BaseCommandEventArgs e) { if (e.Command == AnkhCommand.DocumentAddToPending || e.Command == AnkhCommand.DocumentRemoveFromPending) { SvnItem i = e.Selection.ActiveDocumentItem; if (i == null) return new SvnItem[0]; else return new SvnItem[] { i }; } else return e.Selection.GetSelectedSvnItems(false); }
public void OnError(Exception ex, BaseCommandEventArgs commandArgs) { if (ex == null) { return; } else if (commandArgs == null) { OnError(ex); } else { Handler.Invoke(ex, new ExceptionInfo(commandArgs)); } }
private PendingChangesPage GetPage(BaseCommandEventArgs e) { PendingChangesPage page = e.Context.GetService <PendingCommitsPage>(); if (page != null && page.Visible) { return(page); } page = e.Context.GetService <RecentChangesPage>(); if (page != null && page.Visible) { return(page); } return(null); }
public string[] GetNames(BaseCommandEventArgs e) { IEnumerable <SvnItem> sel = e.Selection.GetSelectedSvnItems(false); if (!ReferenceEquals(sel, _selection)) { List <SvnItem> full = new List <SvnItem>(); full.AddRange(sel); string[] names = new string[full.Count]; for (int i = 0; i < names.Length; i++) { names[i] = full[i].Name; } _selection = sel; _names = names; if (_names.Length == 1) { _cached = _names[0]; if (_control != null) { _control.Grid.SelectedObject = new SvnItemData(e.Context, full[0]); } } else { _cached = null; List <Ankh.Scc.SvnItemData> items = new List <SvnItemData>(); foreach (SvnItem i in full) { items.Add(new Ankh.Scc.SvnItemData(e.Context, i)); } _control.Grid.SelectedObjects = items.Count > 0 ? items.ToArray() : null; } } return(_names); }
static IEnumerable<PendingChange> GetChanges(BaseCommandEventArgs e) { IPendingChangesManager pcm = e.GetService<IPendingChangesManager>(); if (e.Command == VisualGitCommand.SolutionCommit) { foreach (PendingChange pc in pcm.GetAll()) { yield return pc; } } else { ProjectListFilter plf = new ProjectListFilter(e.Context, e.Selection.GetSelectedProjects(false)); foreach (PendingChange pc in pcm.GetAll()) { if (plf.ShowChange(pc)) yield return pc; } } }
bool TryGetIssue(BaseCommandEventArgs e, out IssueMarker value) { value = null; IVsTextView tv = ((ISelectionContextEx)e.Selection).ActiveFrameTextView; if (tv == null) { LogMessageEditor editor = e.Selection.GetActiveControl<LogMessageEditor>(); if (editor == null) return false; tv = ((IAnkhHasVsTextView)editor).TextView; } int x, y; if (!ErrorHandler.Succeeded(tv.GetCaretPos(out y, out x))) return false; IVsTextLines lines; if (!ErrorHandler.Succeeded(tv.GetBuffer(out lines))) return false; string text, pre = null, post = null; text = GetLine(lines, y); if (string.IsNullOrEmpty(text)) return false; string combined = null; int start = 0; if (y > 0) { pre = GetLine(lines, y - 1); combined = pre + '\n'; start = combined.Length; } combined += text; post = GetLine(lines, y + 1); if (!string.IsNullOrEmpty(post)) combined += '\n' + post; if ((y > 0) && !ErrorHandler.Succeeded(tv.GetTextStream(y - 1, 0, y, 0, out pre))) return false; if (!ErrorHandler.Succeeded(tv.GetTextStream(y + 1, 0, y + 2, 0, out post))) post = null; if (!string.IsNullOrEmpty(pre)) { combined = pre.TrimEnd('\r', '\n') + '\n'; start = combined.Length; } combined += text; if (!string.IsNullOrEmpty(post)) { post = post.TrimEnd('\r', '\n'); combined += '\n' + post; } if (_issueService == null) _issueService = e.GetService<IAnkhIssueService>(); IEnumerable<IssueMarker> markers; int posToCheck = x + start; if (!_issueService.TryGetIssues(combined, out markers)) return false; foreach (IssueMarker im in markers) { if (im.Index > posToCheck) break; if (im.Index + im.Length >= posToCheck) { value = im; return true; } } return false; }
public ExceptionInfo(BaseCommandEventArgs e) { _commandArgs = e; }
public void OnError(Exception ex, BaseCommandEventArgs commandArgs) { if (ex == null) return; else if (commandArgs == null) OnError(ex); else Handler.Invoke(ex, new ExceptionInfo(commandArgs)); }
private static List<string> GetRecentNames(BaseCommandEventArgs e) { List<string> names = (List<string>)e.Selection.Cache[typeof(ItemMoveToChangeList)]; if (names != null) return names; names = new List<string>(); foreach (string cl in e.GetService<IPendingChangesManager>().GetSuggestedChangeLists()) { names.Add(cl); if (names.Count >= 10) break; } e.Selection.Cache[typeof(ItemMoveToChangeList)] = names; return names; }
private IEnumerable<GitItem> GetAllRoots(BaseCommandEventArgs e) { IVisualGitProjectLayoutService pls = e.GetService<IVisualGitProjectLayoutService>(); var result = new Dictionary<string, GitItem>(FileSystemUtil.StringComparer); foreach (var gitItem in pls.GetUpdateRoots(null)) { if (gitItem.IsVersioned) result[gitItem.FullPath] = gitItem; } return result.Values; }
private void Handle(Exception ex, BaseCommandEventArgs exceptionInfo) { if (ex == null) throw new ArgumentNullException("ex"); // We're not interested in the ProgressRunnerException. Get the inner // exception unless we don't have one. while (ex is ProgressRunnerException && ex.InnerException != null) { ex = ex.InnerException; } #if DEBUG && !TEST_ERROR_HANDLING GetService<IVisualGitDialogOwner>() .MessageBox.Show( ex.Message, CommandResources.OperationNotCompletedSuccessfully, MessageBoxButtons.OK, MessageBoxIcon.Warning ); #else Reporter.Report(ex); #endif }
/// <summary> /// Gets the "project root" /// </summary> /// <param name="e"></param> /// <returns></returns> private static SvnItem GetRoot(BaseCommandEventArgs e) { SvnItem item = null; switch (e.Command) { case AnkhCommand.SolutionIssueTrackerSetup: IAnkhSolutionSettings ss = e.GetService<IAnkhSolutionSettings>(); if (ss == null) return null; string root = ss.ProjectRoot; if (string.IsNullOrEmpty(root)) return null; item = e.GetService<IFileStatusCache>()[root]; break; } return item; }
static IEnumerable<SvnProject> GetSelectedProjects(BaseCommandEventArgs e) { foreach (SvnProject p in e.Selection.GetSelectedProjects(false)) { yield return p; } }
bool TryGetMarker(BaseCommandEventArgs e, bool issue, out TextMarker value) { value = null; IVsTextView tv = ((ISelectionContextEx)e.Selection).ActiveFrameTextView; if (tv == null) { LogMessageEditor editor = e.Selection.GetActiveControl <LogMessageEditor>(); if (editor == null) { return(false); } tv = ((IAnkhHasVsTextView)editor).TextView; } int x, y; if (!VSErr.Succeeded(tv.GetCaretPos(out y, out x))) { return(false); } IVsTextLines lines; if (!VSErr.Succeeded(tv.GetBuffer(out lines))) { return(false); } string text, pre = null, post = null; text = GetLine(lines, y); if (string.IsNullOrEmpty(text)) { return(false); } string combined = null; int start = 0; if (y > 0) { pre = GetLine(lines, y - 1); combined = pre + '\n'; start = combined.Length; } combined += text; post = GetLine(lines, y + 1); if (!string.IsNullOrEmpty(post)) { combined += '\n' + post; } if (_issueService == null) { _issueService = e.GetService <IAnkhIssueService>(); } IEnumerable <TextMarker> markers; int posToCheck = x + start; if (issue) { if (!_issueService.TryGetIssues(combined, out markers)) { return(false); } } else { if (!_issueService.TryGetRevisions(combined, out markers)) { return(false); } } foreach (TextMarker im in markers) { if (im.Index > posToCheck) { break; } if (im.Index + im.Length >= posToCheck) { value = im; return(true); } } return(false); }