Exemplo n.º 1
0
        private static void runAction(Control owner, JiraNamedEntity action, JiraIssueListModel model,
                                      JiraIssue issue, List <JiraField> fields, StatusLabel status, Action onFinish)
        {
            JiraIssue issueWithTime = SmartJiraServerFacade.Instance.getIssue(issue.Server, issue.Key);

            issueWithTime.SecurityLevel = SmartJiraServerFacade.Instance.getSecurityLevel(issue);
            object           rawIssueObject   = SmartJiraServerFacade.Instance.getRawIssueObject(issue);
            List <JiraField> fieldsWithValues = JiraActionFieldType.fillFieldValues(issue, rawIssueObject, fields);

            // PLVS-133 - this should never happen but does?
            if (model == null)
            {
                owner.Invoke(new MethodInvoker(()
                                               =>
                                               PlvsUtils.showError("Issue List Model was null, please report this as a bug",
                                                                   new Exception("IssueActionRunner.runAction()"))));
                model = JiraIssueListModelImpl.Instance;
            }

            if (fieldsWithValues == null || fieldsWithValues.Count == 0)
            {
                runActionWithoutFields(owner, action, model, issue, status, onFinish);
            }
            else
            {
                owner.Invoke(new MethodInvoker(() =>
                                               new IssueWorkflowAction(issue, action, model, fieldsWithValues, status, onFinish).initAndShowDialog()));
            }
        }
Exemplo n.º 2
0
 private void createIssueWorker(JiraIssue issue, bool keepDialogOpen)
 {
     try {
         string key = SmartJiraServerFacade.Instance.createIssue(server, issue);
         this.safeInvoke(new MethodInvoker(delegate {
             setAllEnabled(true);
             buttonCancel.Enabled = true;
             if (!keepDialogOpen)
             {
                 Close();
             }
             else
             {
                 if (keepDialogOpen)
                 {
                     textSummary.Text     = "";
                     textDescription.Text = "";
                 }
             }
             AtlassianPanel.Instance.Jira.findAndOpenIssue(key, delegate {
                 if (keepDialogOpen)
                 {
                     bringDialogToFront();
                 }
             });
         }));
     } catch (Exception e) {
         this.safeInvoke(new MethodInvoker(delegate {
             PlvsUtils.showError("Unable to create issue", e);
             setAllEnabled(true);
             buttonCancel.Enabled = true;
         }));
     }
 }
Exemplo n.º 3
0
        private void getPlansWorker()
        {
            fillServerData();
            try {
                ICollection <BambooPlan> plans = facade.getPlanList(server);
                this.safeInvoke(new MethodInvoker(() => fillPlanList(plans)));
            } catch (Exception e) {
                this.safeInvoke(new MethodInvoker(() => PlvsUtils.showError("Unable to retrieve build plans", e)));
            } finally {
                gettingPlans = false;

                this.safeInvoke(new MethodInvoker(delegate {
//                    buttonCancel.Enabled = true;
                    radioUseFavourites.Enabled  = true;
                    radioSelectManually.Enabled = true;
                    name.Enabled              = true;
                    url.Enabled               = true;
                    user.Enabled              = true;
                    password.Enabled          = true;
                    checkEnabled.Enabled      = true;
                    checkShared.Enabled       = true;
                    checkDontUseProxy.Enabled = true;
                    checkIfValid();
                }));
            }
        }
 private static void findFinished(bool success, string message, Exception e)
 {
     if (!success)
     {
         PlvsUtils.showError(message, e);
     }
 }
 private void linkErrorDetails_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     if (exception == null)
     {
         return;
     }
     PlvsUtils.showError("Failed to connect to server \"" + server.Name + "\"", exception);
 }
 private void fillFieldWrap()
 {
     try {
         getMetadata();
     } catch (Exception e) {
         this.safeInvoke(new MethodInvoker(delegate {
             PlvsUtils.showError("Unable to initialize field editor component", e);
             Close();
         }));
     }
 }
Exemplo n.º 7
0
 private void updateIconOrBaloonClicked()
 {
     notifyUpdate.Visible = false;
     if (updateAction != null)
     {
         updateAction();
     }
     else if (updateException != null)
     {
         PlvsUtils.showError("Unable to retrieve autoupdate information", updateException);
     }
 }
