Ejemplo n.º 1
0
        private void runAction(JiraNamedEntity action)
        {
            Thread runner = new Thread(new ThreadStart(delegate
            {
                try
                {
                    status.setInfo("Retrieveing fields for action \"" + action.Name + "\"...");
                    var fields = JiraServerFacade.Instance.getFieldsForAction(issue, action.Id);
                    if (fields == null || fields.Count == 0)
                    {
                        runActionLocally(action);
                    }
                    else
                    {
                        status.setInfo("Action \"" + action.Name
                                       + "\" requires input fields, opening action screen in the browser...");
                        Process.Start(issue.Server.Url
                                      + "/secure/WorkflowUIDispatcher.jspa?id=" + issue.Id
                                      + "&action=" + action.Id);
                    }
                }
                catch (Exception e)
                {
                    status.setError("Failed to run action " + action.Name + " on issue " + issue.Key, e);
                }
            }));

            runner.Start();
        }
 private void logWorkWorker(Action action, Action finished, bool closeDialogOnFinish)
 {
     try {
         status.setInfo("Logging work for issue " + issue.Key + "...");
         action();
         status.setInfo("Logged work for issue " + issue.Key);
         UsageCollector.Instance.bumpJiraIssuesOpen();
         JiraIssue updatedIssue = facade.getIssue(issue.Server, issue.Key);
         parent.safeInvoke(new MethodInvoker(() => {
             model.updateIssue(updatedIssue);
             if (activeIssueManager.isActive(issue))
             {
                 activeIssueManager.resetTimeSpent();
             }
         }));
     } catch (Exception e) {
         status.setError("Failed to log work for issue " + issue.Key, e);
     }
     parent.safeInvoke(new MethodInvoker(() => {
         if (closeDialogOnFinish)
         {
             Close();
         }
         if (finished != null)
         {
             finished();
         }
     }));
 }
        private void initializeThreadWorker()
        {
            SortedDictionary <string, JiraProject> projects = JiraServerCache.Instance.getProjects(issue.Server);

            if (projects.ContainsKey(issue.ProjectKey))
            {
                status.setInfo("Retrieving issue field data...");
                JiraProject project = projects[issue.ProjectKey];
                issueTypes        = SmartJiraServerFacade.Instance.getIssueTypes(issue.Server, project);
                subtaskIssueTypes = SmartJiraServerFacade.Instance.getSubtaskIssueTypes(issue.Server, project);
                versions          = SmartJiraServerFacade.Instance.getVersions(issue.Server, project);
                comps             = SmartJiraServerFacade.Instance.getComponents(issue.Server, project);

                status.setInfo("");

                if (!Visible)
                {
                    return;
                }

                this.safeInvoke(new MethodInvoker(delegate {
                    panelContent.Visible  = true;
                    panelThrobber.Visible = false;

                    verticalPosition = 0;

                    fillFields();
                    addCommentField();

                    if (textUnsupported != null)
                    {
                        textUnsupported.Location = new Point(LABEL_X_POS, verticalPosition);
                        panelContent.Controls.Add(textUnsupported);
                        verticalPosition += textUnsupported.Height + MARGIN;
                    }

                    ClientSize = new Size(INITIAL_WIDTH,
                                          Math.Min(verticalPosition, INITIAL_HEIGHT) + buttonOk.Height + 4 * MARGIN);

                    // resize to perform layout
                    Size = new Size(Width + 1, Height + 1);

                    updateOkButton();
                }));
            }
            else
            {
                status.setInfo("");
                if (Visible)
                {
                    Invoke(new MethodInvoker(() => MessageBox.Show("Unable to retrieve issue data", Constants.ERROR_CAPTION,
                                                                   MessageBoxButtons.OK, MessageBoxIcon.Error)));
                }
            }
        }
        private void runGetBuildDetailsThread()
        {
            status.setInfo("Retrieving build details...");
            Thread t = PlvsUtils.createThread(getBuildDetailsRunner);

            t.Start();
        }
Ejemplo n.º 5
0
        private void IssueDetailsPanel_VisibleChanged(object sender, EventArgs e)
        {
            if (Visible)
            {
                model.addListener(this);

                rebuildAllPanels(false);
                status.setInfo("No issue details yet");
                runRefreshThread();
            }
            else
            {
                model.removeListener(this);
            }
        }
