1 | /** |
2 | * |
3 | */ |
4 | package de.uka.ipd.sdq.dsexplore.launch; |
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.events.ModifyEvent; |
11 | import org.eclipse.swt.events.ModifyListener; |
12 | import org.eclipse.swt.widgets.Composite; |
13 | import org.eclipse.swt.widgets.Text; |
14 | |
15 | import de.uka.ipd.sdq.workflow.launchconfig.RunConfigPlugin; |
16 | import de.uka.ipd.sdq.workflow.launchconfig.tabs.TabHelper; |
17 | import de.uka.ipd.sdq.workflow.pcm.runconfig.FileNamesInputTab; |
18 | |
19 | /** |
20 | * The DSEFileNamesInputTab has additional QML logic. |
21 | * |
22 | * @author noorshams |
23 | * |
24 | */ |
25 | public class DSEFileNamesInputTab extends FileNamesInputTab { |
26 | |
27 | protected Text textQMLDefinitionFile; |
28 | |
29 | protected QMLManager qmlManager; |
30 | |
31 | public DSEFileNamesInputTab(QMLManager qmlManager) { |
32 | super(); |
33 | this.qmlManager = qmlManager; |
34 | } |
35 | |
36 | @Override |
37 | public void createControl(Composite parent) { |
38 | super.createControl(parent); |
39 | |
40 | final ModifyListener modifyListener = new ModifyListener() { |
41 | |
42 | public void modifyText(ModifyEvent e) { |
43 | DSEFileNamesInputTab.this.setDirty(true); |
44 | DSEFileNamesInputTab.this.updateLaunchConfigurationDialog(); |
45 | } |
46 | }; |
47 | |
48 | |
49 | /** |
50 | * Add QML input section |
51 | */ |
52 | this.textQMLDefinitionFile = new Text(container, SWT.SINGLE | SWT.BORDER); |
53 | String[] qmlExtension = new String[1]; |
54 | qmlExtension[0] = DSEConstantsContainer.QML_DEFINITION_EXTENSION; |
55 | TabHelper.createFileInputSection(container, modifyListener, "QML Criteria Definitions", qmlExtension, textQMLDefinitionFile, getShell(), DSEConstantsContainer.DEFAULT_QML_CRITERIA_DEFINITIONS_FILE); |
56 | } |
57 | |
58 | protected void loadQML() { |
59 | qmlManager.processQMLFile(textQMLDefinitionFile.getText(), textUsage.getText()); |
60 | } |
61 | |
62 | @Override |
63 | public void initializeFrom(ILaunchConfiguration configuration) { |
64 | super.initializeFrom(configuration); |
65 | |
66 | try { |
67 | String currentQMLPath = configuration.getAttribute(DSEConstantsContainer.QML_DEFINITION_FILE, ""); |
68 | this.textQMLDefinitionFile.setText(currentQMLPath); |
69 | } catch (CoreException e) { |
70 | RunConfigPlugin.errorLogger(getName(),DSEConstantsContainer.QML_DEFINITION_FILE, e.getMessage()); |
71 | } |
72 | |
73 | loadQML(); |
74 | } |
75 | |
76 | @Override |
77 | public void performApply(ILaunchConfigurationWorkingCopy configuration) { |
78 | super.performApply(configuration); |
79 | |
80 | configuration.setAttribute( |
81 | DSEConstantsContainer.QML_DEFINITION_FILE, |
82 | this.textQMLDefinitionFile.getText()); |
83 | |
84 | loadQML(); |
85 | } |
86 | |
87 | @Override |
88 | public boolean isValid(ILaunchConfiguration launchConfig) { |
89 | setErrorMessage(null); |
90 | |
91 | if(!qmlManager.isQMLLoaded()){ |
92 | String errorMessage = "Select Usage Model and load QML Definition! For help, click the help button (?) in the bottom-left corner."; |
93 | if(qmlManager.getDiagnosis() != null) { |
94 | errorMessage += " "+qmlManager.getDiagnosis(); |
95 | } |
96 | setErrorMessage(errorMessage); |
97 | return false; |
98 | } else if(!qmlManager.hasActivatedObjectives()) { |
99 | setErrorMessage("No objectives for specified UsageModel found in QML Definition. Make sure the right UsageModel is referenced and objectives are defined."); |
100 | return false; |
101 | } |
102 | return super.isValid(launchConfig); |
103 | } |
104 | } |