/// <summary>
        /// Initialization of the package; this method is called right after the package is sited, so this is the place
        /// where you can put all the initilaization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override void Initialize()
        {
//            Trace.WriteLine (string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", this.ToString()));
//            base.Initialize();
//
//            // Add our command handlers for menu (commands must exist in the .vsct file)
//            OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
//            if ( null != mcs )
//            {
//                // Create the command for the menu item.
//                CommandID menuCommandID = new CommandID(GuidList.guidJiraEditorLinksCmdSet, (int)PkgCmdIDList.cmdidMyCommand);
//                MenuCommand menuItem = new MenuCommand(MenuItemCallback, menuCommandID );
//                mcs.AddCommand( menuItem );
//            }



            JiraLinkMarkerTypeProvider markerTypeProvider = new JiraLinkMarkerTypeProvider();

            ((IServiceContainer)this).AddService(markerTypeProvider.GetType(), markerTypeProvider, true);

            base.Initialize();

            // Now it's time to initialize our copies of the marker IDs. We need them to be
            // able to create marker instances.
            JiraLinkMarkerTypeProvider.InitializeMarkerIds(this);

            // Advise event sinks. We need to know when a solution is opened and closed
            // (SolutionEventSink), when a document is opened and closed (TextManagerEventSink),
            // and when a document is saved (RunningDocTableEventSink).
            SolutionEventSink        solutionEventSink        = new SolutionEventSink();
            TextManagerEventSink     textManagerEventSink     = new TextManagerEventSink();
            RunningDocTableEventSink runningDocTableEventSink = new RunningDocTableEventSink();

            IVsSolution solution = (IVsSolution)GetService(typeof(SVsSolution));

            ErrorHandler.ThrowOnFailure(solution.AdviseSolutionEvents(solutionEventSink, out solutionEventCookie));

            IConnectionPointContainer textManager = (IConnectionPointContainer)GetService(typeof(SVsTextManager));
            Guid interfaceGuid = typeof(IVsTextManagerEvents).GUID;

            textManager.FindConnectionPoint(ref interfaceGuid, out tmConnectionPoint);
            tmConnectionPoint.Advise(textManagerEventSink, out tmConnectionCookie);

            IVsRunningDocumentTable rdt = (IVsRunningDocumentTable)GetService(typeof(SVsRunningDocumentTable));

            ErrorHandler.ThrowOnFailure(rdt.AdviseRunningDocTableEvents(runningDocTableEventSink, out rdtEventCookie));

            // Since we register custom text markers we have to ensure the font and color
            // cache is up-to-date.
            ValidateFontAndColorCacheManagerIsUpToDate();
        }
Пример #2
0
        protected override void Initialize()
        {
            PlvsLogger.log("plvsPackage.Initialize() - enter");
            base.Initialize();

            if (InCommandLineMode)
            {
                return;
            }

            installCrashHandler();

            ProxyListener.Instance.init();

            OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;

            if (null != mcs)
            {
                // toggle tool window command
                CommandID      menuCommandId = new CommandID(GuidList.guidplvsCmdSet, (int)PkgCmdIDList.cmdidToggleToolWindow);
                OleMenuCommand menuItem      = new OleMenuCommand(toggleToolWindowMenuItemCallback, menuCommandId);
                menuItem.BeforeQueryStatus += toggleToolWindow_BeforeQueryStatus;
                mcs.AddCommand(menuItem);

                // find issue command
                menuCommandId = new CommandID(GuidList.guidplvsCmdSet, (int)PkgCmdIDList.cmdidFindIssue);
                menuItem      = new OleMenuCommand(findIssueMenuItemCallback, menuCommandId);
                menuItem.BeforeQueryStatus += toolWindowCommand_BeforeQueryStatus;
                mcs.AddCommand(menuItem);

                // create issue command
                menuCommandId = new CommandID(GuidList.guidplvsCmdSet, (int)PkgCmdIDList.cmdidCreateIssue);
                menuItem      = new OleMenuCommand(createIssueMenuItemCallback, menuCommandId);
                menuItem.BeforeQueryStatus += toolWindowCommand_BeforeQueryStatus;
                mcs.AddCommand(menuItem);

                // project properties command
                menuCommandId = new CommandID(GuidList.guidplvsCmdSet, (int)PkgCmdIDList.cmdidProjectProperties);
                menuItem      = new OleMenuCommand(projectPropertiesMenuItemCallback, menuCommandId);
                menuItem.BeforeQueryStatus += toolWindowCommand_BeforeQueryStatus;
                mcs.AddCommand(menuItem);

                // global properties command
                menuCommandId = new CommandID(GuidList.guidplvsCmdSet, (int)PkgCmdIDList.cmdidGlobalProperties);
                menuItem      = new OleMenuCommand(globalPropertiesMenuItemCallback, menuCommandId);
                menuItem.BeforeQueryStatus += toolWindowCommand_BeforeQueryStatus;
                mcs.AddCommand(menuItem);
            }

            SolutionEventSink solutionEventSink = new SolutionEventSink(this, createAtlassianWindow, createIssueDetailsWindow, createBuildDetailsWindow);
            IVsSolution       solution          = (IVsSolution)GetService(typeof(SVsSolution));

            ErrorHandler.ThrowOnFailure(solution.AdviseSolutionEvents(solutionEventSink, out solutionEventCookie));

#if !VS2010
            JiraLinkMarkerTypeProvider markerTypeProvider = new JiraLinkMarkerTypeProvider();
            ((IServiceContainer)this).AddService(markerTypeProvider.GetType(), markerTypeProvider, true);

            // Now it's time to initialize our copies of the marker IDs. We need them to be
            // able to create marker instances.
            JiraLinkMarkerTypeProvider.InitializeMarkerIds(this);

            RunningDocTableEventSink runningDocTableEventSink = new RunningDocTableEventSink();
            TextManagerEventSink     textManagerEventSink     = new TextManagerEventSink();

            IConnectionPointContainer textManager = (IConnectionPointContainer)GetService(typeof(SVsTextManager));
            Guid interfaceGuid = typeof(IVsTextManagerEvents).GUID;

            try {
                textManager.FindConnectionPoint(ref interfaceGuid, out tmConnectionPoint);
                tmConnectionPoint.Advise(textManagerEventSink, out tmConnectionCookie);
// ReSharper disable EmptyGeneralCatchClause
            }
            catch {}
            // ReSharper restore EmptyGeneralCatchClause

            IVsRunningDocumentTable rdt = (IVsRunningDocumentTable)GetService(typeof(SVsRunningDocumentTable));
            ErrorHandler.ThrowOnFailure(rdt.AdviseRunningDocTableEvents(runningDocTableEventSink, out rdtEventCookie));

            // Since we register custom text markers we have to ensure the font and color
            // cache is up-to-date.
            ValidateFontAndColorCacheManagerIsUpToDate();
#endif
            ((IServiceContainer)this).AddService(typeof(AnkhSvnJiraConnector), new ServiceCreatorCallback(CreateAnkhSvnConnector), true);
        }