Changeset 194 for trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/swt/GenerateSequencesDialog.java
- Timestamp:
- 09/24/11 04:17:48 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/swt/GenerateSequencesDialog.java
r188 r194 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.Group; … … 14 15 import org.eclipse.swt.layout.GridData; 15 16 17 import de.ugoe.cs.util.console.CommandExecuter; 18 19 import org.eclipse.swt.events.SelectionAdapter; 20 import org.eclipse.swt.events.SelectionEvent; 21 16 22 public class GenerateSequencesDialog extends Dialog { 17 23 24 private String processName; 25 26 protected Button btnNumberAll; 27 protected Button btnLengthAll; 28 protected Spinner numberSpinner; 29 protected Spinner iterationsSpinner; 30 protected Spinner minLengthSpinner; 31 protected Spinner maxLengthSpinner; 32 18 33 protected Object result; 19 34 protected Shell shlGenerateSequences; 20 private Text text;35 private Text sequencesNameText; 21 36 private final FormToolkit formToolkit = new FormToolkit(Display.getDefault()); 22 37 … … 53 68 private void createContents() { 54 69 shlGenerateSequences = new Shell(getParent(), SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL); 55 shlGenerateSequences.setSize(201, 248);70 shlGenerateSequences.setSize(201, 303); 56 71 shlGenerateSequences.setText("Generate Sequences"); 57 72 shlGenerateSequences.setLayout(new GridLayout(2, false)); … … 62 77 group.setLayout(new GridLayout(1, false)); 63 78 64 text = new Text(group, SWT.BORDER);65 text.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));79 sequencesNameText = new Text(group, SWT.BORDER); 80 sequencesNameText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); 66 81 67 82 Group grpNumber = new Group(shlGenerateSequences, SWT.NONE); … … 70 85 grpNumber.setLayout(new GridLayout(2, false)); 71 86 72 Spinner spinner = new Spinner(grpNumber, SWT.BORDER); 73 spinner.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); 74 75 Button btnAll = new Button(grpNumber, SWT.CHECK); 76 btnAll.setText("All"); 87 numberSpinner = new Spinner(grpNumber, SWT.BORDER); 88 numberSpinner.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); 89 numberSpinner.setMinimum(1); 90 numberSpinner.setMaximum(Integer.MAX_VALUE); 91 92 btnNumberAll = new Button(grpNumber, SWT.CHECK); 93 btnNumberAll.addSelectionListener(new SelectionAdapter() { 94 @Override 95 public void widgetSelected(SelectionEvent e) { 96 numberSpinner.setEnabled(!btnNumberAll.getSelection()); 97 btnLengthAll.setEnabled(!btnNumberAll.getSelection()); 98 iterationsSpinner.setEnabled(!btnNumberAll.getSelection()); 99 } 100 }); 101 btnNumberAll.setText("All"); 102 103 Group grpIterations = new Group(shlGenerateSequences, SWT.NONE); 104 grpIterations.setLayout(new GridLayout(1, false)); 105 grpIterations.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1)); 106 grpIterations.setText("Iterations");; 107 108 iterationsSpinner = new Spinner(grpIterations, SWT.BORDER); 109 iterationsSpinner.setMinimum(1); 110 iterationsSpinner.setMaximum(Integer.MAX_VALUE); 111 iterationsSpinner.setSelection(100000); 112 iterationsSpinner.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); 77 113 78 114 Group grpLength = new Group(shlGenerateSequences, SWT.NONE); … … 81 117 grpLength.setLayout(new GridLayout(4, false)); 82 118 83 Button btnAll_1 = new Button(grpLength, SWT.CHECK); 84 btnAll_1.setText("All"); 119 btnLengthAll = new Button(grpLength, SWT.CHECK); 120 btnLengthAll.addSelectionListener(new SelectionAdapter() { 121 @Override 122 public void widgetSelected(SelectionEvent e) { 123 minLengthSpinner.setEnabled(!btnLengthAll.getSelection()); 124 maxLengthSpinner.setEnabled(!btnLengthAll.getSelection()); 125 } 126 }); 127 btnLengthAll.setText("All"); 85 128 new Label(grpLength, SWT.NONE); 86 129 new Label(grpLength, SWT.NONE); … … 91 134 label.setText("Min."); 92 135 93 Spinner spinner_2 = new Spinner(grpLength, SWT.BORDER); 94 spinner_2.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); 136 minLengthSpinner = new Spinner(grpLength, SWT.BORDER); 137 minLengthSpinner.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); 138 minLengthSpinner.setMinimum(1); 95 139 96 140 Label label_1 = new Label(grpLength, SWT.NONE); … … 98 142 label_1.setText("Max."); 99 143 100 Spinner spinner_1 = new Spinner(grpLength, SWT.BORDER); 101 spinner_1.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); 102 spinner_1.setToolTipText("0 means no limitations"); 144 maxLengthSpinner = new Spinner(grpLength, SWT.BORDER); 145 maxLengthSpinner.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); 146 maxLengthSpinner.setToolTipText("0 means no limitations"); 147 maxLengthSpinner.setMinimum(1); 103 148 104 149 Button btnGenerate = formToolkit.createButton(shlGenerateSequences, "Generate!", SWT.NONE); 150 btnGenerate.addSelectionListener(new SelectionAdapter() { 151 @Override 152 public void widgetSelected(SelectionEvent e) { 153 if("".equals(sequencesNameText.getText())) { 154 MessageBox messageBox = new MessageBox(shlGenerateSequences, SWT.ERROR); 155 messageBox.setText("Error"); 156 messageBox.setMessage("Sequences name not defined!"); 157 messageBox.open(); 158 return; 159 } 160 String sequencesName = sequencesNameText.getText(); 161 int number = numberSpinner.getSelection(); 162 int minLength = minLengthSpinner.getSelection(); 163 int maxLength = maxLengthSpinner.getSelection(); 164 int maxIter = iterationsSpinner.getSelection(); 165 if( maxIter<=number ) { 166 maxIter = number; 167 } 168 String command = ""; 169 if( btnNumberAll.getSelection() ) { 170 if( minLength>maxLength ) { 171 MessageBox messageBox = new MessageBox(shlGenerateSequences, SWT.ERROR); 172 messageBox.setText("Error"); 173 messageBox.setMessage("Min. length must be smaller than or equal to max. length!"); 174 messageBox.open(); 175 return; 176 } 177 command = "generateFixedLengthSequences " + processName + " " + sequencesName + " " + minLength + " " + maxLength + " true"; 178 } else { 179 command = "generateRandomSequences " + processName + " " + sequencesName + " " + number + " " + maxIter; 180 if( !btnLengthAll.getSelection() ) { 181 if( minLength>maxLength ) { 182 MessageBox messageBox = new MessageBox(shlGenerateSequences, SWT.ERROR); 183 messageBox.setText("Error"); 184 messageBox.setMessage("Min. length must be smaller than or equal to max. length!"); 185 messageBox.open(); 186 return; 187 } 188 command += " " + minLength + " " + maxLength; 189 } 190 } 191 CommandExecuter.getInstance().exec(command); 192 shlGenerateSequences.dispose(); 193 } 194 }); 105 195 106 196 Button btnAbort = formToolkit.createButton(shlGenerateSequences, "Abort", SWT.NONE); 107 197 btnAbort.addSelectionListener(new SelectionAdapter() { 198 @Override 199 public void widgetSelected(SelectionEvent e) { 200 shlGenerateSequences.dispose(); 201 } 202 }); 203 204 } 205 206 public void setProcessName(String name) { 207 this.processName = name; 108 208 } 109 209 }
Note: See TracChangeset
for help on using the changeset viewer.