EMMA Coverage Report (generated Sun Feb 05 10:43:15 CET 2012)
[all classes][de.uka.ipd.sdq.reliability.solver.runconfig]

COVERAGE SUMMARY FOR SOURCE FILE [OptionsTab.java]

nameclass, %method, %block, %line, %
OptionsTab.java0%   (0/12)0%   (0/59)0%   (0/2729)0%   (0/772)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class OptionsTab0%   (0/1)0%   (0/28)0%   (0/2188)0%   (0/631)
<static initializer> 0%   (0/1)0%   (0/3)0%   (0/2)
OptionsTab (): void 0%   (0/1)0%   (0/78)0%   (0/26)
access$0 (OptionsTab, boolean): void 0%   (0/1)0%   (0/4)0%   (0/1)
access$1 (OptionsTab): void 0%   (0/1)0%   (0/3)0%   (0/1)
access$2 (OptionsTab): void 0%   (0/1)0%   (0/3)0%   (0/1)
access$3 (OptionsTab): Shell 0%   (0/1)0%   (0/3)0%   (0/1)
access$4 (OptionsTab): Text 0%   (0/1)0%   (0/3)0%   (0/1)
access$5 (OptionsTab, String): Path 0%   (0/1)0%   (0/4)0%   (0/1)
access$6 (OptionsTab, String): String 0%   (0/1)0%   (0/4)0%   (0/1)
access$7 (OptionsTab, String): String 0%   (0/1)0%   (0/4)0%   (0/1)
access$8 (OptionsTab): Text 0%   (0/1)0%   (0/3)0%   (0/1)
access$9 (OptionsTab): Text 0%   (0/1)0%   (0/3)0%   (0/1)
activated (ILaunchConfigurationWorkingCopy): void 0%   (0/1)0%   (0/1)0%   (0/1)
createControl (Composite): void 0%   (0/1)0%   (0/1119)0%   (0/265)
deactivated (ILaunchConfigurationWorkingCopy): void 0%   (0/1)0%   (0/1)0%   (0/1)
getCurrentFilePath (String): Path 0%   (0/1)0%   (0/16)0%   (0/5)
getDirectoryName (String): String 0%   (0/1)0%   (0/23)0%   (0/6)
getFileName (String): String 0%   (0/1)0%   (0/16)0%   (0/4)
getImage (): Image 0%   (0/1)0%   (0/4)0%   (0/1)
getName (): String 0%   (0/1)0%   (0/2)0%   (0/1)
getRelativeFilePath (String): Path 0%   (0/1)0%   (0/27)0%   (0/7)
initializeFrom (ILaunchConfiguration): void 0%   (0/1)0%   (0/365)0%   (0/134)
isValid (ILaunchConfiguration): boolean 0%   (0/1)0%   (0/158)0%   (0/46)
performApply (ILaunchConfigurationWorkingCopy): void 0%   (0/1)0%   (0/142)0%   (0/52)
resolveFile (String): String 0%   (0/1)0%   (0/21)0%   (0/7)
resolvePath (String): String 0%   (0/1)0%   (0/43)0%   (0/11)
setDefaults (ILaunchConfigurationWorkingCopy): void 0%   (0/1)0%   (0/62)0%   (0/36)
updateFieldsEnablement (): void 0%   (0/1)0%   (0/73)0%   (0/22)
     
class OptionsTab$10%   (0/1)0%   (0/2)0%   (0/17)0%   (0/6)
OptionsTab$1 (OptionsTab): void 0%   (0/1)0%   (0/6)0%   (0/2)
handleEvent (Event): void 0%   (0/1)0%   (0/11)0%   (0/4)
     
class OptionsTab$100%   (0/1)0%   (0/3)0%   (0/68)0%   (0/22)
OptionsTab$10 (OptionsTab): void 0%   (0/1)0%   (0/6)0%   (0/2)
widgetDefaultSelected (SelectionEvent): void 0%   (0/1)0%   (0/1)0%   (0/1)
widgetSelected (SelectionEvent): void 0%   (0/1)0%   (0/61)0%   (0/19)
     
class OptionsTab$110%   (0/1)0%   (0/3)0%   (0/83)0%   (0/22)
OptionsTab$11 (OptionsTab): void 0%   (0/1)0%   (0/6)0%   (0/2)
widgetDefaultSelected (SelectionEvent): void 0%   (0/1)0%   (0/1)0%   (0/1)
widgetSelected (SelectionEvent): void 0%   (0/1)0%   (0/76)0%   (0/19)
     
class OptionsTab$20%   (0/1)0%   (0/2)0%   (0/17)0%   (0/6)
OptionsTab$2 (OptionsTab): void 0%   (0/1)0%   (0/6)0%   (0/2)
modifyText (ModifyEvent): void 0%   (0/1)0%   (0/11)0%   (0/4)
     
class OptionsTab$30%   (0/1)0%   (0/3)0%   (0/18)0%   (0/7)
OptionsTab$3 (OptionsTab): void 0%   (0/1)0%   (0/6)0%   (0/2)
keyPressed (KeyEvent): void 0%   (0/1)0%   (0/1)0%   (0/1)
keyReleased (KeyEvent): void 0%   (0/1)0%   (0/11)0%   (0/4)
     
class OptionsTab$40%   (0/1)0%   (0/3)0%   (0/68)0%   (0/22)
OptionsTab$4 (OptionsTab): void 0%   (0/1)0%   (0/6)0%   (0/2)
widgetDefaultSelected (SelectionEvent): void 0%   (0/1)0%   (0/1)0%   (0/1)
widgetSelected (SelectionEvent): void 0%   (0/1)0%   (0/61)0%   (0/19)
     
class OptionsTab$50%   (0/1)0%   (0/3)0%   (0/83)0%   (0/22)
OptionsTab$5 (OptionsTab): void 0%   (0/1)0%   (0/6)0%   (0/2)
widgetDefaultSelected (SelectionEvent): void 0%   (0/1)0%   (0/1)0%   (0/1)
widgetSelected (SelectionEvent): void 0%   (0/1)0%   (0/76)0%   (0/19)
     
class OptionsTab$60%   (0/1)0%   (0/3)0%   (0/18)0%   (0/7)
OptionsTab$6 (OptionsTab): void 0%   (0/1)0%   (0/6)0%   (0/2)
keyPressed (KeyEvent): void 0%   (0/1)0%   (0/1)0%   (0/1)
keyReleased (KeyEvent): void 0%   (0/1)0%   (0/11)0%   (0/4)
     
class OptionsTab$70%   (0/1)0%   (0/3)0%   (0/68)0%   (0/21)
OptionsTab$7 (OptionsTab): void 0%   (0/1)0%   (0/6)0%   (0/2)
widgetDefaultSelected (SelectionEvent): void 0%   (0/1)0%   (0/1)0%   (0/1)
widgetSelected (SelectionEvent): void 0%   (0/1)0%   (0/61)0%   (0/18)
     
class OptionsTab$80%   (0/1)0%   (0/3)0%   (0/83)0%   (0/21)
OptionsTab$8 (OptionsTab): void 0%   (0/1)0%   (0/6)0%   (0/2)
widgetDefaultSelected (SelectionEvent): void 0%   (0/1)0%   (0/1)0%   (0/1)
widgetSelected (SelectionEvent): void 0%   (0/1)0%   (0/76)0%   (0/18)
     
class OptionsTab$90%   (0/1)0%   (0/3)0%   (0/18)0%   (0/7)
OptionsTab$9 (OptionsTab): void 0%   (0/1)0%   (0/6)0%   (0/2)
keyPressed (KeyEvent): void 0%   (0/1)0%   (0/1)0%   (0/1)
keyReleased (KeyEvent): void 0%   (0/1)0%   (0/11)0%   (0/4)

