Ejemplo n.º 1
0
        public CommandBar AddGitExtMainMenuBar(string toolsMenuName)
        {
            CommandBar mainMenuBar = null;

            try
            {
                mainMenuBar = (CommandBar)_application.Commands
                              .AddCommandBar("GitExt", vsCommandBarType.vsCommandBarTypeMenu, GetMenuBar(), 4);

                ((CommandBarPopup)mainMenuBar.Parent).Caption = GitMainMenuName;
            }
            catch (Exception ex)
            {
                try
                {
                    OutputPane.OutputString("Error creating git menu (trying to add commands to tools menu): " + ex);
                    if (mainMenuBar == null)
                    {
                        mainMenuBar = (CommandBar)GetMenuBar().Controls[toolsMenuName];
                    }
                }
                catch (Exception ex2)
                {
                    OutputPane.OutputString("Error menu: " + ex2);
                }
            }

            return(mainMenuBar);
        }
Ejemplo n.º 2
0
        private void AddToolbarOrMenuCommand(CommandBar bar, string commandName, string caption,
                                             string tooltip, int iconIndex, int insertIndex, vsCommandStyle commandStyle, bool beginGroup)
        {
            // Do not try to add commands to a null bar
            if (bar == null)
            {
                return;
            }

            // Get commands collection
            var commands = (Commands2)_application.Commands;
            var command  = GetCommand(commandName, caption, tooltip, iconIndex, commandStyle, commands);

            if (command == null)
            {
                return;
            }
            if (!HasCommand(bar, caption))
            {
#if DEBUG
                OutputPane.OutputString("Add toolbar command: " + caption + Environment.NewLine);
#endif
                var control = (CommandBarButton)command.AddControl(bar, insertIndex);
                control.Style      = CommandStyleToButtonStyle(commandStyle);
                control.BeginGroup = beginGroup;
            }
        }
Ejemplo n.º 3
0
 public void BeginBuild()
 {
     OutputPane.OutputString(
         string.Format("------ Ice Builder Build started: Project: {0}, Configuration: {1} {2} ------\n",
                       ProjectUtil.GetProjectName(Project),
                       ProjectConfiguration.ConfigurationName,
                       ProjectConfiguration.PlatformName));
 }
