| 1 | package de.uka.ipd.sdq.pcmsolver.runconfig; |
| 2 | |
| 3 | import java.util.ArrayList; |
| 4 | |
| 5 | import org.eclipse.core.resources.IContainer; |
| 6 | import org.eclipse.core.runtime.CoreException; |
| 7 | import org.eclipse.debug.core.ILaunchConfiguration; |
| 8 | import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; |
| 9 | import org.eclipse.emf.common.ui.dialogs.WorkspaceResourceDialog; |
| 10 | import org.eclipse.jface.viewers.ViewerFilter; |
| 11 | import org.eclipse.swt.SWT; |
| 12 | import org.eclipse.swt.custom.StackLayout; |
| 13 | import org.eclipse.swt.events.ModifyEvent; |
| 14 | import org.eclipse.swt.events.ModifyListener; |
| 15 | import org.eclipse.swt.events.SelectionAdapter; |
| 16 | import org.eclipse.swt.events.SelectionEvent; |
| 17 | import org.eclipse.swt.events.SelectionListener; |
| 18 | import org.eclipse.swt.layout.GridData; |
| 19 | import org.eclipse.swt.layout.GridLayout; |
| 20 | import org.eclipse.swt.widgets.Button; |
| 21 | import org.eclipse.swt.widgets.Combo; |
| 22 | import org.eclipse.swt.widgets.Composite; |
| 23 | import org.eclipse.swt.widgets.DirectoryDialog; |
| 24 | import org.eclipse.swt.widgets.Group; |
| 25 | import org.eclipse.swt.widgets.Label; |
| 26 | import org.eclipse.swt.widgets.Text; |
| 27 | |
| 28 | import de.uka.ipd.sdq.workflow.pcm.runconfig.FileNamesInputTab; |
| 29 | |
| 30 | public class MainConfigTab extends FileNamesInputTab { |
| 31 | |
| 32 | private Text textSamplingDist; |
| 33 | private Text textMaxDomain; |
| 34 | |
| 35 | private Text lqnsConfig1; |
| 36 | private Text lqnsConfig2; |
| 37 | private Text lqnsConfig3; |
| 38 | private Text lqnsConfig4; |
| 39 | private Button lqnsConfigStopOnMessageLoss; |
| 40 | private Button lqnsConfigInfTaskMult; |
| 41 | protected Combo comboLqnsOutput; |
| 42 | |
| 43 | private Text lqsimConfig1; |
| 44 | private Text lqsimConfig2; |
| 45 | private Text lqsimConfig3; |
| 46 | private Button lqsimConfigStopOnMessageLoss; |
| 47 | protected Combo comboLqsimOutput; |
| 48 | |
| 49 | private Text lqnsConfigPragma; |
| 50 | private Text lqnsimConfigPragma; |
| 51 | |
| 52 | private Group sresConfigGroup; |
| 53 | private Group lqnsConfigGroup; |
| 54 | private Group lqsimConfigGroup; |
| 55 | |
| 56 | private StackLayout stackLayout; |
| 57 | |
| 58 | protected Combo comboSolver; |
| 59 | private Text textLqnsOutputDir; |
| 60 | private Text textLqsimOutputDir; |
| 61 | private Text textSREOutputFile; |
| 62 | |
| 63 | private Button checkboxUseExpressionAsInput; |
| 64 | |
| 65 | // Create a listener for GUI modification events: |
| 66 | final ModifyListener listener = new ModifyListener() { |
| 67 | |
| 68 | public void modifyText(ModifyEvent e) { |
| 69 | MainConfigTab.this.setDirty(true); |
| 70 | MainConfigTab.this.updateLaunchConfigurationDialog(); |
| 71 | } |
| 72 | }; |
| 73 | |
| 74 | // private class MainConfigTabListener extends SelectionAdapter implements ModifyListener { |
| 75 | // public void modifyText(ModifyEvent e) { |
| 76 | // updateLaunchConfigurationDialog(); |
| 77 | // MainConfigTab.this.setDirty(true); |
| 78 | // } |
| 79 | // } |
| 80 | |
| 81 | private class ComboBoxListener extends SelectionAdapter implements SelectionListener{ |
| 82 | @Override |
| 83 | public void widgetSelected(SelectionEvent e) { |
| 84 | super.widgetSelected(e); |
| 85 | String selectedText = ((Combo)e.getSource()).getText(); |
| 86 | setVisibleConfigurationOptions(selectedText); |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | |
| 91 | //private MainConfigTabListener listener = new MainConfigTabListener(); |
| 92 | private ComboBoxListener comboListener = new ComboBoxListener(); |
| 93 | |
| 94 | |
| 95 | |
| 96 | |
| 97 | @Override |
| 98 | public void createControl(Composite parent) { |
| 99 | Composite container = new Composite(parent, SWT.NONE); |
| 100 | setControl(container); |
| 101 | container.setLayout(new GridLayout()); |
| 102 | |
| 103 | comboSolver = new Combo (container, SWT.READ_ONLY); |
| 104 | comboSolver.setItems (new String [] { |
| 105 | MessageStrings.SRE_SOLVER, |
| 106 | MessageStrings.LQNS_SOLVER, |
| 107 | MessageStrings.LQSIM_SOLVER |
| 108 | }); |
| 109 | comboSolver.setSize (400, 200); |
| 110 | comboSolver.addModifyListener(listener); |
| 111 | comboSolver.addSelectionListener(comboListener); |
| 112 | |
| 113 | Composite innerContainer = new Composite(container, SWT.NONE); |
| 114 | stackLayout = new StackLayout(); |
| 115 | innerContainer.setLayout(stackLayout); |
| 116 | innerContainer.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, true, 1, 1)); |
| 117 | |
| 118 | |
| 119 | sresConfigGroup = createSREWidgets(innerContainer); |
| 120 | lqnsConfigGroup = createLQNSWidgets(innerContainer); |
| 121 | lqsimConfigGroup = createLQSIMWidgets(innerContainer); |
| 122 | } |
| 123 | |
| 124 | |
| 125 | |
| 126 | private Group createLQSIMWidgets(Composite container) { |
| 127 | |
| 128 | final SelectionListener selectionListener = new SelectionListener() { |
| 129 | |
| 130 | public void widgetDefaultSelected(SelectionEvent e) { |
| 131 | MainConfigTab.this.setDirty(true); |
| 132 | MainConfigTab.this.updateLaunchConfigurationDialog(); |
| 133 | } |
| 134 | |
| 135 | public void widgetSelected(SelectionEvent e) { |
| 136 | MainConfigTab.this.setDirty(true); |
| 137 | MainConfigTab.this.updateLaunchConfigurationDialog(); |
| 138 | } |
| 139 | }; |
| 140 | |
| 141 | final GridLayout analysisGL = new GridLayout(); |
| 142 | analysisGL.numColumns = 4; |
| 143 | |
| 144 | final Group group = new Group(container, SWT.NONE); |
| 145 | group.setLayout(analysisGL); |
| 146 | group.setText("Configuration (see LQSim manual for details or use defaults)"); |
| 147 | group.setLayoutData(new GridData(500, SWT.DEFAULT)); |
| 148 | |
| 149 | GridData threeColumnGridData = new GridData(SWT.LEFT, SWT.CENTER, true, false); |
| 150 | threeColumnGridData.horizontalSpan = 3; |
| 151 | |
| 152 | Label label1 = new Label(group, SWT.NONE); |
| 153 | label1.setText("Run Time (optional):"); |
| 154 | label1.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false)); |
| 155 | |
| 156 | lqsimConfig1 = new Text(group, SWT.SINGLE | SWT.BORDER); |
| 157 | lqsimConfig1.setLayoutData(threeColumnGridData); |
| 158 | lqsimConfig1.addModifyListener(listener); |
| 159 | |
| 160 | Label label2 = new Label(group, SWT.NONE); |
| 161 | label2.setText("Blocks (optional):"); |
| 162 | label2.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false)); |
| 163 | |
| 164 | lqsimConfig2 = new Text(group, SWT.SINGLE | SWT.BORDER); |
| 165 | lqsimConfig2.setLayoutData(threeColumnGridData); |
| 166 | lqsimConfig2.addModifyListener(listener); |
| 167 | |
| 168 | Label label3 = new Label(group, SWT.NONE); |
| 169 | label3.setText("Processor Sharing Time Quantum:"); |
| 170 | label3.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false)); |
| 171 | |
| 172 | lqsimConfig3 = new Text(group, SWT.SINGLE | SWT.BORDER); |
| 173 | lqsimConfig3.setLayoutData(threeColumnGridData); |
| 174 | lqsimConfig3.addModifyListener(listener); |
| 175 | |
| 176 | Label labelStopOnMessageLoss = new Label(group, SWT.NONE); |
| 177 | labelStopOnMessageLoss.setText("\"Stop On Message Loss\" Pragma:"); |
| 178 | labelStopOnMessageLoss.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false)); |
| 179 | |
| 180 | lqsimConfigStopOnMessageLoss = new Button(group, SWT.CHECK); |
| 181 | lqsimConfigStopOnMessageLoss.setEnabled(true); |
| 182 | lqsimConfigStopOnMessageLoss.setText("Stop on message loss"); |
| 183 | lqsimConfigStopOnMessageLoss.addSelectionListener(selectionListener); |
| 184 | lqsimConfigStopOnMessageLoss.setSelection(true); |
| 185 | lqsimConfigStopOnMessageLoss.setLayoutData(threeColumnGridData); |
| 186 | |
| 187 | Label label4 = new Label(group, SWT.NONE); |
| 188 | label4.setText("Output Type:"); |
| 189 | label4.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false)); |
| 190 | |
| 191 | comboLqsimOutput = new Combo(group, SWT.READ_ONLY); |
| 192 | comboLqsimOutput.setItems (new String [] { |
| 193 | MessageStrings.LQN_OUTPUT_HTML, |
| 194 | MessageStrings.LQN_OUTPUT_HUMAN, |
| 195 | MessageStrings.LQN_OUTPUT_XML |
| 196 | }); |
| 197 | comboLqsimOutput.setSize (400, 200); |
| 198 | comboLqsimOutput.setLayoutData(threeColumnGridData); |
| 199 | comboLqsimOutput.addModifyListener(listener); |
| 200 | // comboLqsimOutput.addSelectionListener(comboListener); |
| 201 | |
| 202 | Label label5 = new Label(group, SWT.NONE); |
| 203 | label5.setText("Output Dir:"); |
| 204 | label5.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false)); |
| 205 | |
| 206 | textLqsimOutputDir = new Text(group, SWT.SINGLE | SWT.BORDER); |
| 207 | textLqsimOutputDir.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); |
| 208 | textLqsimOutputDir.addModifyListener(listener); |
| 209 | |
| 210 | createFolderSelectionButtons(group,textLqsimOutputDir); |
| 211 | |
| 212 | Label labelPragma = new Label(group, SWT.NONE); |
| 213 | labelPragma.setText("Additional Pragmas:"); |
| 214 | labelPragma.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false)); |
| 215 | |
| 216 | lqnsimConfigPragma = new Text(group, SWT.SINGLE | SWT.BORDER); |
| 217 | lqnsimConfigPragma.setLayoutData(threeColumnGridData); |
| 218 | lqnsimConfigPragma.addModifyListener(listener); |
| 219 | |
| 220 | return group; |
| 221 | } |
| 222 | |
| 223 | |
| 224 | |
| 225 | private Group createLQNSWidgets(Composite container) { |
| 226 | final SelectionListener selectionListener = new SelectionListener() { |
| 227 | |
| 228 | public void widgetDefaultSelected(SelectionEvent e) { |
| 229 | MainConfigTab.this.setDirty(true); |
| 230 | MainConfigTab.this.updateLaunchConfigurationDialog(); |
| 231 | } |
| 232 | |
| 233 | public void widgetSelected(SelectionEvent e) { |
| 234 | MainConfigTab.this.setDirty(true); |
| 235 | MainConfigTab.this.updateLaunchConfigurationDialog(); |
| 236 | } |
| 237 | }; |
| 238 | |
| 239 | final GridLayout analysisGL = new GridLayout(); |
| 240 | analysisGL.numColumns = 4; |
| 241 | |
| 242 | final Group group = new Group(container, SWT.NONE); |
| 243 | group.setLayout(analysisGL); |
| 244 | group.setText("Configuration (see LQNS manual for details or use defaults)"); |
| 245 | group.setLayoutData(new GridData(500, SWT.DEFAULT)); |
| 246 | |
| 247 | GridData threeColumnGridData = new GridData(SWT.LEFT, SWT.CENTER, true, false); |
| 248 | threeColumnGridData.horizontalSpan = 3; |
| 249 | |
| 250 | Label label1 = new Label(group, SWT.NONE); |
| 251 | label1.setText("Convergence Value:"); |
| 252 | label1.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false)); |
| 253 | |
| 254 | lqnsConfig1 = new Text(group, SWT.SINGLE | SWT.BORDER); |
| 255 | lqnsConfig1.setLayoutData(threeColumnGridData); |
| 256 | lqnsConfig1.addModifyListener(listener); |
| 257 | |
| 258 | Label label2 = new Label(group, SWT.NONE); |
| 259 | label2.setText("Iteration Limit:"); |
| 260 | label2.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false)); |
| 261 | |
| 262 | lqnsConfig2 = new Text(group, SWT.SINGLE | SWT.BORDER); |
| 263 | lqnsConfig2.setLayoutData(threeColumnGridData); |
| 264 | lqnsConfig2.addModifyListener(listener); |
| 265 | |
| 266 | Label label3 = new Label(group, SWT.NONE); |
| 267 | label3.setText("Print Interval Intermediate Results:"); |
| 268 | label3.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false)); |
| 269 | |
| 270 | lqnsConfig3 = new Text(group, SWT.SINGLE | SWT.BORDER); |
| 271 | lqnsConfig3.setLayoutData(threeColumnGridData); |
| 272 | lqnsConfig3.addModifyListener(listener); |
| 273 | |
| 274 | Label label4 = new Label(group, SWT.NONE); |
| 275 | label4.setText("Under-relaxation Coefficient:"); |
| 276 | label4.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false)); |
| 277 | |
| 278 | lqnsConfig4 = new Text(group, SWT.SINGLE | SWT.BORDER); |
| 279 | lqnsConfig4.setLayoutData(threeColumnGridData); |
| 280 | lqnsConfig4.addModifyListener(listener); |
| 281 | |
| 282 | Label labelStopOnMessageLoss = new Label(group, SWT.NONE); |
| 283 | labelStopOnMessageLoss.setText("\"Stop On Message Loss\" Pragma:"); |
| 284 | labelStopOnMessageLoss.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false)); |
| 285 | |
| 286 | lqnsConfigStopOnMessageLoss = new Button(group, SWT.CHECK); |
| 287 | lqnsConfigStopOnMessageLoss.setEnabled(true); |
| 288 | lqnsConfigStopOnMessageLoss.setText("Stop on message loss"); |
| 289 | lqnsConfigStopOnMessageLoss.addSelectionListener(selectionListener); |
| 290 | lqnsConfigStopOnMessageLoss.setSelection(true); |
| 291 | lqnsConfigStopOnMessageLoss.setLayoutData(threeColumnGridData); |
| 292 | |
| 293 | Label labelInfTaskMult = new Label(group, SWT.NONE); |
| 294 | labelInfTaskMult.setText("Infinite Task Multiplicity:"); |
| 295 | labelInfTaskMult.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false)); |
| 296 | |
| 297 | lqnsConfigInfTaskMult = new Button(group, SWT.CHECK); |
| 298 | lqnsConfigInfTaskMult.setEnabled(true); |
| 299 | lqnsConfigInfTaskMult.setText(""); |
| 300 | lqnsConfigInfTaskMult.addSelectionListener(selectionListener); |
| 301 | lqnsConfigInfTaskMult.setSelection(true); |
| 302 | lqnsConfigInfTaskMult.setLayoutData(threeColumnGridData); |
| 303 | |
| 304 | Label label5 = new Label(group, SWT.NONE); |
| 305 | label5.setText("Output Type:"); |
| 306 | label5.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false)); |
| 307 | |
| 308 | comboLqnsOutput = new Combo(group, SWT.READ_ONLY); |
| 309 | comboLqnsOutput.setItems (new String [] { |
| 310 | MessageStrings.LQN_OUTPUT_HTML, |
| 311 | MessageStrings.LQN_OUTPUT_HUMAN, |
| 312 | MessageStrings.LQN_OUTPUT_XML |
| 313 | }); |
| 314 | comboLqnsOutput.setSize (400, 200); |
| 315 | comboLqnsOutput.setLayoutData(threeColumnGridData); |
| 316 | comboLqnsOutput.addModifyListener(listener); |
| 317 | comboLqnsOutput.addSelectionListener(comboListener); |
| 318 | |
| 319 | Label label6 = new Label(group, SWT.NONE); |
| 320 | label6.setText("Output Dir:"); |
| 321 | label6.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false)); |
| 322 | |
| 323 | textLqnsOutputDir = new Text(group, SWT.SINGLE | SWT.BORDER); |
| 324 | textLqnsOutputDir.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); |
| 325 | textLqnsOutputDir.addModifyListener(listener); |
| 326 | |
| 327 | createFolderSelectionButtons(group,textLqnsOutputDir); |
| 328 | |
| 329 | Label labelPragma = new Label(group, SWT.NONE); |
| 330 | labelPragma.setText("Additional Pragmas:"); |
| 331 | labelPragma.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false)); |
| 332 | |
| 333 | lqnsConfigPragma = new Text(group, SWT.SINGLE | SWT.BORDER); |
| 334 | lqnsConfigPragma.setLayoutData(threeColumnGridData); |
| 335 | lqnsConfigPragma.addModifyListener(listener); |
| 336 | |
| 337 | return group; |
| 338 | } |
| 339 | |
| 340 | |
| 341 | |
| 342 | private void createFolderSelectionButtons(final Group group, Text text) { |
| 343 | final Button workspaceButton = new Button(group, SWT.NONE); |
| 344 | workspaceButton.setText("Workspace..."); |
| 345 | workspaceButton.addSelectionListener(new WorkspaceButtonSelectionListener(text)); |
| 346 | |
| 347 | final Button fileSystemButton = new Button(group, SWT.NONE); |
| 348 | fileSystemButton.setText("File System..."); |
| 349 | fileSystemButton.addSelectionListener(new FileSystemButtonSelectionAdapter(text)); |
| 350 | } |
| 351 | |
| 352 | |
| 353 | |
| 354 | private Group createSREWidgets(Composite container) { |
| 355 | |
| 356 | final SelectionListener selectionListener = new SelectionListener() { |
| 357 | |
| 358 | public void widgetDefaultSelected(SelectionEvent e) { |
| 359 | MainConfigTab.this.setDirty(true); |
| 360 | MainConfigTab.this.updateLaunchConfigurationDialog(); |
| 361 | } |
| 362 | |
| 363 | public void widgetSelected(SelectionEvent e) { |
| 364 | MainConfigTab.this.setDirty(true); |
| 365 | MainConfigTab.this.updateLaunchConfigurationDialog(); |
| 366 | } |
| 367 | }; |
| 368 | |
| 369 | final GridLayout analysisGL = new GridLayout(); |
| 370 | analysisGL.numColumns = 4; |
| 371 | |
| 372 | GridData threeColumnGridData = new GridData(SWT.LEFT, SWT.CENTER, true, false); |
| 373 | threeColumnGridData.horizontalSpan = 3; |
| 374 | |
| 375 | |
| 376 | final Group group = new Group(container, SWT.NONE); |
| 377 | group.setLayout(analysisGL); |
| 378 | group.setText("Configuration"); |
| 379 | group.setLayoutData(new GridData(500, SWT.DEFAULT)); |
| 380 | |
| 381 | Label samplingDist = new Label(group, SWT.NONE); |
| 382 | samplingDist.setText("Sampling Distance:"); |
| 383 | samplingDist.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false)); |
| 384 | |
| 385 | textSamplingDist = new Text(group, SWT.SINGLE | SWT.BORDER); |
| 386 | textSamplingDist.setLayoutData(threeColumnGridData); |
| 387 | textSamplingDist.addModifyListener(listener); |
| 388 | |
| 389 | Label maxDomain = new Label(group, SWT.NONE); |
| 390 | maxDomain.setText("Maximum Domain Size:"); |
| 391 | maxDomain.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false)); |
| 392 | |
| 393 | textMaxDomain = new Text(group, SWT.SINGLE | SWT.BORDER); |
| 394 | textMaxDomain.setLayoutData(threeColumnGridData); |
| 395 | textMaxDomain.addModifyListener(listener); |
| 396 | |
| 397 | Label useExpressionLabel = new Label(group, SWT.NONE); |
| 398 | useExpressionLabel.setText("Use of Expression Model File:"); |
| 399 | useExpressionLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false)); |
| 400 | |
| 401 | // Create the check box to choose whether Expression model should be read in |
| 402 | checkboxUseExpressionAsInput = new Button(group, SWT.CHECK); |
| 403 | checkboxUseExpressionAsInput.setEnabled(true); |
| 404 | checkboxUseExpressionAsInput.setText("Use expression file below as input. If not checked, file is used as output file."); |
| 405 | checkboxUseExpressionAsInput.addSelectionListener(selectionListener); |
| 406 | checkboxUseExpressionAsInput.setLayoutData(threeColumnGridData); |
| 407 | checkboxUseExpressionAsInput.setSelection(false); |
| 408 | |
| 409 | Label label6 = new Label(group, SWT.NONE); |
| 410 | label6.setText("Expression Model File:"); |
| 411 | label6.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false)); |
| 412 | |
| 413 | textSREOutputFile = new Text(group, SWT.SINGLE | SWT.BORDER); |
| 414 | textSREOutputFile.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); |
| 415 | textSREOutputFile.addModifyListener(listener); |
| 416 | |
| 417 | //createFolderSelectionButtons(group,textSREOutputFile); |
| 418 | //String[] filenameExtensions = {".expression", ".spa"}; |
| 419 | //this.createFileInputSection(group, modifyListener, "Expression Model File (use as input or output):", filenameExtensions, textSREOutputFile); |
| 420 | createFolderSelectionButtons(group,textSREOutputFile); |
| 421 | |
| 422 | return group; |
| 423 | |
| 424 | } |
| 425 | |
| 426 | @Override |
| 427 | public String getName() { |
| 428 | return "Solver"; |
| 429 | } |
| 430 | |
| 431 | @Override |
| 432 | public void initializeFrom(ILaunchConfiguration configuration) { |
| 433 | try{ |
| 434 | String solverStr = configuration.getAttribute(MessageStrings.SOLVER, |
| 435 | MessageStrings.SRE_SOLVER); |
| 436 | String[] items = comboSolver.getItems(); |
| 437 | for (int i=0; i<items.length; i++){ |
| 438 | String str = items[i]; |
| 439 | if (str.equals(solverStr)){ |
| 440 | comboSolver.select(i); |
| 441 | } |
| 442 | } |
| 443 | setVisibleConfigurationOptions(solverStr); |
| 444 | } catch(CoreException e){ |
| 445 | comboSolver.select(0); |
| 446 | } |
| 447 | try{ |
| 448 | String outputStr = configuration.getAttribute(MessageStrings.LQNS_OUTPUT, |
| 449 | MessageStrings.LQN_OUTPUT_HUMAN); |
| 450 | String[] items = comboLqnsOutput.getItems(); |
| 451 | for (int i=0; i<items.length; i++){ |
| 452 | String str = items[i]; |
| 453 | if (str.equals(outputStr)){ |
| 454 | comboLqnsOutput.select(i); |
| 455 | } |
| 456 | } |
| 457 | } catch(CoreException e){ |
| 458 | comboLqnsOutput.select(0); |
| 459 | } |
| 460 | try{ |
| 461 | String outputStr = configuration.getAttribute(MessageStrings.LQSIM_OUTPUT, |
| 462 | MessageStrings.LQN_OUTPUT_HUMAN); |
| 463 | String[] items = comboLqsimOutput.getItems(); |
| 464 | for (int i=0; i<items.length; i++){ |
| 465 | String str = items[i]; |
| 466 | if (str.equals(outputStr)){ |
| 467 | comboLqsimOutput.select(i); |
| 468 | } |
| 469 | } |
| 470 | } catch(CoreException e){ |
| 471 | comboLqsimOutput.select(0); |
| 472 | } |
| 473 | try{ |
| 474 | textSamplingDist.setText(configuration.getAttribute(MessageStrings.SAMPLING_DIST, "1.0")); |
| 475 | } catch(CoreException e){ |
| 476 | textSamplingDist.setText("1.0"); |
| 477 | } |
| 478 | try{ |
| 479 | textMaxDomain.setText(configuration.getAttribute(MessageStrings.MAX_DOMAIN, "256")); |
| 480 | } catch(CoreException e){ |
| 481 | textMaxDomain.setText("256"); |
| 482 | } |
| 483 | try{ |
| 484 | textSREOutputFile.setText(configuration.getAttribute(MessageStrings.SRE_OUTPUT_FILE, System.getProperty("user.dir"))); |
| 485 | } catch(CoreException e){ |
| 486 | textSREOutputFile.setText(System.getProperty("user.dir")); |
| 487 | } |
| 488 | |
| 489 | |
| 490 | try{ |
| 491 | lqnsConfig1.setText(configuration.getAttribute(MessageStrings.CONV_VALUE, "0.001")); |
| 492 | } catch(CoreException e){ |
| 493 | lqnsConfig1.setText("0.001"); |
| 494 | } |
| 495 | try{ |
| 496 | lqnsConfig2.setText(configuration.getAttribute(MessageStrings.IT_LIMIT, "50")); |
| 497 | } catch(CoreException e){ |
| 498 | lqnsConfig2.setText("50"); |
| 499 | } |
| 500 | try{ |
| 501 | lqnsConfig3.setText(configuration.getAttribute(MessageStrings.PRINT_INT, "10")); |
| 502 | } catch(CoreException e){ |
| 503 | lqnsConfig3.setText("10"); |
| 504 | } |
| 505 | try{ |
| 506 | lqnsConfig4.setText(configuration.getAttribute(MessageStrings.UNDER_COEFF, "0.5")); |
| 507 | } catch(CoreException e){ |
| 508 | lqnsConfig4.setText("0.5"); |
| 509 | } |
| 510 | |
| 511 | try{ |
| 512 | textLqnsOutputDir.setText(configuration.getAttribute(MessageStrings.LQNS_OUTPUT_DIR, System.getProperty("user.dir"))); |
| 513 | } catch(CoreException e){ |
| 514 | textLqnsOutputDir.setText(System.getProperty("user.dir")); |
| 515 | } |
| 516 | |
| 517 | try{ |
| 518 | lqnsConfigPragma.setText(configuration.getAttribute(MessageStrings.PRAGMAS, "")); |
| 519 | } catch(CoreException e){ |
| 520 | lqnsConfigPragma.setText(""); |
| 521 | } |
| 522 | |
| 523 | try{ |
| 524 | lqsimConfig1.setText(configuration.getAttribute(MessageStrings.RUN_TIME, "")); |
| 525 | } catch(CoreException e){ |
| 526 | lqsimConfig1.setText(""); |
| 527 | } |
| 528 | try{ |
| 529 | lqsimConfig2.setText(configuration.getAttribute(MessageStrings.BLOCKS, "")); |
| 530 | } catch(CoreException e){ |
| 531 | lqsimConfig2.setText(""); |
| 532 | } |
| 533 | try{ |
| 534 | lqsimConfig3.setText(configuration.getAttribute(MessageStrings.PS_QUANTUM, "0.001")); |
| 535 | } catch(CoreException e){ |
| 536 | lqsimConfig3.setText("0.001"); |
| 537 | } |
| 538 | try{ |
| 539 | textLqsimOutputDir.setText(configuration.getAttribute(MessageStrings.LQSIM_OUTPUT_DIR, System.getProperty("user.dir"))); |
| 540 | } catch(CoreException e){ |
| 541 | textLqsimOutputDir.setText(System.getProperty("user.dir")); |
| 542 | } |
| 543 | |
| 544 | try { |
| 545 | this.checkboxUseExpressionAsInput.setSelection(configuration.getAttribute( |
| 546 | MessageStrings.SRE_IS_USE_INPUT_MODEL, false)); |
| 547 | } catch (CoreException e) { |
| 548 | this.checkboxUseExpressionAsInput.setSelection(false); |
| 549 | } |
| 550 | try { |
| 551 | this.lqnsConfigStopOnMessageLoss.setSelection(configuration.getAttribute( |
| 552 | MessageStrings.STOP_ON_MESSAGE_LOSS_LQNS, true)); |
| 553 | } catch (CoreException e) { |
| 554 | this.lqnsConfigStopOnMessageLoss.setSelection(true); |
| 555 | } |
| 556 | try { |
| 557 | this.lqsimConfigStopOnMessageLoss.setSelection(configuration.getAttribute( |
| 558 | MessageStrings.STOP_ON_MESSAGE_LOSS_LQSIM, true)); |
| 559 | } catch (CoreException e) { |
| 560 | this.lqsimConfigStopOnMessageLoss.setSelection(true); |
| 561 | } |
| 562 | |
| 563 | try{ |
| 564 | lqnsimConfigPragma.setText(configuration.getAttribute(MessageStrings.PRAGMAS, "")); |
| 565 | } catch(CoreException e){ |
| 566 | lqnsimConfigPragma.setText(""); |
| 567 | } |
| 568 | |
| 569 | try { |
| 570 | this.lqnsConfigInfTaskMult.setSelection(configuration.getAttribute( |
| 571 | MessageStrings.INFINITE_TASK_MULTIPLICITY, true)); |
| 572 | } catch (CoreException e) { |
| 573 | this.lqnsConfigInfTaskMult.setSelection(true); |
| 574 | } |
| 575 | |
| 576 | updateLaunchConfigurationDialog(); |
| 577 | } |
| 578 | |
| 579 | private void setVisibleConfigurationOptions(String solverStr) { |
| 580 | if (solverStr.equals("SRES (Stochastic Regular Expression Solver)")) |
| 581 | stackLayout.topControl = sresConfigGroup; |
| 582 | else if (solverStr.equals("LQNS (Layered Queueing Network Solver)")) |
| 583 | stackLayout.topControl = lqnsConfigGroup; |
| 584 | else if (solverStr.equals("LQSIM (Layered Queueing Simulation)")) |
| 585 | stackLayout.topControl = lqsimConfigGroup; |
| 586 | |
| 587 | lqsimConfigGroup.getParent().layout(); |
| 588 | } |
| 589 | |
| 590 | @Override |
| 591 | public void performApply(ILaunchConfigurationWorkingCopy configuration) { |
| 592 | configuration.setAttribute(MessageStrings.SOLVER, comboSolver.getText()); |
| 593 | configuration.setAttribute(MessageStrings.SAMPLING_DIST, textSamplingDist.getText()); |
| 594 | configuration.setAttribute(MessageStrings.MAX_DOMAIN, Integer.parseInt(textMaxDomain.getText())); |
| 595 | |
| 596 | configuration.setAttribute(MessageStrings.CONV_VALUE, lqnsConfig1.getText()); |
| 597 | configuration.setAttribute(MessageStrings.IT_LIMIT, lqnsConfig2.getText()); |
| 598 | configuration.setAttribute(MessageStrings.PRINT_INT, lqnsConfig3.getText()); |
| 599 | configuration.setAttribute(MessageStrings.UNDER_COEFF, lqnsConfig4.getText()); |
| 600 | configuration.setAttribute(MessageStrings.LQNS_OUTPUT, comboLqnsOutput.getText()); |
| 601 | configuration.setAttribute(MessageStrings.LQSIM_OUTPUT, comboLqsimOutput.getText()); |
| 602 | |
| 603 | configuration.setAttribute(MessageStrings.STOP_ON_MESSAGE_LOSS_LQNS, lqnsConfigStopOnMessageLoss.getSelection()); |
| 604 | configuration.setAttribute(MessageStrings.STOP_ON_MESSAGE_LOSS_LQSIM, lqsimConfigStopOnMessageLoss.getSelection()); |
| 605 | |
| 606 | configuration.setAttribute(MessageStrings.INFINITE_TASK_MULTIPLICITY, lqnsConfigInfTaskMult.getSelection()); |
| 607 | |
| 608 | configuration.setAttribute(MessageStrings.RUN_TIME, lqsimConfig1.getText()); |
| 609 | configuration.setAttribute(MessageStrings.BLOCKS, lqsimConfig2.getText()); |
| 610 | configuration.setAttribute(MessageStrings.PS_QUANTUM, lqsimConfig3.getText()); |
| 611 | |
| 612 | configuration.setAttribute(MessageStrings.PRAGMAS, lqnsimConfigPragma.getText()); |
| 613 | configuration.setAttribute(MessageStrings.PRAGMAS, lqnsConfigPragma.getText()); |
| 614 | |
| 615 | configuration.setAttribute(MessageStrings.LQNS_OUTPUT_DIR, textLqnsOutputDir.getText()); |
| 616 | configuration.setAttribute(MessageStrings.LQSIM_OUTPUT_DIR, textLqsimOutputDir.getText()); |
| 617 | configuration.setAttribute(MessageStrings.SRE_OUTPUT_FILE, textSREOutputFile.getText()); |
| 618 | |
| 619 | configuration.setAttribute(MessageStrings.SRE_IS_USE_INPUT_MODEL, checkboxUseExpressionAsInput.getSelection()); |
| 620 | } |
| 621 | |
| 622 | @Override |
| 623 | public void setDefaults(ILaunchConfigurationWorkingCopy configuration) { |
| 624 | // TODO Auto-generated method stub |
| 625 | |
| 626 | } |
| 627 | |
| 628 | @Override |
| 629 | public boolean isValid(ILaunchConfiguration launchConfig) { |
| 630 | setErrorMessage(null); |
| 631 | |
| 632 | String sampDist = textSamplingDist.getText(); |
| 633 | if (sampDist.equals("")){ |
| 634 | setErrorMessage("Sampling distance is missing!"); |
| 635 | return false; |
| 636 | } |
| 637 | try { |
| 638 | Double.parseDouble(sampDist); |
| 639 | } catch (NumberFormatException e){ |
| 640 | setErrorMessage("Sampling distance is not a Double Value!"); |
| 641 | return false; |
| 642 | } |
| 643 | |
| 644 | String maxDom = textMaxDomain.getText(); |
| 645 | if (maxDom.equals("")){ |
| 646 | setErrorMessage("Maximum domain size is missing!"); |
| 647 | return false; |
| 648 | } |
| 649 | try { |
| 650 | Integer.parseInt(maxDom); |
| 651 | } catch (NumberFormatException e){ |
| 652 | setErrorMessage("Maximum domain is not an Integer Value!"); |
| 653 | return false; |
| 654 | } |
| 655 | |
| 656 | String outputDir = textLqnsOutputDir.getText(); |
| 657 | if(outputDir.equals("")){ |
| 658 | setErrorMessage("Output folder must be set!"); |
| 659 | return false; |
| 660 | } |
| 661 | if (outputDir.contains(" ")){ |
| 662 | setErrorMessage("Output folder must not contain a space character, as the LQN solvers cannot handle that."); |
| 663 | return false; |
| 664 | } |
| 665 | return true; |
| 666 | } |
| 667 | |
| 668 | @Override |
| 669 | public void activated(ILaunchConfigurationWorkingCopy workingCopy) { |
| 670 | // Leave this method empty to prevent unnecessary invocation of |
| 671 | // initializeFrom() and multiple resulting invocations of |
| 672 | // performApply(). |
| 673 | } |
| 674 | |
| 675 | @Override |
| 676 | public void deactivated(ILaunchConfigurationWorkingCopy workingCopy) {} |
| 677 | |
| 678 | class FileSystemButtonSelectionAdapter extends SelectionAdapter { |
| 679 | |
| 680 | private Text field; |
| 681 | |
| 682 | public FileSystemButtonSelectionAdapter(Text field){ |
| 683 | this.field = field; |
| 684 | } |
| 685 | |
| 686 | /* (non-Javadoc) |
| 687 | * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent) |
| 688 | */ |
| 689 | @Override |
| 690 | public void widgetSelected(SelectionEvent e) { |
| 691 | String resultOpenFolderDialog = openFileSystemFolderDialog(); |
| 692 | if (!resultOpenFolderDialog.equals(new String(""))) { |
| 693 | field.setText(resultOpenFolderDialog); |
| 694 | } |
| 695 | } |
| 696 | } |
| 697 | |
| 698 | |
| 699 | /** Button SelectionListener - call a WorkspaceResourceDialog */ |
| 700 | class WorkspaceButtonSelectionListener extends SelectionAdapter { |
| 701 | |
| 702 | private Text field; |
| 703 | |
| 704 | public WorkspaceButtonSelectionListener(Text field) { |
| 705 | this.field = field; |
| 706 | } |
| 707 | |
| 708 | @Override |
| 709 | public void widgetSelected(SelectionEvent e) { |
| 710 | String resultOpenFolderDialog = openWorkspaceResourceFolderDialog(); |
| 711 | if (!resultOpenFolderDialog.equals(new String(""))) { |
| 712 | field.setText(resultOpenFolderDialog); |
| 713 | } |
| 714 | } |
| 715 | } |
| 716 | |
| 717 | private String openFileSystemFolderDialog(){ |
| 718 | String folderName = ""; |
| 719 | |
| 720 | DirectoryDialog dirDialog = new DirectoryDialog(getShell(), SWT.OPEN); |
| 721 | dirDialog.setText("Select a folder."); |
| 722 | |
| 723 | if (dirDialog.open() != null) { |
| 724 | folderName = dirDialog.getFilterPath(); |
| 725 | |
| 726 | } |
| 727 | return folderName; |
| 728 | } |
| 729 | |
| 730 | private String openWorkspaceResourceFolderDialog(){ |
| 731 | String msg = "Select a folder."; |
| 732 | |
| 733 | IContainer container = null; |
| 734 | IContainer[] containers = WorkspaceResourceDialog.openFolderSelection(getShell(), |
| 735 | null, msg, false, null, new ArrayList<ViewerFilter>()); |
| 736 | |
| 737 | if (containers.length != 0) |
| 738 | container = containers[0]; |
| 739 | if (container != null) |
| 740 | return container.getLocation().toOSString(); |
| 741 | |
| 742 | return ""; |
| 743 | } |
| 744 | } |