1package de.uka.ipd.sdq.reliability.solver.runconfig;
2 
3import java.net.URL;
4 
5import org.eclipse.core.resources.IFile;
6import org.eclipse.core.resources.ResourcesPlugin;
7import org.eclipse.core.runtime.CoreException;
8import org.eclipse.core.runtime.FileLocator;
9import org.eclipse.core.runtime.Path;
10import org.eclipse.debug.core.ILaunchConfiguration;
11import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
12import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
13import org.eclipse.emf.common.ui.dialogs.WorkspaceResourceDialog;
14import org.eclipse.swt.SWT;
15import org.eclipse.swt.custom.ScrolledComposite;
16import org.eclipse.swt.events.KeyEvent;
17import org.eclipse.swt.events.KeyListener;
18import org.eclipse.swt.events.ModifyEvent;
19import org.eclipse.swt.events.ModifyListener;
20import org.eclipse.swt.events.SelectionEvent;
21import org.eclipse.swt.events.SelectionListener;
22import org.eclipse.swt.graphics.Image;
23import org.eclipse.swt.layout.GridData;
24import org.eclipse.swt.layout.GridLayout;
25import org.eclipse.swt.widgets.Button;
26import org.eclipse.swt.widgets.Composite;
27import org.eclipse.swt.widgets.Event;
28import org.eclipse.swt.widgets.FileDialog;
29import org.eclipse.swt.widgets.Group;
30import org.eclipse.swt.widgets.Label;
31import org.eclipse.swt.widgets.Listener;
32import org.eclipse.swt.widgets.Shell;
33import org.eclipse.swt.widgets.Spinner;
34import org.eclipse.swt.widgets.Text;
35 
36import de.uka.ipd.sdq.pcmsolver.runconfig.MessageStrings;
37import de.uka.ipd.sdq.reliability.core.MarkovEvaluationType;
38import de.uka.ipd.sdq.workflow.launchconfig.RunConfigImages;
39 
40/**
41 * This tab page shows additional options for the PCM Solver Reliability launch.
42 * 
43 * @author brosch
44 * 
45 */
46public class OptionsTab extends AbstractLaunchConfigurationTab {
47 
48        /**
49         * The path to the image file for the tab icon.
50         */
51        private static final String FILENAME_TAB_IMAGE_PATH = "icons/options_tab.gif";
52 
53        /**
54         * Default setting for physical states iteration.
55         */
56        private static final boolean ITERATION_OVER_PHYSICAL_SYSTEM_STATES_ENABLED = true;
57 
58        /**
59         * Default setting for logging.
60         */
61        private static final String LOGFILEDEFAULT = "";
62 
63        /**
64         * Default setting for type of evaluation mode.
65         */
66        private static final MarkovEvaluationType MARKOV_EVALUATION_MODE = MarkovEvaluationType.POINTSOFFAILURE;
67 
68        /**
69         * Default setting for applying Markov model reduction ("optimize" option).
70         */
71        private static final boolean MARKOV_MODEL_REDUCTION_ENABLED = true;
72 
73        /**
74         * Default setting for storing the Markov model.
75         */
76        private static final boolean MARKOV_MODEL_STORAGE_ENABLED = false;
77 
78        /**
79         * Default setting for addition of Markov model traces.
80         */
81        private static final boolean MARKOV_MODEL_TRACES_ENABLED = false;
82 
83        /**
84         * Default name for the Markov model file.
85         */
86        private static final String MARKOVMODELFILEDEFAULT = "";
87 
88        /**
89         * Default setting for number of evaluated system states.
90         */
91        private static final int NUMBER_OF_EVALUATED_SYSTEM_STATES = 1;
92 
93        /**
94         * Default setting for number of evaluated system states.
95         */
96        private static final boolean NUMBER_OF_EVALUATED_SYSTEM_STATES_ENABLED = false;
97 
98        /**
99         * Default setting for number of decimal places.
100         */
101        private static final int NUMBER_OF_EXACT_DECIMAL_PLACES = 1;
102 
103        /**
104         * Default setting for exact decimal places shown of result.
105         */
106        private static final boolean NUMBER_OF_EXACT_DECIMAL_PLACES_ENABLED = false;
107 
108        /**
109         * The id of this plug-in.
110         */
111        private static final String PLUGIN_ID = "de.uka.ipd.sdq.reliability.solver";
112 
113        /**
114         * Default setting for saving results file.
115         */
116        private static final String SAVE_FILE_DEFAULT = "";
117 
118        /**
119         * Default setting for saving results.
120         */
121        private static final boolean SAVE_RESULTS_TO_FILE_ENABLED = false;
122 
123        /**
124         * Default setting for single result printing.
125         */
126        private static final boolean SINGLERESULTSDEFAULT = false;
127 
128        /**
129         * Default setting for solving time limit.
130         */
131        private static final int SOLVING_TIME_LIMIT = 1;
132 
133        /**
134         * Default setting for solving time limit.
135         */
136        private static final boolean SOLVING_TIME_LIMIT_ENABLED = false;
137 
138        /**
139         * Default setting for Markov statistics.
140         */
141        private static final boolean STATISTICSDEFAULT = false;
142 
143        /**
144         * Button to a file dialog, starting in the user's file system.
145         */
146        private Button buttonFileSystemFileDialogLogFile = null;
147 
148        /**
149         * Button to a file dialog, starting in the user's file system.
150         */
151        private Button buttonFileSystemFileDialogModelFile = null;
152 
153        /**
154         * Button to a file dialog, starting in the user's file system.
155         */
156        private Button buttonFileSystemFileDialogSaveToFile = null;
157 
158        /**
159         * Button to a file dialog, starting in the user's workspace.
160         */
161        private Button buttonWorkspaceFileDialogLogFile = null;
162 
163        /**
164         * Button to a file dialog, starting in the user's workspace.
165         */
166        private Button buttonWorkspaceFileDialogModelFile = null;
167 
168        /**
169         * Button to a file dialog, starting in the user's workspace.
170         */
171        private Button buttonWorkspaceFileDialogSaveToFile = null;
172 
173        /**
174         * Checks for iteration over physical system states.
175         */
176        private Button checkIterateOverPhysicalSystemStates;
177 
178        /**
179         * Checks for Markov model traces enablement.
180         */
181        private Button checkMarkovModelTraces = null;
182 
183        /**
184         * Checks for Markov statistics.
185         */
186        private Button checkMarkovStatistics = null;
187 
188        /**
189         * Checks for number of evaluated system states.
190         */
191        private Button checkNumberOfEvaluatedSystemStates = null;
192 
193        /**
194         * Checks for number of exact decimal places.
195         */
196        private Button checkNumberOfExactDecimalPlaces = null;
197 
198        /**
199         * Checks for optimize option.
200         */
201        private Button checkOptimize = null;
202 
203        /**
204         * Checks whether results should be saved to a file.
205         */
206        private Button checkSaveResultsToFile = null;
207 
208        /**
209         * Checks for single result prints.
210         */
211        private Button checkSingleResults = null;
212 
213        /**
214         * Checks for solving time limits.
215         */
216        private Button checkSolvingTimeLimit = null;
217 
218        /**
219         * Checks for Markov model storage.
220         */
221        private Button checkStoreMarkovModel = null;
222 
223        /**
224         * Radio button for failure categories (simplified evaluation without
225         * failure recovery).
226         */
227        private Button radioFailureCategories = null;
228 
229        /**
230         * Radio button for failure types.
231         */
232        private Button radioFailureTypes = null;
233 
234        /**
235         * Radio button for points of failure.
236         */
237        private Button radioPointsOfFailure = null;
238 
239        /**
240         * Radio button for single failure mode (simplified evaluation without
241         * failure recovery).
242         */
243        private Button radioSingleFailureMode = null;
244 
245        /**
246         * Spinner for number of evaluated system states.
247         */
248        private Spinner spinnerNumberOfEvaluatedSystemStates = null;
249 
250        /**
251         * Spinner for number of exact decimal places.
252         */
253        private Spinner spinnerNumberOfExactDecimalPlaces = null;
254 
255        /**
256         * Spinner for solving time limits.
257         */
258        private Spinner spinnerSolvingTimeLimit = null;
259 
260        /**
261         * Text box to specify the logging file.
262         */
263        private Text textLogFile = null;
264 
265        /**
266         * Text box to specify the model file.
267         */
268        private Text textMarkovModelFile = null;
269 
270        /**
271         * Text box to specify the results file.
272         */
273        private Text textSaveResultsToFile = null;
274 
275        /*
276         * (non-Javadoc)
277         * 
278         * @see
279         * org.eclipse.debug.ui.AbstractLaunchConfigurationTab#activated(org.eclipse
280         * .debug.core.ILaunchConfigurationWorkingCopy)
281         */
282        public void activated(final ILaunchConfigurationWorkingCopy workingCopy) {
283                // Leave this method empty to prevent unnecessary invocation of
284                // initializeFrom() and multiple resulting invocations of
285                // performApply().
286        }
287 
288        /*
289         * (non-Javadoc)
290         * 
291         * @see
292         * org.eclipse.debug.ui.ILaunchConfigurationTab#createControl(org.eclipse
293         * .swt.widgets.Composite)
294         */
295        public void createControl(final Composite parent) {
296 
297                // Create a listener for GUI events:
298                final Listener listener = new Listener() {
299                        public void handleEvent(final Event event) {
300                                setDirty(true);
301                                updateLaunchConfigurationDialog();
302                                updateFieldsEnablement();
303                        }
304                };
305 
306                // Create a listener for GUI modification events:
307                final ModifyListener modifyListener = new ModifyListener() {
308                        public void modifyText(final ModifyEvent e) {
309                                setDirty(true);
310                                updateLaunchConfigurationDialog();
311                                updateFieldsEnablement();
312                        }
313                };
314 
315                // Create a new Composite to hold the page's controls.
316                // The composite will show scroll bars if the size of
317                // the dialog decreases below the minimum size of the
318                // contained controls:
319                ScrolledComposite container = new ScrolledComposite(parent,
320                                SWT.H_SCROLL | SWT.V_SCROLL);
321                container.setExpandHorizontal(true);
322                container.setExpandVertical(true);
323                Composite contentContainer = new Composite(container, SWT.NONE);
324                container.setContent(contentContainer);
325                GridLayout layout = new GridLayout();
326                contentContainer.setLayout(layout);
327 
328                // Sets the scrolled composite to be the displayed
329                // top-level control in this tab:
330                setControl(container);
331 
332                // Create a new GridLayout for the stop conditions Group:
333                final GridLayout stopConditionsLayout = new GridLayout();
334                stopConditionsLayout.numColumns = 2;
335 
336                // Create the logging Group with the verbose logging check box:
337                final Group stopConditionsGroup = new Group(contentContainer, SWT.NONE);
338                stopConditionsGroup.setLayout(stopConditionsLayout);
339                stopConditionsGroup.setText("Stop Conditions");
340                stopConditionsGroup.setLayoutData(new GridData(SWT.FILL, SWT.CENTER,
341                                true, false));
342 
343                // Create the check box and spinner for specifying the number of
344                // evaluated system states
345                checkNumberOfEvaluatedSystemStates = new Button(stopConditionsGroup,
346                                SWT.CHECK);
347                checkNumberOfEvaluatedSystemStates
348                                .setText("Number of evaluated system states:");
349                checkNumberOfEvaluatedSystemStates
350                                .setSelection(NUMBER_OF_EVALUATED_SYSTEM_STATES_ENABLED);
351                checkNumberOfEvaluatedSystemStates.addListener(SWT.Selection, listener);
352                checkNumberOfEvaluatedSystemStates.setLayoutData(new GridData(SWT.FILL,
353                                SWT.CENTER, false, false, 1, 1));
354 
355                spinnerNumberOfEvaluatedSystemStates = new Spinner(stopConditionsGroup,
356                                SWT.NORMAL);
357                spinnerNumberOfEvaluatedSystemStates.setIncrement(1);
358                spinnerNumberOfEvaluatedSystemStates.setMinimum(1);
359                spinnerNumberOfEvaluatedSystemStates.setMaximum(1000000);
360                spinnerNumberOfEvaluatedSystemStates
361                                .setSelection(NUMBER_OF_EVALUATED_SYSTEM_STATES);
362                spinnerNumberOfEvaluatedSystemStates
363                                .setEnabled(NUMBER_OF_EVALUATED_SYSTEM_STATES_ENABLED);
364                spinnerNumberOfEvaluatedSystemStates.setLayoutData(new GridData(
365                                SWT.FILL, SWT.CENTER, false, false, 1, 1));
366                spinnerNumberOfEvaluatedSystemStates.addListener(SWT.Selection,
367                                listener);
368                spinnerNumberOfEvaluatedSystemStates.addModifyListener(modifyListener);
369 
370                // Create the check box and spinner for showing the number of exact
371                // decimal places
372                checkNumberOfExactDecimalPlaces = new Button(stopConditionsGroup,
373                                SWT.CHECK);
374                checkNumberOfExactDecimalPlaces
375                                .setText("Number of exact decimal places:");
376                checkNumberOfExactDecimalPlaces
377                                .setSelection(NUMBER_OF_EXACT_DECIMAL_PLACES_ENABLED);
378                checkNumberOfExactDecimalPlaces.addListener(SWT.Selection, listener);
379                checkNumberOfExactDecimalPlaces.setLayoutData(new GridData(SWT.FILL,
380                                SWT.CENTER, false, false, 1, 1));
381 
382                spinnerNumberOfExactDecimalPlaces = new Spinner(stopConditionsGroup,
383                                SWT.NORMAL);
384                spinnerNumberOfExactDecimalPlaces.setIncrement(1);
385                spinnerNumberOfExactDecimalPlaces.setMinimum(1);
386                spinnerNumberOfExactDecimalPlaces.setMaximum(10);
387                spinnerNumberOfExactDecimalPlaces
388                                .setSelection(NUMBER_OF_EXACT_DECIMAL_PLACES);
389                spinnerNumberOfExactDecimalPlaces
390                                .setEnabled(NUMBER_OF_EXACT_DECIMAL_PLACES_ENABLED);
391                spinnerNumberOfExactDecimalPlaces.setLayoutData(new GridData(SWT.FILL,
392                                SWT.CENTER, false, false, 1, 1));
393                spinnerNumberOfExactDecimalPlaces.addListener(SWT.Selection, listener);
394                spinnerNumberOfExactDecimalPlaces.addModifyListener(modifyListener);
395 
396                // Create the check box and spinner for limiting solving time
397                checkSolvingTimeLimit = new Button(stopConditionsGroup, SWT.CHECK);
398                checkSolvingTimeLimit.setText("Solving time (in seconds):");
399                checkSolvingTimeLimit.setSelection(SOLVING_TIME_LIMIT_ENABLED);
400                checkSolvingTimeLimit.addListener(SWT.Selection, listener);
401                checkSolvingTimeLimit.setLayoutData(new GridData(SWT.FILL, SWT.CENTER,
402                                false, false, 1, 1));
403 
404                spinnerSolvingTimeLimit = new Spinner(stopConditionsGroup, SWT.NORMAL);
405                spinnerSolvingTimeLimit.setIncrement(1);
406                spinnerSolvingTimeLimit.setMinimum(1);
407                spinnerSolvingTimeLimit.setMaximum(86400); // 24h
408                spinnerSolvingTimeLimit.setSelection(SOLVING_TIME_LIMIT);
409                spinnerSolvingTimeLimit.setEnabled(SOLVING_TIME_LIMIT_ENABLED);
410                spinnerSolvingTimeLimit.setLayoutData(new GridData(SWT.FILL,
411                                SWT.CENTER, false, false, 1, 1));
412                spinnerSolvingTimeLimit.addListener(SWT.Selection, listener);
413                spinnerSolvingTimeLimit.addModifyListener(modifyListener);
414 
415                // Create a new GridLayout for the Markov transformation Group:
416                final GridLayout markovTransformationLayout = new GridLayout();
417                markovTransformationLayout.numColumns = 4;
418 
419                // Create the Markov transformation Group
420                Group markovTransformationGroup = new Group(contentContainer, SWT.NONE);
421                markovTransformationGroup.setLayout(markovTransformationLayout);
422                markovTransformationGroup.setText("Markov Transformation");
423                markovTransformationGroup.setLayoutData(new GridData(SWT.FILL,
424                                SWT.CENTER, true, false));
425 
426                // Add an optimize option as check box
427                checkOptimize = new Button(markovTransformationGroup, SWT.CHECK);
428                checkOptimize.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false,
429                                false, markovTransformationLayout.numColumns, 1));
430                checkOptimize.setText("Apply Markov model reduction");
431                checkOptimize.setSelection(MARKOV_MODEL_REDUCTION_ENABLED);
432                checkOptimize.addListener(SWT.Selection, listener);
433 
434                // Add an option for Markov model traces as check box
435                checkMarkovModelTraces = new Button(markovTransformationGroup,
436                                SWT.CHECK);
437                checkMarkovModelTraces.setLayoutData(new GridData(SWT.FILL, SWT.CENTER,
438                                false, false, markovTransformationLayout.numColumns, 1));
439                checkMarkovModelTraces.setText("Add Markov traces");
440                checkMarkovModelTraces.setSelection(MARKOV_MODEL_TRACES_ENABLED);
441                checkMarkovModelTraces.addListener(SWT.Selection, listener);
442 
443                // Add an option to iterate over physical system states as check box
444                checkIterateOverPhysicalSystemStates = new Button(
445                                markovTransformationGroup, SWT.CHECK);
446                checkIterateOverPhysicalSystemStates.setLayoutData(new GridData(
447                                SWT.FILL, SWT.CENTER, false, false,
448                                markovTransformationLayout.numColumns, 1));
449                checkIterateOverPhysicalSystemStates
450                                .setText("Iterate over physical system states");
451                checkIterateOverPhysicalSystemStates
452                                .setSelection(ITERATION_OVER_PHYSICAL_SYSTEM_STATES_ENABLED);
453                checkIterateOverPhysicalSystemStates.addListener(SWT.Selection,
454                                listener);
455 
456                // Add a store markov model option as check box
457                checkStoreMarkovModel = new Button(markovTransformationGroup, SWT.CHECK);
458                checkStoreMarkovModel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER,
459                                false, false, markovTransformationLayout.numColumns, 1));
460                checkStoreMarkovModel.setText("Store Markov model");
461                checkStoreMarkovModel.setSelection(MARKOV_MODEL_STORAGE_ENABLED);
462                checkStoreMarkovModel.addListener(SWT.Selection, listener);
463 
464                // Add a label showing where to specify the model file
465                Label labelModelFile = new Label(markovTransformationGroup, SWT.NONE);
466                labelModelFile.setText("Model file:");
467 
468                // Create the model file text box
469                textMarkovModelFile = new Text(markovTransformationGroup, SWT.BORDER);
470                textMarkovModelFile.setLayoutData(new GridData(SWT.FILL, SWT.CENTER,
471                                true, false));
472                textMarkovModelFile.setEnabled(MARKOV_MODEL_STORAGE_ENABLED);
473                textMarkovModelFile.setText(MARKOVMODELFILEDEFAULT);
474                textMarkovModelFile.addKeyListener(new KeyListener() {
475 
476                        @Override
477                        public void keyPressed(final KeyEvent e) {
478                                // nothing happens here
479                        }
480 
481                        @Override
482                        public void keyReleased(final KeyEvent e) {
483                                setDirty(true);
484                                updateLaunchConfigurationDialog();
485                                updateFieldsEnablement();
486                        }
487 
488                });
489 
490                // Create the button responsible for triggering a file dialog,
491                // starting in the user's workspace
492                buttonWorkspaceFileDialogModelFile = new Button(
493                                markovTransformationGroup, SWT.NONE);
494                buttonWorkspaceFileDialogModelFile.setLayoutData(new GridData(SWT.FILL,
495                                SWT.CENTER, false, false));
496                buttonWorkspaceFileDialogModelFile.setText("Workspace...");
497                buttonWorkspaceFileDialogModelFile
498                                .setEnabled(MARKOV_MODEL_STORAGE_ENABLED);
499                buttonWorkspaceFileDialogModelFile
500                                .addSelectionListener(new SelectionListener() {
501 
502                                        @Override
503                                        public void widgetDefaultSelected(final SelectionEvent e) {
504                                                // nothing happens here
505                                        }
506 
507                                        @Override
508                                        public void widgetSelected(final SelectionEvent e) {
509                                                IFile file = WorkspaceResourceDialog.openNewFile(
510                                                                getShell(), "Save As",
511                                                                "Select the parent folder:",
512                                                                getRelativeFilePath(textMarkovModelFile
513                                                                                .getText().trim()), null);
514                                                if (file != null) {
515                                                        String newModelFile = file.getLocation()
516                                                                        .toOSString();
517                                                        if (newModelFile != null) {
518                                                                String portableString = file.getFullPath()
519                                                                                .toPortableString();
520                                                                newModelFile = "platform:/resource"
521                                                                                + portableString;
522                                                                // did the user select "*.markov" as extension
523                                                                // and
524                                                                // not add ".markov" to the file they specified?
525                                                                if (!newModelFile.endsWith(".markov")) {
526                                                                        newModelFile += ".markov"; // append ".txt"
527                                                                        // extension
528                                                                }
529                                                                textMarkovModelFile.setText(newModelFile);
530                                                                updateLaunchConfigurationDialog();
531                                                                updateFieldsEnablement();
532                                                        }
533                                                }
534                                        }
535                                });
536 
537                // Create the button responsible for triggering a file dialog,
538                // starting in the user's file system
539                buttonFileSystemFileDialogModelFile = new Button(
540                                markovTransformationGroup, SWT.NONE);
541                buttonFileSystemFileDialogModelFile.setLayoutData(new GridData(
542                                SWT.FILL, SWT.CENTER, false, false));
543                buttonFileSystemFileDialogModelFile.setText("File System...");
544                buttonFileSystemFileDialogModelFile
545                                .setEnabled(MARKOV_MODEL_STORAGE_ENABLED);
546                buttonFileSystemFileDialogModelFile
547                                .addSelectionListener(new SelectionListener() {
548 
549                                        @Override
550                                        public void widgetDefaultSelected(final SelectionEvent e) {
551                                                // nothing happens here
552                                        }
553 
554                                        @Override
555                                        public void widgetSelected(final SelectionEvent e) {
556                                                FileDialog fileDiag = new FileDialog(new Shell(),
557                                                                SWT.SAVE);
558                                                fileDiag
559                                                                .setFilterPath(getDirectoryName(textMarkovModelFile
560                                                                                .getText().trim()));
561                                                fileDiag.setFilterExtensions(new String[] { "*.markov",
562                                                                "*.*" });
563                                                fileDiag.setFileName(getFileName(textMarkovModelFile
564                                                                .getText().trim()));
565                                                fileDiag.setOverwrite(true);
566                                                String modelFile = fileDiag.open();
567                                                if (modelFile != null) {
568                                                        // did the user select "*.markov" as extension and
569                                                        // not add ".markov" to the file they specified?
570                                                        if (fileDiag.getFilterIndex() == 0
571                                                                        && !modelFile.endsWith(".markov")) {
572                                                                modelFile += ".markov"; // append ".txt"
573                                                                // extension
574                                                        }
575                                                        textMarkovModelFile.setText(modelFile);
576                                                        updateLaunchConfigurationDialog();
577                                                        updateFieldsEnablement();
578                                                }
579                                        }
580                                });
581 
582                // Create evaluation mode Group
583                final GridLayout evaluationModeLayout = new GridLayout();
584                final Group evaluationModeGroup = new Group(contentContainer, SWT.NONE);
585                evaluationModeGroup.setLayout(evaluationModeLayout);
586                evaluationModeGroup.setText("Evaluation Mode");
587                evaluationModeGroup.setLayoutData(new GridData(SWT.FILL, SWT.CENTER,
588                                true, false));
589 
590                // Of the following four radio buttons, only one must be enabled
591                // (checked). Make sure
592                // the boolean default values used are set accordingly (only one true).
593                radioSingleFailureMode = new Button(evaluationModeGroup, SWT.RADIO);
594                radioSingleFailureMode
595                                .setText("Single failure mode (simplified evaluation without failure recovery)");
596                radioSingleFailureMode
597                                .setSelection(MarkovEvaluationType.SINGLE == MARKOV_EVALUATION_MODE);
598                radioSingleFailureMode.addListener(SWT.Selection, listener);
599                radioSingleFailureMode.setLayoutData(new GridData(SWT.FILL, SWT.CENTER,
600                                false, false, 1, 1));
601 
602                radioFailureCategories = new Button(evaluationModeGroup, SWT.RADIO);
603                radioFailureCategories
604                                .setText("Failure categories (simplified evaluation without failure recovery)");
605                radioFailureCategories
606                                .setSelection(MarkovEvaluationType.CLASSES == MARKOV_EVALUATION_MODE);
607                radioFailureCategories.addListener(SWT.Selection, listener);
608                radioFailureCategories.setLayoutData(new GridData(SWT.FILL, SWT.CENTER,
609                                false, false, 1, 1));
610 
611                radioFailureTypes = new Button(evaluationModeGroup, SWT.RADIO);
612                radioFailureTypes.setText("Failure types");
613                radioFailureTypes
614                                .setSelection(MarkovEvaluationType.TYPES == MARKOV_EVALUATION_MODE);
615                radioFailureTypes.addListener(SWT.Selection, listener);
616                radioFailureTypes.setLayoutData(new GridData(SWT.FILL, SWT.CENTER,
617                                false, false, 1, 1));
618 
619                radioPointsOfFailure = new Button(evaluationModeGroup, SWT.RADIO);
620                radioPointsOfFailure
621                                .setText("Points of failure (includes detailed reliability report)");
622                radioPointsOfFailure
623                                .setSelection(MarkovEvaluationType.POINTSOFFAILURE == MARKOV_EVALUATION_MODE);
624                radioPointsOfFailure.addListener(SWT.Selection, listener);
625                radioPointsOfFailure.setLayoutData(new GridData(SWT.FILL, SWT.CENTER,
626                                false, false, 1, 1));
627 
628                // Create a new GridLayout for the logging Group:
629                final GridLayout loggingLayout = new GridLayout();
630                loggingLayout.numColumns = 4;
631 
632                // Create the logging Group with the verbose logging check box:
633                final Group loggingGroup = new Group(contentContainer, SWT.NONE);
634                loggingGroup.setLayout(loggingLayout);
635                loggingGroup.setText("Logging");
636                loggingGroup.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
637                                false));
638 
639                // Create the Markov statistics check box:
640                checkMarkovStatistics = new Button(loggingGroup, SWT.CHECK);
641                checkMarkovStatistics.setLayoutData(new GridData(SWT.FILL, SWT.CENTER,
642                                false, false, loggingLayout.numColumns, 1));
643                checkMarkovStatistics.setText("Print Markov statistics on console");
644                checkMarkovStatistics.setSelection(STATISTICSDEFAULT);
645                checkMarkovStatistics.addListener(SWT.Selection, listener);
646 
647                // Create the Markov statistics check box:
648                checkSingleResults = new Button(loggingGroup, SWT.CHECK);
649                checkSingleResults.setLayoutData(new GridData(SWT.FILL, SWT.CENTER,
650                                false, false, loggingLayout.numColumns, 1));
651                checkSingleResults
652                                .setText("Log results of individual Markov transformation runs");
653                checkSingleResults.setSelection(SINGLERESULTSDEFAULT);
654                checkSingleResults.addListener(SWT.Selection, listener);
655 
656                // Add a label showing where to specify the log file
657                Label labelLogFile = new Label(loggingGroup, SWT.NONE);
658                labelLogFile.setText("Log file:");
659 
660                // Create the logging file text box
661                textLogFile = new Text(loggingGroup, SWT.BORDER);
662                textLogFile.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
663                                false));
664                textLogFile.setText(LOGFILEDEFAULT);
665                textLogFile.setEnabled(SINGLERESULTSDEFAULT);
666                textLogFile.addKeyListener(new KeyListener() {
667 
668                        @Override
669                        public void keyPressed(final KeyEvent e) {
670                                // nothing happens here
671                        }
672 
673                        @Override
674                        public void keyReleased(final KeyEvent e) {
675                                setDirty(true);
676                                updateLaunchConfigurationDialog();
677                                updateFieldsEnablement();
678                        }
679 
680                });
681 
682                // Create the button responsible for triggering a file dialog,
683                // starting in the user's workspace
684                buttonWorkspaceFileDialogLogFile = new Button(loggingGroup, SWT.NONE);
685                buttonWorkspaceFileDialogLogFile.setLayoutData(new GridData(SWT.FILL,
686                                SWT.CENTER, false, false));
687                buttonWorkspaceFileDialogLogFile.setText("Workspace...");
688                buttonWorkspaceFileDialogLogFile.setEnabled(SINGLERESULTSDEFAULT);
689                buttonWorkspaceFileDialogLogFile
690                                .addSelectionListener(new SelectionListener() {
691 
692                                        @Override
693                                        public void widgetDefaultSelected(final SelectionEvent e) {
694                                                // nothing happens here
695                                        }
696 
697                                        @Override
698                                        public void widgetSelected(final SelectionEvent e) {
699                                                IFile file = WorkspaceResourceDialog.openNewFile(
700                                                                getShell(), "Save As",
701                                                                "Select the parent folder:",
702                                                                getRelativeFilePath(textLogFile.getText()
703                                                                                .trim()), null);
704                                                if (file != null) {
705                                                        String newLogFile = file.getLocation().toOSString();
706                                                        if (newLogFile != null) {
707                                                                String portableString = file.getFullPath()
708                                                                                .toPortableString();
709                                                                newLogFile = "platform:/resource"
710                                                                                + portableString;
711                                                                // did the user select "*.txt" as extension and
712                                                                // not add ".txt" to the file they specified?
713                                                                if (!newLogFile.endsWith(".txt")) {
714                                                                        newLogFile += ".txt"; // append ".txt"
715                                                                        // extension
716                                                                }
717                                                                textLogFile.setText(newLogFile);
718                                                                updateLaunchConfigurationDialog();
719                                                                updateFieldsEnablement();
720                                                        }
721                                                }
722                                        }
723                                });
724 
725                // Create the button responsible for triggering a file dialog,
726                // starting in the user's file system
727                buttonFileSystemFileDialogLogFile = new Button(loggingGroup, SWT.NONE);
728                buttonFileSystemFileDialogLogFile.setLayoutData(new GridData(SWT.FILL,
729                                SWT.CENTER, false, false));
730                buttonFileSystemFileDialogLogFile.setText("File System...");
731                buttonFileSystemFileDialogLogFile.setEnabled(SINGLERESULTSDEFAULT);
732                buttonFileSystemFileDialogLogFile
733                                .addSelectionListener(new SelectionListener() {
734 
735                                        @Override
736                                        public void widgetDefaultSelected(final SelectionEvent e) {
737                                                // nothing happens here
738                                        }
739 
740                                        @Override
741                                        public void widgetSelected(final SelectionEvent e) {
742                                                FileDialog fileDiag = new FileDialog(new Shell(),
743                                                                SWT.SAVE);
744                                                fileDiag.setFilterPath(getDirectoryName(textLogFile
745                                                                .getText().trim()));
746                                                fileDiag.setFilterExtensions(new String[] { "*.txt",
747                                                                "*.*" });
748                                                fileDiag.setFileName(getFileName(textLogFile.getText()
749                                                                .trim()));
750                                                fileDiag.setOverwrite(true);
751                                                String logFile = fileDiag.open();
752                                                if (logFile != null) {
753                                                        // did the user select "*.txt" as extension and
754                                                        // not add ".txt" to the file they specified?
755                                                        if (fileDiag.getFilterIndex() == 0
756                                                                        && !logFile.endsWith(".txt")) {
757                                                                logFile += ".txt"; // append ".txt" extension
758                                                        }
759                                                        textLogFile.setText(logFile);
760                                                        updateLaunchConfigurationDialog();
761                                                        updateFieldsEnablement();
762                                                }
763                                        }
764 
765                                });
766 
767                // Create a new GridLayout for the Markov analysis Group:
768                final GridLayout markovAnalysisResultsLayout = new GridLayout();
769                markovAnalysisResultsLayout.numColumns = 4;
770 
771                // Create the Markov analysis Group
772                final Group markovAnalysisResultsGroup = new Group(contentContainer,
773                                SWT.NONE);
774                markovAnalysisResultsGroup.setLayout(markovAnalysisResultsLayout);
775                markovAnalysisResultsGroup.setText("Markov Analysis Results");
776                markovAnalysisResultsGroup.setLayoutData(new GridData(SWT.FILL,
777                                SWT.CENTER, true, false));
778 
779                // Create the Markov statistics check box:
780                checkSaveResultsToFile = new Button(markovAnalysisResultsGroup,
781                                SWT.CHECK);
782                checkSaveResultsToFile.setLayoutData(new GridData(SWT.FILL, SWT.CENTER,
783                                false, false, markovAnalysisResultsLayout.numColumns, 1));
784                checkSaveResultsToFile.setText("Save results to file");
785                checkSaveResultsToFile.setSelection(SAVE_RESULTS_TO_FILE_ENABLED);
786                checkSaveResultsToFile.addListener(SWT.Selection, listener);
787 
788                // Add a label showing where to specify the results file
789                Label labelSaveResultsToFile = new Label(markovAnalysisResultsGroup,
790                                SWT.NONE);
791                labelSaveResultsToFile.setText("File:");
792 
793                // Create the textbox to specify a file for saving the Markov analysis
794                // results
795                textSaveResultsToFile = new Text(markovAnalysisResultsGroup, SWT.BORDER);
796                textSaveResultsToFile.setLayoutData(new GridData(SWT.FILL, SWT.CENTER,
797                                true, false));
798                textSaveResultsToFile.setText(SAVE_FILE_DEFAULT);
799                textSaveResultsToFile.setEnabled(SAVE_RESULTS_TO_FILE_ENABLED);
800                textSaveResultsToFile.addKeyListener(new KeyListener() {
801 
802                        @Override
803                        public void keyPressed(final KeyEvent e) {
804                                // nothing happens here
805                        }
806 
807                        @Override
808                        public void keyReleased(final KeyEvent e) {
809                                setDirty(true);
810                                updateLaunchConfigurationDialog();
811                                updateFieldsEnablement();
812                        }
813 
814                });
815 
816                // Create the button responsible for triggering a file dialog,
817                // starting in the user's workspace
818                buttonWorkspaceFileDialogSaveToFile = new Button(
819                                markovAnalysisResultsGroup, SWT.NONE);
820                buttonWorkspaceFileDialogSaveToFile.setLayoutData(new GridData(
821                                SWT.FILL, SWT.CENTER, false, false));
822                buttonWorkspaceFileDialogSaveToFile.setText("Workspace...");
823                buttonWorkspaceFileDialogSaveToFile
824                                .setEnabled(SAVE_RESULTS_TO_FILE_ENABLED);
825                buttonWorkspaceFileDialogSaveToFile
826                                .addSelectionListener(new SelectionListener() {
827 
828                                        @Override
829                                        public void widgetDefaultSelected(final SelectionEvent e) {
830                                                // nothing happens here
831                                        }
832 
833                                        @Override
834                                        public void widgetSelected(final SelectionEvent e) {
835                                                IFile file = WorkspaceResourceDialog.openNewFile(
836                                                                getShell(), "Save As",
837                                                                "Select the parent folder:",
838                                                                getRelativeFilePath(textSaveResultsToFile
839                                                                                .getText().trim()), null);
840                                                if (file != null) {
841                                                        String newSaveToFile = file.getLocation()
842                                                                        .toOSString();
843                                                        if (newSaveToFile != null) {
844                                                                String portableString = file.getFullPath()
845                                                                                .toPortableString();
846                                                                newSaveToFile = "platform:/resource"
847                                                                                + portableString;
848                                                                // did the user select "*.markovresult" as
849                                                                // extension and
850                                                                // not add ".markovresult" to the file they
851                                                                // specified?
852                                                                if (!newSaveToFile.endsWith(".markovresult")) {
853                                                                        newSaveToFile += ".markovresult"; // append
854                                                                                                                                                // ".markovresult"
855                                                                        // extension
856                                                                }
857                                                                textSaveResultsToFile.setText(newSaveToFile);
858                                                                updateLaunchConfigurationDialog();
859                                                                updateFieldsEnablement();
860                                                        }
861                                                }
862                                        }
863                                });
864 
865                // Create the button responsible for triggering a file dialog,
866                // starting in the user's file system
867                buttonFileSystemFileDialogSaveToFile = new Button(
868                                markovAnalysisResultsGroup, SWT.NONE);
869                buttonFileSystemFileDialogSaveToFile.setLayoutData(new GridData(
870                                SWT.FILL, SWT.CENTER, false, false));
871                buttonFileSystemFileDialogSaveToFile.setText("File System...");
872                buttonFileSystemFileDialogSaveToFile.setEnabled(SINGLERESULTSDEFAULT);
873                buttonFileSystemFileDialogSaveToFile
874                                .addSelectionListener(new SelectionListener() {
875 
876                                        @Override
877                                        public void widgetDefaultSelected(final SelectionEvent e) {
878                                                // nothing happens here
879                                        }
880 
881                                        @Override
882                                        public void widgetSelected(final SelectionEvent e) {
883                                                FileDialog fileDiag = new FileDialog(new Shell(),
884                                                                SWT.SAVE);
885                                                fileDiag
886                                                                .setFilterPath(getDirectoryName(textSaveResultsToFile
887                                                                                .getText().trim()));
888                                                fileDiag.setFilterExtensions(new String[] {
889                                                                "*.markovresult", "*.*" });
890                                                fileDiag.setFileName(getFileName(textSaveResultsToFile
891                                                                .getText().trim()));
892                                                fileDiag.setOverwrite(true);
893                                                String saveToFile = fileDiag.open();
894                                                if (saveToFile != null) {
895                                                        // did the user select "*.markovresult" as extension
896                                                        // and
897                                                        // not add ".markovresult" to the file they
898                                                        // specified?
899                                                        if (fileDiag.getFilterIndex() == 0
900                                                                        && !saveToFile.endsWith(".markovresult")) {
901                                                                saveToFile += ".markovresult"; // append
902                                                                                                                                // ".markovresult"
903                                                                                                                                // extension
904                                                        }
905                                                        textSaveResultsToFile.setText(saveToFile);
906                                                        updateLaunchConfigurationDialog();
907                                                        updateFieldsEnablement();
908                                                }
909                                        }
910 
911                                });
912 
913                // After all internal controls have been created,
914                // calculate the minimal size of the contentContainer.
915                // Scrollbars will be shown if the dialog size decreases
916                // below the calculated min size:
917                container.setMinSize(contentContainer.computeSize(SWT.DEFAULT,
918                                SWT.DEFAULT));
919        }
920 
921        /*
922         * (non-Javadoc)
923         * 
924         * @see
925         * org.eclipse.debug.ui.AbstractLaunchConfigurationTab#deactivated(org.eclipse
926         * .debug.core.ILaunchConfigurationWorkingCopy)
927         */
928        public void deactivated(final ILaunchConfigurationWorkingCopy workingCopy) {
929        }
930 
931        /**
932         * Returns the currently selected file path.
933         * 
934         * Only valid and absolute paths are accepted.
935         * 
936         * @return the currently selected file path
937         */
938        private Path getCurrentFilePath(final String path) {
939                if (Path.ROOT.isValidPath(path)) {
940                        Path resultPath = new Path(path);
941                        if (resultPath.isAbsolute()) {
942                                return resultPath;
943                        }
944                }
945                return null;
946        }
947 
948        /**
949         * Returns the current file directory as a String.
950         * 
951         * @return the current file directory
952         */
953        private String getDirectoryName(final String path) {
954                Path filePath = getCurrentFilePath(path);
955                if (filePath == null) {
956                        return null;
957                }
958                if (filePath.toFile().isDirectory()) {
959                        return filePath.toOSString();
960                }
961                return new Path(filePath.toFile().getParent()).toOSString();
962        }
963 
964        /**
965         * Returns the current file name as a String.
966         * 
967         * @return the current file name
968         */
969        private String getFileName(String path) {
970                Path filePath = getCurrentFilePath(path);
971                if ((filePath == null) || (filePath.toFile().isDirectory())) {
972                        return null;
973                }
974                return filePath.toFile().getName();
975        }
976 
977        /*
978         * (non-Javadoc)
979         * 
980         * @see org.eclipse.debug.ui.AbstractLaunchConfigurationTab#getImage()
981         */
982        public Image getImage() {
983                return RunConfigImages.getTabImage(PLUGIN_ID, FILENAME_TAB_IMAGE_PATH);
984        }
985 
986        /*
987         * (non-Javadoc)
988         * 
989         * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getName()
990         */
991        public String getName() {
992                return "Analysis Options";
993        }
994 
995        /**
996         * Returns the currently selected file path, relative to the workspace.
997         * 
998         * Returns an empty path if the current file path is not valid or not within
999         * the workspace.
1000         * 
1001         * @return the currently selected file path
1002         */
1003        private Path getRelativeFilePath(final String path) {
1004                Path logFilePath = getCurrentFilePath(path);
1005                Path workspacePath = (Path) ResourcesPlugin.getWorkspace().getRoot()
1006                                .getLocation();
1007                Path resultPath = new Path("");
1008                if ((logFilePath != null) && (workspacePath.isPrefixOf(logFilePath))) {
1009                        resultPath = (Path) logFilePath.makeRelativeTo(workspacePath);
1010                }
1011                return resultPath;
1012        }
1013 
1014        /*
1015         * (non-Javadoc)
1016         * 
1017         * @see
1018         * org.eclipse.debug.ui.ILaunchConfigurationTab#initializeFrom(org.eclipse
1019         * .debug.core.ILaunchConfiguration)
1020         */
1021        public void initializeFrom(final ILaunchConfiguration configuration) {
1022                // Try to retrieve the settings from the given configuration:
1023                try {
1024                        checkMarkovStatistics.setSelection(configuration.getAttribute(
1025                                        MessageStrings.MARKOV_STATISTICS, STATISTICSDEFAULT));
1026                        checkSingleResults.setSelection(configuration.getAttribute(
1027                                        MessageStrings.SINGLE_RESULTS, SINGLERESULTSDEFAULT));
1028                        checkNumberOfEvaluatedSystemStates
1029                                        .setSelection(configuration
1030                                                        .getAttribute(
1031                                                                        MessageStrings.NUMBER_OF_EVALUATED_SYSTEM_STATES_ENABLED,
1032                                                                        false));
1033                        checkNumberOfExactDecimalPlaces
1034                                        .setSelection(configuration
1035                                                        .getAttribute(
1036                                                                        MessageStrings.NUMBER_OF_EXACT_DECIMAL_PLACES_ENABLED,
1037                                                                        false));
1038                        checkSolvingTimeLimit.setSelection(configuration.getAttribute(
1039                                        MessageStrings.SOLVING_TIME_LIMIT_ENABLED, false));
1040                        spinnerNumberOfEvaluatedSystemStates.setSelection(configuration
1041                                        .getAttribute(
1042                                                        MessageStrings.NUMBER_OF_EVALUATED_SYSTEM_STATES,
1043                                                        NUMBER_OF_EVALUATED_SYSTEM_STATES));
1044                        spinnerNumberOfExactDecimalPlaces.setSelection(configuration
1045                                        .getAttribute(
1046                                                        MessageStrings.NUMBER_OF_EXACT_DECIMAL_PLACES,
1047                                                        NUMBER_OF_EXACT_DECIMAL_PLACES));
1048                        spinnerSolvingTimeLimit.setSelection(configuration.getAttribute(
1049                                        MessageStrings.SOLVING_TIME_LIMIT, SOLVING_TIME_LIMIT));
1050                        textLogFile.setEnabled(configuration.getAttribute(
1051                                        MessageStrings.SINGLE_RESULTS, SINGLERESULTSDEFAULT));
1052                        textLogFile.setText(configuration.getAttribute(
1053                                        MessageStrings.LOG_FILE, LOGFILEDEFAULT));
1054                        buttonWorkspaceFileDialogLogFile.setEnabled(configuration
1055                                        .getAttribute(MessageStrings.SINGLE_RESULTS,
1056                                                        SINGLERESULTSDEFAULT));
1057                        buttonFileSystemFileDialogLogFile.setEnabled(configuration
1058                                        .getAttribute(MessageStrings.SINGLE_RESULTS,
1059                                                        SINGLERESULTSDEFAULT));
1060                        checkOptimize.setSelection(configuration.getAttribute(
1061                                        MessageStrings.MARKOV_MODEL_REDUCTION_ENABLED,
1062                                        MARKOV_MODEL_REDUCTION_ENABLED));
1063                        checkMarkovModelTraces.setSelection(configuration.getAttribute(
1064                                        MessageStrings.MARKOV_MODEL_TRACES_ENABLED,
1065                                        MARKOV_MODEL_TRACES_ENABLED));
1066                        checkIterateOverPhysicalSystemStates
1067                                        .setSelection(configuration
1068                                                        .getAttribute(
1069                                                                        MessageStrings.ITERATION_OVER_PHYSICAL_SYSTEM_STATES_ENABLED,
1070                                                                        ITERATION_OVER_PHYSICAL_SYSTEM_STATES_ENABLED));
1071                        checkStoreMarkovModel.setSelection(configuration.getAttribute(
1072                                        MessageStrings.MARKOV_MODEL_STORAGE_ENABLED,
1073                                        MARKOV_MODEL_STORAGE_ENABLED));
1074                        textMarkovModelFile.setEnabled(configuration.getAttribute(
1075                                        MessageStrings.MARKOV_MODEL_STORAGE_ENABLED,
1076                                        MARKOV_MODEL_STORAGE_ENABLED));
1077                        textMarkovModelFile.setText(configuration.getAttribute(
1078                                        MessageStrings.MARKOV_MODEL_FILE, MARKOVMODELFILEDEFAULT));
1079                        buttonWorkspaceFileDialogModelFile.setEnabled(configuration
1080                                        .getAttribute(MessageStrings.MARKOV_MODEL_STORAGE_ENABLED,
1081                                                        MARKOV_MODEL_STORAGE_ENABLED));
1082                        buttonFileSystemFileDialogModelFile.setEnabled(configuration
1083                                        .getAttribute(MessageStrings.MARKOV_MODEL_STORAGE_ENABLED,
1084                                                        MARKOV_MODEL_STORAGE_ENABLED));
1085 
1086                        checkSaveResultsToFile.setSelection(configuration.getAttribute(
1087                                        MessageStrings.SAVE_RESULTS_TO_FILE_ENABLED,
1088                                        SAVE_RESULTS_TO_FILE_ENABLED));
1089                        textSaveResultsToFile.setEnabled(configuration.getAttribute(
1090                                        MessageStrings.SAVE_RESULTS_TO_FILE_ENABLED,
1091                                        SAVE_RESULTS_TO_FILE_ENABLED));
1092                        textSaveResultsToFile.setText(configuration.getAttribute(
1093                                        MessageStrings.SAVE_FILE_DEFAULT, SAVE_FILE_DEFAULT));
1094                        buttonWorkspaceFileDialogSaveToFile.setEnabled(configuration
1095                                        .getAttribute(MessageStrings.SAVE_RESULTS_TO_FILE_ENABLED,
1096                                                        SAVE_RESULTS_TO_FILE_ENABLED));
1097                        buttonFileSystemFileDialogSaveToFile.setEnabled(configuration
1098                                        .getAttribute(MessageStrings.SAVE_RESULTS_TO_FILE_ENABLED,
1099                                                        SAVE_RESULTS_TO_FILE_ENABLED));
1100 
1101                        MarkovEvaluationType evalType;
1102                        try {
1103                                evalType = MarkovEvaluationType.valueOf(configuration
1104                                                .getAttribute(MessageStrings.MARKOV_EVALUATION_MODE,
1105                                                                MARKOV_EVALUATION_MODE.toString()));
1106                        } catch (IllegalArgumentException e) {
1107                                evalType = MARKOV_EVALUATION_MODE;
1108                        }
1109                        radioFailureCategories
1110                                        .setSelection(MarkovEvaluationType.CLASSES == evalType);
1111                        radioPointsOfFailure
1112                                        .setSelection(MarkovEvaluationType.POINTSOFFAILURE == evalType);
1113                        radioSingleFailureMode
1114                                        .setSelection(MarkovEvaluationType.SINGLE == evalType);
1115                        radioFailureTypes
1116                                        .setSelection(MarkovEvaluationType.TYPES == evalType);
1117                } catch (CoreException e) {
1118                        // Defaults apply:
1119                        checkMarkovStatistics.setSelection(STATISTICSDEFAULT);
1120                        checkSingleResults.setSelection(SINGLERESULTSDEFAULT);
1121                        checkNumberOfEvaluatedSystemStates
1122                                        .setSelection(NUMBER_OF_EVALUATED_SYSTEM_STATES_ENABLED);
1123                        spinnerNumberOfEvaluatedSystemStates
1124                                        .setSelection(NUMBER_OF_EVALUATED_SYSTEM_STATES);
1125                        checkNumberOfExactDecimalPlaces
1126                                        .setSelection(NUMBER_OF_EXACT_DECIMAL_PLACES_ENABLED);
1127                        spinnerNumberOfExactDecimalPlaces
1128                                        .setSelection(NUMBER_OF_EXACT_DECIMAL_PLACES);
1129                        checkSolvingTimeLimit.setSelection(SOLVING_TIME_LIMIT_ENABLED);
1130                        spinnerSolvingTimeLimit.setSelection(SOLVING_TIME_LIMIT);
1131                        textLogFile.setEnabled(SINGLERESULTSDEFAULT);
1132                        textLogFile.setText(LOGFILEDEFAULT);
1133                        buttonWorkspaceFileDialogLogFile.setEnabled(SINGLERESULTSDEFAULT);
1134                        buttonFileSystemFileDialogLogFile.setEnabled(SINGLERESULTSDEFAULT);
1135                        checkOptimize.setSelection(MARKOV_MODEL_REDUCTION_ENABLED);
1136                        checkMarkovModelTraces.setSelection(MARKOV_MODEL_TRACES_ENABLED);
1137                        checkIterateOverPhysicalSystemStates
1138                                        .setSelection(ITERATION_OVER_PHYSICAL_SYSTEM_STATES_ENABLED);
1139                        checkStoreMarkovModel.setSelection(MARKOV_MODEL_STORAGE_ENABLED);
1140                        textMarkovModelFile.setEnabled(MARKOV_MODEL_STORAGE_ENABLED);
1141                        textMarkovModelFile.setText(MARKOVMODELFILEDEFAULT);
1142                        buttonWorkspaceFileDialogModelFile
1143                                        .setEnabled(MARKOV_MODEL_STORAGE_ENABLED);
1144                        buttonFileSystemFileDialogModelFile
1145                                        .setEnabled(MARKOV_MODEL_STORAGE_ENABLED);
1146                        radioSingleFailureMode
1147                                        .setSelection(MarkovEvaluationType.SINGLE == MARKOV_EVALUATION_MODE);
1148                        radioFailureCategories
1149                                        .setSelection(MarkovEvaluationType.CLASSES == MARKOV_EVALUATION_MODE);
1150                        radioFailureTypes
1151                                        .setSelection(MarkovEvaluationType.TYPES == MARKOV_EVALUATION_MODE);
1152                        radioPointsOfFailure
1153                                        .setSelection(MarkovEvaluationType.POINTSOFFAILURE == MARKOV_EVALUATION_MODE);
1154 
1155                        checkSaveResultsToFile.setSelection(SAVE_RESULTS_TO_FILE_ENABLED);
1156                        textSaveResultsToFile.setEnabled(SAVE_RESULTS_TO_FILE_ENABLED);
1157                        textSaveResultsToFile.setText(SAVE_FILE_DEFAULT);
1158                        buttonWorkspaceFileDialogSaveToFile
1159                                        .setEnabled(SAVE_RESULTS_TO_FILE_ENABLED);
1160                        buttonFileSystemFileDialogSaveToFile
1161                                        .setEnabled(SAVE_RESULTS_TO_FILE_ENABLED);
1162                }
1163 
1164                // Update the state of the dialog:
1165                updateLaunchConfigurationDialog();
1166                updateFieldsEnablement();
1167        }
1168 
1169        /*
1170         * (non-Javadoc)
1171         * 
1172         * @see
1173         * org.eclipse.debug.ui.AbstractLaunchConfigurationTab#isValid(org.eclipse
1174         * .debug.core.ILaunchConfiguration)
1175         */
1176        public boolean isValid(final ILaunchConfiguration configuration) {
1177                // single result logging enabled?
1178                if (checkSingleResults.getSelection()) {
1179                        if (getCurrentFilePath(resolvePath(textLogFile.getText().trim())) == null) {
1180                                setErrorMessage("Invalid log file!");
1181                                return false;
1182                        } else if (getCurrentFilePath(
1183                                        resolveFile(textLogFile.getText().trim())).toFile()
1184                                        .isDirectory()) {
1185                                setErrorMessage("Log file is a directory!");
1186                                return false;
1187                        } else if (!getCurrentFilePath(
1188                                        resolvePath(textLogFile.getText().trim())).toFile()
1189                                        .getParentFile().exists()) {
1190                                setErrorMessage("Log file directory does not exist!");
1191                                return false;
1192                        }
1193                }
1194                if (checkStoreMarkovModel.getSelection()) {
1195                        if (getCurrentFilePath(resolvePath(textMarkovModelFile.getText()
1196                                        .trim())) == null) {
1197                                setErrorMessage("Invalid Markov model file!");
1198                                return false;
1199                        } else if (getCurrentFilePath(
1200                                        resolveFile(textMarkovModelFile.getText().trim())).toFile()
1201                                        .isDirectory()) {
1202                                setErrorMessage("Markov model file is a directory!");
1203                                return false;
1204                        } else if (!getCurrentFilePath(
1205                                        resolvePath(textMarkovModelFile.getText().trim())).toFile()
1206                                        .getParentFile().exists()) {
1207                                setErrorMessage("Markov model file directory does not exist!");
1208                                return false;
1209                        }
1210                }
1211                if (checkSaveResultsToFile.getSelection()) {
1212                        if (getCurrentFilePath(resolvePath(textSaveResultsToFile.getText()
1213                                        .trim())) == null) {
1214                                setErrorMessage("Invalid results file!");
1215                                return false;
1216                        } else if (getCurrentFilePath(
1217                                        resolveFile(textSaveResultsToFile.getText().trim()))
1218                                        .toFile().isDirectory()) {
1219                                setErrorMessage("Results file is a directory!");
1220                                return false;
1221                        } else if (!getCurrentFilePath(
1222                                        resolvePath(textSaveResultsToFile.getText().trim()))
1223                                        .toFile().getParentFile().exists()) {
1224                                setErrorMessage("Results file directory does not exist!");
1225                                return false;
1226                        }
1227                }
1228 
1229                setErrorMessage(null); // will clear any error messages shown
1230                return true;
1231        }
1232 
1233        /*
1234         * (non-Javadoc)
1235         * 
1236         * @see
1237         * org.eclipse.debug.ui.ILaunchConfigurationTab#performApply(org.eclipse
1238         * .debug.core.ILaunchConfigurationWorkingCopy)
1239         */
1240        public void performApply(final ILaunchConfigurationWorkingCopy configuration) {
1241                // Store the settings into the configuration:
1242                configuration.setAttribute(MessageStrings.MARKOV_STATISTICS,
1243                                checkMarkovStatistics.getSelection());
1244                configuration.setAttribute(MessageStrings.SINGLE_RESULTS,
1245                                checkSingleResults.getSelection());
1246 
1247                configuration.setAttribute(
1248                                MessageStrings.NUMBER_OF_EVALUATED_SYSTEM_STATES_ENABLED,
1249                                checkNumberOfEvaluatedSystemStates.getSelection());
1250                configuration.setAttribute(
1251                                MessageStrings.NUMBER_OF_EVALUATED_SYSTEM_STATES, Integer
1252                                                .parseInt(spinnerNumberOfEvaluatedSystemStates
1253                                                                .getText()));
1254 
1255                configuration.setAttribute(
1256                                MessageStrings.NUMBER_OF_EXACT_DECIMAL_PLACES_ENABLED,
1257                                checkNumberOfExactDecimalPlaces.getSelection());
1258                configuration.setAttribute(
1259                                MessageStrings.NUMBER_OF_EXACT_DECIMAL_PLACES, Integer
1260                                                .parseInt(spinnerNumberOfExactDecimalPlaces.getText()));
1261 
1262                configuration.setAttribute(MessageStrings.SOLVING_TIME_LIMIT_ENABLED,
1263                                checkSolvingTimeLimit.getSelection());
1264                configuration.setAttribute(MessageStrings.SOLVING_TIME_LIMIT, Integer
1265                                .parseInt(spinnerSolvingTimeLimit.getText()));
1266 
1267                configuration.setAttribute(MessageStrings.LOG_FILE, textLogFile
1268                                .getText().trim());
1269 
1270                configuration.setAttribute(
1271                                MessageStrings.MARKOV_MODEL_REDUCTION_ENABLED, checkOptimize
1272                                                .getSelection());
1273 
1274                configuration.setAttribute(MessageStrings.MARKOV_MODEL_TRACES_ENABLED,
1275                                checkMarkovModelTraces.getSelection());
1276 
1277                configuration.setAttribute(
1278                                MessageStrings.ITERATION_OVER_PHYSICAL_SYSTEM_STATES_ENABLED,
1279                                checkIterateOverPhysicalSystemStates.getSelection());
1280 
1281                configuration.setAttribute(MessageStrings.MARKOV_MODEL_STORAGE_ENABLED,
1282                                checkStoreMarkovModel.getSelection());
1283                configuration.setAttribute(MessageStrings.MARKOV_MODEL_FILE,
1284                                textMarkovModelFile.getText().trim());
1285 
1286                if (radioSingleFailureMode.getSelection()) {
1287                        configuration.setAttribute(MessageStrings.MARKOV_EVALUATION_MODE,
1288                                        MarkovEvaluationType.SINGLE.toString());
1289                } else if (radioFailureCategories.getSelection()) {
1290                        configuration.setAttribute(MessageStrings.MARKOV_EVALUATION_MODE,
1291                                        MarkovEvaluationType.CLASSES.toString());
1292                } else if (radioFailureTypes.getSelection()) {
1293                        configuration.setAttribute(MessageStrings.MARKOV_EVALUATION_MODE,
1294                                        MarkovEvaluationType.TYPES.toString());
1295                } else if (radioPointsOfFailure.getSelection()) {
1296                        configuration.setAttribute(MessageStrings.MARKOV_EVALUATION_MODE,
1297                                        MarkovEvaluationType.POINTSOFFAILURE.toString());
1298                }
1299 
1300                configuration.setAttribute(MessageStrings.SAVE_RESULTS_TO_FILE_ENABLED,
1301                                checkSaveResultsToFile.getSelection());
1302                configuration.setAttribute(MessageStrings.SAVE_FILE_DEFAULT,
1303                                textSaveResultsToFile.getText().trim());
1304        }
1305 
1306        /**
1307         * Resolves a file's path in case it starts with "platform:/" and returns
1308         * the entire absolute path to the file, including the file's name.
1309         * 
1310         * @param fileURL
1311         *            the path to a file, including the file's name (and its
1312         *            extension)
1313         * @return the absolute path to the file, including the file's name
1314         */
1315        private String resolveFile(String fileURL) {
1316                // if this is a platform URL, first resolve it to an absolute path
1317                if (fileURL.startsWith("platform:")) {
1318                        try {
1319                                URL solvedURL = FileLocator.resolve(new URL(fileURL));
1320                                fileURL = solvedURL.getPath();
1321                        } catch (Exception e) {
1322                                e.printStackTrace();
1323                                return "";
1324                        }
1325                }
1326                return fileURL;
1327        }
1328 
1329        /** returns the path including the last slash */
1330        private String resolvePath(String fileURL) {
1331                // if this is a platform URL, first resolve it to an absolute path
1332                if (fileURL.startsWith("platform:")) {
1333                        try {
1334                                URL solvedURL = FileLocator.resolve(new URL(fileURL));
1335                                fileURL = solvedURL.getPath();
1336                        } catch (Exception e) {
1337                                e.printStackTrace();
1338                                return "";
1339                        }
1340                }
1341 
1342                // now this should be an absolute path, but it can have either slashes
1343                // or backslashes
1344                int indexBackslash = fileURL.lastIndexOf("\\");
1345                int indexSlash = fileURL.lastIndexOf("/");
1346                // the right directory separator is the one where the above results in
1347                // the higher index (assuming that linux file systems do not allow
1348                // backslashes in file names...)
1349                int index = indexBackslash > indexSlash ? indexBackslash : indexSlash;
1350                String folderPath = fileURL.substring(0, index + 1);
1351                return folderPath;
1352        }
1353 
1354        /*
1355         * (non-Javadoc)
1356         * 
1357         * @see
1358         * org.eclipse.debug.ui.ILaunchConfigurationTab#setDefaults(org.eclipse.
1359         * debug.core.ILaunchConfigurationWorkingCopy)
1360         */
1361        public void setDefaults(final ILaunchConfigurationWorkingCopy configuration) {
1362                // Load default settings into the configuration:
1363                configuration.setAttribute(MessageStrings.MARKOV_STATISTICS,
1364                                STATISTICSDEFAULT);
1365                configuration.setAttribute(MessageStrings.SINGLE_RESULTS,
1366                                SINGLERESULTSDEFAULT);
1367                configuration.setAttribute(
1368                                MessageStrings.NUMBER_OF_EVALUATED_SYSTEM_STATES_ENABLED,
1369                                NUMBER_OF_EVALUATED_SYSTEM_STATES_ENABLED);
1370                configuration.setAttribute(
1371                                MessageStrings.NUMBER_OF_EVALUATED_SYSTEM_STATES,
1372                                NUMBER_OF_EVALUATED_SYSTEM_STATES);
1373                configuration.setAttribute(
1374                                MessageStrings.NUMBER_OF_EXACT_DECIMAL_PLACES_ENABLED,
1375                                NUMBER_OF_EXACT_DECIMAL_PLACES_ENABLED);
1376                configuration.setAttribute(
1377                                MessageStrings.NUMBER_OF_EXACT_DECIMAL_PLACES,
1378                                NUMBER_OF_EXACT_DECIMAL_PLACES);
1379                configuration.setAttribute(MessageStrings.SOLVING_TIME_LIMIT_ENABLED,
1380                                SOLVING_TIME_LIMIT_ENABLED);
1381                configuration.setAttribute(MessageStrings.SOLVING_TIME_LIMIT,
1382                                SOLVING_TIME_LIMIT);
1383                configuration.setAttribute(MessageStrings.LOG_FILE, LOGFILEDEFAULT);
1384                configuration.setAttribute(
1385                                MessageStrings.MARKOV_MODEL_REDUCTION_ENABLED,
1386                                MARKOV_MODEL_REDUCTION_ENABLED);
1387                configuration.setAttribute(MessageStrings.MARKOV_MODEL_TRACES_ENABLED,
1388                                MARKOV_MODEL_TRACES_ENABLED);
1389                configuration.setAttribute(
1390                                MessageStrings.ITERATION_OVER_PHYSICAL_SYSTEM_STATES_ENABLED,
1391                                ITERATION_OVER_PHYSICAL_SYSTEM_STATES_ENABLED);
1392                configuration.setAttribute(MessageStrings.MARKOV_MODEL_STORAGE_ENABLED,
1393                                MARKOV_MODEL_STORAGE_ENABLED);
1394                configuration.setAttribute(MessageStrings.MARKOV_MODEL_FILE,
1395                                MARKOVMODELFILEDEFAULT);
1396                configuration.setAttribute(MessageStrings.MARKOV_EVALUATION_MODE,
1397                                MARKOV_EVALUATION_MODE.toString());
1398        }
1399 
1400        /**
1401         * Updates the status of the spinner fields.
1402         */
1403        private void updateFieldsEnablement() {
1404                spinnerNumberOfEvaluatedSystemStates
1405                                .setEnabled(checkNumberOfEvaluatedSystemStates.getSelection());
1406                spinnerNumberOfExactDecimalPlaces
1407                                .setEnabled(checkNumberOfExactDecimalPlaces.getSelection());
1408                spinnerSolvingTimeLimit
1409                                .setEnabled(checkSolvingTimeLimit.getSelection());
1410                textLogFile.setEnabled(checkSingleResults.getSelection());
1411                buttonWorkspaceFileDialogLogFile.setEnabled(checkSingleResults
1412                                .getSelection());
1413                buttonFileSystemFileDialogLogFile.setEnabled(checkSingleResults
1414                                .getSelection());
1415                textMarkovModelFile.setEnabled(checkStoreMarkovModel.getSelection());
1416                buttonWorkspaceFileDialogModelFile.setEnabled(checkStoreMarkovModel
1417                                .getSelection());
1418                buttonFileSystemFileDialogModelFile.setEnabled(checkStoreMarkovModel
1419                                .getSelection());
1420                textSaveResultsToFile.setEnabled(checkSaveResultsToFile.getSelection());
1421                buttonWorkspaceFileDialogSaveToFile.setEnabled(checkSaveResultsToFile
1422                                .getSelection());
1423                buttonFileSystemFileDialogSaveToFile.setEnabled(checkSaveResultsToFile
1424                                .getSelection());
1425        }
1426}

[all classes][de.uka.ipd.sdq.reliability.solver.runconfig]
EMMA 2.0.9414 (unsupported private build) (C) Vladimir Roubtsov