public GitHubIssueNode(GitHubIssue issue) { super( GitHubIssuesConnector.ID, issue.getRepository().getID(), issue, GitHubIssues.getInstance().getIssueProvider(), GitHubIssues.getInstance().getIssueStatusProvider(), GitHubIssues.getInstance().getChangesProvider()); }
@Override public void actionPerformed(ActionEvent e) { final GitHubIssuePanel p = getPanel(); p.setNewCommentEnabled(false); GitHubIssues gitHubIssues = GitHubIssues.getInstance(); RequestProcessor rp = gitHubIssues.getRequestProcessor(); rp.post( new Runnable() { @Override public void run() { try { String comment = p.getNewComment(); if (StringUtils.isEmpty(comment)) { closeReopen(); } else { Comment newComment = comment(comment); if (newComment != null) { closeReopen(); } } SwingUtilities.invokeLater( new Runnable() { @Override public void run() { p.update(); } }); } finally { p.setNewCommentEnabled(true); } } }); }
@NbBundle.Messages({"GitHubIssueController.delete.comment.fail=Can't delete this issue."}) private void deleteComment() { final Comment deletedComment = getPanel().getDeletedComment(); if (deletedComment == null) { return; } RequestProcessor rp = GitHubIssues.getInstance().getRequestProcessor(); rp.post( new Runnable() { @Override public void run() { GitHubRepository repository = getPanel().getIssue().getRepository(); final boolean success = GitHubIssueSupport.deleteComment(repository, deletedComment); SwingUtilities.invokeLater( new Runnable() { @Override public void run() { if (success) { // remove comment panel getPanel().removeDeletedComment(); } else { // show error message UiUtils.showErrorDialog(Bundle.GitHubIssueController_delete_comment_fail()); } } }); } }); }
@NbBundle.Messages({ "GitHubIssueController.edit.comment.title=Edit Comment", "GitHubIssueController.edit.comment.fail=Can't edit this comment." }) private void editComment() { final Comment comment = getPanel().getEditedComment(); final String editedBody = CommentTabbedPanel.showDialog( Bundle.GitHubIssueController_edit_comment_title(), comment.getBody()); if (editedBody != null) { final GitHubIssue issue = getPanel().getIssue(); if (issue != null) { RequestProcessor rp = GitHubIssues.getInstance().getRequestProcessor(); rp.post( new Runnable() { @Override public void run() { Comment editedComment = issue.editComment(comment, editedBody); if (editedComment == null) { UiUtils.showErrorDialog(Bundle.GitHubIssueController_edit_comment_fail()); return; } SwingUtilities.invokeLater( new Runnable() { @Override public void run() { getPanel().loadComments(); } }); } }); } } }
@Override public void actionPerformed(ActionEvent e) { String actionCommand = e.getActionCommand(); final boolean isNewPullRequest = actionCommand.equals("New PR"); // NOI18N GitHubIssuePanel p = getPanel(); p.setCreatePullRequestButtonEnabled(false); final GitHubIssue issue = p.getIssue(); if (isNewPullRequest && !p.isNewPullRequestSelected()) { // remove the new pull request from the panle SwingUtilities.invokeLater( new Runnable() { @Override public void run() { getPanel().setNewPullRequest(null); } }); return; } RequestProcessor rp = GitHubIssues.getInstance().getRequestProcessor(); rp.post( new Runnable() { @Override public void run() { final GitHubRepository repository = issue.getRepository(); GitHubCache cache = GitHubCache.create(repository); final User mySelf = cache.getMySelf(); List<RepositoryBranch> baseBranches = cache.getBranches(true); final HashMap<Repository, List<RepositoryBranch>> baseRepositories = new HashMap<>(); baseRepositories.put(repository.getRepository(), baseBranches); final Map<Repository, List<RepositoryBranch>> headRepositories = getHeadRepositories(repository, baseBranches); SwingUtilities.invokeLater( new Runnable() { @Override public void run() { try { if (baseRepositories.isEmpty() || headRepositories.isEmpty()) { UiUtils.showErrorDialog( Bundle .CreatePullRequestAction_error_message_cannot_find_base_head_repositories()); return; } // create descriptor final CreatePullRequestPanel createPullRequestPanel = new CreatePullRequestPanel(baseRepositories, headRepositories); createPullRequestPanel.setMessage( Bundle.CreatePullRequestAction_confirmation_message()); final NotifyDescriptor.Confirmation descriptor = new NotifyDescriptor.Confirmation( createPullRequestPanel, Bundle.CreatePullRequestAction_descriptor_title(), NotifyDescriptor.OK_CANCEL_OPTION, NotifyDescriptor.QUESTION_MESSAGE); // add listeners ChangeListener changeListener = new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { descriptor.setValid(false); createPullRequestPanel.setErrorMessage(""); // NOI18N } }; createPullRequestPanel.addChangeListener(changeListener); ComparePullRequestPropertyChangeListener propertyChangeListener = new ComparePullRequestPropertyChangeListener( repository, createPullRequestPanel, descriptor); createPullRequestPanel.addPropertyChangeListener(propertyChangeListener); changeListener.stateChanged(null); // show dialog if (DialogDisplayer.getDefault().notify(descriptor) == NotifyDescriptor.OK_OPTION) { RepositoryBranch selectedBaseBranch = createPullRequestPanel.getSelectedBaseBranch(); RepositoryBranch selectedHeadBranch = createPullRequestPanel.getSelectedHeadBranch(); String baseBranch = selectedBaseBranch.getName(); String headBranch = mySelf.getLogin() + ":" + selectedHeadBranch.getName(); // NOI18N PullRequest pullRequest; try { if (isNewPullRequest) { // set new pull request to panel PullRequestMarker baseMarker = new PullRequestMarker(); baseMarker.setLabel(baseBranch); PullRequestMarker headMarker = new PullRequestMarker(); headMarker.setLabel(headBranch); PullRequest newPullRequest = new PullRequest().setBase(baseMarker).setHead(headMarker); getPanel().setNewPullRequest(newPullRequest); } else { pullRequest = issue.createPullRequest(headBranch, baseBranch); if (pullRequest != null) { getPanel().refresh(); } } } catch (IOException ex) { UiUtils.showErrorDialog( "Can't create a pull request:" + ex.getMessage()); // NOI18N } } else if (isNewPullRequest) { getPanel().setNewPullRequestSelected(false); } // remove listeners createPullRequestPanel.removeChangeListener(changeListener); createPullRequestPanel.removePropertyChangeListener(propertyChangeListener); } finally { getPanel().setCreatePullRequestButtonEnabled(true); } } }); } }); }
@NbBundle.Messages({ "SubmitIssueAction.message.pull.request.added.fail=The pull request has not been added.", "SubmitIssueAction.message.issue.added.fail=The issue has not been added.", "SubmitIssueAction.message.issue.updated.fail=The issue has not been updated." }) @Override public void actionPerformed(ActionEvent e) { final GitHubIssuePanel p = getPanel(); p.setSubmitButtonEnabled(false); RequestProcessor rp = GitHubIssues.getInstance().getRequestProcessor(); rp.post( new Runnable() { @Override public void run() { SwingUtilities.invokeLater( new Runnable() { @Override public void run() { GitHubIssue issue = p.getIssue(); CreateIssueParams issueParams = getCreateIssueParams(issue.isNew(), p); if (issue.isNew()) { if (p.isNewPullRequestSelected()) { // add pull request // can be added only title and body to a pull request // add other than those after the pull request was created PullRequest newPullRequest = p.getNewPullRequest(); if (newPullRequest != null) { newPullRequest .setTitle(issueParams.getTitle()) .setBody(issueParams.getBody()); try { PullRequest createdPullRequest = issue.createPullRequest(newPullRequest); if (createdPullRequest != null) { issue.editIssue(issueParams); p.update(); } else { // show dialog UiUtils.showErrorDialog( Bundle.SubmitIssueAction_message_pull_request_added_fail()); } } catch (IOException ex) { UiUtils.showErrorDialog(ex.getMessage()); } } } else { // add issue Issue newIssue = issue.submitNewIssue(issueParams); if (newIssue != null) { p.update(); } else { // show dialog UiUtils.showErrorDialog( Bundle.SubmitIssueAction_message_issue_added_fail()); } } } else { // edit issue Issue editIssue = issue.editIssue(issueParams); if (editIssue != null) { p.update(); } else { // show dialog UiUtils.showErrorDialog( Bundle.SubmitIssueAction_message_issue_updated_fail()); } } p.setSubmitButtonEnabled(true); } }); } }); }