| 1 | package de.uka.ipd.sdq.cip.runtime.dialogs; |
| 2 | |
| 3 | import org.eclipse.swt.SWT; |
| 4 | import org.eclipse.swt.layout.GridData; |
| 5 | import org.eclipse.swt.layout.GridLayout; |
| 6 | import org.eclipse.swt.widgets.Composite; |
| 7 | |
| 8 | import de.uka.ipd.sdq.cip.configuration.Transformation; |
| 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.ConstantsContainer; |
| 12 | |
| 13 | |
| 14 | public class CompletionConfigurationWidget { |
| 15 | |
| 16 | private FileSelectionWidget file1; |
| 17 | private FileSelectionWidget file2; |
| 18 | private FileSelectionWidget file3; |
| 19 | |
| 20 | public void createControl(Composite mainComponent) { |
| 21 | GridLayout mainlayout = new GridLayout(); |
| 22 | mainComponent.setLayout(mainlayout); |
| 23 | |
| 24 | file1 = new FileSelectionWidget(mainComponent, SWT.NONE); |
| 25 | GridData gd = new GridData(); |
| 26 | gd.grabExcessHorizontalSpace = true; |
| 27 | gd.grabExcessVerticalSpace = false; |
| 28 | gd.verticalAlignment = SWT.FILL; |
| 29 | gd.horizontalAlignment = SWT.FILL; |
| 30 | file1.setLayoutData(gd); |
| 31 | |
| 32 | file2 = new FileSelectionWidget(mainComponent, SWT.NONE); |
| 33 | gd = new GridData(); |
| 34 | gd.grabExcessHorizontalSpace = true; |
| 35 | gd.grabExcessVerticalSpace = false; |
| 36 | gd.verticalAlignment = SWT.FILL; |
| 37 | gd.horizontalAlignment = SWT.FILL; |
| 38 | file2.setLayoutData(gd); |
| 39 | |
| 40 | file3 = new FileSelectionWidget(mainComponent, SWT.NONE); |
| 41 | gd = new GridData(); |
| 42 | gd.grabExcessHorizontalSpace = true; |
| 43 | gd.grabExcessVerticalSpace = false; |
| 44 | gd.verticalAlignment = SWT.FILL; |
| 45 | gd.horizontalAlignment = SWT.FILL; |
| 46 | file3.setLayoutData(gd); |
| 47 | |
| 48 | } |
| 49 | |
| 50 | public void setVisible(TransformationType type, TransformationQVTType qvtType) { |
| 51 | |
| 52 | file2.setVisible(false); |
| 53 | file3.setVisible(false); |
| 54 | |
| 55 | if(type == TransformationType.FEATURE) { |
| 56 | file1.setCaption(ConstantsContainer.FEATURECONFIG_FILE_CAPTION); |
| 57 | file1.setFileExtensions(ConstantsContainer.FEATURECONFIG_FILE_EXTENSIONS); |
| 58 | } |
| 59 | else if(type == TransformationType.REGISTERED) { |
| 60 | file1.setCaption(ConstantsContainer.MARK_MODEL_CAPTION); |
| 61 | file1.setFileExtensions(null); |
| 62 | } |
| 63 | else if(type == TransformationType.ANNOTATED) { |
| 64 | file1.setCaption(ConstantsContainer.COMPLETION_FILE_CAPTION); |
| 65 | file1.setFileExtensions(ConstantsContainer.COMPLETION_FILE_EXTENSIONS_QVTR); |
| 66 | file2.setVisible(true); |
| 67 | file2.setCaption(ConstantsContainer.MARK_MODEL_CAPTION); |
| 68 | file2.setFileExtensions(null); |
| 69 | file3.setVisible(true); |
| 70 | file3.setCaption(ConstantsContainer.MARK_METAMODEL_CAPTION); |
| 71 | file3.setFileExtensions(null); |
| 72 | } |
| 73 | else if(type == TransformationType.PLAIN) { |
| 74 | file1.setCaption(ConstantsContainer.COMPLETION_FILE_CAPTION); |
| 75 | if(qvtType == TransformationQVTType.QVTR) { |
| 76 | file1.setFileExtensions(ConstantsContainer.COMPLETION_FILE_EXTENSIONS_QVTR); |
| 77 | } else { |
| 78 | file1.setFileExtensions(ConstantsContainer.COMPLETION_FILE_EXTENSIONS_QVTO); |
| 79 | file2.setVisible(true); |
| 80 | file2.setCaption(ConstantsContainer.OPTIONAL_MODEL_CAPTION); |
| 81 | file2.setFileExtensions(null); |
| 82 | } |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | public void setTransformation(Transformation transformation) { |
| 87 | if(transformation.getType() == TransformationType.FEATURE) { |
| 88 | file1.setText(transformation.getFeatureFileURI()); |
| 89 | } |
| 90 | else if(transformation.getType() == TransformationType.REGISTERED) { |
| 91 | file1.setText(transformation.getConfigFileURI()); |
| 92 | } |
| 93 | else if(transformation.getType() == TransformationType.ANNOTATED) { |
| 94 | file1.setText(transformation.getQVTFileURI()); |
| 95 | file2.setText(transformation.getConfigFileURI()); |
| 96 | file3.setText(transformation.getMetamodelFileURI()); |
| 97 | } |
| 98 | else if(transformation.getType() == TransformationType.PLAIN) { |
| 99 | file1.setText(transformation.getQVTFileURI()); |
| 100 | file2.setText(transformation.getOptionalModelFileURI()); |
| 101 | } |
| 102 | |
| 103 | setVisible(transformation.getType(), transformation.getQVTType()); |
| 104 | } |
| 105 | |
| 106 | public void getTransformation(Transformation transformation) { |
| 107 | if(transformation.getType() == TransformationType.FEATURE) { |
| 108 | transformation.setFeatureFileURI(file1.getText()); |
| 109 | } |
| 110 | else if(transformation.getType() == TransformationType.REGISTERED) { |
| 111 | transformation.setConfigFileURI(file1.getText()); |
| 112 | } |
| 113 | else if(transformation.getType() == TransformationType.ANNOTATED) { |
| 114 | transformation.setQVTFileURI(file1.getText()); |
| 115 | transformation.setConfigFileURI(file2.getText()); |
| 116 | transformation.setMetamodelFileURI(file3.getText()); |
| 117 | } |
| 118 | else if(transformation.getType() == TransformationType.PLAIN) { |
| 119 | transformation.setQVTFileURI(file1.getText()); |
| 120 | transformation.setOptionalModelFileURI(file2.getText()); |
| 121 | } |
| 122 | } |
| 123 | |
| 124 | public String getFile1Text() { |
| 125 | return file1.getText(); |
| 126 | } |
| 127 | |
| 128 | public String getFile2Text() { |
| 129 | return file2.getText(); |
| 130 | } |
| 131 | |
| 132 | public String getFile3Text() { |
| 133 | return file3.getText(); |
| 134 | } |
| 135 | } |