Ejemplo n.º 1
0
 public CommandEventArgs(VisualGitCommand command, VisualGitContext context, object argument, bool promptUser, bool dontPromptUser)
     : this(command, context)
 {
     _argument = argument;
     _promptUser = promptUser;
     _dontPromptUser = dontPromptUser;
 }
Ejemplo n.º 2
0
        public bool TryGetParameterList(VisualGitCommand command, out string definition)
        {
            EnsureLoaded();

            CommandMapItem item;

            if (_map.TryGetValue(command, out item))
            {
                definition = item.ArgumentDefinition;

                return !string.IsNullOrEmpty(definition);
            }
            else
                definition = null;

            return false;
        }
Ejemplo n.º 3
0
 public int Schedule(TimeSpan timeSpan, VisualGitCommand command)
 {
     return ScheduleAt(DateTime.Now + timeSpan, CreateHandler(command));
 }
Ejemplo n.º 4
0
 public CommandUpdateEventArgs(VisualGitCommand command, VisualGitContext context)
     : base(command, context)
 {
 }
Ejemplo n.º 5
0
 public CommandAttribute(VisualGitCommand command, VisualGitCommandContext context)
     : this(command)
 {
     _context = context;
 }
Ejemplo n.º 6
0
        bool IsTickCommand(VisualGitCommand c)
        {
            if (c < VisualGitCommand.TickFirst || c >= VisualGitCommand.TickLast)
                return false;

            return true;
        }
Ejemplo n.º 7
0
        public void SafePostTickCommand(ref bool tick, VisualGitCommand command)
        {
            if (tick)
                return;

            tick = true;
            lock (_delayTasks)
            {
                _delayedCommands.Add((int)command);
            }
        }
