1 | package genius.gui;
|
---|
2 |
|
---|
3 | import java.awt.BorderLayout;
|
---|
4 | import java.awt.Component;
|
---|
5 | import java.awt.Dimension;
|
---|
6 | import java.awt.Frame;
|
---|
7 | import java.awt.event.MouseEvent;
|
---|
8 |
|
---|
9 | import javax.swing.JFrame;
|
---|
10 | import javax.swing.JMenu;
|
---|
11 | import javax.swing.JMenuBar;
|
---|
12 | import javax.swing.JScrollPane;
|
---|
13 | import javax.swing.JSplitPane;
|
---|
14 | import javax.swing.JTabbedPane;
|
---|
15 |
|
---|
16 | import genius.gui.actions.AboutAction;
|
---|
17 | import genius.gui.actions.OpenManual;
|
---|
18 | import genius.gui.actions.Session;
|
---|
19 | import genius.gui.actions.Tournament;
|
---|
20 | import genius.gui.boaframework.BOARepositoryUI;
|
---|
21 | import genius.gui.boaparties.BoaPartiesPanel;
|
---|
22 | import genius.gui.domainrepository.DomainRepositoryUI;
|
---|
23 | import genius.gui.panels.tab.CloseTabbedPane;
|
---|
24 | import genius.gui.repository.PartyRepositoryUI;
|
---|
25 |
|
---|
26 | /**
|
---|
27 | * main application and main GUI panel.
|
---|
28 | *
|
---|
29 | */
|
---|
30 | @SuppressWarnings("serial")
|
---|
31 | public class MainPanel extends JFrame implements GeniusAppInterface {
|
---|
32 |
|
---|
33 | private JTabbedPane repoArea = new JTabbedPane();
|
---|
34 | private CloseTabbedPane editArea = new CloseTabbedPane();
|
---|
35 |
|
---|
36 | public MainPanel() {
|
---|
37 | setLayout(new BorderLayout());
|
---|
38 | setMinimumSize(new Dimension(1280, 1024));
|
---|
39 | String version = getClass().getPackage().getImplementationVersion();
|
---|
40 | if (version != null) // if the version is defined in the MANIFEST file, e.g. Genius is in a .jar
|
---|
41 | setTitle("GENIUS " + version);
|
---|
42 | else
|
---|
43 | setTitle("GENIUS");
|
---|
44 | JSplitPane splitpane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
|
---|
45 | repoArea, editArea);
|
---|
46 | splitpane.setDividerLocation(300);
|
---|
47 |
|
---|
48 | add(splitpane, BorderLayout.CENTER);
|
---|
49 | repoArea.addTab("Domains",
|
---|
50 | new JScrollPane(new DomainRepositoryUI(this)));
|
---|
51 | repoArea.addTab("BOA Components",
|
---|
52 | new JScrollPane(new BOARepositoryUI(this)));
|
---|
53 | repoArea.addTab("Parties", new PartyRepositoryUI());
|
---|
54 | repoArea.addTab("Boa Parties", new BoaPartiesPanel());
|
---|
55 |
|
---|
56 | setJMenuBar(new MenuBar(this));
|
---|
57 |
|
---|
58 | editArea.addCloseListener((MouseEvent e, int overTabIndex) -> editArea
|
---|
59 | .remove(overTabIndex));
|
---|
60 | setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
---|
61 | }
|
---|
62 |
|
---|
63 | /**
|
---|
64 | * For testing
|
---|
65 | */
|
---|
66 | public static void main(String[] args) {
|
---|
67 | MainPanel mainpanel = new MainPanel();
|
---|
68 |
|
---|
69 | mainpanel.pack();
|
---|
70 | mainpanel.setVisible(true);
|
---|
71 |
|
---|
72 | }
|
---|
73 |
|
---|
74 | @Override
|
---|
75 | public void addTab(String title, Component comp) {
|
---|
76 | editArea.addTab(title, comp);
|
---|
77 | editArea.setSelectedComponent(comp);
|
---|
78 | }
|
---|
79 |
|
---|
80 | @Override
|
---|
81 | public Frame getMainFrame() {
|
---|
82 | return this;
|
---|
83 | }
|
---|
84 | }
|
---|
85 |
|
---|
86 | @SuppressWarnings("serial")
|
---|
87 | class MenuBar extends JMenuBar {
|
---|
88 | private JMenu startMenu = new JMenu();
|
---|
89 | private JMenu helpMenu = new JMenu();
|
---|
90 |
|
---|
91 | public MenuBar(GeniusAppInterface mainPanel) {
|
---|
92 | startMenu.setText("Start");
|
---|
93 | startMenu.add(new Session(mainPanel));
|
---|
94 | startMenu.add(new Tournament(mainPanel));
|
---|
95 |
|
---|
96 | add(startMenu);
|
---|
97 |
|
---|
98 | helpMenu.setText("Help");
|
---|
99 | helpMenu.add(new OpenManual());
|
---|
100 | helpMenu.add(new AboutAction());
|
---|
101 | add(helpMenu);
|
---|
102 | }
|
---|
103 | } |
---|