1 | package de.ugoe.cs.eventbench.swt;
|
---|
2 |
|
---|
3 | import org.eclipse.swt.widgets.Display;
|
---|
4 | import org.eclipse.swt.widgets.Shell;
|
---|
5 | import org.eclipse.swt.widgets.Menu;
|
---|
6 | import org.eclipse.swt.SWT;
|
---|
7 | import org.eclipse.swt.widgets.MenuItem;
|
---|
8 | import org.eclipse.swt.widgets.Text;
|
---|
9 | import org.eclipse.swt.widgets.TabFolder;
|
---|
10 | import org.eclipse.swt.widgets.TabItem;
|
---|
11 | import org.eclipse.swt.layout.GridLayout;
|
---|
12 | import org.eclipse.swt.layout.GridData;
|
---|
13 | import org.eclipse.swt.events.SelectionAdapter;
|
---|
14 | import org.eclipse.swt.events.SelectionEvent;
|
---|
15 |
|
---|
16 | public class MainWindow {
|
---|
17 |
|
---|
18 | protected Shell shell;
|
---|
19 |
|
---|
20 | protected TabItem consoleTab;
|
---|
21 | protected TabItem sequencesTab;
|
---|
22 | protected TabItem modelsTab;
|
---|
23 | protected TabItem dataTab;
|
---|
24 | protected ConsoleTabComposite consoleTabComposite;
|
---|
25 | protected SequencesTabComposite sequencesTabComposite;
|
---|
26 | protected ModelsTabComposite modelsTabComposite;
|
---|
27 | protected DataTabComposite dataTabComposite;
|
---|
28 |
|
---|
29 |
|
---|
30 | /**
|
---|
31 | * Open the window.
|
---|
32 | * @wbp.parser.entryPoint
|
---|
33 | */
|
---|
34 | public void open() {
|
---|
35 | Display display = Display.getDefault();
|
---|
36 | createContents();
|
---|
37 | new SWTConsole(getTextConsoleOutput());
|
---|
38 | shell.open();
|
---|
39 | shell.layout();
|
---|
40 | while (!shell.isDisposed()) {
|
---|
41 | if (!display.readAndDispatch()) {
|
---|
42 | display.sleep();
|
---|
43 | }
|
---|
44 | }
|
---|
45 | }
|
---|
46 |
|
---|
47 | /**
|
---|
48 | * Create contents of the window.
|
---|
49 | */
|
---|
50 | protected void createContents() {
|
---|
51 | shell = new Shell();
|
---|
52 | shell.setSize(500, 300);
|
---|
53 | shell.setText("SWT Application");
|
---|
54 | shell.setLayout(new GridLayout(1, false));
|
---|
55 |
|
---|
56 | Menu menu = new Menu(shell, SWT.BAR);
|
---|
57 | shell.setMenuBar(menu);
|
---|
58 |
|
---|
59 | MenuItem mntmFile = new MenuItem(menu, SWT.CASCADE);
|
---|
60 | mntmFile.setText("File");
|
---|
61 |
|
---|
62 | Menu menu_1 = new Menu(mntmFile);
|
---|
63 | mntmFile.setMenu(menu_1);
|
---|
64 |
|
---|
65 | MenuItem mntmShowHistory = new MenuItem(menu_1, SWT.NONE);
|
---|
66 | mntmShowHistory.setText("Show History");
|
---|
67 |
|
---|
68 | MenuItem mntmExecBatchFile = new MenuItem(menu_1, SWT.NONE);
|
---|
69 | mntmExecBatchFile.setText("Exec. Batch File");
|
---|
70 |
|
---|
71 | new MenuItem(menu_1, SWT.SEPARATOR);
|
---|
72 |
|
---|
73 | MenuItem mntmLoad = new MenuItem(menu_1, SWT.NONE);
|
---|
74 | mntmLoad.setText("Load...");
|
---|
75 |
|
---|
76 | MenuItem mntmSave = new MenuItem(menu_1, SWT.NONE);
|
---|
77 | mntmSave.setText("Save...");
|
---|
78 |
|
---|
79 | new MenuItem(menu_1, SWT.SEPARATOR);
|
---|
80 |
|
---|
81 | MenuItem mntmExit = new MenuItem(menu_1, SWT.NONE);
|
---|
82 | mntmExit.setText("Exit");
|
---|
83 |
|
---|
84 | MenuItem mntmHelp = new MenuItem(menu, SWT.CASCADE);
|
---|
85 | mntmHelp.setText("Help");
|
---|
86 |
|
---|
87 | Menu menu_2 = new Menu(mntmHelp);
|
---|
88 | mntmHelp.setMenu(menu_2);
|
---|
89 |
|
---|
90 | MenuItem mntmAbout = new MenuItem(menu_2, SWT.NONE);
|
---|
91 | mntmAbout.setText("About");
|
---|
92 |
|
---|
93 | TabFolder tabFolder = new TabFolder(shell, SWT.NONE);
|
---|
94 | tabFolder.addSelectionListener(new SelectionAdapter() {
|
---|
95 | @Override
|
---|
96 | public void widgetSelected(SelectionEvent e) {
|
---|
97 | if( e.item == sequencesTab ) {
|
---|
98 | sequencesTabComposite.updateSequenceList();
|
---|
99 | }
|
---|
100 | else if(e.item == modelsTab ) {
|
---|
101 | modelsTabComposite.updateModelList();
|
---|
102 | }
|
---|
103 | else if(e.item == dataTab) {
|
---|
104 | dataTabComposite.updateDataList();
|
---|
105 | }
|
---|
106 | }
|
---|
107 | });
|
---|
108 | tabFolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
|
---|
109 |
|
---|
110 | consoleTab = new TabItem(tabFolder, SWT.NONE);
|
---|
111 | consoleTab.setText("Console");
|
---|
112 |
|
---|
113 | consoleTabComposite = new ConsoleTabComposite(tabFolder, SWT.NO_BACKGROUND);
|
---|
114 | consoleTab.setControl(consoleTabComposite);
|
---|
115 |
|
---|
116 | sequencesTab = new TabItem(tabFolder, SWT.NONE);
|
---|
117 | sequencesTab.setText("Sequences");
|
---|
118 |
|
---|
119 | sequencesTabComposite = new SequencesTabComposite(tabFolder, SWT.NO_BACKGROUND);
|
---|
120 | sequencesTab.setControl(sequencesTabComposite);
|
---|
121 |
|
---|
122 | modelsTab = new TabItem(tabFolder, SWT.NONE);
|
---|
123 | modelsTab.setText("Models");
|
---|
124 |
|
---|
125 | modelsTabComposite = new ModelsTabComposite(tabFolder, SWT.NO_BACKGROUND);
|
---|
126 | modelsTab.setControl(modelsTabComposite);
|
---|
127 |
|
---|
128 | dataTab = new TabItem(tabFolder, SWT.NONE);
|
---|
129 | dataTab.setText("Data");
|
---|
130 |
|
---|
131 | dataTabComposite = new DataTabComposite(tabFolder, SWT.NO_BACKGROUND);
|
---|
132 | dataTab.setControl(dataTabComposite);
|
---|
133 |
|
---|
134 | }
|
---|
135 | public Text getTextConsoleOutput() {
|
---|
136 | return consoleTabComposite.textConsoleOutput;
|
---|
137 | }
|
---|
138 | }
|
---|