Esempio n. 1
0
        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;
        }
Esempio n. 2
0
        public void OnUpdate(CommandUpdateEventArgs e)
        {
            PendingCommitsPage commitPage = e.Context.GetService<PendingCommitsPage>();
            if (commitPage == null)
            {
                e.Enabled = false;
                return;
            }

            switch (e.Command)
            {
                case VisualGitCommand.CommitPendingChanges:
                    e.Enabled = true
                        // check if commit page or issues page is visible
                        && (false
                             || commitPage.Visible
                             )
                         // make sure commit page can commit
                         && commitPage.CanCommit()
                         ;
                    break;
                case VisualGitCommand.PendingChangesApplyWorkingCopy:
                    e.Enabled = commitPage.Visible && commitPage.CanApplyToWorkingCopy();
                    break;
            }
        }
        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)
        {
            GitItem item = GetRoot(e);

            if(item == null || !item.IsVersioned || item.IsDeleteScheduled || item.Status.State == GitStatus.Added || item.FullPath == null)
                e.Enabled = false;
        }
Esempio n. 5
0
        public override void OnUpdate(CommandUpdateEventArgs e)
        {
            GitItem i = EnumTools.GetSingle(e.Selection.GetSelectedGitItems(false));

            if (i == null)
                e.Enabled = false;
        }
Esempio n. 6
0
        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((VisualGitCommand)cd.ID, GetService<VisualGitContext>());
                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;
        }
Esempio n. 7
0
        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;
        }
Esempio n. 8
0
        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)
        {
            WorkingCopyExplorerControl ctrl = e.Selection.ActiveDialogOrFrameControl as WorkingCopyExplorerControl;

            if (ctrl == null)
                e.Enabled = false;
            else
                e.Enabled = ctrl.IsWcRootSelected();
        }
Esempio n. 10
0
        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 == VisualGitCommand.PcLogEditorPasteFileList && !lme.PasteSource.HasPendingChanges)
                e.Enabled = false;
        }
Esempio n. 11
0
 public override void OnUpdate(CommandUpdateEventArgs e)
 {
     switch (e.Command)
     {
         case VisualGitCommand.ShowPendingChanges:
             if (!e.State.SccProviderActive)
                 e.Visible = e.Enabled = false;
             break;
     }
 }
Esempio n. 12
0
        public void OnUpdate(CommandUpdateEventArgs e)
        {
            ILogControl lc = e.Selection.GetActiveControl<ILogControl>();

            if (lc == null)
            {
                e.Enabled = false;
                return;
            }
        }
Esempio n. 13
0
        public virtual void OnUpdate(CommandUpdateEventArgs e)
        {
            SmartListView list = GetListView(e);

            if (list == null)
            {
                e.Enabled = false;
                return;
            }

            OnUpdate(list, e);
        }
Esempio n. 14
0
        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;
        }
Esempio n. 15
0
        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;
        }
Esempio n. 16
0
        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;
            }
        }
Esempio n. 17
0
        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;
        }
Esempio n. 18
0
        public override void OnUpdate(CommandUpdateEventArgs e)
        {
            if (!SmartListView.SupportsGrouping)
            {
                e.Visible = e.Enabled = false; // Group by is XP+
                e.DynamicMenuEnd = (e.Command != (VisualGitCommand)VisualGitCommandMenu.ListViewGroup);
                return;
            }

            if (e.Command == (VisualGitCommand)VisualGitCommandMenu.ListViewGroup)
                return;

            base.OnUpdate(e);
        }
Esempio n. 19
0
        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;
        }
Esempio n. 20
0
        public void OnUpdate(CommandUpdateEventArgs e)
        {
            ILogControl logWindow = e.Selection.GetActiveControl<ILogControl>();

            if (logWindow == null || logWindow.Origins == null)
            {
                e.Enabled = false;
                return;
            }

            if (UpdateForChangedFiles(e))
                return;

            UpdateForRevChanges(logWindow, e);
        }
