private void getMetadata()
        {
            PlvsLogger.log("FieldEditor.getMetadata()");

            object           rawIssueObject = facade.getRawIssueObject(issue);
            List <JiraField> filledFields   = JiraActionFieldType.fillFieldValues(issue, rawIssueObject, new List <JiraField> {
                field
            });

            field = filledFields[0];
            field.setRawIssueObject(rawIssueObject);

            SortedDictionary <string, JiraProject> projects = JiraServerCache.Instance.getProjects(issue.Server);

            if (!projects.ContainsKey(issue.ProjectKey))
            {
                return;
            }

            JiraProject project = projects[issue.ProjectKey];

            // todo: these are not always necessary. refactor to make it more efficient and smart
            List <JiraNamedEntity> versions = facade.getVersions(issue.Server, project);

            versions.Reverse();
            List <JiraNamedEntity> comps = facade.getComponents(issue.Server, project);

            this.safeInvoke(new MethodInvoker(() => createEditorWidget(versions, comps, rawIssueObject)));
        }
        public FieldEditor(string title, JiraIssueListModel model, AbstractJiraServerFacade facade, JiraIssue issue, string fieldId, Point location)
        {
            PlvsLogger.log("FieldEditor - ctor");

            this.model   = model;
            this.facade  = facade;
            this.issue   = issue;
            this.fieldId = fieldId;

            InitializeComponent();

            buttonOk.Enabled     = false;
            buttonCancel.Enabled = false;

            StartPosition = FormStartPosition.Manual;
            Location      = location;

            Text = title;

            field = new JiraField(fieldId, null);

            Thread t = PlvsUtils.createThread(fillFieldWrap);

            t.Start();
        }
        private void addEditorWidget(JiraFieldEditorProvider editor)
        {
            PlvsLogger.log("FieldEditor.addEditorWidget()");

            Controls.Remove(labelInfo);
            editorControl          = editor.Widget;
            editorControl.Location = new Point(MARGIN, MARGIN);
            Controls.Add(editorControl);
            editor.resizeToWidth(Width);

            ClientSize = new Size(editorControl.Width + 2 * MARGIN, editorControl.Height + 2 * MARGIN + (ClientSize.Height - buttonOk.Location.Y));

            Resize += fieldEditorResize;

            if (customWidth != -1 && customHeight != -1)
            {
                Size = new Size(customWidth, customHeight);
            }
        }
Exemple #4
0
        public int OnAfterOpenSolution(object pUnkReserved, int fNewSolution)
        {
            PlvsLogger.log("SolutionEventSink.OnAfterOpenSolution()");
            try {
                GlobalSettings.checkFirstRun();

                JiraServerModel.Instance.clear();
                JiraServerModel.Instance.load();
                BambooServerModel.Instance.clear();
                BambooServerModel.Instance.load();
                RecentlyViewedIssuesModel.Instance.load();
                JiraCustomFilter.load();

                DTE dte = (DTE)Package.GetGlobalService(typeof(DTE));
                PlvsUtils.Dte = dte;

                ToolWindowManager.Instance.AtlassianWindow = createAtlassianWindow();

                AtlassianPanel.Instance.reinitialize(dte, package);

                ToolWindowManager.Instance.IssueDetailsWindow = createIssueDetailsWindow();
                ToolWindowManager.Instance.BuildDetailsWindow = createBuildDetailsWindow();

                IssueDetailsWindow.Instance.Solution = dte.Solution;
                BuildDetailsWindow.Instance.Solution = dte.Solution;

                JiraEditorLinkManager.OnSolutionOpened();
                Autoupdate.Instance.initialize();
            }
            catch (Exception e) {
                Debug.WriteLine(e);
                new ExceptionViewer("Failed to initialize JIRA tool windows", e).ShowDialog();
            }

            return(VSConstants.S_OK);
        }
        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);
        }
        private void createEditorWidget(IEnumerable <JiraNamedEntity> versions, IEnumerable <JiraNamedEntity> comps, object rawIssueObject)
        {
            PlvsLogger.log("FieldEditor.createEditorWidget()");

            switch (JiraActionFieldType.getFieldTypeForFieldId(fieldId))
            {
            case JiraActionFieldType.WidgetType.SUMMARY:
                editorProvider = new TextLineFieldEditorProvider(field, issue.Summary, fieldValid);
                break;

            case JiraActionFieldType.WidgetType.DESCRIPTION:
                string descr = JiraIssueUtils.getRawIssueObjectPropertyValue <string>(rawIssueObject, "description") ?? "";
                editorProvider = new TextAreaFieldEditorProvider(facade, issue, field, descr, fieldValid);
                break;

            case JiraActionFieldType.WidgetType.ENVIRONMENT:
                string env = JiraIssueUtils.getRawIssueObjectPropertyValue <string>(rawIssueObject, "environment") ?? "";
                editorProvider = new TextAreaFieldEditorProvider(facade, issue, field, env, fieldValid);
                break;

            case JiraActionFieldType.WidgetType.VERSIONS:
                editorProvider = new NamedEntityListFieldEditorProvider(field, issue.Versions, versions, fieldValid);
                break;

            case JiraActionFieldType.WidgetType.FIX_VERSIONS:
                editorProvider = new NamedEntityListFieldEditorProvider(field, issue.FixVersions, versions, fieldValid);
                break;

            case JiraActionFieldType.WidgetType.ASSIGNEE:
                editorProvider = new UserFieldEditorProvider(issue.Server, field,
                                                             field.Values.IsNullOrEmpty() ? "" : field.Values[0], fieldValid, true);
                break;

            case JiraActionFieldType.WidgetType.COMPONENTS:
                editorProvider = new NamedEntityListFieldEditorProvider(field, issue.Components, comps, fieldValid);
                break;

            case JiraActionFieldType.WidgetType.PRIORITY:
                editorProvider = new NamedEntityComboEditorProvider(issue.Server, field, issue.PriorityId,
                                                                    JiraServerCache.Instance.getPriorities(issue.Server),
                                                                    fieldValid);
                break;

            case JiraActionFieldType.WidgetType.TIMETRACKING:
                List <JiraField> fields = JiraActionFieldType.fillFieldValues(issue, rawIssueObject, new List <JiraField> {
                    field
                });
                editorProvider = new TimeTrackingEditorProvider(field, fields[0].Values[0], fieldValid);
                break;

            default:
                MessageBox.Show("Unsupported field type selected for editing",
                                Constants.ERROR_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error);
                Close();
                break;
            }

            buttonCancel.Enabled = true;
            buttonOk.Enabled     = editorProvider != null ? editorProvider.FieldValid : false;
            if (editorProvider != null)
            {
                addEditorWidget(editorProvider);
            }
        }