public void OnUpdate(CommandUpdateEventArgs e) { if (e.State.SccProviderActive) foreach (GitProject p in e.Selection.GetSelectedProjects(false)) { IGitProjectInfo 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 } GitItem 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.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 } IVisualGitSccService scc = e.GetService<IVisualGitSccService>(); 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) || !GitItem.IsValidPath(solutionFilename)) solutionFilename = null; if (solutionFilename == null || scc.IsSolutionManaged) { e.Visible = e.Enabled = false; // Already handled return; } GitItem 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; } else { e.Visible = e.Enabled = false; } }
public override void OnUpdate(CommandUpdateEventArgs e) { IVisualGitSolutionSettings ss = e.GetService<IVisualGitSolutionSettings>(); if (ss != null && !string.IsNullOrEmpty(ss.ProjectRoot) && ss.ProjectRootGitItem.IsVersioned) { IVisualGitConfigurationService cs = e.GetService<IVisualGitConfigurationService>(); if (!string.IsNullOrEmpty(cs.Instance.PatchExePath)) return; } e.Enabled = false; }
public void OnUpdate(CommandUpdateEventArgs e) { IGitLogItem item = EnumTools.GetSingle(e.Selection.GetSelection<IGitLogItem>()); if (item != null) { ILogControl logWindow = e.Selection.GetActiveControl<ILogControl>(); if (logWindow != null) { GitOrigin origin = EnumTools.GetSingle(logWindow.Origins); if (origin != null) { GitItem gitItem = e.GetService<IFileStatusCache>()[origin.Target.FullPath]; if (gitItem != null && !gitItem.IsDirectory) { if (null == e.Selection.GetActiveControl<ILogControl>()) e.Enabled = false; return; } } } } e.Enabled = false; }
public override void OnUpdate(CommandUpdateEventArgs e) { bool add; IPendingChangesManager pcm = null; add = (e.Command == VisualGitCommand.ItemAddToPending) || (e.Command == VisualGitCommand.DocumentAddToPending); foreach (GitItem 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) { switch (e.Command) { case VisualGitCommand.ItemResolveMineConflict: case VisualGitCommand.ItemResolveTheirsConflict: case VisualGitCommand.ItemResolveMergeTool: e.Enabled = false; return; } bool foundOne = false; bool canDiff = true; foreach (GitItem item in e.Selection.GetSelectedGitItems(true)) { if (!item.IsConflicted) continue; foundOne = true; if (item.IsTreeConflicted) switch (e.Command) { case VisualGitCommand.ItemResolveMerge: case VisualGitCommand.ItemResolveMergeTool: case VisualGitCommand.ItemResolveMineFull: case VisualGitCommand.ItemResolveTheirsFull: case VisualGitCommand.ItemResolveMineConflict: case VisualGitCommand.ItemResolveTheirsConflict: case VisualGitCommand.ItemResolveBase: e.Enabled = false; // Git can't handle these and neither can we. return; case VisualGitCommand.ItemResolveWorking: default: break; } if (!item.IsTextFile) { canDiff = false; } } if (!foundOne) e.Enabled = false; else if (!canDiff && (e.Command == VisualGitCommand.ItemResolveTheirsConflict || e.Command == VisualGitCommand.ItemResolveMineConflict)) e.Enabled = false; else if (e.Command == VisualGitCommand.ItemResolveMergeTool) e.Enabled = false; else if (e.Command == VisualGitCommand.ItemResolveMergeTool && string.IsNullOrEmpty(e.GetService<IVisualGitConfigurationService>().Instance.MergeExePath)) e.Enabled = false; }
public override void OnUpdate(CommandUpdateEventArgs e) { IFileStatusCache statusCache; switch (e.Command) { case VisualGitCommand.SolutionSwitchDialog: IVisualGitSolutionSettings solutionSettings = e.GetService<IVisualGitSolutionSettings>(); if (solutionSettings == null || string.IsNullOrEmpty(solutionSettings.ProjectRoot)) { e.Enabled = false; return; } statusCache = e.GetService<IFileStatusCache>(); GitItem solutionItem = statusCache[solutionSettings.ProjectRoot]; if (!solutionItem.IsVersioned) { e.Enabled = false; return; } break; case VisualGitCommand.SwitchProject: statusCache = e.GetService<IFileStatusCache>(); IProjectFileMapper pfm = e.GetService<IProjectFileMapper>(); foreach (GitProject item in e.Selection.GetSelectedProjects(true)) { IGitProjectInfo pi = pfm.GetProjectInfo(item); if (pi == null || pi.ProjectDirectory == null) { e.Enabled = false; return; } GitItem projectItem = statusCache[pi.ProjectDirectory]; if (!projectItem.IsVersioned) { e.Enabled = false; return; } } break; case VisualGitCommand.LogSwitchToRevision: ILogControl logWindow = e.Selection.GetActiveControl<ILogControl>(); if (logWindow == null) { e.Enabled = false; return; } GitOrigin origin = EnumTools.GetSingle(logWindow.Origins); if (origin == null) { e.Enabled = false; return; } int count = 0; foreach (IGitLogItem item in e.Selection.GetSelection<IGitLogItem>()) { count++; if (count > 1) break; } if (count != 1) e.Enabled = false; break; } }
void UpdateForRevChanges(ILogControl logWindow, CommandUpdateEventArgs e) { GitOrigin first = EnumTools.GetSingle(logWindow.Origins); if (first == null) { e.Enabled = false; return; } if (e.GetService<IFileStatusCache>()[first.Target.FullPath].IsDirectory) { // We can't diff directories at this time e.Enabled = false; return; } // Note: We can't have a local directory, but we can have a remote one. }
/// <see cref="VisualGit.Commands.ICommandHandler.OnUpdate" /> public void OnUpdate(CommandUpdateEventArgs e) { IFileStatusCache statusCache; int n = 0; switch (e.Command) { case VisualGitCommand.LogMergeThisRevision: ILogControl logWindow = e.Selection.GetActiveControl<ILogControl>(); if (logWindow == null) { e.Enabled = false; return; } GitOrigin origin = EnumTools.GetSingle(logWindow.Origins); if (origin == null) { e.Enabled = false; return; } IGitLogItem logItem = EnumTools.GetSingle(e.Selection.GetSelection<IGitLogItem>()); e.Enabled = logItem != null; return; case VisualGitCommand.ItemMerge: foreach (GitItem item in e.Selection.GetSelectedGitItems(false)) { if (!item.IsVersioned) { e.Enabled = false; return; } n++; if (n > 1) break; } break; case VisualGitCommand.ProjectMerge: statusCache = e.GetService<IFileStatusCache>(); IProjectFileMapper pfm = e.GetService<IProjectFileMapper>(); foreach (GitProject project in e.Selection.GetSelectedProjects(false)) { IGitProjectInfo projInfo = pfm.GetProjectInfo(project); if (projInfo == null || string.IsNullOrEmpty(projInfo.ProjectDirectory)) { e.Enabled = false; return; } GitItem projectDir = statusCache[projInfo.ProjectDirectory]; if (!projectDir.IsVersioned) { e.Enabled = false; return; } n++; if (n > 1) break; } break; case VisualGitCommand.SolutionMerge: statusCache = e.GetService<IFileStatusCache>(); IVisualGitSolutionSettings solutionSettings = e.GetService<IVisualGitSolutionSettings>(); if (solutionSettings == null || string.IsNullOrEmpty(solutionSettings.ProjectRoot)) { e.Enabled = false; return; } GitItem 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) { switch (e.Command) { case VisualGitCommand.ProjectHistory: GitProject p = EnumTools.GetFirst(e.Selection.GetSelectedProjects(false)); if (p == null) break; IGitProjectInfo 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 VisualGitCommand.SolutionHistory: IVisualGitSolutionSettings ss = e.GetService<IVisualGitSolutionSettings>(); if (ss == null || string.IsNullOrEmpty(ss.ProjectRoot)) break; if (e.GetService<IFileStatusCache>()[ss.ProjectRoot].HasCopyableHistory) return; // Ok, we have history! break; // No history case VisualGitCommand.DocumentHistory: GitItem docitem = e.Selection.ActiveDocumentItem; if (docitem != null && docitem.HasCopyableHistory) return; break; // No history case VisualGitCommand.Log: int itemCount = 0; int needsRemoteCount = 0; foreach (GitItem item in e.Selection.GetSelectedGitItems(false)) { if (!item.IsVersioned) { e.Enabled = false; return; } if (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 VisualGitCommand.AnnotateShowLog: if (EnumTools.GetSingle(e.Selection.GetSelection<IAnnotateSection>()) != null) return; break; } e.Enabled = false; }
public override void OnUpdate(CommandUpdateEventArgs e) { IVisualGitSolutionSettings settings = e.GetService<IVisualGitSolutionSettings>(); if (settings == null || string.IsNullOrEmpty(settings.ProjectRoot)) { e.Enabled = false; return; } if (!settings.ProjectRootGitItem.IsVersioned) e.Enabled = false; }
public void OnUpdate(CommandUpdateEventArgs e) { e.GetService<CommandMapper>().EnableCustomizeMode(); e.Enabled = e.Visible = false; }