Esempio n. 21
0
        public override void OnUpdate(CommandUpdateEventArgs e)
        {
            foreach (GitItem i in e.Selection.GetSelectedGitItems(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;
        }
Esempio n. 22
0
        protected override void OnUpdate(SmartListView list, CommandUpdateEventArgs e)
        {
            int n = (int)(e.Command - VisualGitCommand.ListViewSort0);

            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.Sortable)
                e.Enabled = false;

            e.Checked = list.SortColumns.Contains(column);
        }
Esempio n. 23
0
        public override void OnUpdate(CommandUpdateEventArgs e)
        {
            if (e.Command == VisualGitCommand.DocumentConflictEdit)
            {
                GitItem item = e.Selection.ActiveDocumentItem;

                if (item != null && item.IsConflicted)
                    return;
            }
            else
                foreach (GitItem item in e.Selection.GetSelectedGitItems(false))
                {
                    if (item.IsConflicted && item.Status.State == GitStatus.Conflicted)
                        return;
                }

            e.Enabled = false;
        }
Esempio n. 24
0
 public void OnUpdate(CommandUpdateEventArgs e)
 {
 }
Esempio n. 25
0
        public override void OnUpdate(CommandUpdateEventArgs e)
        {
            bool first = true;
            foreach (GitItem item in e.Selection.GetSelectedGitItems(false))
            {
                if (!item.Exists)
                    continue;

                switch (e.Command)
                {
                    case VisualGitCommand.ItemOpenTextEditor:
                    case VisualGitCommand.ItemOpenVisualStudio:
                        if (!item.IsFile)
                        {
                            e.Enabled = false;
                            return;
                        }
                        first = false;
                        break;
                    case VisualGitCommand.ItemOpenSolutionExplorer:
                        if (!item.InSolution)
                            continue;
                        goto default;
                    default:
                        if (!first)
                        {
                            e.Enabled = false;
                            return;
                        }

                        first = false;
                        break;
                }
            }

            e.Enabled = !first;
        }
Esempio n. 26
0
        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;
            }
        }
Esempio n. 27
0
 public override void OnUpdate(CommandUpdateEventArgs e)
 {
     e.Enabled = !EnumTools.IsEmpty(GetChanges(e));
 }
Esempio n. 28
0
        public int QueryStatus(ref Guid pguidCmdGroup, uint cCmds, OLECMD[] prgCmds, IntPtr pCmdText)
        {
            if ((prgCmds == null))
                return Microsoft.VisualStudio.VSConstants.E_INVALIDARG;

            System.Diagnostics.Debug.Assert(cCmds == 1, "Multiple commands"); // Should never happen in VS

            CommandID cd = new CommandID(pguidCmdGroup, unchecked((int)prgCmds[0].cmdID));

            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;

                CommandUpdateEventArgs ee = new CommandUpdateEventArgs((VisualGitCommand)cd.ID, GetService<VisualGitContext>());

                if (d.UpdateHandler != null)
                    d.UpdateHandler(d.Control, ee);

                if (ee.DynamicMenuEnd)
                    return (int)OLEConstants.OLECMDERR_E_NOTSUPPORTED;

                OLECMDF cmdf = OLECMDF.OLECMDF_SUPPORTED;

                ee.UpdateFlags(ref cmdf);

                prgCmds[0].cmdf = (uint)cmdf;

                return VSConstants.S_OK;
            }

            return (int)Constants.OLECMDERR_E_NOTSUPPORTED;
        }
Esempio n. 29
0
        public override void OnUpdate(CommandUpdateEventArgs e)
        {
            GitItem node = EnumTools.GetSingle(e.Selection.GetSelectedGitItems(false));

            if (node == null && e.Selection.IsSingleNodeSelection)
                node = EnumTools.GetFirst(e.Selection.GetSelectedGitItems(false));

            bool enable = true;
            if (node == null)
                enable = false;
            else if (e.Command == VisualGitCommand.ItemSelectInWorkingCopyExplorer)
                enable = node.Exists;
            else if (e.Command == VisualGitCommand.ItemSelectInSolutionExplorer)
            {
                if (e.Selection.IsSolutionExplorerSelection)
                    e.Visible = enable = false;
                else if (!node.InSolution)
                    enable = false;
            }

            if (!enable)
                e.Enabled = false;
        }
 public void OnUpdate(CommandUpdateEventArgs e)
 {
     if (ProjectRoot == null)
         e.Enabled = false;
 }