Ejemplo n.º 4
0
        public static void OutputString(string toOutput, bool show = false)
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            OutputPane.OutputString(toOutput);

            if (show)
            {
                Show();
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GitExtCommands"/> class.
        /// Adds our command handlers for menu (commands must exist in the command table file)
        /// </summary>
        /// <param name="package">Owner package, not null.</param>
        private GitExtCommands(Package package)
        {
            if (package == null)
            {
                throw new ArgumentNullException("package");
            }

            _package        = package;
            _application    = (DTE2)ServiceProvider.GetService(typeof(DTE));
            _commandService = ServiceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService;

            try
            {
                //RegisterCommand("Difftool_Selection", new ToolbarCommand<OpenWithDiftool>(runForSelection: true));
                RegisterCommand("Difftool", new ToolbarCommand <OpenWithDiftool>(), gitExtDiffCommand);
                //RegisterCommand("ShowFileHistory_Selection", new ToolbarCommand<FileHistory>(runForSelection: true));
                RegisterCommand("ShowFileHistory", new ToolbarCommand <FileHistory>(), gitExtHistoryCommand);
                //RegisterCommand("ResetChanges_Selection", new ToolbarCommand<Revert>(runForSelection: true));
                RegisterCommand("ResetChanges", new ToolbarCommand <Revert>(), gitExtResetFileCommand);
                RegisterCommand("Browse", new ToolbarCommand <Browse>(), gitExtBrowseCommand);
                RegisterCommand("Clone", new ToolbarCommand <Clone>(), gitExtCloneCommand);
                RegisterCommand("CreateNewRepository", new ToolbarCommand <Init>(), gitExtNewCommand);
                RegisterCommand("Commit", new ToolbarCommand <Commit>(), gitExtCommitCommand);
                RegisterCommand("Pull", new ToolbarCommand <Pull>(), gitExtPullCommand);
                RegisterCommand("Push", new ToolbarCommand <Push>(), gitExtPushCommand);
                RegisterCommand("Stash", new ToolbarCommand <Stash>(), gitExtStashCommand);
                RegisterCommand("Remotes", new ToolbarCommand <Remotes>(), gitExtRemotesCommand);
                RegisterCommand("GitIgnore", new ToolbarCommand <GitIgnore>(), gitExtGitIgnoreCommand);
                RegisterCommand("ApplyPatch", new ToolbarCommand <ApplyPatch>(), gitExtApplyPatchCommand);
                RegisterCommand("FormatPatch", new ToolbarCommand <FormatPatch>(), gitExtFormatPatchCommand);
                RegisterCommand("ViewChanges", new ToolbarCommand <ViewChanges>(), gitExtViewChangesCommand);
                RegisterCommand("Blame", new ToolbarCommand <Blame>(), gitExtBlameCommand);
                RegisterCommand("FindFile", new ToolbarCommand <FindFile>(), gitExtFindFileCommand);
                RegisterCommand("SwitchBranch", new ToolbarCommand <SwitchBranch>(), gitExtCheckoutCommand);
                RegisterCommand("CreateBranch", new ToolbarCommand <CreateBranch>(), gitExtCreateBranchCommand);
                RegisterCommand("Merge", new ToolbarCommand <Merge>(), gitExtMergeCommand);
                RegisterCommand("Rebase", new ToolbarCommand <Rebase>(), gitExtRebaseCommand);
                RegisterCommand("SolveMergeConflicts", new ToolbarCommand <SolveMergeConflicts>(), gitExtSolveConflictsCommand);
                RegisterCommand("CherryPick", new ToolbarCommand <Cherry>(), gitExtCherryPickCommand);
                RegisterCommand("Bash", new ToolbarCommand <Bash>(), gitExtBashCommand);
                RegisterCommand("Settings", new ToolbarCommand <Settings>(), gitExtSettingsCommand);
                RegisterCommand("About", new ToolbarCommand <About>(), gitExtAboutCommand);
            }
            catch (Exception ex)
            {
                if (OutputPane != null)
                {
                    OutputPane.OutputString("Error adding commands: " + ex);
                }
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GitExtCommands"/> class.
        /// Adds our command handlers for menu (commands must exist in the command table file)
        /// </summary>
        /// <param name="package">Owner package, not null.</param>
        private GitExtCommands(Package package)
        {
            if (package == null)
            {
                throw new ArgumentNullException("package");
            }

            _package        = package;
            _application    = (DTE2)ServiceProvider.GetService(typeof(DTE));
            _commandService = ServiceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService;

            try
            {
                //RegisterCommand("Difftool_Selection", new ToolbarCommand<OpenWithDiftool>(runForSelection: true));
                RegisterCommand("Difftool", new ToolbarCommand <OpenWithDiftool>(), 0x1100);
                //RegisterCommand("ShowFileHistory_Selection", new ToolbarCommand<FileHistory>(runForSelection: true));
                RegisterCommand("ShowFileHistory", new ToolbarCommand <FileHistory>(), 0x1101);
                //RegisterCommand("ResetChanges_Selection", new ToolbarCommand<Revert>(runForSelection: true));
                RegisterCommand("ResetChanges", new ToolbarCommand <Revert>(), 0x1102);
                RegisterCommand("Browse", new ToolbarCommand <Browse>(), 0x1103);
                RegisterCommand("Clone", new ToolbarCommand <Clone>(), 0x1104);
                RegisterCommand("CreateNewRepository", new ToolbarCommand <Init>(), 0x1105);
                RegisterCommand("Commit", new ToolbarCommand <Commit>(), 0x1106);
                RegisterCommand("Pull", new ToolbarCommand <Pull>(), 0x1107);
                RegisterCommand("Push", new ToolbarCommand <Push>(), 0x1108);
                RegisterCommand("Stash", new ToolbarCommand <Stash>(), 0x1109);
                RegisterCommand("Remotes", new ToolbarCommand <Remotes>(), 0x110a);
                RegisterCommand("GitIgnore", new ToolbarCommand <GitIgnore>(), 0x110b);
                RegisterCommand("ApplyPatch", new ToolbarCommand <ApplyPatch>(), 0x110c);
                RegisterCommand("FormatPatch", new ToolbarCommand <FormatPatch>(), 0x110d);
                RegisterCommand("ViewChanges", new ToolbarCommand <ViewChanges>(), 0x110e);
                RegisterCommand("FindFile", new ToolbarCommand <FindFile>(), 0x110f);
                RegisterCommand("SwitchBranch", new ToolbarCommand <SwitchBranch>(), 0x1110);
                RegisterCommand("CreateBranch", new ToolbarCommand <CreateBranch>(), 0x1111);
                RegisterCommand("Merge", new ToolbarCommand <Merge>(), 0x1112);
                RegisterCommand("Rebase", new ToolbarCommand <Rebase>(), 0x1113);
                RegisterCommand("SolveMergeConflicts", new ToolbarCommand <SolveMergeConflicts>(), 0x1114);
                RegisterCommand("CherryPick", new ToolbarCommand <Cherry>(), 0x1115);
                RegisterCommand("Bash", new ToolbarCommand <Bash>(), 0x1116);
                RegisterCommand("Settings", new ToolbarCommand <Settings>(), 0x1117);
                RegisterCommand("About", new ToolbarCommand <About>(), 0x1118);
            }
            catch (Exception ex)
            {
                if (OutputPane != null)
                {
                    OutputPane.OutputString("Error adding commands: " + ex);
                }
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="GitExtCommands"/> class.
        /// Adds our command handlers for menu (commands must exist in the command table file)
        /// </summary>
        /// <param name="package">Owner package, not null.</param>
        private GitExtCommands(Package package, _DTE dte, IMenuCommandService menuCommandService)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            _package        = package ?? throw new ArgumentNullException(nameof(package));
            _application    = dte;
            _commandService = menuCommandService;

            try
            {
                RegisterCommands();
                PluginHelpers.AllowCaptionUpdate = true;
            }
            catch (Exception ex)
            {
                OutputPane?.OutputString("Error adding commands: " + ex);
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GitExtCommands"/> class.
        /// Adds our command handlers for menu (commands must exist in the command table file)
        /// </summary>
        /// <param name="package">Owner package, not null.</param>
        private GitExtCommands(Package package)
        {
            if (package == null)
            {
                throw new ArgumentNullException(nameof(package));
            }

            _package        = package;
            _application    = (DTE2)ServiceProvider.GetService(typeof(DTE));
            _commandService = ServiceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService;

            try
            {
                RegisterCommands();
                PluginHelpers.AllowCaptionUpdate = true;
            }
            catch (Exception ex)
            {
                OutputPane?.OutputString("Error adding commands: " + ex);
            }
        }
Ejemplo n.º 9
0
        private void AddToolbarOrMenuCommand(CommandBar bar, string commandName, string caption,
                                             string tooltip, int iconIndex, int insertIndex, vsCommandStyle commandStyle, bool beginGroup)
        {
            // Do not try to add commands to a null bar
            if (bar == null)
            {
                return;
            }

            // Get commands collection
            var commands     = (Commands2)m_application.Commands;
            var contextGUIDS = new object[] { };

            // Add command
            Command command = GetCommand(commandName);

            if (!m_visualStudioCommands.ContainsKey(commandName))
            {
                if (command == null)
                {
                    if (iconIndex > 0)
                    {
                        try
                        {
                            command = commands.AddNamedCommand2(m_addIn,
                                                                commandName, caption, tooltip, false, iconIndex,
                                                                ref contextGUIDS,
                                                                (int)vsCommandStatus.vsCommandStatusSupported +
                                                                (int)vsCommandStatus.vsCommandStatusEnabled,
                                                                (int)commandStyle,
                                                                vsCommandControlType.vsCommandControlTypeButton);
                        }
                        catch
                        {
                        }
                    }

                    if (command == null && commandStyle != vsCommandStyle.vsCommandStylePict)
                    {
                        command = commands.AddNamedCommand2(m_addIn,
                                                            commandName, caption, tooltip, true, -1, ref contextGUIDS,
                                                            (int)vsCommandStatus.vsCommandStatusSupported +
                                                            (int)vsCommandStatus.vsCommandStatusEnabled,
                                                            (int)commandStyle,
                                                            vsCommandControlType.vsCommandControlTypeButton);
                    }
                }
                if (command != null)
                {
                    m_visualStudioCommands[commandName] = command;
                }
            }
            if (command != null)
            {
                if (!HasCommand(bar, caption))
                {
#if DEBUG
                    OutputPane.OutputString("Add toolbar command: " + caption + Environment.NewLine);
#endif
                    CommandBarButton control = command.AddControl(bar, insertIndex) as CommandBarButton;
                    control.Style      = CommandStyleToButtonStyle(commandStyle);
                    control.BeginGroup = beginGroup;
                }
            }
        }
Ejemplo n.º 10
0
 public void EndBuild(bool succeed)
 {
     OutputPane.OutputString(
         string.Format("------ Build {0} ------\n\n", (succeed ? "succeeded" : "failed")));
     Package.Instance.BuildDone();
 }
Ejemplo n.º 11
0
        public void AddPopupCommand(CommandBarPopup popup, string commandName, string caption,
                                    string tooltip, int iconIndex, int insertIndex)
        {
            // Do not try to add commands to a null menu
            if (popup == null)
            {
                return;
            }

            // Get commands collection
            var commands     = (Commands2)m_application.Commands;
            var contextGUIDS = new object[] { };

            // Add command
            Command command = GetCommand(commandName);

            if (!m_visualStudioCommands.ContainsKey(commandName))
            {
                if (command == null)
                {
                    if (iconIndex > 0)
                    {
                        try
                        {
                            command = commands.AddNamedCommand2(m_addIn,
                                                                commandName, caption, tooltip, false, iconIndex,
                                                                ref contextGUIDS,
                                                                (int)vsCommandStatus.vsCommandStatusSupported +
                                                                (int)vsCommandStatus.vsCommandStatusEnabled,
                                                                (int)vsCommandStyle.vsCommandStylePictAndText,
                                                                vsCommandControlType.vsCommandControlTypeButton);
                        }
                        catch
                        {
                        }
                    }

                    if (command == null)
                    {
                        command = commands.AddNamedCommand2(m_addIn,
                                                            commandName, caption, tooltip, true, -1, ref contextGUIDS,
                                                            (int)vsCommandStatus.vsCommandStatusSupported +
                                                            (int)vsCommandStatus.vsCommandStatusEnabled,
                                                            (int)vsCommandStyle.vsCommandStylePictAndText,
                                                            vsCommandControlType.vsCommandControlTypeButton);
                    }
                }
                if (command != null)
                {
                    m_visualStudioCommands[commandName] = command;
                }
            }

            if (command != null && popup != null)
            {
                if (!HasCommand(popup.CommandBar, caption))
                {
                    OutputPane.OutputString("Add popup command: " + caption + Environment.NewLine);

                    command.AddControl(popup.CommandBar, insertIndex);
                }
            }
        }
Ejemplo n.º 12
0
        private void WriteLineToOutput(string message)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            OutputPane.OutputString(message + Environment.NewLine);
        }
Ejemplo n.º 13
0
        private async Task WriteLineToOutputAsync(string message)
        {
            await JoinableTaskFactory.SwitchToMainThreadAsync(DisposalToken);

            OutputPane.OutputString(message + Environment.NewLine);
        }