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) { 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) { 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 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 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 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 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; }
public override void OnUpdate(CommandUpdateEventArgs e) { IFileStatusCache statusCache; switch (e.Command) { case AnkhCommand.SolutionSwitchDialog: IAnkhSolutionSettings solutionSettings = e.GetService<IAnkhSolutionSettings>(); if (solutionSettings == null || string.IsNullOrEmpty(solutionSettings.ProjectRoot)) { e.Enabled = false; return; } statusCache = e.GetService<IFileStatusCache>(); SvnItem solutionItem = statusCache[solutionSettings.ProjectRoot]; if (!solutionItem.IsVersioned) { e.Enabled = false; return; } break; case AnkhCommand.SwitchProject: statusCache = e.GetService<IFileStatusCache>(); IProjectFileMapper pfm = e.GetService<IProjectFileMapper>(); foreach (SvnProject item in e.Selection.GetSelectedProjects(true)) { ISvnProjectInfo pi = pfm.GetProjectInfo(item); if (pi == null || pi.ProjectDirectory == null) { e.Enabled = false; return; } SvnItem projectItem = statusCache[pi.ProjectDirectory]; if (!projectItem.IsVersioned) { e.Enabled = false; return; } } break; case AnkhCommand.SwitchItem: bool foundOne = false, error = false; foreach (SvnItem item in e.Selection.GetSelectedSvnItems(false)) { if (item.IsVersioned && !foundOne) foundOne = true; else { error = true; break; } } e.Enabled = foundOne && !error; break; } }
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 override void OnUpdate(CommandUpdateEventArgs e) { int i; switch (e.Command) { case AnkhCommand.ProjectHistory: SvnProject p = EnumTools.GetFirst(e.Selection.GetSelectedProjects(false)); if (p == null) break; ISvnProjectInfo pi = e.GetService<IProjectFileMapper>().GetProjectInfo(p); if (pi == null || string.IsNullOrEmpty(pi.ProjectDirectory)) break; // No project location if (e.GetService<IFileStatusCache>()[pi.ProjectDirectory].HasCopyableHistory) return; // Ok, we have history! break; // No history case AnkhCommand.SolutionHistory: IAnkhSolutionSettings ss = e.GetService<IAnkhSolutionSettings>(); if (ss == null || string.IsNullOrEmpty(ss.ProjectRoot)) break; if (e.GetService<IFileStatusCache>()[ss.ProjectRoot].HasCopyableHistory) return; // Ok, we have history! break; // No history case AnkhCommand.DocumentHistory: SvnItem docitem = e.Selection.ActiveDocumentItem; if (docitem != null && docitem.HasCopyableHistory) return; break; // No history case AnkhCommand.Log: int itemCount = 0; int needsRemoteCount = 0; foreach (SvnItem item in e.Selection.GetSelectedSvnItems(false)) { if (!item.IsVersioned) { e.Enabled = false; return; } if (item.IsReplaced || item.IsAdded) { if (item.HasCopyableHistory) needsRemoteCount++; else { e.Enabled = false; return; } } itemCount++; } if (itemCount == 0 || (needsRemoteCount != 0 && itemCount > 1)) { e.Enabled = false; return; } if (needsRemoteCount >= 1) { // One remote log Debug.Assert(needsRemoteCount == 1); return; } // Local log only return; case AnkhCommand.ReposExplorerLog: i = 0; foreach (ISvnRepositoryItem item in e.Selection.GetSelection<ISvnRepositoryItem>()) { if (item == null || item.Origin == null) continue; i++; if (i > 1) break; } if (i == 1) return; break; case AnkhCommand.AnnotateShowLog: if (EnumTools.GetSingle(e.Selection.GetSelection<IAnnotateSection>()) != null) return; break; } e.Enabled = false; }
/// <summary> /// /// </summary> /// <param name="e">The <see cref="Ankh.Commands.CommandUpdateEventArgs"/> instance containing the event data.</param> public override void OnUpdate(CommandUpdateEventArgs e) { ISvnStatusCache cache; int count = 0; switch (e.Command) { case AnkhCommand.ItemEditProperties: case AnkhCommand.ItemShowPropertyChanges: foreach (SvnItem i in e.Selection.GetSelectedSvnItems(false)) { if (i.IsVersioned) { count++; if (e.Command == AnkhCommand.ItemShowPropertyChanges && !i.IsPropertyModified) { e.Enabled = false; return; } if (e.Selection.IsSingleNodeSelection) { break; } if (count > 1) { e.Enabled = false; return; } } } break; case AnkhCommand.ProjectEditProperties: IProjectFileMapper pfm = e.GetService <IProjectFileMapper>(); cache = e.GetService <ISvnStatusCache>(); foreach (SccProject project in e.Selection.GetSelectedProjects(false)) { ISccProjectInfo info = pfm.GetProjectInfo(project); if (info == null || string.IsNullOrEmpty(info.ProjectDirectory)) { e.Enabled = false; return; } SvnItem projectFolder = cache[info.ProjectDirectory]; if (projectFolder.IsVersioned) { count++; } if (count > 1) { break; } } break; case AnkhCommand.SolutionEditProperties: cache = e.GetService <ISvnStatusCache>(); IAnkhSolutionSettings solutionSettings = e.GetService <IAnkhSolutionSettings>(); if (solutionSettings == null || string.IsNullOrEmpty(solutionSettings.ProjectRoot)) { e.Enabled = false; return; } SvnItem solutionItem = cache[solutionSettings.ProjectRoot]; if (solutionItem.IsVersioned) { count = 1; } break; default: throw new InvalidOperationException(); } if (count == 0 || (count > 1 && !e.Selection.IsSingleNodeSelection)) { e.Enabled = false; } }
/// <see cref="Ankh.Commands.ICommandHandler.OnUpdate" /> public void OnUpdate(CommandUpdateEventArgs e) { IFileStatusCache statusCache; int n = 0; switch (e.Command) { case AnkhCommand.ItemMerge: foreach (SvnItem item in e.Selection.GetSelectedSvnItems(false)) { if (!item.IsVersioned) { e.Enabled = false; return; } n++; if (n > 1) break; } break; case AnkhCommand.ProjectMerge: statusCache = e.GetService<IFileStatusCache>(); IProjectFileMapper pfm = e.GetService<IProjectFileMapper>(); foreach (SvnProject project in e.Selection.GetSelectedProjects(false)) { ISvnProjectInfo projInfo = pfm.GetProjectInfo(project); if (projInfo == null || string.IsNullOrEmpty(projInfo.ProjectDirectory)) { e.Enabled = false; return; } SvnItem projectDir = statusCache[projInfo.ProjectDirectory]; if (!projectDir.IsVersioned) { e.Enabled = false; return; } n++; if (n > 1) break; } break; case AnkhCommand.SolutionMerge: statusCache = e.GetService<IFileStatusCache>(); IAnkhSolutionSettings solutionSettings = e.GetService<IAnkhSolutionSettings>(); if (solutionSettings == null || string.IsNullOrEmpty(solutionSettings.ProjectRoot)) { e.Enabled = false; return; } SvnItem solutionItem = statusCache[solutionSettings.ProjectRoot]; if (solutionItem.IsVersioned) n = 1; break; default: throw new InvalidOperationException(); } if (n != 1) 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) { if (!e.State.SolutionExists || (e.Command == AnkhCommand.FileSccAddProjectToSubversion && e.State.EmptySolution)) { e.Enabled = false; return; } if (e.State.OtherSccProviderActive) { e.Enabled = false; return; // Only one scc provider can be active at a time } IAnkhSccService scc = e.GetService <IAnkhSccService>(); ISvnStatusCache cache = e.GetService <ISvnStatusCache>(); if (scc == null || cache == null) { 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.Enabled = false; // Already handled return; } SvnItem item = cache[solutionFilename]; if (!item.Exists || !item.IsFile || item.ParentDirectory.NeedsWorkingCopyUpgrade) { // Decide where you store the .sln first e.Enabled = false; return; } if (!item.IsVersioned) { // If the .sln is ignored hide it in the context menus // but don't hide it on the node itself e.HideOnContextMenu = item.IsIgnored && !e.Selection.IsSolutionSelected; } return; } IProjectFileMapper pfm = e.GetService <IProjectFileMapper>(); int n = 0; bool foundOne = false; foreach (IEnumerable <SccProject> projects in new IEnumerable <SccProject>[] { e.Selection.GetSelectedProjects(true), e.Selection.GetSelectedProjects(false) }) { foreach (SccProject p in projects) { foundOne = true; ISccProjectInfo 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.Enabled = false; }
public override void OnUpdate(CommandUpdateEventArgs e) { if (e.State.SolutionBuilding || e.State.Debugging || e.State.SolutionOpening) { e.Enabled = false; return; } if (IsSolutionCommand(e.Command)) { IAnkhSolutionSettings settings = e.GetService <IAnkhSolutionSettings>(); if (settings == null || string.IsNullOrEmpty(settings.ProjectRoot)) { e.Enabled = false; return; } if (!settings.ProjectRootSvnItem.IsVersioned) { e.Enabled = false; } } else if (IsFolderCommand(e.Command)) { bool forHead = IsHeadCommand(e.Command); bool foundOne = false; Uri root = null; foreach (SvnItem dir in e.Selection.GetSelectedSvnItems(false)) { if (!dir.IsDirectory || !dir.IsVersioned) { e.Enabled = false; break; } foundOne = true; if (!forHead) { Uri reposRoot = dir.WorkingCopy.RepositoryRoot; if (root != reposRoot) { if (root == null) { reposRoot = root; } else { e.Enabled = false; break; } } } } if (!foundOne) { e.Enabled = false; } } else { IProjectFileMapper pfm = null; ISvnStatusCache fsc = null; Uri rootUrl = null; foreach (SccProject p in GetSelectedProjects(e)) { if (pfm == null) { pfm = e.GetService <IProjectFileMapper>(); } ISccProjectInfo pi = pfm.GetProjectInfo(p); if (pi == null || pi.ProjectDirectory == null) { continue; } if (fsc == null) { fsc = e.GetService <ISvnStatusCache>(); } SvnItem rootItem = fsc[pi.ProjectDirectory]; if (!rootItem.IsVersioned) { continue; } if (IsHeadCommand(e.Command)) { return; // Ok, we can update } if (rootUrl == null) { rootUrl = rootItem.WorkingCopy.RepositoryRoot; } else if (rootUrl != rootItem.WorkingCopy.RepositoryRoot) { // Multiple repositories selected; can't choose uniform version e.Enabled = false; return; } } if (rootUrl == null) { 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; }
/// <summary> /// /// </summary> /// <param name="e">The <see cref="Ankh.Commands.CommandUpdateEventArgs"/> instance containing the event data.</param> public override void OnUpdate(CommandUpdateEventArgs e) { IFileStatusCache cache; int count = 0; switch (e.Command) { case AnkhCommand.ItemEditProperties: case AnkhCommand.ItemShowPropertyChanges: foreach (SvnItem i in e.Selection.GetSelectedSvnItems(false)) { if (i.IsVersioned) { count++; if (e.Command == AnkhCommand.ItemShowPropertyChanges && !i.IsPropertyModified) { e.Enabled = false; return; } if (e.Selection.IsSingleNodeSelection) break; if (count > 1) { e.Enabled = false; return; } } } break; case AnkhCommand.ProjectEditProperties: IProjectFileMapper pfm = e.GetService<IProjectFileMapper>(); cache = e.GetService<IFileStatusCache>(); foreach (SvnProject project in e.Selection.GetSelectedProjects(false)) { ISvnProjectInfo info = pfm.GetProjectInfo(project); if (info == null || string.IsNullOrEmpty(info.ProjectDirectory)) { e.Enabled = false; return; } SvnItem projectFolder = cache[info.ProjectDirectory]; if (projectFolder.IsVersioned) count++; if (count > 1) break; } break; case AnkhCommand.SolutionEditProperties: cache = e.GetService<IFileStatusCache>(); IAnkhSolutionSettings solutionSettings = e.GetService<IAnkhSolutionSettings>(); if (solutionSettings == null || string.IsNullOrEmpty(solutionSettings.ProjectRoot)) { e.Enabled = false; return; } SvnItem solutionItem = cache[solutionSettings.ProjectRoot]; if (solutionItem.IsVersioned) count = 1; break; default: throw new InvalidOperationException(); } if (count == 0 || (count > 1 && !e.Selection.IsSingleNodeSelection)) e.Enabled = false; }
public override void OnUpdate(CommandUpdateEventArgs e) { int i; switch (e.Command) { case AnkhCommand.ProjectHistory: SccProject p = EnumTools.GetFirst(e.Selection.GetSelectedProjects(false)); if (p == null) { break; } ISccProjectInfo pi = e.GetService <IProjectFileMapper>().GetProjectInfo(p); if (pi == null || string.IsNullOrEmpty(pi.ProjectDirectory)) { break; // No project location } if (e.GetService <ISvnStatusCache>()[pi.ProjectDirectory].HasCopyableHistory) { return; // Ok, we have history! } break; // No history case AnkhCommand.SolutionHistory: IAnkhSolutionSettings ss = e.GetService <IAnkhSolutionSettings>(); if (ss == null || string.IsNullOrEmpty(ss.ProjectRoot)) { break; } if (e.GetService <ISvnStatusCache>()[ss.ProjectRoot].HasCopyableHistory) { return; // Ok, we have history! } break; // No history case AnkhCommand.DocumentHistory: SvnItem docitem = e.Selection.ActiveDocumentSvnItem; if (docitem != null && docitem.HasCopyableHistory) { return; } break; // No history case AnkhCommand.Log: int itemCount = 0; int needsRemoteCount = 0; foreach (SvnItem item in e.Selection.GetSelectedSvnItems(false)) { if (!item.IsVersioned) { e.Enabled = false; return; } if (item.IsReplaced || item.IsAdded) { if (item.HasCopyableHistory) { needsRemoteCount++; } else { e.Enabled = false; return; } } itemCount++; } if (itemCount == 0 || (needsRemoteCount != 0 && itemCount > 1)) { e.Enabled = false; return; } if (needsRemoteCount >= 1) { // One remote log Debug.Assert(needsRemoteCount == 1); return; } // Local log only return; case AnkhCommand.ReposExplorerLog: i = 0; foreach (ISvnRepositoryItem item in e.Selection.GetSelection <ISvnRepositoryItem>()) { if (item == null || item.Origin == null) { continue; } i++; break; } if (i >= 1) { return; } break; case AnkhCommand.AnnotateShowLog: IAnnotateSection section = EnumTools.GetSingle(e.Selection.GetSelection <IAnnotateSection>()); if (section != null && section.Revision >= 0) { return; } break; } e.Enabled = false; }
public override void OnUpdate(CommandUpdateEventArgs e) { if (IsSolutionCommand(e.Command)) { IAnkhSolutionSettings settings = e.GetService<IAnkhSolutionSettings>(); if (settings == null || string.IsNullOrEmpty(settings.ProjectRoot)) { e.Enabled = false; return; } if (!settings.ProjectRootSvnItem.IsVersioned) e.Enabled = false; } else if (IsFolderCommand(e.Command)) { bool forHead = IsHeadCommand(e.Command); bool foundOne = false; Uri root = null; foreach (SvnItem dir in e.Selection.GetSelectedSvnItems(false)) { if (!dir.IsDirectory || !dir.IsVersioned) { e.Enabled = false; break; } foundOne = true; if (!forHead) { Uri reposRoot = dir.WorkingCopy.RepositoryRoot; if (root != reposRoot) { if (root == null) reposRoot = root; else { e.Enabled = false; break; } } } } if (!foundOne) { e.Enabled = false; } } else { IProjectFileMapper pfm = null; IFileStatusCache fsc = null; Uri rootUrl = null; foreach (SvnProject p in GetSelectedProjects(e)) { if (pfm == null) pfm = e.GetService<IProjectFileMapper>(); ISvnProjectInfo pi = pfm.GetProjectInfo(p); if (pi == null || pi.ProjectDirectory == null) continue; if (fsc == null) fsc = e.GetService<IFileStatusCache>(); SvnItem rootItem = fsc[pi.ProjectDirectory]; if (!rootItem.IsVersioned) continue; if (IsHeadCommand(e.Command)) return; // Ok, we can update if (rootUrl == null) rootUrl = rootItem.WorkingCopy.RepositoryRoot; else if (rootUrl != rootItem.WorkingCopy.RepositoryRoot) { // Multiple repositories selected; can't choose uniform version e.Enabled = false; return; } } if (rootUrl == null) e.Enabled = false; } }