Ejemplo n.º 6
0
        private static void runActionWithoutFields(
            Control owner, JiraNamedEntity action, JiraIssueListModel model,
            JiraIssue issue, StatusLabel status, Action onFinish)
        {
            status.setInfo("Running action \"" + action.Name + "\" on issue " + issue.Key + "...");
            SmartJiraServerFacade.Instance.runIssueActionWithoutParams(issue, action);
            status.setInfo("Action \"" + action.Name + "\" successfully run on issue " + issue.Key);
            var newIssue = SmartJiraServerFacade.Instance.getIssue(issue.Server, issue.Key);

            UsageCollector.Instance.bumpJiraIssuesOpen();
            owner.Invoke(new MethodInvoker(() => { model.updateIssue(newIssue); if (onFinish != null)
                                                   {
                                                       onFinish();
                                                   }
                                           }));
        }
Ejemplo n.º 7
0
        private void addComment(JiraIssue issue)
        {
            SmartJiraServerFacade facade = SmartJiraServerFacade.Instance;
            NewIssueComment       dlg    = new NewIssueComment(issue, facade);

            dlg.ShowDialog();
            if (dlg.DialogResult != DialogResult.OK)
            {
                return;
            }

            Thread addCommentThread =
                PlvsUtils.createThread(delegate {
                try {
                    jiraStatus.setInfo("Adding comment to issue...");
                    facade.addComment(issue, dlg.CommentBody);
                    issue = facade.getIssue(issue.Server, issue.Key);
                    jiraStatus.setInfo("Comment added");
                    UsageCollector.Instance.bumpJiraIssuesOpen();
                    container.safeInvoke(new MethodInvoker(() => JiraIssueListModelImpl.Instance.updateIssue(issue)));
                } catch (Exception ex) {
                    jiraStatus.setError("Adding comment failed", ex);
                }
            });

            addCommentThread.Start();
        }
Ejemplo n.º 8
0
        private void findBuildWorker(IEnumerable <BambooServer> servers, string buildKey)
        {
            List <BambooBuild> foundBuilds = new List <BambooBuild>();
            List <Exception>   errors      = new List <Exception>();

            foreach (BambooServer server in servers)
            {
                try {
                    status.setInfo("Searching for build " + buildKey + " on server \"" + server.Name + "\"");
                    BambooBuild build = BambooServerFacade.Instance.getBuildByKey(server, buildKey);
                    foundBuilds.Add(build);
                } catch (Exception e) {
                    errors.Add(e);
                }
            }
            this.safeInvoke(new MethodInvoker(delegate {
                if (foundBuilds.Count > 0)
                {
                    status.setInfo("");
                    foreach (BambooBuild build in foundBuilds)
                    {
                        BuildDetailsWindow.Instance.openBuild(build);
                    }
                }
                else if (errors.Count > 0)
                {
                    PlvsUtils.showErrors("Build key " + buildKey + " not found", errors);
                    status.setError("Build key " + buildKey + " not found", errors);
                }
                else if (foundBuilds.Count == 0)
                {
                    PlvsUtils.showError("Build key " + buildKey + " not found", null);
                    status.setInfo("Build key " + buildKey + " not found");
                }
                DialogResult = DialogResult.OK;
                Close();
            }));
        }
Ejemplo n.º 9
0
        public static void runAction(Control owner, JiraNamedEntity action, JiraIssueListModel model, JiraIssue issue, StatusLabel status, Action onFinish)
        {
            Thread runner = PlvsUtils.createThread(delegate {
                try {
                    status.setInfo("Retrieving fields for action \"" + action.Name + "\"...");
                    List <JiraField> fields = SmartJiraServerFacade.Instance.getFieldsForAction(issue, action.Id);
                    runAction(owner, action, model, issue, fields, status, onFinish);
                } catch (Exception e) {
                    status.setError("Failed to run action " + action.Name + " on issue " + issue.Key, e);
                }
            });

            runner.Start();
        }
        private void initBuildTree()
        {
            if (splitter != null)
            {
                toolStripContainer.ContentPanel.Controls.Remove(splitter);
            }

            if (linkAddBambooServers != null)
            {
                Controls.Remove(linkAddBambooServers);
            }

            if (BambooServerModel.Instance.getAllServers().Count == 0)
            {
                toolStripContainer.Visible = false;

                linkAddBambooServers = new LinkLabel
                {
                    Dock      = DockStyle.Fill,
                    Font      = new Font("Microsoft Sans Serif", 9.75F, FontStyle.Regular, GraphicsUnit.Point, 238),
                    Image     = Resources.bamboo_blue_16_with_padding,
                    Location  = new Point(0, 0),
                    Name      = "linkAddBambooServers",
                    Size      = new Size(1120, 510),
                    TabIndex  = 0,
                    TabStop   = true,
                    Text      = "Add Bamboo Servers",
                    TextAlign = ContentAlignment.MiddleCenter
                };

                linkAddBambooServers.LinkClicked += linkAddBambooServers_LinkClicked;

                Controls.Add(linkAddBambooServers);
            }
            else
            {
                toolStripContainer.Visible = true;

                splitter = new SplitContainer();

                buildTree = new BambooBuildTree(splitter)
                {
                    CollapseExpandManager =
                        new TreeNodeCollapseExpandStatusManager(
                            ParameterStoreManager.Instance.getStoreFor(ParameterStoreManager.StoreType.SETTINGS))
                };

                updateBuildTreeModel();
                splitter.Panel1.Controls.Add(buildTree);

                buildHistoryTable = new BambooBuildHistoryTable(status);
                buildHistoryTable.showHistoryForBuild(null);

                splitter.SplitterDistance = Width - 300;
                splitter.Panel2.Controls.Add(buildHistoryTable);

                splitter.Orientation = Orientation.Vertical;
                splitter.Dock        = DockStyle.Fill;
                toolStripContainer.ContentPanel.Controls.Add(splitter);

                updateBuildListButtons();

                buildTree.SelectionChanged += buildTreeSelectionChanged;
                buildTree.MouseDoubleClick += buildTreeMouseDoubleClick;
                buildTree.KeyPress         += buildTreeKeyPress;

                int count = BambooServerModel.Instance.getAllEnabledServers().Count;
                if (count == 0)
                {
                    status.setInfo("No Bamboo servers enabled");
                }
                else
                {
                    showPollTimeInfo();
                }

                comboGroupBy.restoreSelectedIndex();
            }
        }
