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