public int QueryStatus(AnkhContext context, uint cCmds, OLECMD[] prgCmds, IntPtr pCmdText) { if (context == null) { throw new ArgumentNullException("context"); } else if (cCmds != 1 || prgCmds == null) { return(-1); } TextQueryType textQuery = TextQueryType.None; if (pCmdText != IntPtr.Zero) { // VS Want's some text from us for either the statusbar or the command text OLECMDTEXTF textType = GetFlags(pCmdText); switch (textType) { case OLECMDTEXTF.OLECMDTEXTF_NAME: textQuery = TextQueryType.Name; break; case OLECMDTEXTF.OLECMDTEXTF_STATUS: textQuery = TextQueryType.Status; break; } } CommandUpdateEventArgs updateArgs = new CommandUpdateEventArgs((AnkhCommand)prgCmds[0].cmdID, context, textQuery); OLECMDF cmdf = OLECMDF.OLECMDF_SUPPORTED; if (PerformUpdate(updateArgs.Command, updateArgs)) { updateArgs.UpdateFlags(ref cmdf); } if (updateArgs.DynamicMenuEnd) { return(VSErr.OLECMDERR_E_NOTSUPPORTED); } if (textQuery != TextQueryType.None && !string.IsNullOrEmpty(updateArgs.Text)) { SetText(pCmdText, updateArgs.Text); } if (_customizeMode && updateArgs.Command != AnkhCommand.ForceUIShow) { prgCmds[0].cmdf = (uint)(cmdf & ~OLECMDF.OLECMDF_INVISIBLE); } else { prgCmds[0].cmdf = (uint)cmdf; } return(0); // S_OK }
protected override void OnUpdate(SmartListView list, Ankh.Commands.CommandUpdateEventArgs e) { bool foundOne = false; e.Checked = true; foreach (SmartColumn sc in list.SortColumns) { foundOne = true; switch (e.Command) { case AnkhCommand.ListViewSortAscending: if (sc.ReverseSort) { e.Checked = false; return; } break; case AnkhCommand.ListViewSortDescending: if (!sc.ReverseSort) { e.Checked = false; return; } break; } } if (!foundOne) { e.Checked = e.Enabled = false; } }
public override void OnUpdate(CommandUpdateEventArgs e) { SvnItem i = EnumTools.GetSingle(e.Selection.GetSelectedSvnItems(false)); if (i == null) e.Enabled = false; }
public override void OnUpdate(CommandUpdateEventArgs e) { bool add; IPendingChangesManager pcm = null; add = (e.Command == AnkhCommand.ItemAddToPending) || (e.Command == AnkhCommand.DocumentAddToPending); foreach (SvnItem i in GetSelection(e)) { if (i.InSolution || !PendingChange.IsPending(i)) continue; if (pcm == null) { pcm = e.GetService<IPendingChangesManager>(); if (pcm == null) break; } if (pcm.Contains(i.FullPath) != add) return; } e.Enabled = false; }
public void OnUpdate(CommandUpdateEventArgs e) { if (e.State.SccProviderActive) foreach (SvnProject p in e.Selection.GetSelectedProjects(false)) { ISvnProjectInfo pi = e.GetService<IProjectFileMapper>().GetProjectInfo(p); if (p == null || pi == null || string.IsNullOrEmpty(pi.ProjectFile)) { break; // No project file } if (!string.IsNullOrEmpty(pi.ProjectDirectory) && string.Equals(pi.ProjectDirectory, pi.ProjectFile, StringComparison.OrdinalIgnoreCase)) { break; // Project file is directory } SvnItem item = e.GetService<IFileStatusCache>()[pi.ProjectFile]; if (item != null && item.IsDirectory) break; // Project file is not file return; // Show the menu } e.Enabled = e.Visible = false; }
public override void OnUpdate(CommandUpdateEventArgs e) { PendingChange.RefreshContext rc = null; foreach (SvnItem i in e.Selection.GetSelectedSvnItems(true)) { if (PendingChange.IsPending(i)) { PendingChange pc; if (rc == null) { rc = new PendingChange.RefreshContext(e.Context); } if (PendingChange.CreateIfPending(rc, i, out pc)) { if (pc.IsNoChangeForPatching()) { continue; } } return; } } e.Enabled = false; }
public override void OnUpdate(CommandUpdateEventArgs e) { bool add; IPendingChangesManager pcm = null; add = (e.Command == AnkhCommand.ItemAddToPending) || (e.Command == AnkhCommand.DocumentAddToPending); foreach (SvnItem i in GetSelection(e)) { if (i.InSolution || !PendingChange.IsPending(i)) { continue; } if (pcm == null) { pcm = e.GetService <IPendingChangesManager>(); if (pcm == null) { break; } } if (pcm.Contains(i.FullPath) != add) { return; } } e.Enabled = false; }
public int Exec(ref Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut) { CommandID cd = new CommandID(pguidCmdGroup, unchecked((int)nCmdID)); List<CommandData> items; if (!_data.TryGetValue(cd, out items)) return (int)Constants.OLECMDERR_E_NOTSUPPORTED; foreach (CommandData d in items) { if (!d.Control.ContainsFocus) continue; CommandEventArgs ce = new CommandEventArgs((AnkhCommand)cd.ID, GetService<AnkhContext>()); if (d.UpdateHandler != null) { CommandUpdateEventArgs ud = new CommandUpdateEventArgs(ce.Command, ce.Context); d.UpdateHandler(d.Control, ud); if (!ud.Enabled) return (int)Constants.OLECMDERR_E_DISABLED; } d.Handler(d.Control, ce); return VSConstants.S_OK; } return (int)Constants.OLECMDERR_E_NOTSUPPORTED; }
public override void OnUpdate(CommandUpdateEventArgs e) { bool multiple = false; foreach (SvnItem item in e.Selection.GetSelectedSvnItems(true)) { if (item.NeedsCleanup) { return; } if (!item.IsVersioned) { continue; } if (!item.IsFile || multiple) { return; } multiple = true; } e.Enabled = false; }
public void OnUpdate(CommandUpdateEventArgs e) { PendingCommitsPage commitPage = e.Context.GetService<PendingCommitsPage>(); PendingIssuesPage issuesPage = e.Context.GetService<PendingIssuesPage>(); if (commitPage == null) { e.Enabled = false; return; } switch (e.Command) { case AnkhCommand.CommitPendingChanges: case AnkhCommand.CommitPendingChangesKeepingLocks: e.Enabled = true // check if commit page or issues page is visible && (false || commitPage.Visible || (issuesPage != null && issuesPage.Visible) ) // make sure commit page can commit && commitPage.CanCommit(e.Command == AnkhCommand.CommitPendingChangesKeepingLocks) ; break; case AnkhCommand.PendingChangesApplyWorkingCopy: e.Enabled = commitPage.Visible && commitPage.CanApplyToWorkingCopy(); break; } }
public override void OnUpdate(CommandUpdateEventArgs e) { ISvnRepositoryItem single = EnumTools.GetSingle(e.Selection.GetSelection<ISvnRepositoryItem>()); if(single == null || single.NodeKind == SvnNodeKind.Directory || single.Origin == null) e.Enabled = false; }
public void OnUpdate(CommandUpdateEventArgs e) { if (!e.State.SolutionExists || !e.State.SccProviderActive) { e.Enabled = false; return; } }
public override void OnUpdate(CommandUpdateEventArgs e) { ISvnRepositoryItem single = EnumTools.GetSingle(e.Selection.GetSelection <ISvnRepositoryItem>()); if (single == null || single.NodeKind == SvnNodeKind.Directory || single.Origin == null) { e.Enabled = false; } }
public void OnUpdate(CommandUpdateEventArgs e) { LogMessageEditor lme = e.Selection.GetActiveControl<LogMessageEditor>(); if (lme == null || lme.ReadOnly || lme.PasteSource == null) e.Enabled = e.Visible = false; else if (e.Command == AnkhCommand.PcLogEditorPasteFileList && !lme.PasteSource.HasPendingChanges) e.Enabled = false; }
public void OnUpdate(CommandUpdateEventArgs e) { PendingCommitsPage page = e.Context.GetService<PendingCommitsPage>(); if (page == null || !page.Visible) e.Enabled = false; else e.Enabled = page.CanCreatePatch(); }
public override void OnUpdate(CommandUpdateEventArgs e) { foreach (SvnItem item in e.Selection.GetSelectedSvnItems(true)) { if (item.IsVersioned) return; } e.Enabled = false; }
public override void OnUpdate(CommandUpdateEventArgs e) { WorkingCopyExplorerControl ctrl = e.Selection.ActiveDialogOrFrameControl as WorkingCopyExplorerControl; if (ctrl == null) e.Enabled = false; else e.Enabled = ctrl.IsWcRootSelected(); }
public override void OnUpdate(CommandUpdateEventArgs e) { bool foundOne = false; bool canDiff = true; foreach (SvnItem item in e.Selection.GetSelectedSvnItems(true)) { if (!item.IsConflicted) { continue; } foundOne = true; if (item.IsTreeConflicted) { switch (e.Command) { case AnkhCommand.ItemResolveMerge: case AnkhCommand.ItemResolveMergeTool: case AnkhCommand.ItemResolveMineFull: case AnkhCommand.ItemResolveTheirsFull: case AnkhCommand.ItemResolveMineConflict: case AnkhCommand.ItemResolveTheirsConflict: case AnkhCommand.ItemResolveBase: e.Enabled = false; // Subversion can't handle these and neither can we. return; case AnkhCommand.ItemResolveWorking: default: break; } } if (!item.IsTextFile) { canDiff = false; } } if (!foundOne) { e.Enabled = false; } else if (!canDiff && (e.Command == AnkhCommand.ItemResolveTheirsConflict || e.Command == AnkhCommand.ItemResolveMineConflict)) { e.Enabled = false; } else if (e.Command == AnkhCommand.ItemResolveMergeTool) { e.Enabled = false; } else if (e.Command == AnkhCommand.ItemResolveMergeTool && string.IsNullOrEmpty(e.GetService <IAnkhConfigurationService>().Instance.MergeExePath)) { e.Enabled = false; } }
public override void OnUpdate(CommandUpdateEventArgs e) { if (!e.State.SolutionExists || e.State.SolutionBuilding || e.State.Debugging || e.State.SolutionOpening) { e.Enabled = false; return; } e.Enabled = !EnumTools.IsEmpty(GetChanges(e)); }
public override void OnUpdate(CommandUpdateEventArgs e) { if (e.Command == AnkhCommand.FileFileAddFromSubversion || e.Command == AnkhCommand.FileSccAddFromSubversion) { if (!e.State.SolutionExists || e.State.SolutionBuilding || e.State.Debugging) { e.Enabled = e.Visible = false; } } }
public override void OnUpdate(CommandUpdateEventArgs e) { switch (e.Command) { case AnkhCommand.ShowPendingChanges: if (!e.State.SccProviderActive) e.Visible = e.Enabled = false; break; } }
public override void OnUpdate(CommandUpdateEventArgs e) { if (!e.State.SolutionExists || e.State.SolutionBuilding || e.State.Debugging || e.State.SolutionOpening) { e.Enabled = false; return; } switch (e.Command) { case AnkhCommand.SolutionSwitchDialog: IAnkhSolutionSettings solutionSettings = e.GetService <IAnkhSolutionSettings>(); SvnItem solutionItem = solutionSettings.ProjectRootSvnItem; if (solutionItem == null || !solutionItem.IsVersioned || solutionItem.IsNewAddition) { e.Enabled = false; return; } break; case AnkhCommand.SwitchProject: SccProject oneProject = EnumTools.GetSingle(e.Selection.GetSelectedProjects(false)); if (oneProject == null) { e.Enabled = false; return; } IProjectFileMapper pfm = e.GetService <IProjectFileMapper>(); ISccProjectInfo pi = pfm.GetProjectInfo(oneProject); if (pi == null || pi.ProjectDirectory == null) { e.Enabled = false; return; } SvnItem projectItem = e.GetService <ISvnStatusCache>()[pi.ProjectDirectory]; if (projectItem == null || !projectItem.IsVersioned || projectItem.IsNewAddition) { e.Enabled = false; } break; case AnkhCommand.SwitchItem: SvnItem oneItem = EnumTools.GetSingle(e.Selection.GetSelectedSvnItems(false)); if (oneItem == null || !oneItem.IsVersioned || oneItem.IsNewAddition) { e.Enabled = false; } break; } }
public override void OnUpdate(CommandUpdateEventArgs e) { foreach (SvnItem item in e.Selection.GetSelectedSvnItems(true)) { if (item.Exists) { return; } } e.Enabled = false; }
public void OnUpdate(CommandUpdateEventArgs e) { IAnkhIssueService service = null; SvnItem item = null; e.Enabled = true && (item = GetRoot(e)) != null && item.IsVersioned // ensure solution (project root) is versioned && (service = e.GetService<IAnkhIssueService>())!= null && service.Connectors != null && service.Connectors.Count > 0; }
private static void OnUpdateRemove(CommandUpdateEventArgs e) { foreach (SvnItem item in e.Selection.GetSelectedSvnItems(false)) { if (item.IsVersioned && !string.IsNullOrEmpty(item.Status.ChangeList)) { return; } } e.Enabled = false; }
public override void OnUpdate(CommandUpdateEventArgs e) { foreach (SvnItem item in e.Selection.GetSelectedSvnItems(false)) { if (item.IsLocked) { return; } } e.Enabled = false; // No need to unlock anything if we are not versioned or not locked }
public void OnUpdate(CommandUpdateEventArgs e) { if (!e.State.SolutionExists) { e.Enabled = false; return; } PendingChangesPage page = GetPage(e); if (page == null || !page.CanRefreshList) e.Enabled = false; }
public virtual void OnUpdate(CommandUpdateEventArgs e) { SmartListView list = GetListView(e); if (list == null) { e.Enabled = false; return; } OnUpdate(list, e); }
/// <summary> /// Raises the <see cref="E:Update"/> event. /// </summary> /// <param name="e">The <see cref="Ankh.Commands.CommandUpdateEventArgs"/> instance containing the event data.</param> protected internal void OnUpdate(CommandUpdateEventArgs e) { if (ICommand != null) { ICommand.OnUpdate(e); } if (Update != null) { Update(this, e); } }
public void OnUpdate(CommandUpdateEventArgs e) { PendingCommitsPage page = e.Context.GetService<PendingCommitsPage>(); if(page == null || !page.Visible || e.Selection.ActiveDialog != null) { e.Enabled = false; return; } e.Checked = page.LogMessageVisible; }
public override void OnUpdate(CommandUpdateEventArgs e) { foreach (SvnItem item in e.Selection.GetSelectedSvnItems(false)) { if (item.IsCasingConflicted) { // Ok, something we can fix! return; } } e.Enabled = false; }
public override void OnUpdate(CommandUpdateEventArgs e) { bool recursive = (e.Command != AnkhCommand.CommitProjectFile); foreach (SvnItem i in e.Selection.GetSelectedSvnItems(recursive)) { if (PendingChange.IsPending(i)) { return; } } e.Enabled = false; }
public override void OnUpdate(CommandUpdateEventArgs e) { if (!e.State.SolutionExists || e.State.SolutionBuilding || e.State.Debugging || e.State.SolutionOpening) { e.Enabled = false; return; } SvnItem item = GetRoot(e); if (item == null || !item.IsVersioned || item.IsDeleteScheduled || item.Status.LocalNodeStatus == SvnStatus.Added || item.Uri == null) { e.Enabled = false; } }
public override void OnUpdate(CommandUpdateEventArgs e) { IAnkhSolutionSettings ss = e.GetService<IAnkhSolutionSettings>(); if (ss != null && !string.IsNullOrEmpty(ss.ProjectRoot) && ss.ProjectRootSvnItem.IsVersioned) { IAnkhConfigurationService cs = e.GetService<IAnkhConfigurationService>(); if (!string.IsNullOrEmpty(cs.Instance.PatchExePath)) return; } e.Enabled = false; }
public override void OnUpdate(CommandUpdateEventArgs e) { if (!SmartListView.SupportsGrouping) { e.Visible = e.Enabled = false; // Group by is XP+ e.DynamicMenuEnd = (e.Command != (AnkhCommand)AnkhCommandMenu.ListViewGroup); return; } if (e.Command == (AnkhCommand)AnkhCommandMenu.ListViewGroup) return; base.OnUpdate(e); }
public override void OnUpdate(CommandUpdateEventArgs e) { if (e.Command == AnkhCommand.DocumentShowChanges) { SvnItem sel = e.Selection.ActiveDocumentSvnItem; if (sel == null || sel.IsDirectory || !sel.IsLocalDiffAvailable) { e.Enabled = false; } return; } bool noConflictDiff = e.Command == AnkhCommand.ItemShowChanges; foreach (SvnItem item in e.Selection.GetSelectedSvnItems(false)) { if (!item.IsFile && (e.Command != AnkhCommand.DiffLocalItem || item.NodeKind != SvnNodeKind.File)) { e.Enabled = false; return; } if (item.IsVersioned && (item.Status.LocalNodeStatus != SvnStatus.Added || item.Status.IsCopied)) { if (e.Command == AnkhCommand.ItemCompareBase || e.Command == AnkhCommand.ItemShowChanges ) { if (!item.IsLocalDiffAvailable) { // skip if local diff is not available // single-select -> don't show 'Show Changes" option // multi-select -> show the option, exclude these items during execution continue; } } if (noConflictDiff && item.IsConflicted) { // Use advanced diff to get a diff, or 'Edit Conflict' to resolve it continue; } return; } } e.Enabled = false; }
internal void OnUpdate(Ankh.Commands.CommandUpdateEventArgs e) { switch (e.Command) { case AnkhCommand.PcLogEditorPasteFileList: if (!UI.HasCheckedItems) { e.Enabled = false; } return; case AnkhCommand.PcLogEditorPasteRecentLog: return; } }
public void OnUpdate(CommandUpdateEventArgs e) { bool disable = true; /* #if DEBUG RecentChangesPage rcPage = e.Context.GetService<RecentChangesPage>(); disable = rcPage == null || !rcPage.Visible; #endif */ if (disable) { e.Enabled = false; return; } }
public override void OnUpdate(CommandUpdateEventArgs e) { foreach (SvnItem item in e.Selection.GetSelectedSvnItems(true)) { if (item.IsVersioned) { return; } else if (item.IsFile && item.IsVersionable && item.InSolution && !item.IsIgnored && !item.IsSccExcluded) { return; // New files can be added } } e.Enabled = false; }
public override void OnUpdate(CommandUpdateEventArgs e) { IAnkhSolutionSettings ss = e.GetService <IAnkhSolutionSettings>(); if (ss != null && !string.IsNullOrEmpty(ss.ProjectRoot) && ss.ProjectRootSvnItem.IsVersioned) { IAnkhConfigurationService cs = e.GetService <IAnkhConfigurationService>(); if (!string.IsNullOrEmpty(cs.Instance.PatchExePath)) { return; } } e.Enabled = false; }
public override void OnUpdate(CommandUpdateEventArgs e) { bool hasDirectory = false; bool hasFile = false; if (e.State.SolutionBuilding || e.State.Debugging || e.State.SolutionOpening) { e.Enabled = false; return; } foreach (SvnItem item in e.Selection.GetSelectedSvnItems(false)) { if (item.IsDirectory) { hasDirectory = true; } else if (item.IsFile) { hasFile = true; } if (hasFile && hasDirectory) { break; } } if (hasDirectory && !hasFile) { // User should use the recursive folder update e.Enabled = false; return; } if (e.Command != AnkhCommand.UpdateProjectFileSpecific) { foreach (SvnItem item in e.Selection.GetSelectedSvnItems(true)) { if (item.IsVersioned) { return; } } } e.Enabled = false; }
public override void OnUpdate(CommandUpdateEventArgs e) { foreach (SvnItem i in e.Selection.GetSelectedSvnItems(true)) { if (i.IsVersioned) { if (i.IsModified || i.IsDocumentDirty) return; // There might be a new version of this file } else if (i.IsIgnored) continue; else if (i.InSolution && i.IsVersionable) return; // The file is 'to be added' } e.Enabled = false; }
public override void OnUpdate(CommandUpdateEventArgs e) { if (e.State.SolutionBuilding || e.State.Debugging || e.State.SolutionOpening) { e.Enabled = false; return; } foreach (SvnItem item in e.Selection.GetSelectedSvnItems(true)) { if (item.IsModified || (item.IsVersioned && item.IsDocumentDirty) || item.IsConflicted) { return; } } e.Enabled = false; }
public override void OnUpdate(CommandUpdateEventArgs e) { switch (e.Command) { case AnkhCommand.SvnNodeAnnotate: ISvnRepositoryItem ri = EnumTools.GetSingle(e.Selection.GetSelection <ISvnRepositoryItem>()); if (ri != null && ri.Origin != null && ri.NodeKind != SvnNodeKind.Directory) { return; } break; case AnkhCommand.ItemAnnotate: foreach (SvnItem item in e.Selection.GetSelectedSvnItems(false)) { if (item.IsFile && item.IsVersioned && item.HasCopyableHistory) { return; } } break; case AnkhCommand.DocumentAnnotate: if (e.Selection.ActiveDocumentSvnItem != null && e.Selection.ActiveDocumentSvnItem.HasCopyableHistory) { return; } break; case AnkhCommand.LogAnnotateRevision: ILogControl logControl = e.Selection.GetActiveControl <ILogControl>(); if (logControl == null || logControl.Origins == null) { e.Visible = e.Enabled = false; return; } if (!EnumTools.IsEmpty(e.Selection.GetSelection <ISvnLogChangedPathItem>())) { return; } break; } e.Enabled = false; }
public override void OnUpdate(CommandUpdateEventArgs e) { foreach (SvnItem item in e.Selection.GetSelectedSvnItems(true)) { if (item.IsVersioned || !item.IsVersionable) { continue; } SvnDirectory dir = item.ParentDirectory; if (dir != null && !dir.NeedsWorkingCopyUpgrade) { return; // We found an add item } } e.Enabled = false; }
public override void OnUpdate(CommandUpdateEventArgs e) { bool foundOne = false; bool canDiff = true; foreach (SvnItem item in e.Selection.GetSelectedSvnItems(true)) { if (!item.IsConflicted) continue; foundOne = true; if (item.IsTreeConflicted) switch (e.Command) { case AnkhCommand.ItemResolveMerge: case AnkhCommand.ItemResolveMergeTool: case AnkhCommand.ItemResolveMineFull: case AnkhCommand.ItemResolveTheirsFull: case AnkhCommand.ItemResolveMineConflict: case AnkhCommand.ItemResolveTheirsConflict: case AnkhCommand.ItemResolveBase: e.Enabled = false; // Subversion can't handle these and neither can we. return; case AnkhCommand.ItemResolveWorking: default: break; } if (!item.IsTextFile) { canDiff = false; } } if (!foundOne) e.Enabled = false; else if (!canDiff && (e.Command == AnkhCommand.ItemResolveTheirsConflict || e.Command == AnkhCommand.ItemResolveMineConflict)) e.Enabled = false; else if (e.Command == AnkhCommand.ItemResolveMergeTool) e.Enabled = false; else if (e.Command == AnkhCommand.ItemResolveMergeTool && string.IsNullOrEmpty(e.GetService<IAnkhConfigurationService>().Instance.MergeExePath)) e.Enabled = false; }
public override void OnUpdate(CommandUpdateEventArgs e) { SvnItem node = EnumTools.GetSingle(e.Selection.GetSelectedSvnItems(false)); if (node == null && e.Selection.IsSingleNodeSelection) { node = EnumTools.GetFirst(e.Selection.GetSelectedSvnItems(false)); } bool enable = true; if (node == null) { enable = false; } else if (e.Command == AnkhCommand.ItemSelectInRepositoryExplorer) { enable = node.Uri != null; } else if (e.Command == AnkhCommand.ItemSelectInWorkingCopyExplorer || e.Command == AnkhCommand.ItemSelectInFileExplorer) { enable = node.Exists; } else if (e.Command == AnkhCommand.ItemSelectInSolutionExplorer) { if (e.State.SolutionExplorerActive) { enable = false; } else if (!node.InSolution) { enable = false; } } if (!enable) { e.Enabled = false; } }
public bool Execute(AnkhCommand command, CommandEventArgs e) { EnsureLoaded(); CommandMapItem item; if (_map.TryGetValue(command, out item)) { try { e.Prepare(item); CommandUpdateEventArgs u = new CommandUpdateEventArgs(command, e.Context); item.OnUpdate(u); if (u.Enabled) { item.OnExecute(e); } else { return(false); } } catch (Exception ex) { IAnkhErrorHandler eh = GetService <IAnkhErrorHandler>(); if (eh != null && eh.IsEnabled(ex)) { eh.OnError(ex, e); return(true); // If we return false VS shows another error box! } throw; } return(item.IsHandled); } return(false); }
public override void OnUpdate(CommandUpdateEventArgs e) { if (StatusCache == null || !StatusCache.EnableUpgradeCommand) { e.Enabled = false; return; } foreach (SvnItem item in e.Selection.GetSelectedSvnItems(true)) { SvnDirectory dir = item.ParentDirectory; if (dir != null && dir.NeedsWorkingCopyUpgrade) { return; } else if (item.IsDirectory && item.AsDirectory().NeedsWorkingCopyUpgrade) { return; } } e.Enabled = false; }
public void OnUpdate(CommandUpdateEventArgs e) { switch (e.Command) { case AnkhCommand.PcLogEditorOpenIssue: { IssueMarker im; if (!TryGetIssue(e, out im)) e.Enabled = false; } break; case AnkhCommand.LogOpenIssue: { ISvnLogItem item = EnumTools.GetSingle(e.Selection.GetSelection<ISvnLogItem>()); if (item == null) e.Enabled = false; else if (EnumTools.IsEmpty(item.Issues)) e.Enabled = false; } break; } }
public override void OnUpdate(CommandUpdateEventArgs e) { if (e.Command == AnkhCommand.SccLock) { return; // Always enabled } bool mustOnly = (e.Command == AnkhCommand.LockMustLock); foreach (SvnItem item in e.Selection.GetSelectedSvnItems(false)) { if (mustOnly && !item.IsReadOnlyMustLock) { continue; } if (item.IsFile && item.IsVersioned && !item.IsNewAddition && !item.IsLocked) { return; } } e.Enabled = false; }
protected override void OnUpdate(SmartListView list, CommandUpdateEventArgs e) { int n = (int)(e.Command - AnkhCommand.ListViewShow0); if (n >= list.AllColumns.Count || n < 0) { e.Text = ""; e.DynamicMenuEnd = true; return; } SmartColumn column = list.AllColumns[n]; if (e.TextQueryType == TextQueryType.Name) { e.Text = column.MenuText; } if (!column.Hideable) e.Enabled = false; e.Checked = list.Columns.Contains(column); }
public override void OnUpdate(CommandUpdateEventArgs e) { bool foundOne = false; foreach (SvnItem item in e.Selection.GetSelectedSvnItems(false)) { if (!item.Exists) { continue; } if (!item.IsFile) { e.Enabled = false; return; } foundOne = true; } if (!foundOne) { e.Enabled = false; } }
public override void OnUpdate(CommandUpdateEventArgs e) { if (!e.State.SolutionExists || (e.Command == AnkhCommand.FileSccAddProjectToSubversion && e.State.EmptySolution)) { e.Visible = e.Enabled = false; return; } if (e.State.OtherSccProviderActive) { e.Visible = e.Enabled = false; return; // Only one scc provider can be active at a time } IAnkhSccService scc = e.GetService<IAnkhSccService>(); IFileStatusCache cache = e.GetService<IFileStatusCache>(); if (scc == null || cache == null) { e.Visible = e.Enabled = false; return; } string solutionFilename = e.Selection.SolutionFilename; if (string.IsNullOrEmpty(solutionFilename) || !SvnItem.IsValidPath(solutionFilename)) solutionFilename = null; if (e.Command == AnkhCommand.FileSccAddSolutionToSubversion) { if (solutionFilename == null || scc.IsSolutionManaged) { e.Visible = e.Enabled = false; // Already handled return; } SvnItem item = cache[solutionFilename]; if (!item.Exists || !item.IsFile) { // Decide where you store the .sln first e.Visible = e.Enabled = false; return; } if (!item.IsVersioned) { // If the .sln is ignored hide it in the context menus // but don't hide it on e.HideOnContextMenu = item.IsIgnored && !e.Selection.IsSolutionSelected; } return; } IProjectFileMapper pfm = e.GetService<IProjectFileMapper>(); int n = 0; bool foundOne = false; foreach (IEnumerable<SvnProject> projects in new IEnumerable<SvnProject>[] { e.Selection.GetSelectedProjects(true), e.Selection.GetSelectedProjects(false) }) { foreach (SvnProject p in projects) { foundOne = true; ISvnProjectInfo pi = pfm.GetProjectInfo(p); if (pi == null || !pi.IsSccBindable) continue; // Not an SCC project // A project is managed if the file says its managed // and the project dir is managed if (pi.ProjectDirectory != null && cache[pi.ProjectDirectory].IsVersioned && scc.IsProjectManaged(p)) continue; // Nothing to do here string projectFile = pi.ProjectFile; if (n > 1 && projectFile != null && cache[projectFile].IsIgnored) e.HideOnContextMenu = true; return; } n++; if (foundOne) break; } e.Visible = e.Enabled = false; }
public int QueryStatus(AnkhContext context, uint cCmds, OLECMD[] prgCmds, IntPtr pCmdText) { if (context == null) throw new ArgumentNullException("context"); else if (cCmds != 1 || prgCmds == null) return -1; TextQueryType textQuery = TextQueryType.None; if (pCmdText != IntPtr.Zero) { // VS Want's some text from us for either the statusbar or the command text OLECMDTEXTF textType = GetFlags(pCmdText); switch (textType) { case OLECMDTEXTF.OLECMDTEXTF_NAME: textQuery = TextQueryType.Name; break; case OLECMDTEXTF.OLECMDTEXTF_STATUS: textQuery = TextQueryType.Status; break; } } CommandUpdateEventArgs updateArgs = new CommandUpdateEventArgs((AnkhCommand)prgCmds[0].cmdID, context, textQuery); OLECMDF cmdf = OLECMDF.OLECMDF_SUPPORTED; if (PerformUpdate(updateArgs.Command, updateArgs)) { updateArgs.UpdateFlags(ref cmdf); } if (updateArgs.DynamicMenuEnd) return (int)OLEConstants.OLECMDERR_E_NOTSUPPORTED; if (textQuery != TextQueryType.None && !string.IsNullOrEmpty(updateArgs.Text)) { SetText(pCmdText, updateArgs.Text); } if (_customizeMode && updateArgs.Command != AnkhCommand.ForceUIShow) prgCmds[0].cmdf = (uint)(cmdf & ~OLECMDF.OLECMDF_INVISIBLE); else prgCmds[0].cmdf = (uint)cmdf; return 0; // S_OK }
public bool PerformUpdate(AnkhCommand command, CommandUpdateEventArgs e) { EnsureLoaded(); CommandMapItem item; if (_map.TryGetValue(command, out item)) { if (!item.AlwaysAvailable && !e.State.SccProviderActive) e.Enabled = false; else try { e.Prepare(item); item.OnUpdate(e); } catch (Exception ex) { IAnkhErrorHandler eh = GetService<IAnkhErrorHandler>(); if (eh != null && eh.IsEnabled(ex)) { eh.OnError(ex, e); return false; } throw; } if (item.HiddenWhenDisabled && !e.Enabled) e.Visible = false; if (item.DynamicMenuEnd) e.DynamicMenuEnd = true; return item.IsHandled; } else if (_defined.Contains(command)) { e.Enabled = e.Visible = false; return true; } return false; }
public bool Execute(AnkhCommand command, CommandEventArgs e) { EnsureLoaded(); CommandMapItem item; if (_map.TryGetValue(command, out item)) { try { e.Prepare(item); CommandUpdateEventArgs u = new CommandUpdateEventArgs(command, e.Context); item.OnUpdate(u); if (u.Enabled) { item.OnExecute(e); } else return false; } catch (Exception ex) { IAnkhErrorHandler eh = GetService<IAnkhErrorHandler>(); if (eh != null && eh.IsEnabled(ex)) { eh.OnError(ex, e); return true; // If we return false VS shows another error box! } throw; } return item.IsHandled; } return false; }
/// <summary> /// Raises the <see cref="E:Update"/> event. /// </summary> /// <param name="e">The <see cref="Ankh.Commands.CommandUpdateEventArgs"/> instance containing the event data.</param> protected internal void OnUpdate(CommandUpdateEventArgs e) { if (ICommand != null) ICommand.OnUpdate(e); if (Update != null) Update(this, e); }
public override void OnUpdate(CommandUpdateEventArgs e) { if (e.Command == AnkhCommand.FileFileAddFromSubversion || e.Command == AnkhCommand.FileSccAddFromSubversion) { if (!e.State.SolutionExists || e.State.SolutionBuilding || e.State.Debugging) e.Enabled = e.Visible = false; } }
public void OnUpdate(CommandUpdateEventArgs e) { }