Ejemplo n.º 8
0
 public void PostIdleCommand(VisualGitCommand command, object args)
 {
     PostIdleAction(
         delegate()
         {
             DirectlyExecCommand(command, args);
         });
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Installs a visual studio command handler for the specified control
 /// </summary>
 /// <param name="context">The context.</param>
 /// <param name="control">The control.</param>
 /// <param name="command">The command.</param>
 /// <param name="handler">The handler.</param>
 public static void Install(IVisualGitServiceProvider context, Control control, VisualGitCommand command, ICommandHandler handler)
 {
     Install(context, control, command,
         delegate(object sender, CommandEventArgs e)
         {
             handler.OnExecute(e);
         },
         delegate(object sender, CommandUpdateEventArgs e)
         {
             handler.OnUpdate(e);
         });
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Installs a visual studio command handler for the specified control
 /// </summary>
 /// <param name="context">The context.</param>
 /// <param name="control">The control.</param>
 /// <param name="command">The command.</param>
 /// <param name="handler">The handler.</param>
 public static void Install(IVisualGitServiceProvider context, Control control, VisualGitCommand command, EventHandler<CommandEventArgs> handler)
 {
     Install(context, control, command, handler, null);
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Installs a visual studio command handler for the specified control
 /// </summary>
 /// <param name="context">The context.</param>
 /// <param name="control">The control.</param>
 /// <param name="command">The command.</param>
 /// <param name="handler">The handler.</param>
 /// <param name="updateHandler">The update handler.</param>
 public static void Install(IVisualGitServiceProvider context, Control control, VisualGitCommand command, EventHandler<CommandEventArgs> handler, EventHandler<CommandUpdateEventArgs> updateHandler)
 {
     Install(context, control, new CommandID(VisualGitId.CommandSetGuid, (int)command), handler, updateHandler);
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CommandMapItem"/> class.
 /// </summary>
 /// <param name="command">The command.</param>
 public CommandMapItem(VisualGitCommand command)
 {
     _command = command;
 }
Ejemplo n.º 13
0
        internal void HandleEvent(VisualGitCommand command)
        {
            List<GitProject> dirtyProjects;
            HybridCollection<string> dirtyCheck;
            HybridCollection<string> maybeAdd;
            bool forceFullRefresh;

            VisualGitSccProvider provider = Context.GetService<VisualGitSccProvider>();

            lock (_lock)
            {
                _posted = false;
                _onIdle = false;

                if (provider == null)
                    return;

                dirtyProjects = _dirtyProjects;
                dirtyCheck = _dirtyCheck;
                maybeAdd = _maybeAdd;
                forceFullRefresh = _forceFullRefresh;
                _dirtyProjects = null;
                _dirtyCheck = null;
                _maybeAdd = null;
                _forceFullRefresh = false;
            }

            using (new FileStatusRefreshHint(forceFullRefresh))
            {
                if (dirtyCheck != null)
                    foreach (string file in dirtyCheck)
                    {
                        DocumentTracker.CheckDirty(file);
                    }

                if (dirtyProjects != null)
                {
                    foreach (GitProject project in dirtyProjects)
                    {
                        if (project.RawHandle == null)
                        {
                            if (project.IsSolution)
                                provider.UpdateSolutionGlyph();

                            continue; // All IVsSccProjects have a RawHandle
                        }

                        try
                        {
                            project.RawHandle.SccGlyphChanged(0, null, null, null);
                        }
                        catch { }
                    }
                }

                if (maybeAdd != null)
                {
                    using (GitClient cl = GetService<IGitClientPool>().GetNoUIClient())
                    {
                        foreach (string file in maybeAdd)
                        {
                            GitItem item = Cache[file];
                            // Only add
                            // * files
                            // * that are unversioned
                            // * that are addable
                            // * that are not ignored
                            // * and just to be sure: that are still part of the solution
                            if (item.IsFile && !item.IsVersioned &&
                                item.IsVersionable && !item.IsIgnored &&
                                item.InSolution)
                            {
                                GitAddArgs aa = new GitAddArgs();
                                aa.ThrowOnError = false; // Just ignore errors here; make the user add them themselves
                                aa.AddParents = true;

                                cl.Add(item.FullPath, aa);
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Gets the <see cref="CommandMapItem"/> for the specified command
        /// </summary>
        /// <param name="command"></param>
        /// <returns>The <see cref="CommandMapItem"/> or null if the command is not valid</returns>
        public CommandMapItem this[VisualGitCommand command]
        {
            get
            {
                CommandMapItem item;

                if (_map.TryGetValue(command, out item))
                    return item;
                else
                {
                    item = new CommandMapItem(command);

                    _map.Add(command, item);

                    return item;
                }
            }
        }
Ejemplo n.º 15
0
 public bool PostExecCommand(VisualGitCommand command, object args, CommandPrompt prompt)
 {
     return PostExecCommand(new CommandID(VisualGitId.CommandSetGuid, (int)command), args, prompt);
 }
Ejemplo n.º 16
0
 public CommandResult DirectlyExecCommand(VisualGitCommand command)
 {
     return DirectlyExecCommand(command, null, CommandPrompt.DoDefault);
 }
Ejemplo n.º 17
0
 public void PostIdleCommand(VisualGitCommand command)
 {
     PostIdleCommand(command, null);
 }
Ejemplo n.º 18
0
 public CommandResult DirectlyExecCommand(VisualGitCommand command, object args)
 {
     return DirectlyExecCommand(command, args, CommandPrompt.DoDefault);
 }
Ejemplo n.º 19
0
        /// <summary>
        /// Posts the tick command.
        /// </summary>
        /// <param name="tick">if set to <c>true</c> [tick].</param>
        /// <param name="command">The command.</param>
        /// <returns></returns>
        public bool PostTickCommand(ref bool tick, VisualGitCommand command)
        {
            if (IsTickCommand(command))
                _ticks[command - VisualGitCommand.TickFirst] = 1;

            if (tick)
                return false;

            tick = true;
            bool ok = false;
            try
            {
                return ok = PostExecCommand(command);
            }
            finally
            {
                if (!ok)
                    tick = false;
            }
        }
Ejemplo n.º 20
0
        public CommandResult DirectlyExecCommand(VisualGitCommand command, object args, CommandPrompt prompt)
        {
            // TODO: Assert that we are in the UI thread

            CommandMapper mapper = GetService<CommandMapper>();

            if (mapper == null)
                return new CommandResult(false, null);

            CommandEventArgs e = new CommandEventArgs(command, VisualGitContext, args, prompt == CommandPrompt.Always, prompt == CommandPrompt.Never);
            bool ok = mapper.Execute(command, e);

            return new CommandResult(ok, e.Result);
        }
Ejemplo n.º 21
0
 public void TockCommand(VisualGitCommand visualGitCommand)
 {
     if (IsTickCommand(visualGitCommand))
         _ticks[visualGitCommand - VisualGitCommand.TickFirst] = 0;
 }
Ejemplo n.º 22
0
 public CommandResult ExecCommand(VisualGitCommand command)
 {
     // The commandhandler in the package always checks enabled; no need to do it here
     return ExecCommand(command, false);
 }
Ejemplo n.º 23
0
 /// <summary>
 /// Defines the class or function as a handler of the specified <see cref="VisualGitCommand"/>
 /// </summary>
 /// <param name="command">The command.</param>
 public CommandAttribute(VisualGitCommand command)
 {
     _command = command;
 }
Ejemplo n.º 24
0
 public CommandResult ExecCommand(VisualGitCommand command, bool verifyEnabled)
 {
     // The commandhandler in the package always checks enabled; no need to do it here
     return ExecCommand(new CommandID(VisualGitId.CommandSetGuid, (int)command), verifyEnabled);
 }
Ejemplo n.º 25
0
 public CommandUpdateEventArgs(VisualGitCommand command, VisualGitContext context, TextQueryType textQuery)
     : this(command, context)
 {
     _queryType = textQuery;
 }
Ejemplo n.º 26
0
 public bool PostExecCommand(VisualGitCommand command)
 {
     return PostExecCommand(command, null, CommandPrompt.DoDefault);
 }
Ejemplo n.º 27
0
 VisualGitAction CreateHandler(VisualGitCommand command)
 {
     return delegate
     {
         if (Commands != null)
             Commands.PostExecCommand(command);
     };
 }
Ejemplo n.º 28
0
 public bool PostExecCommand(VisualGitCommand command, object args)
 {
     return PostExecCommand(command, args, CommandPrompt.DoDefault);
 }
Ejemplo n.º 29
0
 public int ScheduleAt(DateTime time, VisualGitCommand command)
 {
     return ScheduleAt(time, CreateHandler(command));
 }
Ejemplo n.º 30
0
        public bool PerformUpdate(VisualGitCommand 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)
                    {
                        IVisualGitErrorHandler eh = GetService<IVisualGitErrorHandler>();

                        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;
        }