Ejemplo n.º 11
0
        private void reloadKnownJiraServers()
        {
            filtersTree.Nodes.Clear();
            model.clear(true);

            getMoreIssues.Visible = false;

            // copy to local list so that we can reuse in our threads
            List <JiraServer> servers = new List <JiraServer>(JiraServerModel.Instance.getAllServers());

            if (servers.Count == 0)
            {
                status.setInfo("No JIRA servers defined");
                return;
            }

            foreach (JiraServer server in servers)
            {
                filtersTree.Nodes.Add(new JiraServerTreeNode(server, 0));
            }

            Thread metadataThread = new Thread(new ThreadStart(delegate
            {
                try
                {
                    foreach (JiraServer server in servers)
                    {
                        status.setInfo("[" + server.Name + "] Loading project definitions...");
                        List <JiraProject> projects = facade.getProjects(server);
                        JiraServerCache.Instance.clearProjects();
                        foreach (JiraProject proj in projects)
                        {
                            JiraServerCache.Instance.addProject(server, proj);
                        }
                        status.setInfo("[" + server.Name + "] Loading issue types...");
                        List <JiraNamedEntity> issueTypes = facade.getIssueTypes(server);
                        JiraServerCache.Instance.clearIssueTypes();
                        foreach (JiraNamedEntity type in issueTypes)
                        {
                            JiraServerCache.Instance.addIssueType(server, type);
                            ImageCache.Instance.getImage(type.IconUrl);
                        }
                        status.setInfo("[" + server.Name + "] Loading issue priorities...");
                        List <JiraNamedEntity> priorities = facade.getPriorities(server);
                        JiraServerCache.Instance.clearPriorities();
                        foreach (JiraNamedEntity prio in priorities)
                        {
                            JiraServerCache.Instance.addPriority(server, prio);
                            ImageCache.Instance.getImage(prio.IconUrl);
                        }
                        status.setInfo("[" + server.Name + "] Loading issue statuses...");
                        List <JiraNamedEntity> statuses = facade.getStatuses(server);
                        JiraServerCache.Instance.clearStatuses();
                        foreach (JiraNamedEntity s in statuses)
                        {
                            JiraServerCache.Instance.addStatus(server, s);
                            ImageCache.Instance.getImage(s.IconUrl);
                        }

                        status.setInfo("[" + server.Name + "] Loading saved filters...");
                        List <JiraSavedFilter> filters = facade.getSavedFilters(server);
                        JiraServer jiraServer          = server;
                        Invoke(new MethodInvoker(delegate
                        {
                            fillSavedFiltersForServer(jiraServer, filters);
                            status.setInfo("Loaded saved filters for server " +
                                           jiraServer.Name);
                            addCustomFilterNodes(jiraServer);
                        }));
                    }
                    Invoke(new MethodInvoker(delegate
                    {
                        filtersTree.Nodes.Add(new RecentlyOpenIssuesTreeNode(3));
                        filtersTree.ExpandAll();
                    }));
                }
                catch (Exception e)
                {
                    status.setError("Failed to load server metadata", e);
                }
            }));

            metadataThread.Start();
        }