1 | package de.uka.ipd.sdq.cip.runtime.wizards; |
2 | |
3 | |
4 | import org.eclipse.jface.wizard.WizardPage; |
5 | import org.eclipse.swt.SWT; |
6 | import org.eclipse.swt.widgets.Composite; |
7 | |
8 | import de.uka.ipd.sdq.cip.completions.RegisteredCompletion; |
9 | import de.uka.ipd.sdq.cip.configuration.TransformationType; |
10 | import de.uka.ipd.sdq.cip.configuration.Transformation.TransformationQVTType; |
11 | import de.uka.ipd.sdq.cip.runtime.dialogs.CompletionConfigurationWidget; |
12 | import de.uka.ipd.sdq.cip.runtime.wizards.CompletionConfigNode.FeatureConfig; |
13 | import de.uka.ipd.sdq.cip.runtime.wizards.CompletionConfigNode.UserDefined; |
14 | import de.uka.ipd.sdq.cip.runtime.wizards.CompletionConfigNode.UserDefinedID; |
15 | |
16 | public class CompletionConfigurationPage extends WizardPage { |
17 | |
18 | private CompletionConfigurationWidget completionConfigurationWidget = null; |
19 | |
20 | protected CompletionConfigurationPage(String pageName) { |
21 | super(pageName); |
22 | completionConfigurationWidget = new CompletionConfigurationWidget(); |
23 | } |
24 | |
25 | @Override |
26 | public void createControl(Composite parent) { |
27 | Composite mainComponent = new Composite(parent, SWT.NONE); |
28 | |
29 | completionConfigurationWidget.createControl(mainComponent); |
30 | |
31 | setControl(mainComponent); |
32 | |
33 | } |
34 | |
35 | public boolean canFinish() { |
36 | CompletionSelectionPage prevpage = (CompletionSelectionPage) getWizard().getPreviousPage(this); |
37 | Object element = prevpage.getSelection(); |
38 | if(element instanceof RegisteredCompletion) { |
39 | if(getFile1Text() != null) |
40 | return true; |
41 | } |
42 | if(element instanceof UserDefined) { |
43 | UserDefined userDefined = (UserDefined) element; |
44 | if(userDefined.getID() == UserDefinedID.ANNOTATED) { |
45 | if(getFile1Text() != null && getFile2Text() != null && getFile3Text() != null) |
46 | return true; |
47 | } |
48 | else { |
49 | if(getFile1Text() != null) |
50 | return true; |
51 | } |
52 | } |
53 | return false; |
54 | } |
55 | |
56 | @Override |
57 | public void setVisible(boolean visible) { |
58 | CompletionSelectionPage prevpage = (CompletionSelectionPage) getWizard().getPreviousPage(this); |
59 | Object element = prevpage.getSelection(); |
60 | |
61 | TransformationType type = TransformationType.NONE; |
62 | TransformationQVTType qvtType = TransformationQVTType.QVTR; |
63 | |
64 | if(element instanceof RegisteredCompletion) { |
65 | type = TransformationType.REGISTERED; |
66 | } |
67 | else if(element instanceof FeatureConfig) |
68 | { |
69 | type = TransformationType.FEATURE; |
70 | } |
71 | else if(element instanceof UserDefined) { |
72 | UserDefined userDefined = (UserDefined) element; |
73 | if(userDefined.getID() == UserDefinedID.ANNOTATED) { |
74 | type = TransformationType.ANNOTATED; |
75 | } |
76 | else if(userDefined.getID() == UserDefinedID.PLAIN) { |
77 | type = TransformationType.PLAIN; |
78 | } |
79 | // QVTO completion |
80 | else if(userDefined.getID() == UserDefinedID.PLAINQVTO) { |
81 | type = TransformationType.PLAIN; |
82 | qvtType = TransformationQVTType.QVTO; |
83 | |
84 | } |
85 | else if(userDefined.getID() == UserDefinedID.FEATURECONFIG) { |
86 | type = TransformationType.FEATURE; |
87 | } |
88 | } |
89 | |
90 | completionConfigurationWidget.setVisible(type,qvtType); |
91 | |
92 | super.setVisible(visible); |
93 | } |
94 | |
95 | public String getFile1Text() { |
96 | return completionConfigurationWidget.getFile1Text(); |
97 | } |
98 | |
99 | public String getFile2Text() { |
100 | return completionConfigurationWidget.getFile2Text(); |
101 | } |
102 | |
103 | public String getFile3Text() { |
104 | return completionConfigurationWidget.getFile3Text(); |
105 | } |
106 | |
107 | |
108 | |
109 | |
110 | } |