Exemplo n.º 8
0
        private void getServerVersion()
        {
            var t = PlvsUtils.createThread(() => {
                try {
                    var buildNumber = facade.getServerBuildNumber(server);
                    this.safeInvoke(new MethodInvoker(delegate {
                        checkShowBranches.Enabled = RestSession.BUILD_NUMBER_4_0 <= buildNumber;
                        checkMyBranches.Enabled   = RestSession.BUILD_NUMBER_5_0 <= buildNumber;
                    }));
                } catch (Exception e) {
                    this.safeInvoke(new MethodInvoker(() => PlvsUtils.showError("Unable to retrieve server version", e)));
                }
            });

            t.Start();
        }
 private void applyChanges()
 {
     try {
         facade.updateIssue(issue, new List <JiraField> {
             field
         });
         JiraIssue updatedIssue = facade.getIssue(issue.Server, issue.Key);
         this.safeInvoke(new MethodInvoker(delegate {
             Close();
             model.updateIssue(updatedIssue);
         }));
     } catch (Exception e) {
         this.safeInvoke(new MethodInvoker(delegate {
             PlvsUtils.showError("Failed to apply changes", e);
             Close();
         }));
     }
 }
Exemplo n.º 10
0
        public void runManualUpdate(bool stableOnly, Form parent, Action onFinished)
        {
            string url = stableOnly ? STABLE_URL : SNAPSHOT_URL;

            if (GlobalSettings.ReportUsage)
            {
                url = UsageCollector.Instance.getUsageReportingUrl(url);
            }
            Thread t = PlvsUtils.createThread(delegate {
                Exception ex;
                if (runSingleUpdateQuery(url, false, out ex))
                {
                    parent.Invoke(new MethodInvoker(delegate { showUpdateDialog(); onFinished(); }));
                }
                else
                {
                    if (ex != null)
                    {
                        parent.Invoke(new MethodInvoker(delegate {
                            PlvsUtils.showError(
                                "Unable to retrieve autoupdate information", ex);
                            onFinished();
                        }));
                    }
                    else
                    {
                        parent.Invoke(new MethodInvoker(delegate {
                            MessageBox.Show("You have the latest connector version installed",
                                            Constants.INFO_CAPTION, MessageBoxButtons.OK,
                                            MessageBoxIcon.Information);
                            onFinished();
                        }));
                    }
                }
            });

            t.Start();
        }
Exemplo n.º 11
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();
            }));
        }
Exemplo n.º 12
0
        public override void PreprocessMouseLeftButtonUp(MouseButtonEventArgs e)
        {
            if (!(Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl)))
            {
                return;
            }

            JiraIssueTextTag textTag = getIssueTagUnderCursor(view, provider.TagAggregatorFactoryService);

            if (textTag == null)
            {
                return;
            }

            e.Handled = true;

            AtlassianPanel.Instance.Jira.findAndOpenIssue(textTag.IssueKey, (success, message, ex) => {
                if (!success)
                {
                    PlvsUtils.showError(message, ex);
                }
            });
        }
Exemplo n.º 13
0
        private void runDeactivateIssueActionsWorker(string newActiveIssue, Action onFinish)
        {
            JiraServer server = JiraServerModel.Instance.getServer(new Guid(CurrentActiveIssue.ServerGuid));

            if (server != null)
            {
                try {
                    JiraIssue issue = SmartJiraServerFacade.Instance.getIssue(server, CurrentActiveIssue.Key);
                    if (issue != null)
                    {
                        List <JiraNamedEntity> actions = SmartJiraServerFacade.Instance.getActionsForIssue(issue);
                        container.safeInvoke(
                            new MethodInvoker(
                                () => new DeactivateIssue(newActiveIssue != null ? string.Format(EXPLANATION_TEXT, issue.Key, newActiveIssue) : null,
                                                          container,
                                                          JiraIssueListModelImpl.Instance,
                                                          SmartJiraServerFacade.Instance,
                                                          ParameterStoreManager.Instance.getStoreFor(ParameterStoreManager.StoreType.ACTIVE_ISSUES),
                                                          issue,
                                                          jiraStatus,
                                                          this,
                                                          actions,
                                                          () => {
                            jiraStatus.setInfo("Work on issue " + CurrentActiveIssue.Key + " stopped");
                            onFinish();
                        }).ShowDialog()));
                    }
                } catch (Exception e) {
                    jiraStatus.setError(FAILED_TO_START_WORK, e);
                    PlvsUtils.showError(FAILED_TO_START_WORK, e);
                }
            }
            else
            {
                PlvsUtils.showError(FAILED_TO_START_WORK, new Exception("Unknown JIRA server"));
            }
        }
        private void setProjectRelatedValuesRunner(JiraProject project)
        {
            try {
                List <JiraNamedEntity> issueTypes = SmartJiraServerFacade.Instance.getIssueTypes(server, project);
                issueTypes.AddRange(SmartJiraServerFacade.Instance.getSubtaskIssueTypes(server, project));
                List <JiraNamedEntity> comps    = SmartJiraServerFacade.Instance.getComponents(server, project);
                List <JiraNamedEntity> versions = SmartJiraServerFacade.Instance.getVersions(server, project);

                versions.Reverse();
                this.safeInvoke(new MethodInvoker(delegate {
                    refillIssueTypes(issueTypes);
                    refillComponents(comps);
                    refillFixFor(versions);
                    refillAffectsVersions(versions);

                    setProjectRelatedSelections();

                    setAllEnabled(true);
                }));
            }
            catch (Exception ex) {
                this.safeInvoke(new MethodInvoker(delegate { PlvsUtils.showError("Unable to retrieve project-related data", ex); }));
            }
        }
 private void showErrorAndResumeEditing(Exception ex)
 {
     PlvsUtils.showError("Failed to run action " + action.Name + " on issue " + issue.Key, ex);
     setThrobberVisible(false);
     setAllEnabled(true);
 }
