| 1 | /** |
| 2 | * |
| 3 | */ |
| 4 | package de.uka.ipd.sdq.reliability.solver.runconfig; |
| 5 | |
| 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.swt.SWT; |
| 10 | import org.eclipse.swt.layout.GridData; |
| 11 | import org.eclipse.swt.layout.GridLayout; |
| 12 | import org.eclipse.swt.widgets.Button; |
| 13 | import org.eclipse.swt.widgets.Composite; |
| 14 | import org.eclipse.swt.widgets.Group; |
| 15 | import org.eclipse.swt.widgets.Text; |
| 16 | |
| 17 | import de.uka.ipd.sdq.workflow.launchconfig.tabs.TabHelper; |
| 18 | import de.uka.ipd.sdq.workflow.pcm.ConstantsContainer; |
| 19 | import de.uka.ipd.sdq.workflow.pcm.runconfig.ConfigurationTab; |
| 20 | |
| 21 | /** |
| 22 | * @author brosch |
| 23 | * |
| 24 | */ |
| 25 | public class ReliabilityConfigurationTab extends ConfigurationTab { |
| 26 | |
| 27 | /** Label for the sensitivity analysis setting. */ |
| 28 | private static final String BUTTON_SENSITIVITY_LABEL = "Perform sensitivity analysis"; |
| 29 | /** Title of the sensitivity analysis group. */ |
| 30 | private static final String GROUP_SENSITIVITY_LABEL = "Sensitivity analysis"; |
| 31 | /** Label of the file selection field for the sensitivity results log file. */ |
| 32 | private static final String LOG_FILE_LABEL = "Sensitivity Result Log File"; |
| 33 | /** Label of the file selection field for the sensitivity model file. */ |
| 34 | private static final String SENSITIVITY_FILE_LABEL = "Sensitivity Model File"; |
| 35 | |
| 36 | /** Button used to enable/disable sensitivity analysis. */ |
| 37 | private Button sensitivityButton; |
| 38 | /** Text containing the location of the sensitivity model file. */ |
| 39 | private Text textResultLogFile; |
| 40 | /** Text containing the location of the sensitivity model file. */ |
| 41 | private Text textSensitivityFile; |
| 42 | |
| 43 | /* |
| 44 | * (non-Javadoc) |
| 45 | * |
| 46 | * @see |
| 47 | * de.uka.ipd.sdq.workflow.pcm.runconfig.ConfigurationTab#createFurtherSections |
| 48 | * (org.eclipse.swt.widgets.Composite) |
| 49 | */ |
| 50 | @Override |
| 51 | protected void createFurtherSections(Composite container) { |
| 52 | // Create sensitivity analysis section: |
| 53 | final Group sensitivityGroup = new Group(container, SWT.NONE); |
| 54 | sensitivityGroup.setText(GROUP_SENSITIVITY_LABEL); |
| 55 | final GridData gd_sensitivityGroup = new GridData(SWT.FILL, SWT.CENTER, |
| 56 | true, false); |
| 57 | sensitivityGroup.setLayoutData(gd_sensitivityGroup); |
| 58 | sensitivityGroup.setLayout(new GridLayout()); |
| 59 | sensitivityButton = new Button(sensitivityGroup, SWT.CHECK); |
| 60 | sensitivityButton.setLayoutData(gd_sensitivityGroup); |
| 61 | sensitivityButton.setText(BUTTON_SENSITIVITY_LABEL); |
| 62 | sensitivityButton.setSelection(false); |
| 63 | sensitivityButton.addSelectionListener(selectionListener); |
| 64 | textSensitivityFile = new Text(sensitivityGroup, SWT.SINGLE |
| 65 | | SWT.BORDER); |
| 66 | textSensitivityFile.setLayoutData(gd_sensitivityGroup); |
| 67 | textSensitivityFile.addModifyListener(modifyListener); |
| 68 | TabHelper.createFileInputSection(sensitivityGroup, modifyListener, |
| 69 | SENSITIVITY_FILE_LABEL, |
| 70 | ConstantsContainer.SENSITIVITY_ANALYSIS_EXTENSION, |
| 71 | textSensitivityFile, getShell(), |
| 72 | ConstantsContainer.DEFAULT_SENSITIVITY_MODEL_FILE); |
| 73 | textResultLogFile = new Text(sensitivityGroup, SWT.SINGLE | SWT.BORDER); |
| 74 | textResultLogFile.setLayoutData(gd_sensitivityGroup); |
| 75 | textResultLogFile.addModifyListener(modifyListener); |
| 76 | TabHelper.createFileInputSection(sensitivityGroup, modifyListener, |
| 77 | LOG_FILE_LABEL, ConstantsContainer.SENSITIVITY_LOG_EXTENSION, |
| 78 | textResultLogFile, getShell(), |
| 79 | ConstantsContainer.DEFAULT_SENSITIVITY_LOG_FILE); |
| 80 | } |
| 81 | |
| 82 | /* |
| 83 | * (non-Javadoc) |
| 84 | * |
| 85 | * @see |
| 86 | * de.uka.ipd.sdq.workflow.pcm.runconfig.ConfigurationTab#initializeFrom |
| 87 | * (org.eclipse.debug.core.ILaunchConfiguration) |
| 88 | */ |
| 89 | @Override |
| 90 | public void initializeFrom(ILaunchConfiguration configuration) { |
| 91 | super.initializeFrom(configuration); |
| 92 | try { |
| 93 | sensitivityButton.setSelection(configuration.getAttribute( |
| 94 | ConstantsContainer.DO_SENSITIVITY_ANALYSIS, |
| 95 | ConstantsContainer.DEFAULT_DO_SENSITIVITY_ANALYSIS)); |
| 96 | textSensitivityFile.setText(configuration.getAttribute( |
| 97 | ConstantsContainer.SENSITIVITY_MODEL_FILE, |
| 98 | ConstantsContainer.DEFAULT_SENSITIVITY_MODEL_FILE)); |
| 99 | textResultLogFile.setText(configuration.getAttribute( |
| 100 | ConstantsContainer.SENSITIVITY_LOG_FILE, |
| 101 | ConstantsContainer.DEFAULT_SENSITIVITY_LOG_FILE)); |
| 102 | } catch (CoreException e) { |
| 103 | sensitivityButton |
| 104 | .setSelection(ConstantsContainer.DEFAULT_DO_SENSITIVITY_ANALYSIS); |
| 105 | textSensitivityFile |
| 106 | .setText(ConstantsContainer.DEFAULT_SENSITIVITY_MODEL_FILE); |
| 107 | textResultLogFile |
| 108 | .setText(ConstantsContainer.DEFAULT_SENSITIVITY_LOG_FILE); |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | /* |
| 113 | * (non-Javadoc) |
| 114 | * |
| 115 | * @see |
| 116 | * de.uka.ipd.sdq.workflow.pcm.runconfig.ConfigurationTab#isValid(org.eclipse |
| 117 | * .debug.core.ILaunchConfiguration) |
| 118 | */ |
| 119 | @Override |
| 120 | public boolean isValid(ILaunchConfiguration launchConfig) { |
| 121 | if (!super.isValid(launchConfig)) { |
| 122 | return false; |
| 123 | } |
| 124 | if (sensitivityButton.getSelection() == true) { |
| 125 | if (!TabHelper.validateFilenameExtension(textSensitivityFile |
| 126 | .getText(), |
| 127 | ConstantsContainer.SENSITIVITY_ANALYSIS_EXTENSION)) { |
| 128 | setErrorMessage("Sensitivity Model File must be present for sensitivity analysis."); |
| 129 | return false; |
| 130 | } |
| 131 | if (!TabHelper.validateFilenameExtension(textResultLogFile |
| 132 | .getText(), ConstantsContainer.SENSITIVITY_LOG_EXTENSION)) { |
| 133 | setErrorMessage("Sensitivity Result Log File must be present for sensitivity analysis."); |
| 134 | return false; |
| 135 | } |
| 136 | } |
| 137 | return true; |
| 138 | } |
| 139 | |
| 140 | /* |
| 141 | * (non-Javadoc) |
| 142 | * |
| 143 | * @see |
| 144 | * de.uka.ipd.sdq.workflow.pcm.runconfig.ConfigurationTab#performApply(org |
| 145 | * .eclipse.debug.core.ILaunchConfigurationWorkingCopy) |
| 146 | */ |
| 147 | @Override |
| 148 | public void performApply(ILaunchConfigurationWorkingCopy configuration) { |
| 149 | super.performApply(configuration); |
| 150 | configuration.setAttribute(ConstantsContainer.DO_SENSITIVITY_ANALYSIS, |
| 151 | this.sensitivityButton.getSelection()); |
| 152 | configuration.setAttribute(ConstantsContainer.SENSITIVITY_MODEL_FILE, |
| 153 | this.textSensitivityFile.getText()); |
| 154 | configuration.setAttribute(ConstantsContainer.SENSITIVITY_LOG_FILE, |
| 155 | this.textResultLogFile.getText()); |
| 156 | } |
| 157 | |
| 158 | /* |
| 159 | * (non-Javadoc) |
| 160 | * |
| 161 | * @see |
| 162 | * de.uka.ipd.sdq.workflow.pcm.runconfig.ConfigurationTab#setDefaults(org |
| 163 | * .eclipse.debug.core.ILaunchConfigurationWorkingCopy) |
| 164 | */ |
| 165 | @Override |
| 166 | public void setDefaults(ILaunchConfigurationWorkingCopy configuration) { |
| 167 | super.setDefaults(configuration); |
| 168 | configuration.setAttribute(ConstantsContainer.DO_SENSITIVITY_ANALYSIS, |
| 169 | ConstantsContainer.DEFAULT_DO_SENSITIVITY_ANALYSIS); |
| 170 | configuration.setAttribute(ConstantsContainer.SENSITIVITY_MODEL_FILE, |
| 171 | ConstantsContainer.DEFAULT_SENSITIVITY_MODEL_FILE); |
| 172 | configuration.setAttribute(ConstantsContainer.SENSITIVITY_LOG_FILE, |
| 173 | ConstantsContainer.DEFAULT_SENSITIVITY_LOG_FILE); |
| 174 | } |
| 175 | |
| 176 | } |