1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package com.atlassian.theplugin.idea.action.jira;
18
19 import com.atlassian.theplugin.commons.ServerType;
20 import com.atlassian.theplugin.commons.Server;
21 import com.atlassian.theplugin.commons.configuration.ProductServerConfiguration;
22 import com.atlassian.theplugin.idea.IdeaHelper;
23 import com.atlassian.theplugin.idea.ThePluginApplicationComponent;
24 import com.intellij.openapi.actionSystem.AnAction;
25 import com.intellij.openapi.actionSystem.AnActionEvent;
26 import com.intellij.openapi.actionSystem.DefaultActionGroup;
27 import com.intellij.openapi.actionSystem.ex.ComboBoxAction;
28
29 import javax.swing.*;
30
31 public class SelectJIRAAction extends ComboBoxAction {
32
33 protected DefaultActionGroup createPopupActionGroup(JComponent jComponent) {
34 ThePluginApplicationComponent appComponent = IdeaHelper.getAppComponent();
35
36 final DefaultActionGroup g = new DefaultActionGroup();
37
38 ProductServerConfiguration jConfig = appComponent.getState().getProductServers(ServerType.JIRA_SERVER);
39
40 final ComboBoxButton button = (ComboBoxButton) jComponent;
41 for (final Server server : jConfig.transientgetEnabledServers()) {
42 g.add(new AnAction(server.getName()) {
43 public void actionPerformed(AnActionEvent event) {
44 button.setText(event.getPresentation().getText());
45 IdeaHelper.getJIRAToolWindowPanel(event).selectServer(server);
46 }
47 });
48 }
49 return g;
50 }
51
52 public void update(AnActionEvent event) {
53 super.update(event);
54 if (IdeaHelper.getCurrentJIRAServer() != null) {
55 event.getPresentation().setText(IdeaHelper.getCurrentJIRAServer().getServer().getName());
56 }
57 }
58 }