1 | package de.uka.ipd.sdq.cip.runtime.wizards; |
2 | |
3 | import org.eclipse.jface.wizard.Wizard; |
4 | |
5 | import de.uka.ipd.sdq.cip.completions.RegisteredCompletion; |
6 | import de.uka.ipd.sdq.cip.configuration.Transformation; |
7 | import de.uka.ipd.sdq.cip.configuration.TransformationType; |
8 | import de.uka.ipd.sdq.cip.configuration.Transformation.TransformationQVTType; |
9 | import de.uka.ipd.sdq.cip.ConstantsContainer; |
10 | import de.uka.ipd.sdq.cip.runtime.RunConfigImages; |
11 | import de.uka.ipd.sdq.cip.runtime.wizards.CompletionConfigNode.FeatureConfig; |
12 | import de.uka.ipd.sdq.cip.runtime.wizards.CompletionConfigNode.UserDefined; |
13 | import de.uka.ipd.sdq.cip.runtime.wizards.CompletionConfigNode.UserDefinedID; |
14 | |
15 | public class NewCompletionWizard extends Wizard { |
16 | |
17 | private CompletionSelectionPage completionSelectionPage; |
18 | private CompletionConfigurationPage completionConfigurationPage; |
19 | private Transformation transformation = null; |
20 | |
21 | public NewCompletionWizard() { |
22 | transformation = new Transformation(); |
23 | } |
24 | |
25 | @Override |
26 | public boolean performFinish() { |
27 | |
28 | transformation.setEnabled(true); |
29 | |
30 | Object element = completionSelectionPage.getSelection(); |
31 | if(element instanceof FeatureConfig) { |
32 | FeatureConfig featureConfig = (FeatureConfig) element; |
33 | transformation.setType(TransformationType.FEATURE); |
34 | transformation.setQVTType(TransformationQVTType.QVTR); |
35 | transformation.setFeatureFileURI(featureConfig.getFileURI()); |
36 | } |
37 | else if(element instanceof RegisteredCompletion) { |
38 | RegisteredCompletion completion = (RegisteredCompletion) element; |
39 | transformation.setType(TransformationType.REGISTERED); |
40 | transformation.setCompletion(completion.getId()); |
41 | if(completion.containsCategory(ConstantsContainer.MARK_COMPLETION)) |
42 | transformation.setConfigFileURI(completionConfigurationPage.getFile1Text()); |
43 | } |
44 | else if(element instanceof UserDefined) { |
45 | UserDefined userDefined = (UserDefined) element; |
46 | if(userDefined.getID() == UserDefinedID.ANNOTATED) { |
47 | transformation.setType(TransformationType.ANNOTATED); |
48 | transformation.setQVTType(TransformationQVTType.QVTR); |
49 | transformation.setQVTFileURI(completionConfigurationPage.getFile1Text()); |
50 | transformation.setConfigFileURI(completionConfigurationPage.getFile2Text()); |
51 | transformation.setMetamodelFileURI(completionConfigurationPage.getFile3Text()); |
52 | } |
53 | else if(userDefined.getID() == UserDefinedID.PLAIN) { |
54 | transformation.setType(TransformationType.PLAIN); |
55 | transformation.setQVTType(TransformationQVTType.QVTR); |
56 | transformation.setQVTFileURI(completionConfigurationPage.getFile1Text()); |
57 | } |
58 | else if(userDefined.getID() == UserDefinedID.PLAINQVTO) { |
59 | transformation.setType(TransformationType.PLAIN); |
60 | transformation.setQVTType(TransformationQVTType.QVTO); |
61 | transformation.setQVTFileURI(completionConfigurationPage.getFile1Text()); |
62 | transformation.setOptionalModelFileURI(completionConfigurationPage.getFile2Text()); |
63 | } |
64 | else if(userDefined.getID() == UserDefinedID.FEATURECONFIG) { |
65 | transformation.setType(TransformationType.FEATURE); |
66 | transformation.setQVTType(TransformationQVTType.QVTR); |
67 | transformation.setFeatureFileURI(completionConfigurationPage.getFile1Text()); |
68 | } |
69 | } |
70 | return true; |
71 | } |
72 | |
73 | @Override |
74 | public void addPages() { |
75 | setDefaultPageImageDescriptor(RunConfigImages.getChiliIconDescriptor()); |
76 | completionSelectionPage = new CompletionSelectionPage("CompletionType"); |
77 | completionSelectionPage.setTitle("Select Completion Type"); |
78 | completionSelectionPage.setDescription("Select a Completion type and configure it."); |
79 | addPage(completionSelectionPage); |
80 | completionConfigurationPage = new CompletionConfigurationPage("CompletionConfiguration"); |
81 | completionConfigurationPage.setTitle("Set Completion Configuration"); |
82 | completionConfigurationPage.setDescription("Add configuration files to the completion."); |
83 | addPage(completionConfigurationPage); |
84 | } |
85 | |
86 | @Override |
87 | public boolean canFinish() { |
88 | if(completionSelectionPage.canFinish()) |
89 | return true; |
90 | if(completionConfigurationPage.canFinish()) |
91 | return true; |
92 | return false; |
93 | } |
94 | |
95 | public Transformation getTransformation() { |
96 | return transformation; |
97 | } |
98 | |
99 | } |