1 | public class Ecore2EcoreModelWizardInitialObjectCreationPage extends WizardPage↵ | | 1 | public class Ecore2XMLModelWizardInitialObjectCreationPage extends WizardPage↵
|
2 | {↵ | | 2 | {↵
|
3 | /**↵ | | 3 | /**↵
|
4 | * <!-- begin-user-doc -->↵ | | 4 | * <!-- begin-user-doc -->↵
|
5 | * <!-- end-user-doc -->↵ | | 5 | * <!-- end-user-doc -->↵
|
6 | * @generated↵ | | 6 | * @generated↵
|
7 | */↵ | | 7 | */↵
|
8 | protected Combo initialObjectField;↵ | | 8 | protected Combo initialObjectField;↵
|
|
9 | /**↵ | | 9 | /**↵
|
10 | * @generated↵ | | 10 | * @generated↵
|
11 | * <!-- begin-user-doc -->↵ | | 11 | * <!-- begin-user-doc -->↵
|
12 | * <!-- end-user-doc -->↵ | | 12 | * <!-- end-user-doc -->↵
|
13 | */↵ | | 13 | */↵
|
14 | protected List<String> encodings;↵ | | 14 | protected List<String> encodings;↵
|
|
15 | /**↵ | | 15 | /**↵
|
16 | * <!-- begin-user-doc -->↵ | | 16 | * <!-- begin-user-doc -->↵
|
17 | * <!-- end-user-doc -->↵ | | 17 | * <!-- end-user-doc -->↵
|
18 | * @generated↵ | | 18 | * @generated↵
|
19 | */↵ | | 19 | */↵
|
20 | protected Combo encodingField;↵ | | 20 | protected Combo encodingField;↵
|
|
21 | /**↵ | | 21 | /**↵
|
22 | * Pass in the selection.↵ | | 22 | * Pass in the selection.↵
|
23 | * <!-- begin-user-doc -->↵ | | 23 | * <!-- begin-user-doc -->↵
|
24 | * <!-- end-user-doc -->↵ | | 24 | * <!-- end-user-doc -->↵
|
25 | * @generated↵ | | 25 | * @generated↵
|
26 | */↵ | | 26 | */↵
|
27 | public Ecore2EcoreModelWizardInitialObjectCreationPage(String pageId)↵ | | 27 | public Ecore2XMLModelWizardInitialObjectCreationPage(String pageId)↵
|
28 | {↵ | | 28 | {↵
|
29 | super(pageId);↵ | | 29 | super(pageId);↵
|
30 | }↵ | | 30 | }↵
|
|
31 | /**↵ | | 31 | /**↵
|
32 | * <!-- begin-user-doc -->↵ | | 32 | * <!-- begin-user-doc -->↵
|
33 | * <!-- end-user-doc -->↵ | | 33 | * <!-- end-user-doc -->↵
|
34 | * @generated↵ | | 34 | * @generated↵
|
35 | */↵ | | 35 | */↵
|
36 | public void createControl(Composite parent)↵ | | 36 | public void createControl(Composite parent)↵
|
37 | {↵ | | 37 | {↵
|
38 | Composite composite = new Composite(parent, SWT.NONE);↵ | | 38 | Composite composite = new Composite(parent, SWT.NONE);↵
|
39 | {↵ | | 39 | {↵
|
40 | GridLayout layout = new GridLayout();↵ | | 40 | GridLayout layout = new GridLayout();↵
|
41 | layout.numColumns = 1;↵ | | 41 | layout.numColumns = 1;↵
|
42 | layout.verticalSpacing = 12;↵ | | 42 | layout.verticalSpacing = 12;↵
|
43 | composite.setLayout(layout);↵ | | 43 | composite.setLayout(layout);↵
|
|
44 | GridData data = new GridData();↵ | | 44 | GridData data = new GridData();↵
|
45 | data.verticalAlignment = GridData.FILL;↵ | | 45 | data.verticalAlignment = GridData.FILL;↵
|
46 | data.grabExcessVerticalSpace = true;↵ | | 46 | data.grabExcessVerticalSpace = true;↵
|
47 | data.horizontalAlignment = GridData.FILL;↵ | | 47 | data.horizontalAlignment = GridData.FILL;↵
|
48 | composite.setLayoutData(data);↵ | | 48 | composite.setLayoutData(data);↵
|
49 | }↵ | | 49 | }↵
|
|
50 | Label containerLabel = new Label(composite, SWT.LEFT);↵ | | 50 | Label containerLabel = new Label(composite, SWT.LEFT);↵
|
51 | {↵ | | 51 | {↵
|
52 | containerLabel.setText(Ecore2EcoreEditorPlugin.INSTANCE.getString("_UI_ModelObject"));↵ | | 52 | containerLabel.setText(Ecore2XMLUIPlugin.INSTANCE.getString("_UI_ModelObject")); //$NON-NLS-1$↵
|
|
53 | GridData data = new GridData();↵ | | 53 | GridData data = new GridData();↵
|
54 | data.horizontalAlignment = GridData.FILL;↵ | | 54 | data.horizontalAlignment = GridData.FILL;↵
|
55 | containerLabel.setLayoutData(data);↵ | | 55 | containerLabel.setLayoutData(data);↵
|
56 | }↵ | | 56 | }↵
|
|
57 | initialObjectField = new Combo(composite, SWT.BORDER);↵ | | 57 | initialObjectField = new Combo(composite, SWT.BORDER);↵
|
58 | {↵ | | 58 | {↵
|
59 | GridData data = new GridData();↵ | | 59 | GridData data = new GridData();↵
|
60 | data.horizontalAlignment = GridData.FILL;↵ | | 60 | data.horizontalAlignment = GridData.FILL;↵
|
61 | data.grabExcessHorizontalSpace = true;↵ | | 61 | data.grabExcessHorizontalSpace = true;↵
|
62 | initialObjectField.setLayoutData(data);↵ | | 62 | initialObjectField.setLayoutData(data);↵
|
63 | }↵ | | 63 | }↵
|
|
64 | for (String objectName : getInitialObjectNames())↵ | | 64 | for (String objectName : getInitialObjectNames())↵
|
65 | {↵ | | 65 | {↵
|
66 | initialObjectField.add(getLabel(objectName));↵ | | 66 | initialObjectField.add(getLabel(objectName));↵
|
67 | }↵ | | 67 | }↵
|
|
68 | if (initialObjectField.getItemCount() == 1)↵ | | 68 | if (initialObjectField.getItemCount() == 1)↵
|
69 | {↵ | | 69 | {↵
|
70 | initialObjectField.select(0);↵ | | 70 | initialObjectField.select(0);↵
|
71 | }↵ | | 71 | }↵
|
72 | initialObjectField.addModifyListener(validator);↵ | | 72 | initialObjectField.addModifyListener(validator);↵
|
|
73 | Label encodingLabel = new Label(composite, SWT.LEFT);↵ | | 73 | Label encodingLabel = new Label(composite, SWT.LEFT);↵
|
74 | {↵ | | 74 | {↵
|
75 | encodingLabel.setText(Ecore2EcoreEditorPlugin.INSTANCE.getString("_UI_XMLEncoding"));↵ | | 75 | encodingLabel.setText(Ecore2XMLUIPlugin.INSTANCE.getString("_UI_XMLEncoding")); //$NON-NLS-1$↵
|
|
76 | GridData data = new GridData();↵ | | 76 | GridData data = new GridData();↵
|
77 | data.horizontalAlignment = GridData.FILL;↵ | | 77 | data.horizontalAlignment = GridData.FILL;↵
|
78 | encodingLabel.setLayoutData(data);↵ | | 78 | encodingLabel.setLayoutData(data);↵
|
79 | }↵ | | 79 | }↵
|
80 | encodingField = new Combo(composite, SWT.BORDER);↵ | | 80 | encodingField = new Combo(composite, SWT.BORDER);↵
|
81 | {↵ | | 81 | {↵
|
82 | GridData data = new GridData();↵ | | 82 | GridData data = new GridData();↵
|
83 | data.horizontalAlignment = GridData.FILL;↵ | | 83 | data.horizontalAlignment = GridData.FILL;↵
|
84 | data.grabExcessHorizontalSpace = true;↵ | | 84 | data.grabExcessHorizontalSpace = true;↵
|
85 | encodingField.setLayoutData(data);↵ | | 85 | encodingField.setLayoutData(data);↵
|
86 | }↵ | | 86 | }↵
|
|
87 | for (String encoding : getEncodings())↵ | | 87 | for (String encoding : getEncodings())↵
|
88 | {↵ | | 88 | {↵
|
89 | encodingField.add(encoding);↵ | | 89 | encodingField.add(encoding);↵
|
90 | }↵ | | 90 | }↵
|
|
91 | encodingField.select(0);↵ | | 91 | encodingField.select(0);↵
|
92 | encodingField.addModifyListener(validator);↵ | | 92 | encodingField.addModifyListener(validator);↵
|
|
93 | setPageComplete(validatePage());↵ | | 93 | setPageComplete(validatePage());↵
|
94 | setControl(composite);↵ | | 94 | setControl(composite);↵
|
95 | }↵ | | 95 | }↵
|
|
96 | /**↵ | | 96 | /**↵
|
97 | * <!-- begin-user-doc -->↵ | | 97 | * <!-- begin-user-doc -->↵
|
98 | * <!-- end-user-doc -->↵ | | 98 | * <!-- end-user-doc -->↵
|
99 | * @generated↵ | | 99 | * @generated↵
|
100 | */↵ | | 100 | */↵
|
101 | protected ModifyListener validator =↵ | | 101 | protected ModifyListener validator =↵
|
102 | new ModifyListener()↵ | | 102 | new ModifyListener()↵
|
103 | {↵ | | 103 | {↵
|
104 | public void modifyText(ModifyEvent e)↵ | | 104 | public void modifyText(ModifyEvent e)↵
|
105 | {↵ | | 105 | {↵
|
106 | setPageComplete(validatePage());↵ | | 106 | setPageComplete(validatePage());↵
|
107 | }↵ | | 107 | }↵
|
108 | };↵ | | 108 | };↵
|
|
109 | /**↵ | | 109 | /**↵
|
110 | * <!-- begin-user-doc -->↵ | | 110 | * <!-- begin-user-doc -->↵
|
111 | * <!-- end-user-doc -->↵ | | 111 | * <!-- end-user-doc -->↵
|
112 | * @generated↵ | | 112 | * @generated↵
|
113 | */↵ | | 113 | */↵
|
114 | protected boolean validatePage()↵ | | 114 | protected boolean validatePage()↵
|
115 | {↵ | | 115 | {↵
|
116 | return getInitialObjectName() != null && getEncodings().contains(encodingField.getText());↵ | | 116 | return getInitialObjectName() != null && getEncodings().contains(encodingField.getText());↵
|
117 | }↵ | | 117 | }↵
|
|
118 | /**↵ | | 118 | /**↵
|
119 | * <!-- begin-user-doc -->↵ | | 119 | * <!-- begin-user-doc -->↵
|
120 | * <!-- end-user-doc -->↵ | | 120 | * <!-- end-user-doc -->↵
|
121 | * @generated↵ | | 121 | * @generated↵
|
122 | */↵ | | 122 | */↵
|
123 | @Override↵ | | 123 | @Override↵
|
124 | public void setVisible(boolean visible)↵ | | 124 | public void setVisible(boolean visible)↵
|
125 | {↵ | | 125 | {↵
|
126 | super.setVisible(visible);↵ | | 126 | super.setVisible(visible);↵
|
127 | if (visible)↵ | | 127 | if (visible)↵
|
128 | {↵ | | 128 | {↵
|
129 | if (initialObjectField.getItemCount() == 1)↵ | | 129 | if (initialObjectField.getItemCount() == 1)↵
|
130 | {↵ | | 130 | {↵
|
131 | initialObjectField.clearSelection();↵ | | 131 | initialObjectField.clearSelection();↵
|
132 | encodingField.setFocus();↵ | | 132 | encodingField.setFocus();↵
|
133 | }↵ | | 133 | }↵
|
134 | else↵ | | 134 | else↵
|
135 | {↵ | | 135 | {↵
|
136 | encodingField.clearSelection();↵ | | 136 | encodingField.clearSelection();↵
|
137 | initialObjectField.setFocus();↵ | | 137 | initialObjectField.setFocus();↵
|
138 | }↵ | | 138 | }↵
|
139 | }↵ | | 139 | }↵
|
140 | }↵ | | 140 | }↵
|
|
141 | /**↵ | | 141 | /**↵
|
142 | * <!-- begin-user-doc -->↵ | | 142 | * <!-- begin-user-doc -->↵
|
143 | * <!-- end-user-doc -->↵ | | 143 | * <!-- end-user-doc -->↵
|
144 | * @generated↵ | | 144 | * @generated↵
|
145 | */↵ | | 145 | */↵
|
146 | public String getInitialObjectName()↵ | | 146 | public String getInitialObjectName()↵
|
147 | {↵ | | 147 | {↵
|
148 | String label = initialObjectField.getText();↵ | | 148 | String label = initialObjectField.getText();↵
|
|
149 | for (String name : getInitialObjectNames())↵ | | 149 | for (String name : getInitialObjectNames())↵
|
150 | {↵ | | 150 | {↵
|
151 | if (getLabel(name).equals(label))↵ | | 151 | if (getLabel(name).equals(label))↵
|
152 | {↵ | | 152 | {↵
|
153 | return name;↵ | | 153 | return name;↵
|
154 | }↵ | | 154 | }↵
|
155 | }↵ | | 155 | }↵
|
156 | return null;↵ | | 156 | return null;↵
|
157 | }↵ | | 157 | }↵
|
|
158 | /**↵ | | 158 | /**↵
|
159 | * <!-- begin-user-doc -->↵ | | 159 | * <!-- begin-user-doc -->↵
|
160 | * <!-- end-user-doc -->↵ | | 160 | * <!-- end-user-doc -->↵
|
161 | * @generated↵ | | 161 | * @generated↵
|
162 | */↵ | | 162 | */↵
|
163 | public String getEncoding()↵ | | 163 | public String getEncoding()↵
|
164 | {↵ | | 164 | {↵
|
165 | return encodingField.getText();↵ | | 165 | return encodingField.getText();↵
|
166 | }↵ | | 166 | }↵
|
|
167 | /**↵ | | 167 | /**↵
|
168 | * Returns the label for the specified type name.↵ | | 168 | * Returns the label for the specified type name.↵
|
169 | * <!-- begin-user-doc -->↵ | | 169 | * <!-- begin-user-doc -->↵
|
170 | * <!-- end-user-doc -->↵ | | 170 | * <!-- end-user-doc -->↵
|
171 | * @generated↵ | | 171 | * @generated↵
|
172 | */↵ | | 172 | */↵
|
173 | protected String getLabel(String typeName)↵ | | 173 | protected String getLabel(String typeName)↵
|
174 | {↵ | | 174 | {↵
|
175 | try↵ | | 175 | try↵
|
176 | {↵ | | 176 | {↵
|
177 | return Ecore2EcorePlugin.INSTANCE.getString("_UI_" + typeName + "_type");↵ | | 177 | return Ecore2XMLUIPlugin.INSTANCE.getString("_UI_" + typeName + "_type"); //$NON-NLS-1$ //$NON-NLS-2$↵
|
178 | }↵ | | 178 | }↵
|
179 | catch(MissingResourceException mre)↵ | | 179 | catch(MissingResourceException mre)↵
|
180 | {↵ | | 180 | {↵
|
181 | Ecore2EcoreEditorPlugin.INSTANCE.log(mre);↵ | | 181 | Ecore2XMLUIPlugin.INSTANCE.log(mre);↵
|
182 | }↵ | | 182 | }↵
|
183 | return typeName;↵ | | 183 | return typeName;↵
|
184 | }↵ | | 184 | }↵
|
|
185 | /**↵ | | 185 | /**↵
|
186 | * <!-- begin-user-doc -->↵ | | 186 | * <!-- begin-user-doc -->↵
|
187 | * <!-- end-user-doc -->↵ | | 187 | * <!-- end-user-doc -->↵
|
188 | * @generated↵ | | 188 | * @generated↵
|
189 | */↵ | | 189 | */↵
|
190 | protected Collection<String> getEncodings()↵ | | 190 | protected Collection<String> getEncodings()↵
|
191 | {↵ | | 191 | {↵
|
192 | if (encodings == null)↵ | | 192 | if (encodings == null)↵
|
193 | {↵ | | 193 | {↵
|
194 | encodings = new ArrayList<String>();↵ | | 194 | encodings = new ArrayList<String>();↵
|
195 | for (StringTokenizer stringTokenizer = new StringTokenizer(Ecore2EcoreEditorPlugin.INSTANCE.getString("_UI_XMLEncodingChoices")); stringTokenizer.hasMoreTokens(); )↵ | | 195 | for (StringTokenizer stringTokenizer = new StringTokenizer(Ecore2XMLUIPlugin.INSTANCE.getString("_UI_XMLEncodingChoices")); stringTokenizer.hasMoreTokens(); ) //$NON-NLS-1$↵
|
196 | {↵ | | 196 | {↵
|
197 | encodings.add(stringTokenizer.nextToken());↵ | | 197 | encodings.add(stringTokenizer.nextToken());↵
|
198 | }↵ | | 198 | }↵
|
199 | }↵ | | 199 | }↵
|
200 | return encodings; | | 200 | return encodings;
|