1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package com.atlassian.theplugin.idea.action.issues.activetoolbar;
17
18 import com.atlassian.theplugin.idea.IdeaHelper;
19 import com.atlassian.theplugin.idea.jira.IssueListToolWindowPanel;
20 import com.atlassian.theplugin.jira.api.JIRAException;
21 import com.atlassian.theplugin.jira.api.JIRAIssue;
22 import com.intellij.openapi.actionSystem.AnAction;
23 import com.intellij.openapi.actionSystem.AnActionEvent;
24 import com.intellij.openapi.project.Project;
25
26 import javax.swing.*;
27
28
29
30
31 public class OpenActiveJiraIssue extends AnAction {
32 public void actionPerformed(final AnActionEvent event) {
33 openIssue(event);
34 }
35
36 public void update(final AnActionEvent event) {
37 event.getPresentation().setEnabled(ActiveIssueUtils.getActiveJiraIssue(event) != null);
38 }
39
40 private void openIssue(final AnActionEvent event) {
41 SwingUtilities.invokeLater(new Runnable() {
42 public void run() {
43 final Project currentProject = IdeaHelper
44 .getCurrentProject(event);
45 final JIRAIssue issue;
46 if (currentProject != null) {
47 final IssueListToolWindowPanel panel = IdeaHelper.getIssueListToolWindowPanel(currentProject);
48 try {
49 issue = ActiveIssueUtils.getJIRAIssue(currentProject);
50 if (issue != null) {
51 if (panel != null) {
52 panel.openIssue(issue);
53 }
54 }
55 } catch (JIRAException e) {
56 if (panel != null) {
57 panel.setStatusErrorMessage("Error opening issue: " + e.getMessage(), e);
58 }
59 }
60 }
61 }
62 });
63 }
64 }