Exemplo n.º 16
0
 private void showErrorAndReset(Exception e)
 {
     PlvsUtils.showError("Failed to perform drop action", e);
     updateModelAndResetToInitialState(null, false);
 }
Exemplo n.º 17
0
        private void runActivateIssueActionsWorker(Action onFinish)
        {
            JiraServer server = JiraServerModel.Instance.getServer(new Guid(CurrentActiveIssue.ServerGuid));

            if (server != null)
            {
                try {
                    int       mods  = 0;
                    JiraIssue issue = SmartJiraServerFacade.Instance.getIssue(server, CurrentActiveIssue.Key);
                    if (issue != null)
                    {
                        string me = CredentialUtils.getUserNameWithoutDomain(server.UserName);
                        if (issue.Assignee == null || issue.Assignee.Equals("Unknown") || !issue.Assignee.Equals(me))
                        {
                            jiraStatus.setInfo("Assigning issue to me...");
                            JiraField assignee = new JiraField("assignee", null)
                            {
                                Values = new List <string> {
                                    me
                                },
                                SettablePropertyName = "name"
                            };
                            var rawIssueObject = SmartJiraServerFacade.Instance.getRawIssueObject(issue);
                            assignee.setRawIssueObject(rawIssueObject);
                            SmartJiraServerFacade.Instance.updateIssue(issue, new List <JiraField> {
                                assignee
                            });
                            ++mods;
                        }
                        List <JiraNamedEntity> actions = SmartJiraServerFacade.Instance.getActionsForIssue(issue);
                        JiraNamedEntity        action  = actions.Find(a => a.Id.Equals(START_PROGRESS_ACTION_ID));
                        if (action == null)
                        {
                            container.safeInvoke(new MethodInvoker(delegate {
                                ActionSelector sel = new ActionSelector(actions);
                                if (sel.ShowDialog() == DialogResult.OK)
                                {
                                    action = sel.SelectedAction;
                                }
                            }));
                        }
//                        foreach (JiraNamedEntity action in actions.Where(action => action.Id.Equals(START_PROGRESS_ACTION_ID))) {
                        if (action != null)
                        {
                            jiraStatus.setInfo("Setting issue in progress...");
                            SmartJiraServerFacade.Instance.runIssueActionWithoutParams(issue, action);
                            ++mods;
                        }
                        if (mods > 0)
                        {
                            issue = SmartJiraServerFacade.Instance.getIssue(server, CurrentActiveIssue.Key);
                        }
                    }
                    jiraStatus.setInfo("Work on issue " + CurrentActiveIssue.Key + " started");
                    container.safeInvoke(new MethodInvoker(() => {
                        JiraIssueListModelImpl.Instance.updateIssue(issue);
                        onFinish();
                    }));
                } catch (Exception e) {
                    CurrentActiveIssue = null;
                    jiraStatus.setError(FAILED_TO_START_WORK, e);
                    container.safeInvoke(new MethodInvoker(() => PlvsUtils.showError(FAILED_TO_START_WORK, e)));
                }
            }
            else
            {
                container.safeInvoke(new MethodInvoker(
                                         () => PlvsUtils.showError(FAILED_TO_START_WORK, new Exception("Unknown JIRA server"))));
            }
        }