Changeset 192 for trunk/EventBenchConsole/src/de/ugoe/cs/eventbench
- Timestamp:
- 09/24/11 02:44:33 (13 years ago)
- Location:
- trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/swt
- Files:
-
- 6 added
- 3 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/swt/CommandHistoryDialog.java
r188 r192 11 11 import org.eclipse.swt.layout.GridData; 12 12 13 public class CommandHistory extends Dialog {13 public class CommandHistoryDialog extends Dialog { 14 14 15 15 protected Object result; … … 21 21 * @param style 22 22 */ 23 public CommandHistory (Shell parent, int style) {23 public CommandHistoryDialog(Shell parent, int style) { 24 24 super(parent, style); 25 25 setText("SWT Dialog"); -
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 } -
trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/swt/ModelPropertiesDialog.java
r188 r192 13 13 import org.eclipse.swt.layout.FillLayout; 14 14 15 public class ModelProperties extends Dialog {15 public class ModelPropertiesDialog extends Dialog { 16 16 17 17 protected Object result; … … 23 23 * @param style 24 24 */ 25 public ModelProperties (Shell parent, int style) {25 public ModelPropertiesDialog(Shell parent, int style) { 26 26 super(parent, style); 27 27 setText("SWT Dialog"); -
trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/swt/SWTConsole.java
r188 r192 3 3 import org.eclipse.swt.widgets.Text; 4 4 5 import de.ugoe.cs.util.StringTools; 5 6 import de.ugoe.cs.util.console.Console; 6 7 import de.ugoe.cs.util.console.ConsoleObserver; … … 38 39 @Override 39 40 public void commandNotification(String command) { 40 output.append("> " + command );41 output.append("> " + command + StringTools.ENDLINE); 41 42 } 42 43 } -
trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/swt/TrainModelDialog.java
r188 r192 3 3 import org.eclipse.swt.widgets.Dialog; 4 4 import org.eclipse.swt.widgets.Display; 5 import org.eclipse.swt.widgets.MessageBox; 5 6 import org.eclipse.swt.widgets.Shell; 6 7 import org.eclipse.swt.widgets.Button; … … 12 13 import org.eclipse.swt.layout.GridLayout; 13 14 import org.eclipse.swt.layout.GridData; 15 import org.eclipse.swt.events.SelectionAdapter; 16 import org.eclipse.swt.events.SelectionEvent; 17 18 import de.ugoe.cs.util.console.CommandExecuter; 19 import de.ugoe.cs.util.console.Console; 14 20 15 21 public class TrainModelDialog extends Dialog { … … 17 23 protected Object result; 18 24 protected Shell shlTrainUsageModel; 19 private Text text_1; 25 26 private Button btnFirstorderMarkovModel; 27 private Button btnHighorderMarkovModel; 28 private Button btnPredictionByPartial; 29 private Button btnDeterministicFiniteAutomaton; 30 31 private Spinner minOrderSpinner; 32 private Spinner maxOrderSpinner; 33 private Text modelnameText; 34 35 private String[] sequenceNames; 36 private Text probEscapeText; 37 private Label lblEscapeProbability; 20 38 21 39 /** … … 51 69 private void createContents() { 52 70 shlTrainUsageModel = new Shell(getParent(), SWT.DIALOG_TRIM | SWT.MIN | SWT.APPLICATION_MODAL); 53 shlTrainUsageModel.setSize(219, 279);71 shlTrainUsageModel.setSize(219, 330); 54 72 shlTrainUsageModel.setText("Train Usage Model"); 55 73 shlTrainUsageModel.setLayout(new GridLayout(2, false)); … … 60 78 grpGeneralInformation.setLayout(new GridLayout(1, false)); 61 79 62 text_1= new Text(grpGeneralInformation, SWT.BORDER);63 text_1.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));80 modelnameText = new Text(grpGeneralInformation, SWT.BORDER); 81 modelnameText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1)); 64 82 65 83 Group grpType = new Group(shlTrainUsageModel, SWT.NONE); 66 84 grpType.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 2, 1)); 67 85 grpType.setText("Type"); 68 grpType.setLayout(new GridLayout(1, false)); 69 70 Button btnFirstorderMarkovModel = new Button(grpType, SWT.RADIO); 71 btnFirstorderMarkovModel.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, false, false, 1, 1)); 86 grpType.setLayout(new GridLayout(2, false)); 87 88 btnFirstorderMarkovModel = new Button(grpType, SWT.RADIO); 89 btnFirstorderMarkovModel.addSelectionListener(new SelectionAdapter() { 90 @Override 91 public void widgetSelected(SelectionEvent e) { 92 minOrderSpinner.setEnabled(false); 93 maxOrderSpinner.setEnabled(false); 94 probEscapeText.setEnabled(false); 95 } 96 }); 97 btnFirstorderMarkovModel.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, false, false, 2, 1)); 72 98 btnFirstorderMarkovModel.setText("First-Order Markov Model"); 73 74 Button btnHighorderMarkovModel = new Button(grpType, SWT.RADIO); 75 btnHighorderMarkovModel.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, false, false, 1, 1)); 99 btnFirstorderMarkovModel.setSelection(true); 100 101 btnHighorderMarkovModel = new Button(grpType, SWT.RADIO); 102 btnHighorderMarkovModel.addSelectionListener(new SelectionAdapter() { 103 @Override 104 public void widgetSelected(SelectionEvent e) { 105 minOrderSpinner.setEnabled(false); 106 maxOrderSpinner.setEnabled(true); 107 probEscapeText.setEnabled(false); 108 } 109 }); 110 btnHighorderMarkovModel.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, false, false, 2, 1)); 76 111 btnHighorderMarkovModel.setText("High-Order Markov Model"); 77 112 78 Button btnPredictionByPartial = new Button(grpType, SWT.RADIO); 79 btnPredictionByPartial.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, false, false, 1, 1)); 113 btnPredictionByPartial = new Button(grpType, SWT.RADIO); 114 btnPredictionByPartial.addSelectionListener(new SelectionAdapter() { 115 @Override 116 public void widgetSelected(SelectionEvent e) { 117 minOrderSpinner.setEnabled(true); 118 maxOrderSpinner.setEnabled(true); 119 probEscapeText.setEnabled(true); 120 } 121 }); 122 btnPredictionByPartial.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, true, false, 2, 1)); 80 123 btnPredictionByPartial.setText("Prediction by Partial Match"); 81 124 82 Button btnDeterministicFiniteAutomaton = new Button(grpType, SWT.RADIO); 83 btnDeterministicFiniteAutomaton.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, false, false, 1, 1)); 125 lblEscapeProbability = new Label(grpType, SWT.NONE); 126 lblEscapeProbability.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, false, 1, 1)); 127 lblEscapeProbability.setText("Escape Probability:"); 128 129 probEscapeText = new Text(grpType, SWT.BORDER); 130 probEscapeText.setText("0.1"); 131 probEscapeText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); 132 probEscapeText.setEnabled(false); 133 134 btnDeterministicFiniteAutomaton = new Button(grpType, SWT.RADIO); 135 btnDeterministicFiniteAutomaton.addSelectionListener(new SelectionAdapter() { 136 @Override 137 public void widgetSelected(SelectionEvent e) { 138 minOrderSpinner.setEnabled(false); 139 maxOrderSpinner.setEnabled(false); 140 probEscapeText.setEnabled(false); 141 } 142 }); 143 btnDeterministicFiniteAutomaton.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, false, false, 2, 1)); 84 144 btnDeterministicFiniteAutomaton.setText("Deterministic Finite Automaton"); 85 145 … … 92 152 lblMin.setText("Min."); 93 153 94 Spinner spinner_1 = new Spinner(grpModelProperties, SWT.BORDER); 154 minOrderSpinner = new Spinner(grpModelProperties, SWT.BORDER); 155 minOrderSpinner.setEnabled(false); 95 156 96 157 Label lblMax = new Label(grpModelProperties, SWT.NONE); 97 158 lblMax.setText("Max."); 98 159 99 Spinner spinner = new Spinner(grpModelProperties, SWT.BORDER); 100 new Label(grpModelProperties, SWT.NONE); 101 new Label(grpModelProperties, SWT.NONE); 102 new Label(grpModelProperties, SWT.NONE); 103 new Label(grpModelProperties, SWT.NONE); 160 maxOrderSpinner = new Spinner(grpModelProperties, SWT.BORDER); 161 maxOrderSpinner.setEnabled(false); 162 maxOrderSpinner.setMinimum(2); 104 163 105 164 Button btnTrain = new Button(shlTrainUsageModel, SWT.NONE); 165 btnTrain.addSelectionListener(new SelectionAdapter() { 166 @Override 167 public void widgetSelected(SelectionEvent e) { 168 String command = ""; 169 String modelname = modelnameText.getText(); 170 if( modelname.equals("")) { 171 MessageBox messageBox = new MessageBox(shlTrainUsageModel, SWT.ERROR); 172 messageBox.setText("Error"); 173 messageBox.setMessage("No modelname defined!"); 174 return; 175 } 176 if( btnFirstorderMarkovModel.getSelection() ) { 177 command = "trainMarkovModel " + modelname + " " + sequenceNames[0]; 178 179 } 180 else if( btnHighorderMarkovModel.getSelection() ) { 181 int modelOrder = maxOrderSpinner.getSelection(); 182 command = "trainMarkovModel " + modelname + " " + sequenceNames[0] + " " + modelOrder; 183 } 184 else if( btnPredictionByPartial.getSelection() ) { 185 int minOrder = minOrderSpinner.getSelection(); 186 int maxOrder = maxOrderSpinner.getSelection(); 187 if( minOrder>maxOrder ) { 188 MessageBox messageBox = new MessageBox(shlTrainUsageModel, SWT.ERROR); 189 messageBox.setText("Error"); 190 messageBox.setMessage("Min. Order must be smaller than or equal to max. order!"); 191 return; 192 } 193 double probEscape = Double.parseDouble(probEscapeText.getText()); 194 if( probEscape<0.0 || probEscape>1.0) { 195 MessageBox messageBox = new MessageBox(shlTrainUsageModel, SWT.ERROR); 196 messageBox.setText("Error"); 197 messageBox.setMessage("Escape probability must be in [0,1]!"); 198 return; 199 } 200 command = "trainPPM " + modelname + " " + sequenceNames[0] + " " + probEscape + " " + maxOrder + " " + minOrder; 201 } 202 else if( btnDeterministicFiniteAutomaton.getSelection() ) { 203 command = "trainDFA " + modelname + " " + sequenceNames[0]; 204 } 205 CommandExecuter.getInstance().exec(command); 206 for( int i=1; i<sequenceNames.length; i++ ) { 207 command = "updateModel " + sequenceNames[i]; 208 CommandExecuter.getInstance().exec(command); 209 } 210 shlTrainUsageModel.dispose(); 211 } 212 }); 106 213 btnTrain.setText("Train!"); 107 214 108 215 Button btnAbort = new Button(shlTrainUsageModel, SWT.NONE); 216 btnAbort.addSelectionListener(new SelectionAdapter() { 217 @Override 218 public void widgetSelected(SelectionEvent e) { 219 shlTrainUsageModel.dispose(); 220 } 221 }); 109 222 btnAbort.setText("Abort"); 110 223 111 224 } 225 226 public void setSequenceNames(String[] sequenceNames) { 227 this.sequenceNames = sequenceNames; 228 } 112 229 }
Note: See TracChangeset
for help on using the changeset viewer.