1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package com.atlassian.theplugin.idea.config.serverconfig;
17
18 import com.atlassian.theplugin.commons.ServerType;
19 import com.atlassian.theplugin.commons.cfg.BambooServerCfg;
20 import com.atlassian.theplugin.commons.cfg.CrucibleServerCfg;
21 import com.atlassian.theplugin.commons.cfg.JiraServerCfg;
22 import com.atlassian.theplugin.commons.cfg.ServerCfg;
23 import com.atlassian.theplugin.commons.cfg.ServerId;
24 import com.atlassian.theplugin.commons.util.MiscUtil;
25
26 import javax.swing.*;
27 import java.awt.*;
28 import java.awt.event.ActionEvent;
29 import java.awt.event.ActionListener;
30 import java.awt.event.WindowAdapter;
31 import java.awt.event.WindowEvent;
32 import java.util.Collection;
33
34 public final class ServerConfigPanelTestUi {
35
36 private ServerConfigPanelTestUi() {
37 }
38
39 public static void main(String[] args) {
40 JFrame frame = new JFrame("ServerConfigPanel test");
41 final BambooServerCfg bambooServerCfg = new BambooServerCfg(false, "mybamboo2", new ServerId());
42 final Collection<ServerCfg> serverCfgs = MiscUtil.buildArrayList(
43 new BambooServerCfg(true, "mybamboo", new ServerId()),
44 bambooServerCfg,
45 new CrucibleServerCfg("Crucible EAC", new ServerId()),
46 new JiraServerCfg("My Jira Server", new ServerId()),
47 new JiraServerCfg("Second Jira", new ServerId())
48 );
49
50 final Collection<ServerCfg> serverCfgs2 = MiscUtil.buildArrayList(
51 new BambooServerCfg(true, "2-mybamboo", new ServerId()),
52 bambooServerCfg,
53 new CrucibleServerCfg("2-Crucible EAC Very Very long name", new ServerId()),
54 new JiraServerCfg("2-My Jira Server", new ServerId()),
55 new JiraServerCfg("2-Second Jira", new ServerId())
56 );
57
58 ServerConfigPanel configPanel = new ServerConfigPanel(null, serverCfgs) {
59 @Override
60 protected JComponent createToolbar() {
61 JToolBar toolbar = new JToolBar("My Fake Toolbar", JToolBar.HORIZONTAL);
62 final JButton button = new JButton("Test Only");
63 button.addActionListener(new ActionListener() {
64
65 public void actionPerformed(final ActionEvent e) {
66 setData(serverCfgs2);
67 }
68 });
69 toolbar.add(button);
70 final JButton addButton = new JButton("Add");
71 addButton.addActionListener(new ActionListener() {
72
73 public void actionPerformed(final ActionEvent e) {
74 addServer(ServerType.CRUCIBLE_SERVER);
75 }
76 });
77 toolbar.add(addButton);
78 return toolbar;
79 }
80 };
81
82 frame.getContentPane().add(configPanel, BorderLayout.CENTER);
83
84
85 frame.addWindowListener(new WindowAdapter() {
86 @Override
87 public void windowClosing(WindowEvent e) {
88 System.exit(0);
89 }
90 });
91 frame.pack();
92 frame.setVisible(true);
93
94 }
95 }