1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
package org.apache.commons.jelly.tags.jface; |
17 |
|
|
18 |
|
import org.apache.commons.jelly.JellyException; |
19 |
|
import org.apache.commons.jelly.Tag; |
20 |
|
import org.apache.commons.jelly.impl.TagFactory; |
21 |
|
import org.apache.commons.jelly.tags.jface.preference.FieldEditorTag; |
22 |
|
import org.apache.commons.jelly.tags.jface.preference.PreferenceDialogTag; |
23 |
|
import org.apache.commons.jelly.tags.jface.preference.PreferencePageTag; |
24 |
|
import org.apache.commons.jelly.tags.jface.window.ApplicationWindowTag; |
25 |
|
import org.apache.commons.jelly.tags.jface.wizard.WizardDialogTag; |
26 |
|
import org.apache.commons.jelly.tags.jface.wizard.WizardPageTag; |
27 |
|
import org.apache.commons.jelly.tags.swt.SwtTagLibrary; |
28 |
|
import org.eclipse.jface.action.Separator; |
29 |
|
import org.eclipse.jface.preference.BooleanFieldEditor; |
30 |
|
import org.eclipse.jface.preference.ColorFieldEditor; |
31 |
|
import org.eclipse.jface.preference.DirectoryFieldEditor; |
32 |
|
import org.eclipse.jface.preference.FileFieldEditor; |
33 |
|
import org.eclipse.jface.preference.FontFieldEditor; |
34 |
|
import org.eclipse.jface.preference.IntegerFieldEditor; |
35 |
|
import org.eclipse.jface.preference.StringFieldEditor; |
36 |
|
import org.eclipse.jface.viewers.CheckboxTreeViewer; |
37 |
|
import org.eclipse.jface.viewers.TableTreeViewer; |
38 |
|
import org.eclipse.jface.viewers.TableViewer; |
39 |
|
import org.eclipse.jface.viewers.TreeViewer; |
40 |
|
import org.eclipse.jface.window.ApplicationWindow; |
41 |
|
import org.eclipse.swt.SWT; |
42 |
|
import org.xml.sax.Attributes; |
43 |
|
|
44 |
|
|
45 |
|
|
46 |
|
|
47 |
|
|
48 |
|
|
49 |
|
|
50 |
|
public class JFaceTagLibrary extends SwtTagLibrary { |
51 |
|
|
52 |
|
public JFaceTagLibrary() { |
53 |
|
|
54 |
|
|
55 |
|
registerViewerTag("tableViewer", TableViewer.class); |
56 |
|
registerViewerTag("tableTreeViewer", TableTreeViewer.class); |
57 |
|
registerViewerTag("treeViewer", TreeViewer.class); |
58 |
|
registerViewerTag("checkboxTreeViewer", CheckboxTreeViewer.class); |
59 |
|
|
60 |
|
|
61 |
|
registerTag("doubleClickListener", DoubleClickListenerTag.class); |
62 |
|
registerTag("selectionChangedListener", SelectionChangedListenerTag.class); |
63 |
|
|
64 |
|
|
65 |
|
registerWindowTag("applicationWindow", ApplicationWindow.class); |
66 |
|
|
67 |
|
|
68 |
|
registerMenuManager("menuManager", MenuManagerTag.class); |
69 |
|
|
70 |
|
|
71 |
|
registerActionTag("action", ActionTag.class); |
72 |
|
|
73 |
|
|
74 |
|
registerContributionItemTag("separator", Separator.class); |
75 |
|
|
76 |
|
|
77 |
|
registerWizardDialogTag("wizardDialog", WizardDialogTag.class); |
78 |
|
registerWizardPageTag("wizardPage", WizardPageTag.class); |
79 |
|
|
80 |
|
|
81 |
|
registerPreferenceDialogTag("preferenceDialog", PreferenceDialogTag.class); |
82 |
|
registerTag("preferencePage", PreferencePageTag.class); |
83 |
|
registerFieldEditorTag("booleanFieldEditor", BooleanFieldEditor.class); |
84 |
|
registerFieldEditorTag("colorFieldEditor", ColorFieldEditor.class); |
85 |
|
registerFieldEditorTag("directoryFieldEditor", DirectoryFieldEditor.class); |
86 |
|
registerFieldEditorTag("fileFieldEditor", FileFieldEditor.class); |
87 |
|
registerFieldEditorTag("fontFieldEditor", FontFieldEditor.class); |
88 |
|
registerFieldEditorTag("integerFieldEditor", IntegerFieldEditor.class); |
89 |
|
|
90 |
|
|
91 |
|
registerFieldEditorTag("stringFieldEditor", StringFieldEditor.class); |
92 |
|
|
93 |
|
} |
94 |
|
|
95 |
|
|
96 |
|
|
97 |
|
|
98 |
|
|
99 |
|
private void registerMenuManager(String name, final Class theClass) { |
100 |
|
registerTagFactory(name, new TagFactory() { |
101 |
|
|
102 |
|
|
103 |
|
|
104 |
|
public Tag createTag(String name, Attributes attributes) throws JellyException { |
105 |
|
return new MenuManagerTag(); |
106 |
|
} |
107 |
|
}); |
108 |
|
|
109 |
|
} |
110 |
|
|
111 |
|
|
112 |
|
|
113 |
|
|
114 |
|
|
115 |
|
|
116 |
|
|
117 |
|
protected void registerViewerTag(String name, Class widgetClass) { |
118 |
|
registerViewerTag(name, widgetClass, SWT.NULL); |
119 |
|
} |
120 |
|
|
121 |
|
|
122 |
|
|
123 |
|
|
124 |
|
|
125 |
|
|
126 |
|
|
127 |
|
|
128 |
|
protected void registerViewerTag(String name, final Class theClass, class="keyword">final int style) { |
129 |
|
registerTagFactory(name, new TagFactory() { |
130 |
|
|
131 |
|
|
132 |
|
|
133 |
|
public Tag createTag(String name, Attributes attributes) throws JellyException { |
134 |
|
return new ViewerTag(theClass, style); |
135 |
|
} |
136 |
|
}); |
137 |
|
} |
138 |
|
|
139 |
|
|
140 |
|
|
141 |
|
|
142 |
|
|
143 |
|
|
144 |
|
|
145 |
|
|
146 |
|
protected void registerWindowTag(String name, final Class theClass) { |
147 |
|
registerTagFactory(name, new TagFactory() { |
148 |
|
|
149 |
|
|
150 |
|
|
151 |
|
public Tag createTag(String name, Attributes attributes) throws JellyException { |
152 |
|
return new ApplicationWindowTag(theClass); |
153 |
|
} |
154 |
|
}); |
155 |
|
} |
156 |
|
|
157 |
|
|
158 |
|
|
159 |
|
|
160 |
|
protected void registerActionTag(String name, final Class theClass) { |
161 |
|
registerTagFactory(name, new TagFactory() { |
162 |
|
|
163 |
|
|
164 |
|
|
165 |
|
public Tag createTag(String name, Attributes attributes) throws JellyException { |
166 |
|
return new ActionTag(theClass); |
167 |
|
} |
168 |
|
}); |
169 |
|
} |
170 |
|
|
171 |
|
|
172 |
|
|
173 |
|
|
174 |
|
protected void registerContributionItemTag(String name, final Class theClass) { |
175 |
|
registerTagFactory(name, new TagFactory() { |
176 |
|
|
177 |
|
|
178 |
|
|
179 |
|
public Tag createTag(String name, Attributes attributes) throws JellyException { |
180 |
|
return new ContributionItemTag(theClass); |
181 |
|
} |
182 |
|
}); |
183 |
|
} |
184 |
|
|
185 |
|
|
186 |
|
|
187 |
|
|
188 |
|
|
189 |
|
protected void registerPreferenceDialogTag(String name, final Class theClass) { |
190 |
|
registerTagFactory(name, new TagFactory() { |
191 |
|
|
192 |
|
|
193 |
|
|
194 |
|
public Tag createTag(String name, Attributes attributes) throws JellyException { |
195 |
|
return new PreferenceDialogTag(theClass); |
196 |
|
} |
197 |
|
}); |
198 |
|
} |
199 |
|
|
200 |
|
|
201 |
|
|
202 |
|
|
203 |
|
|
204 |
|
protected void registerFieldEditorTag(String name, final Class theClass) { |
205 |
|
registerTagFactory(name, new TagFactory() { |
206 |
|
|
207 |
|
|
208 |
|
|
209 |
|
public Tag createTag(String name, Attributes attributes) throws JellyException { |
210 |
|
return new FieldEditorTag(theClass); |
211 |
|
} |
212 |
|
}); |
213 |
|
} |
214 |
|
|
215 |
|
|
216 |
|
|
217 |
|
|
218 |
|
|
219 |
|
protected void registerWizardDialogTag(String name, final Class theClass) { |
220 |
|
registerTagFactory(name, new TagFactory() { |
221 |
|
|
222 |
|
|
223 |
|
|
224 |
|
public Tag createTag(String name, Attributes attributes) throws JellyException { |
225 |
|
return new WizardDialogTag(theClass); |
226 |
|
} |
227 |
|
}); |
228 |
|
} |
229 |
|
|
230 |
|
protected void registerWizardPageTag(String name, final Class theClass) { |
231 |
|
registerTagFactory(name, new TagFactory() { |
232 |
|
|
233 |
|
|
234 |
|
|
235 |
|
public Tag createTag(String name, Attributes attributes) throws JellyException { |
236 |
|
return new WizardPageTag(theClass); |
237 |
|
} |
238 |
|
}); |
239 |
|
} |
240 |
|
|
241 |
|
|
242 |
|
|
243 |
|
|
244 |
|
protected void registerWidgetTag(String name, Class widgetClass) { |
245 |
|
registerWidgetTag(name, widgetClass, SWT.NULL); |
246 |
|
} |
247 |
|
|
248 |
|
|
249 |
|
|
250 |
|
|
251 |
|
protected void registerWidgetTag(String name, final Class widgetClass, class="keyword">final int style) { |
252 |
|
registerTagFactory(name, new TagFactory() { |
253 |
|
|
254 |
|
|
255 |
|
|
256 |
0 |
public Tag createTag(String name, Attributes attributes) throws JellyException { |
257 |
0 |
return new JFaceWidgetTag(widgetClass, style); |
258 |
|
} |
259 |
|
}); |
260 |
|
} |
261 |
|
|
262 |
|
|
263 |
|
|
264 |
|
|
265 |
|
protected void registerLayoutTag(String name, final Class layoutClass) { |
266 |
|
registerTagFactory(name, new TagFactory() { |
267 |
|
|
268 |
|
|
269 |
|
|
270 |
|
public Tag createTag(String name, Attributes attributes) throws JellyException { |
271 |
|
return new JFaceLayoutTag(layoutClass); |
272 |
|
} |
273 |
|
}); |
274 |
|
} |
275 |
|
|
276 |
|
} |