[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));
|
---|
[11] | 39 | setTitle(
|
---|
| 40 | "GENIUS " + getClass().getPackage().getImplementationVersion());
|
---|
| 41 | JSplitPane splitpane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
|
---|
| 42 | repoArea, editArea);
|
---|
[19] | 43 | splitpane.setDividerLocation(300);
|
---|
| 44 |
|
---|
[15] | 45 | add(splitpane, BorderLayout.CENTER);
|
---|
[11] | 46 | repoArea.addTab("Domains",
|
---|
| 47 | new JScrollPane(new DomainRepositoryUI(this)));
|
---|
[14] | 48 | repoArea.addTab("BOA Components",
|
---|
[18] | 49 | new JScrollPane(new BOARepositoryUI(this)));
|
---|
[17] | 50 | repoArea.addTab("Parties", new PartyRepositoryUI());
|
---|
| 51 | repoArea.addTab("Boa Parties", new BoaPartiesPanel());
|
---|
[1] | 52 |
|
---|
[16] | 53 | setJMenuBar(new MenuBar(this));
|
---|
[1] | 54 |
|
---|
[20] | 55 | editArea.addCloseListener((MouseEvent e, int overTabIndex) -> editArea
|
---|
| 56 | .remove(overTabIndex));
|
---|
[21] | 57 | setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
---|
[1] | 58 | }
|
---|
| 59 |
|
---|
[21] | 60 | /**
|
---|
| 61 | * For testing
|
---|
| 62 | */
|
---|
[1] | 63 | public static void main(String[] args) {
|
---|
| 64 | MainPanel mainpanel = new MainPanel();
|
---|
[11] | 65 |
|
---|
[1] | 66 | mainpanel.pack();
|
---|
[15] | 67 | mainpanel.setVisible(true);
|
---|
[11] | 68 |
|
---|
[1] | 69 | }
|
---|
[11] | 70 |
|
---|
| 71 | @Override
|
---|
| 72 | public void addTab(String title, Component comp) {
|
---|
| 73 | editArea.addTab(title, comp);
|
---|
[20] | 74 | editArea.setSelectedComponent(comp);
|
---|
[11] | 75 | }
|
---|
| 76 |
|
---|
| 77 | @Override
|
---|
| 78 | public Frame getMainFrame() {
|
---|
| 79 | return this;
|
---|
| 80 | }
|
---|
[1] | 81 | }
|
---|
| 82 |
|
---|
[16] | 83 | @SuppressWarnings("serial")
|
---|
[1] | 84 | class MenuBar extends JMenuBar {
|
---|
| 85 | private JMenu startMenu = new JMenu();
|
---|
| 86 | private JMenu helpMenu = new JMenu();
|
---|
| 87 |
|
---|
[16] | 88 | public MenuBar(GeniusAppInterface mainPanel) {
|
---|
[1] | 89 | startMenu.setText("Start");
|
---|
[16] | 90 | startMenu.add(new Session(mainPanel));
|
---|
| 91 | startMenu.add(new Tournament(mainPanel));
|
---|
| 92 |
|
---|
[1] | 93 | add(startMenu);
|
---|
| 94 |
|
---|
| 95 | helpMenu.setText("Help");
|
---|
| 96 | helpMenu.add(new OpenManual());
|
---|
| 97 | helpMenu.add(new AboutAction());
|
---|
| 98 | add(helpMenu);
|
---|
| 99 | }
|
---|
| 100 | } |
---|