- Timestamp:
- 09/24/11 02:44:33 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/swt/MainWindow.java
r188 r192 1 1 package de.ugoe.cs.eventbench.swt; 2 3 import java.util.Collection;4 2 5 3 import org.eclipse.swt.widgets.Display; … … 9 7 import org.eclipse.swt.widgets.MenuItem; 10 8 import org.eclipse.swt.widgets.Text; 11 import org.eclipse.swt.widgets.Label;12 9 import org.eclipse.swt.widgets.TabFolder; 13 10 import org.eclipse.swt.widgets.TabItem; 14 import org.eclipse.swt.widgets.Composite;15 import org.eclipse.swt.widgets.Button;16 import org.eclipse.swt.widgets.List;17 11 import org.eclipse.swt.layout.GridLayout; 18 12 import org.eclipse.swt.layout.GridData; … … 20 14 import org.eclipse.swt.events.SelectionEvent; 21 15 22 import de.ugoe.cs.eventbench.data.Event;23 import de.ugoe.cs.eventbench.data.GlobalDataContainer;24 import de.ugoe.cs.util.console.CommandExecuter;25 import de.ugoe.cs.util.console.TextConsole;26 import org.eclipse.swt.events.KeyAdapter;27 import org.eclipse.swt.events.KeyEvent;28 29 16 public class MainWindow { 30 17 31 18 protected Shell shell; 32 private Text textCommand; 33 private Text textConsoleOutput; 34 private List list; 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; 35 28 36 /**37 * Launch the application.38 * @param args39 */40 public static void main(String[] args) {41 // TODO this main method needs to be removed/remodeled when merging with other project42 try {43 CommandExecuter.getInstance().addCommandPackage(44 "de.ugoe.cs.eventbench.commands");45 CommandExecuter.getInstance().addCommandPackage(46 "de.ugoe.cs.eventbench.windows.commands");47 CommandExecuter.getInstance().addCommandPackage(48 "de.ugoe.cs.eventbench.web.commands");49 new TextConsole();50 51 MainWindow window = new MainWindow();52 window.open();53 } catch (Exception e) {54 e.printStackTrace();55 }56 }57 29 58 30 /** 59 31 * Open the window. 32 * @wbp.parser.entryPoint 60 33 */ 61 34 public void open() { 62 35 Display display = Display.getDefault(); 63 36 createContents(); 64 new SWTConsole( textConsoleOutput);37 new SWTConsole(getTextConsoleOutput()); 65 38 shell.open(); 66 39 shell.layout(); … … 119 92 120 93 TabFolder tabFolder = new TabFolder(shell, SWT.NONE); 121 tabFolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); 122 123 TabItem tbtmConsoleMode = new TabItem(tabFolder, SWT.NONE); 124 tbtmConsoleMode.setText("Console"); 125 126 Composite composite = new Composite(tabFolder, SWT.NO_BACKGROUND); 127 tbtmConsoleMode.setControl(composite); 128 composite.setLayout(new GridLayout(3, false)); 129 130 Label lblCommand = new Label(composite, SWT.NONE); 131 lblCommand.setText("Command:"); 132 133 textCommand = new Text(composite, SWT.BORDER); 134 textCommand.addKeyListener(new KeyAdapter() { 94 tabFolder.addSelectionListener(new SelectionAdapter() { 135 95 @Override 136 public void keyReleased(KeyEvent e) { 137 if( e.keyCode==SWT.CR ) { 138 String command = textCommand.getText().trim(); 139 CommandExecuter.getInstance().exec(command); 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(); 140 105 } 141 106 } 142 107 }); 143 GridData gd_textCommand = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1); 144 gd_textCommand.widthHint = 304; 145 textCommand.setLayoutData(gd_textCommand); 108 tabFolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); 146 109 147 Button btnEnter = new Button(composite, SWT.NONE); 148 btnEnter.addSelectionListener(new SelectionAdapter() { 149 @Override 150 public void widgetSelected(SelectionEvent e) { 151 // Event handler for executing commands 152 String command = textCommand.getText().trim(); 153 CommandExecuter.getInstance().exec(command); 154 } 155 }); 156 btnEnter.setText("Enter"); 110 consoleTab = new TabItem(tabFolder, SWT.NONE); 111 consoleTab.setText("Console"); 157 112 158 textConsoleOutput = new Text(composite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.CANCEL); 159 GridData gd_textConsoleOutput = new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1); 160 gd_textConsoleOutput.heightHint = 102; 161 gd_textConsoleOutput.widthHint = 456; 162 textConsoleOutput.setLayoutData(gd_textConsoleOutput); 113 consoleTabComposite = new ConsoleTabComposite(tabFolder, SWT.NO_BACKGROUND); 114 consoleTab.setControl(consoleTabComposite); 163 115 164 TabItem tbtmSequences= new TabItem(tabFolder, SWT.NONE);165 tbtmSequences.setText("Sequences");116 sequencesTab = new TabItem(tabFolder, SWT.NONE); 117 sequencesTab.setText("Sequences"); 166 118 167 Composite composite_2 = new Composite(tabFolder, SWT.NO_BACKGROUND); 168 tbtmSequences.setControl(composite_2); 169 composite_2.setLayout(new GridLayout(5, false)); 119 sequencesTabComposite = new SequencesTabComposite(tabFolder, SWT.NO_BACKGROUND); 120 sequencesTab.setControl(sequencesTabComposite); 170 121 171 list = new List(composite_2, SWT.BORDER | SWT.V_SCROLL | SWT.MULTI); 172 list.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 5, 1)); 173 list.setItems(new String[] {}); 174 for( String sequencesName : GlobalDataContainer.getInstance().getAllSequencesNames() ) { 175 list.add(sequencesName); 176 } 122 modelsTab = new TabItem(tabFolder, SWT.NONE); 123 modelsTab.setText("Models"); 177 124 178 Button btnEdit = new Button(composite_2, SWT.NONE); 179 btnEdit.addSelectionListener(new SelectionAdapter() { 180 @Override 181 public void widgetSelected(SelectionEvent e) { 182 // TODO edit sequences event handler 183 } 184 }); 185 btnEdit.setText("Edit"); 125 modelsTabComposite = new ModelsTabComposite(tabFolder, SWT.NO_BACKGROUND); 126 modelsTab.setControl(modelsTabComposite); 127 128 dataTab = new TabItem(tabFolder, SWT.NONE); 129 dataTab.setText("Data"); 186 130 187 Button btnDelete = new Button(composite_2, SWT.NONE); 188 btnDelete.addSelectionListener(new SelectionAdapter() { 189 @Override 190 public void widgetSelected(SelectionEvent e) { 191 String[] selectedSequences = list.getSelection(); 192 for( String selected : selectedSequences) { 193 GlobalDataContainer.getInstance().removeData(selected); 194 } 195 } 196 }); 197 btnDelete.setText("Delete"); 131 dataTabComposite = new DataTabComposite(tabFolder, SWT.NO_BACKGROUND); 132 dataTab.setControl(dataTabComposite); 198 133 199 Button btnReplay = new Button(composite_2, SWT.NONE);200 btnReplay.setText("Replay");201 202 Button btnTrainModel = new Button(composite_2, SWT.NONE);203 btnTrainModel.setText("Train Model");204 205 Button btnParse = new Button(composite_2, SWT.NONE);206 btnParse.setText("Parse");207 208 TabItem tbtmModels = new TabItem(tabFolder, SWT.NONE);209 tbtmModels.setText("Models");210 211 Composite composite_1 = new Composite(tabFolder, SWT.NO_BACKGROUND);212 tbtmModels.setControl(composite_1);213 composite_1.setLayout(new GridLayout(5, false));214 215 List list_1 = new List(composite_1, SWT.BORDER | SWT.V_SCROLL | SWT.MULTI);216 list_1.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 5, 1));217 218 Button btnShow = new Button(composite_1, SWT.NONE);219 btnShow.setText("Visualize");220 221 Button btnDelete_1 = new Button(composite_1, SWT.NONE);222 btnDelete_1.setText("Delete");223 224 Button btnGenSequences = new Button(composite_1, SWT.NONE);225 btnGenSequences.setText("Gen. Sequences");226 227 Button btnProperties = new Button(composite_1, SWT.NONE);228 btnProperties.setText("Properties");229 230 Button btnCreateDot = new Button(composite_1, SWT.NONE);231 btnCreateDot.setText("Create DOT");232 233 TabItem tbtmData = new TabItem(tabFolder, SWT.NONE);234 tbtmData.setText("Data");235 236 Composite composite_3 = new Composite(tabFolder, SWT.NO_BACKGROUND);237 tbtmData.setControl(composite_3);238 composite_3.setLayout(new GridLayout(3, false));239 240 List list_2 = new List(composite_3, SWT.BORDER | SWT.V_SCROLL);241 list_2.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1));242 243 Button btnLoad = new Button(composite_3, SWT.NONE);244 btnLoad.setText("Load");245 246 Button btnSave = new Button(composite_3, SWT.NONE);247 btnSave.setText("Save");248 249 Button btnDelete_2 = new Button(composite_3, SWT.NONE);250 btnDelete_2.setText("Delete");251 252 134 } 253 135 public Text getTextConsoleOutput() { 254 return textConsoleOutput;136 return consoleTabComposite.textConsoleOutput; 255 137 } 256 138 }
Note: See TracChangeset
for help on using the changeset viewer.