1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.seasar.uruma.debug.action; |
17 | |
|
18 | |
import java.lang.reflect.Field; |
19 | |
import java.util.Date; |
20 | |
import java.util.Dictionary; |
21 | |
import java.util.Enumeration; |
22 | |
import java.util.List; |
23 | |
|
24 | |
import org.eclipse.jface.action.MenuManager; |
25 | |
import org.eclipse.jface.viewers.StructuredViewer; |
26 | |
import org.eclipse.swt.browser.Browser; |
27 | |
import org.eclipse.swt.widgets.Control; |
28 | |
import org.eclipse.swt.widgets.Widget; |
29 | |
import org.osgi.framework.Bundle; |
30 | |
import org.seasar.framework.beans.BeanDesc; |
31 | |
import org.seasar.framework.beans.PropertyDesc; |
32 | |
import org.seasar.framework.beans.factory.BeanDescFactory; |
33 | |
import org.seasar.uruma.annotation.EventListener; |
34 | |
import org.seasar.uruma.annotation.EventListenerType; |
35 | |
import org.seasar.uruma.annotation.ExportValue; |
36 | |
import org.seasar.uruma.annotation.InitializeMethod; |
37 | |
import org.seasar.uruma.binding.context.ApplicationContextDef; |
38 | |
import org.seasar.uruma.binding.enables.EnablesDependingDef; |
39 | |
import org.seasar.uruma.binding.method.EventListenerDef; |
40 | |
import org.seasar.uruma.binding.method.GenericAction; |
41 | |
import org.seasar.uruma.binding.value.BindingCommand; |
42 | |
import org.seasar.uruma.binding.value.command.ExportSelectionCommand; |
43 | |
import org.seasar.uruma.binding.value.command.ExportValueCommand; |
44 | |
import org.seasar.uruma.binding.value.command.ImportSelectionCommand; |
45 | |
import org.seasar.uruma.binding.value.command.ImportValueCommand; |
46 | |
import org.seasar.uruma.component.Template; |
47 | |
import org.seasar.uruma.component.UIComponent; |
48 | |
import org.seasar.uruma.component.UIComponentContainer; |
49 | |
import org.seasar.uruma.component.UIElement; |
50 | |
import org.seasar.uruma.component.jface.MenuComponent; |
51 | |
import org.seasar.uruma.component.jface.MenuItemComponent; |
52 | |
import org.seasar.uruma.component.rcp.PartComponent; |
53 | |
import org.seasar.uruma.component.rcp.PerspectiveComponent; |
54 | |
import org.seasar.uruma.component.rcp.ViewPartComponent; |
55 | |
import org.seasar.uruma.component.rcp.WorkbenchComponent; |
56 | |
import org.seasar.uruma.context.ApplicationContext; |
57 | |
import org.seasar.uruma.context.PartContext; |
58 | |
import org.seasar.uruma.context.WidgetHandle; |
59 | |
import org.seasar.uruma.context.WindowContext; |
60 | |
import org.seasar.uruma.core.TemplateManager; |
61 | |
import org.seasar.uruma.core.UrumaMessageCodes; |
62 | |
import org.seasar.uruma.desc.FormDesc; |
63 | |
import org.seasar.uruma.desc.PartActionDesc; |
64 | |
import org.seasar.uruma.exception.BindingException; |
65 | |
import org.seasar.uruma.rcp.configuration.ContributionBuilder; |
66 | |
import org.seasar.uruma.rcp.util.BundleUtil; |
67 | |
import org.seasar.uruma.rcp.util.UrumaServiceUtil; |
68 | |
import org.seasar.uruma.ui.UrumaApplicationWindow; |
69 | |
import org.seasar.uruma.util.HtmlTagUtil; |
70 | |
import org.seasar.uruma.util.S2ContainerListToHtmlUtil; |
71 | |
|
72 | |
|
73 | |
|
74 | |
|
75 | |
|
76 | |
|
77 | 0 | public class UrumaDebugViewAction { |
78 | |
|
79 | |
|
80 | |
@ExportValue(id = "debugBrowser") |
81 | |
public String html; |
82 | |
|
83 | |
public Browser debugBrowser; |
84 | |
|
85 | |
|
86 | |
|
87 | |
|
88 | |
@InitializeMethod |
89 | |
public void initialize() { |
90 | 0 | doS2Container(); |
91 | 0 | } |
92 | |
|
93 | |
|
94 | |
|
95 | |
|
96 | |
@EventListener(id = "s2container", type = EventListenerType.SELECTION) |
97 | |
public void doS2Container() { |
98 | 0 | html = S2ContainerListToHtmlUtil.list(""); |
99 | 0 | } |
100 | |
|
101 | |
|
102 | |
|
103 | |
|
104 | |
@EventListener(id = "bundle", type = EventListenerType.SELECTION) |
105 | |
public void doBundle() { |
106 | 0 | html = HtmlTagUtil.createHeader(); |
107 | 0 | html += HtmlTagUtil.createH1("Workspace Path"); |
108 | |
|
109 | |
|
110 | |
|
111 | |
|
112 | 0 | String symbolicName = UrumaServiceUtil.getService().getPluginId(); |
113 | 0 | Bundle urumaBundle = BundleUtil.getBundle(symbolicName); |
114 | 0 | Bundle[] bundles = urumaBundle.getBundleContext().getBundles(); |
115 | 0 | for (Bundle bundle : bundles) { |
116 | 0 | html += HtmlTagUtil.createH1("[" + convertStatus(bundle.getState()) |
117 | |
+ "][" + bundle.getBundleId() + "] " |
118 | |
+ bundle.getSymbolicName()); |
119 | 0 | Date date = new Date(bundle.getLastModified()); |
120 | 0 | html += HtmlTagUtil.createTable("[" + date + "]", "[" |
121 | |
+ bundle.getLocation() + "]"); |
122 | 0 | Dictionary headers = bundle.getHeaders(); |
123 | 0 | Enumeration elements = headers.keys(); |
124 | 0 | while (elements.hasMoreElements()) { |
125 | 0 | String key = (String) elements.nextElement(); |
126 | 0 | String value = (String) headers.get(key); |
127 | 0 | html += HtmlTagUtil.createTr(key, value); |
128 | 0 | } |
129 | 0 | html += HtmlTagUtil.closeTable(); |
130 | |
} |
131 | 0 | html += HtmlTagUtil.closeHeader(); |
132 | 0 | } |
133 | |
|
134 | |
private String convertStatus(final int i) { |
135 | 0 | String result = ""; |
136 | 0 | switch (i) { |
137 | |
case 32: |
138 | 0 | result = "ACTIVE"; |
139 | 0 | break; |
140 | |
|
141 | |
case 8: |
142 | 0 | result = "LAZY"; |
143 | 0 | break; |
144 | |
|
145 | |
case 4: |
146 | 0 | result = "RESOLVED"; |
147 | 0 | break; |
148 | |
|
149 | |
default: |
150 | 0 | result = String.valueOf(i); |
151 | |
break; |
152 | |
} |
153 | 0 | return result; |
154 | |
} |
155 | |
|
156 | |
|
157 | |
|
158 | |
|
159 | |
@EventListener(id = "component", type = EventListenerType.SELECTION) |
160 | |
public void doComponent() { |
161 | 0 | html = HtmlTagUtil.createHeader(); |
162 | |
|
163 | |
|
164 | |
|
165 | |
|
166 | 0 | WorkbenchComponent workbenchComponent = UrumaServiceUtil.getService() |
167 | |
.getWorkbenchComponent(); |
168 | |
|
169 | 0 | html += HtmlTagUtil.createH1("WorkbenchComponent"); |
170 | |
|
171 | 0 | html += HtmlTagUtil.createTable(); |
172 | 0 | html += HtmlTagUtil.createTr("id", workbenchComponent.getId()); |
173 | 0 | html += HtmlTagUtil.createTr("ClassName", workbenchComponent.getClass() |
174 | |
.getName()); |
175 | 0 | html += HtmlTagUtil.createTr("basePath", workbenchComponent |
176 | |
.getBasePath()); |
177 | 0 | html += HtmlTagUtil.createTr("Location", workbenchComponent |
178 | |
.getLocation()); |
179 | 0 | html += HtmlTagUtil.createTr("Path", workbenchComponent.getPath()); |
180 | 0 | html += HtmlTagUtil.createTr("Renderer", workbenchComponent |
181 | |
.getRenderer().getClass().getName()); |
182 | |
|
183 | 0 | html += HtmlTagUtil.createTr("title", workbenchComponent.title); |
184 | 0 | html += HtmlTagUtil.createTr("image", workbenchComponent.image); |
185 | 0 | html += HtmlTagUtil.createTr("initHeight", |
186 | |
workbenchComponent.initHeight); |
187 | 0 | html += HtmlTagUtil.createTr("initWidth", workbenchComponent.initWidth); |
188 | 0 | html += HtmlTagUtil.createTr("initialPerspectiveId", |
189 | |
workbenchComponent.initialPerspectiveId); |
190 | 0 | html += HtmlTagUtil.createTr("menu", workbenchComponent.menu); |
191 | 0 | html += HtmlTagUtil.createTr("statusLine", |
192 | |
workbenchComponent.statusLine); |
193 | 0 | html += HtmlTagUtil.createTr("style", workbenchComponent.style); |
194 | |
|
195 | 0 | html += HtmlTagUtil.closeTable(); |
196 | |
|
197 | 0 | List<UIElement> list = workbenchComponent.getChildren(); |
198 | 0 | for (UIElement element : list) { |
199 | 0 | createUIElement(element); |
200 | |
} |
201 | |
|
202 | 0 | html += HtmlTagUtil.closeHeader(); |
203 | 0 | } |
204 | |
|
205 | |
private void createUIElement(final UIElement element) { |
206 | 0 | if (MenuComponent.class.isAssignableFrom(element.getClass())) { |
207 | 0 | MenuComponent c = (MenuComponent) element; |
208 | 0 | html += HtmlTagUtil.createH2("MenuComponent"); |
209 | 0 | html += HtmlTagUtil.createTable(); |
210 | 0 | html += HtmlTagUtil.createTr("id", c.getId()); |
211 | 0 | html += HtmlTagUtil.createTr("ClassName", c.getClass().getName()); |
212 | |
|
213 | 0 | html += HtmlTagUtil.createTr("BasePath", c.getBasePath()); |
214 | 0 | html += HtmlTagUtil.createTr("Location", c.getLocation()); |
215 | 0 | html += HtmlTagUtil.createTr("Path", c.getPath()); |
216 | |
|
217 | 0 | html += HtmlTagUtil.createTr("BasePath", c.getBasePath()); |
218 | 0 | html += HtmlTagUtil.createTr("Location", c.getLocation()); |
219 | 0 | html += HtmlTagUtil.createTr("Path", c.getPath()); |
220 | |
|
221 | 0 | html += HtmlTagUtil.createTr("accelerator", c.accelerator); |
222 | 0 | html += HtmlTagUtil.createTr("defaultItemId", c.defaultItemId); |
223 | 0 | html += HtmlTagUtil.createTr("description", c.description); |
224 | 0 | html += HtmlTagUtil.createTr("disabledImage", c.disabledImage); |
225 | 0 | html += HtmlTagUtil.createTr("enabled", c.enabled); |
226 | 0 | html += HtmlTagUtil.createTr("enablesDependingId", |
227 | |
c.enablesDependingId); |
228 | 0 | html += HtmlTagUtil.createTr("enablesFor", c.enablesFor); |
229 | 0 | html += HtmlTagUtil.createTr("hoverImage", c.hoverImage); |
230 | 0 | html += HtmlTagUtil.createTr("image", c.image); |
231 | 0 | html += HtmlTagUtil.createTr("selection", c.selection); |
232 | 0 | html += HtmlTagUtil.createTr("text", c.text); |
233 | 0 | html += HtmlTagUtil.createTr("visible", c.visible); |
234 | 0 | html += HtmlTagUtil.createTr("Renderer", c.getRenderer().getClass() |
235 | |
.getName()); |
236 | 0 | html += HtmlTagUtil.closeTable(); |
237 | |
|
238 | 0 | for (UIElement elementChild : c.getChildren()) { |
239 | 0 | createUIElement(elementChild); |
240 | |
} |
241 | |
|
242 | 0 | } else if (MenuItemComponent.class.isAssignableFrom(element.getClass())) { |
243 | 0 | MenuItemComponent c = (MenuItemComponent) element; |
244 | 0 | html += HtmlTagUtil.createH2("MenuItemComponent"); |
245 | 0 | html += HtmlTagUtil.createTable(); |
246 | 0 | html += HtmlTagUtil.createTr("id", c.getId()); |
247 | 0 | html += HtmlTagUtil.createTr("ClassName", c.getClass().getName()); |
248 | |
|
249 | 0 | html += HtmlTagUtil.createTr("BasePath", c.getBasePath()); |
250 | 0 | html += HtmlTagUtil.createTr("Location", c.getLocation()); |
251 | 0 | html += HtmlTagUtil.createTr("Path", c.getPath()); |
252 | |
|
253 | 0 | html += HtmlTagUtil.createTr("accelerator", c.accelerator); |
254 | 0 | html += HtmlTagUtil.createTr("description", c.description); |
255 | 0 | html += HtmlTagUtil.createTr("disabledImage", c.disabledImage); |
256 | 0 | html += HtmlTagUtil.createTr("enabled", c.enabled); |
257 | 0 | html += HtmlTagUtil.createTr("enablesDependingId", |
258 | |
c.enablesDependingId); |
259 | 0 | html += HtmlTagUtil.createTr("enablesFor", c.enablesFor); |
260 | 0 | html += HtmlTagUtil.createTr("hoverImage", c.hoverImage); |
261 | 0 | html += HtmlTagUtil.createTr("image", c.image); |
262 | 0 | html += HtmlTagUtil.createTr("selection", c.selection); |
263 | 0 | html += HtmlTagUtil.createTr("text", c.text); |
264 | 0 | html += HtmlTagUtil.createTr("Renderer", c.getRenderer().getClass() |
265 | |
.getName()); |
266 | 0 | html += HtmlTagUtil.closeTable(); |
267 | |
|
268 | 0 | } else if (PerspectiveComponent.class.isAssignableFrom(element |
269 | |
.getClass())) { |
270 | 0 | PerspectiveComponent c = (PerspectiveComponent) element; |
271 | |
|
272 | 0 | html += HtmlTagUtil.createH2("PerspectiveComponent"); |
273 | 0 | html += HtmlTagUtil.createTable(); |
274 | 0 | html += HtmlTagUtil.createTr("id", c.id); |
275 | 0 | html += HtmlTagUtil.createTr("ClassName", c.getClass().getName()); |
276 | |
|
277 | 0 | html += HtmlTagUtil.createTr("BasePath", c.getBasePath()); |
278 | 0 | html += HtmlTagUtil.createTr("Location", c.getLocation()); |
279 | 0 | html += HtmlTagUtil.createTr("Path", c.getPath()); |
280 | |
|
281 | 0 | html += HtmlTagUtil.createTr("name", c.name); |
282 | 0 | html += HtmlTagUtil.createTr("fixed", c.fixed); |
283 | 0 | html += HtmlTagUtil.createTr("iconicon", c.icon); |
284 | 0 | html += HtmlTagUtil.createTr("clazz", c.clazz); |
285 | 0 | html += HtmlTagUtil.closeTable(); |
286 | 0 | for (UIElement elementChild : c.getChildren()) { |
287 | 0 | createUIElement(elementChild); |
288 | |
} |
289 | |
|
290 | 0 | } else if (PartComponent.class.isAssignableFrom(element.getClass())) { |
291 | 0 | PartComponent c = (PartComponent) element; |
292 | |
|
293 | 0 | html += HtmlTagUtil.createH3("PartComponent"); |
294 | 0 | html += HtmlTagUtil.createTable(); |
295 | 0 | html += HtmlTagUtil.createTr("ClassName", c.getClass().getName()); |
296 | 0 | html += HtmlTagUtil.createTr("BasePath", c.getBasePath()); |
297 | 0 | html += HtmlTagUtil.createTr("Location", c.getLocation()); |
298 | 0 | html += HtmlTagUtil.createTr("Path", c.getPath()); |
299 | |
|
300 | 0 | html += HtmlTagUtil.createTr("ref", c.ref); |
301 | 0 | html += HtmlTagUtil.createTr("position", c.position); |
302 | 0 | html += HtmlTagUtil.createTr("ratio", c.ratio); |
303 | 0 | html += HtmlTagUtil.closeTable(); |
304 | |
|
305 | 0 | } else if (ViewPartComponent.class.isAssignableFrom(element.getClass())) { |
306 | 0 | ViewPartComponent c = (ViewPartComponent) element; |
307 | |
|
308 | 0 | html += HtmlTagUtil.createH3("ViewPartComponent"); |
309 | 0 | html += HtmlTagUtil.createTable(); |
310 | 0 | html += HtmlTagUtil.createTr("id", c.getId()); |
311 | 0 | html += HtmlTagUtil.createTr("ClassName", c.getClass().getName()); |
312 | 0 | html += HtmlTagUtil.createTr("BasePath", c.getBasePath()); |
313 | 0 | html += HtmlTagUtil.createTr("Location", c.getLocation()); |
314 | 0 | html += HtmlTagUtil.createTr("Path", c.getPath()); |
315 | 0 | html += HtmlTagUtil.createTr("Renderer", c.getRenderer().getClass() |
316 | |
.getName()); |
317 | |
|
318 | 0 | html += HtmlTagUtil.createTr("position", c.allowMultiple); |
319 | 0 | html += HtmlTagUtil.createTr("background", c.background); |
320 | 0 | html += HtmlTagUtil.createTr("backgroundImage", c.backgroundImage); |
321 | 0 | html += HtmlTagUtil.createTr("category", c.category); |
322 | 0 | html += HtmlTagUtil.createTr("enabled", c.enabled); |
323 | 0 | html += HtmlTagUtil.createTr("enablesDependingId", |
324 | |
c.enablesDependingId); |
325 | 0 | html += HtmlTagUtil.createTr("enablesFor", c.enablesFor); |
326 | 0 | html += HtmlTagUtil.createTr("fontHeight", c.fontHeight); |
327 | 0 | html += HtmlTagUtil.createTr("fontName", c.fontName); |
328 | 0 | html += HtmlTagUtil.createTr("fontStyle", c.fontStyle); |
329 | 0 | html += HtmlTagUtil.createTr("foreground", c.foreground); |
330 | 0 | html += HtmlTagUtil.createTr("height", c.height); |
331 | 0 | html += HtmlTagUtil.createTr("image", c.image); |
332 | 0 | html += HtmlTagUtil.createTr("menu", c.menu); |
333 | 0 | html += HtmlTagUtil.createTr("title", c.title); |
334 | 0 | html += HtmlTagUtil.createTr("toolTipText", c.toolTipText); |
335 | 0 | html += HtmlTagUtil.createTr("visible", c.visible); |
336 | 0 | html += HtmlTagUtil.createTr("width", c.width); |
337 | 0 | html += HtmlTagUtil.createTr("x", c.x); |
338 | 0 | html += HtmlTagUtil.createTr("y", c.y); |
339 | 0 | html += HtmlTagUtil.closeTable(); |
340 | 0 | for (UIElement elementChild : c.getChildren()) { |
341 | 0 | createUIElement(elementChild); |
342 | |
} |
343 | 0 | } else { |
344 | 0 | html += element.getClass().getName() + "<br />"; |
345 | |
} |
346 | 0 | } |
347 | |
|
348 | 0 | private static final ImportValueCommand IMPORT_VALUE_COMMAND = new ImportValueCommand(); |
349 | |
|
350 | 0 | private static final ExportValueCommand EXPORT_VALUE_COMMAND = new ExportValueCommand(); |
351 | |
|
352 | 0 | private static final ImportSelectionCommand IMPORT_SELECTION_COMMAND = new ImportSelectionCommand(); |
353 | |
|
354 | 0 | private static final ExportSelectionCommand EXPORT_SELECTION_COMMAND = new ExportSelectionCommand(); |
355 | |
|
356 | |
|
357 | |
|
358 | |
|
359 | |
@EventListener(id = "context", type = EventListenerType.SELECTION) |
360 | |
public void doCcontext() { |
361 | 0 | html = HtmlTagUtil.createHeader(); |
362 | |
|
363 | |
|
364 | |
|
365 | 0 | WindowContext wc = UrumaServiceUtil.getService() |
366 | |
.getWorkbenchWindowContext(); |
367 | 0 | ApplicationContext ac = wc.getApplicationContext(); |
368 | |
|
369 | 0 | html += HtmlTagUtil.createH1("ApplicationContext"); |
370 | 0 | html += HtmlTagUtil.createTable(); |
371 | 0 | html += HtmlTagUtil.createTr("ClassName", ac.getClass().getName()); |
372 | 0 | html += HtmlTagUtil.closeTable(); |
373 | |
|
374 | |
|
375 | |
|
376 | |
|
377 | 0 | html += HtmlTagUtil.createH1("WindowContext"); |
378 | 0 | html += HtmlTagUtil.createTable("Name", wc.getName()); |
379 | 0 | html += HtmlTagUtil.createTr("ClassName", wc.getClass().getName()); |
380 | 0 | html += HtmlTagUtil.createTr("WorkbenchActionObject", wc |
381 | |
.getPartActionObject().getClass().getName()); |
382 | |
|
383 | |
|
384 | 0 | for (PartContext pc : wc.getPartContextList()) { |
385 | 0 | html += HtmlTagUtil.createTr("PartContext Name", pc.getName()); |
386 | |
} |
387 | |
|
388 | 0 | html += HtmlTagUtil.closeTable(); |
389 | |
|
390 | |
|
391 | 0 | for (EnablesDependingDef ed : wc.getEnablesDependingDefList()) { |
392 | 0 | html += HtmlTagUtil.createH1("EnablesDependingDef"); |
393 | 0 | html += HtmlTagUtil.createTable(); |
394 | 0 | html += HtmlTagUtil.createTr("ClassName", ed.getClass().getName()); |
395 | 0 | html += HtmlTagUtil.createTr("targetId", ed.getTargetId()); |
396 | 0 | html += HtmlTagUtil.createTr("type", ed.getType().name()); |
397 | |
|
398 | |
|
399 | 0 | createWidgetHandle(ed.getWidgetHandle()); |
400 | |
|
401 | 0 | html += HtmlTagUtil.closeTable(); |
402 | |
} |
403 | |
|
404 | |
|
405 | 0 | for (PartContext pc : wc.getPartContextList()) { |
406 | 0 | PartActionDesc partActionDesc = pc.getPartActionDesc(); |
407 | 0 | FormDesc formDesc = pc.getFormDesc(); |
408 | 0 | html += HtmlTagUtil.createH1("PartContext"); |
409 | 0 | html += HtmlTagUtil.createTable("Name", pc.getName()); |
410 | 0 | html += HtmlTagUtil.createTr("ClassName", pc.getClass().getName()); |
411 | |
|
412 | 0 | html += HtmlTagUtil.createTrSub1("PartActionClass Name", |
413 | |
partActionDesc.getPartActionClass().getSimpleName()); |
414 | 0 | html += HtmlTagUtil.createTr("partActionObject", pc |
415 | |
.getPartActionObject().getClass().getSimpleName()); |
416 | 0 | String initializeMethodName = " "; |
417 | 0 | if (partActionDesc.getInitializeMethod() != null) { |
418 | 0 | initializeMethodName = partActionDesc.getInitializeMethod() |
419 | |
.getName() |
420 | |
+ "()"; |
421 | |
} |
422 | 0 | html += HtmlTagUtil.createTr("InitializeMethodName", |
423 | |
initializeMethodName); |
424 | |
|
425 | 0 | String postOpenMethodName = " "; |
426 | 0 | if (partActionDesc.getPostOpenMethod() != null) { |
427 | 0 | postOpenMethodName = partActionDesc.getPostOpenMethod() |
428 | |
.getName() |
429 | |
+ "()"; |
430 | |
} |
431 | 0 | html += HtmlTagUtil.createTr("PostOpenMethodName", |
432 | |
postOpenMethodName); |
433 | |
|
434 | |
for (EventListenerDef eld : partActionDesc |
435 | 0 | .getEventListenerDefList()) { |
436 | 0 | html += HtmlTagUtil.createTrSub1( |
437 | |
"EventListenerDef TargetMethodName", eld |
438 | |
.getTargetMethod().getName()); |
439 | 0 | html += HtmlTagUtil.createTr("Type", eld.getType().getName()); |
440 | 0 | html += HtmlTagUtil.createTr("isSWTEvent", String.valueOf(eld |
441 | |
.getType().isSWTEvent())); |
442 | |
} |
443 | |
|
444 | |
for (ApplicationContextDef acd : partActionDesc |
445 | 0 | .getApplicationContextDefList()) { |
446 | 0 | html += HtmlTagUtil.createTrSub1("ApplicationContextDef Name", |
447 | |
acd.getName()); |
448 | 0 | html += HtmlTagUtil.createTr("PropertyName", acd |
449 | |
.getPropertyDesc().getPropertyName()); |
450 | |
} |
451 | |
|
452 | 0 | html += HtmlTagUtil.createTrSub1("FormClass Name", formDesc |
453 | |
.getFormClass().getSimpleName()); |
454 | 0 | html += HtmlTagUtil.createTr("formObject", pc.getFormObject() |
455 | |
.getClass().getSimpleName()); |
456 | |
|
457 | 0 | dealFields(pc, IMPORT_VALUE_COMMAND); |
458 | 0 | dealFields(pc, EXPORT_VALUE_COMMAND); |
459 | 0 | dealFields(pc, IMPORT_SELECTION_COMMAND); |
460 | 0 | dealFields(pc, EXPORT_SELECTION_COMMAND); |
461 | |
|
462 | 0 | for (WidgetHandle wh : pc.getWidgetHandles()) { |
463 | |
|
464 | 0 | createWidgetHandle(wh); |
465 | |
} |
466 | |
|
467 | 0 | html += HtmlTagUtil.closeTable(); |
468 | 0 | } |
469 | |
|
470 | 0 | html += HtmlTagUtil.closeHeader(); |
471 | 0 | } |
472 | |
|
473 | |
private void dealFields(final PartContext context, |
474 | |
final BindingCommand command) { |
475 | 0 | Object form = context.getFormObject(); |
476 | 0 | FormDesc formDesc = context.getFormDesc(); |
477 | 0 | if (form == null || formDesc == null) { |
478 | 0 | return; |
479 | |
} |
480 | 0 | html += HtmlTagUtil.createTrSub1("BindingCommand Class Name", command |
481 | |
.getClass().getSimpleName()); |
482 | |
|
483 | 0 | List<PropertyDesc> targetProperties = command |
484 | |
.getTargetPropertyDescs(formDesc); |
485 | 0 | for (PropertyDesc pd : targetProperties) { |
486 | 0 | String id = command.getId(pd.getField()); |
487 | |
|
488 | 0 | WidgetHandle handle = context.getWidgetHandle(id); |
489 | 0 | if (handle != null) { |
490 | 0 | Object widget = handle.getWidget(); |
491 | |
|
492 | 0 | html += HtmlTagUtil.createTrSub2("PropertyName", pd |
493 | |
.getPropertyName()); |
494 | 0 | html += HtmlTagUtil.createTr("WidgetName", widget.getClass() |
495 | |
.getSimpleName()); |
496 | 0 | } else { |
497 | 0 | throw new BindingException(UrumaMessageCodes.WIDGET_NOT_FOUND, |
498 | |
id, form.getClass(), pd.getField()); |
499 | |
} |
500 | 0 | } |
501 | 0 | } |
502 | |
|
503 | |
private void createWidgetHandle(final WidgetHandle wh) { |
504 | 0 | html += HtmlTagUtil.createTrSub1("WidgetHandle Id", wh.getId()); |
505 | 0 | html += HtmlTagUtil.createTr("Class Name", wh.getClass().getName()); |
506 | 0 | html += HtmlTagUtil.createTr("widgetClass", wh.getWidgetClass() |
507 | |
.getName()); |
508 | |
|
509 | 0 | if (StructuredViewer.class.isAssignableFrom(wh.getWidgetClass())) { |
510 | 0 | StructuredViewer viewer = wh.<StructuredViewer> getCastWidget(); |
511 | 0 | html += HtmlTagUtil.createTr("LabelProvider", getSimpleName(viewer |
512 | |
.getLabelProvider())); |
513 | 0 | html += HtmlTagUtil.createTr("ContentProvider", |
514 | |
getSimpleName(viewer.getContentProvider())); |
515 | 0 | html += HtmlTagUtil.createTr("Comparator", getSimpleName(viewer |
516 | |
.getComparator())); |
517 | 0 | html += HtmlTagUtil.createTr("Sorter", getSimpleName(viewer |
518 | |
.getSorter())); |
519 | |
|
520 | 0 | } else if (GenericAction.class.isAssignableFrom(wh.getWidgetClass())) { |
521 | |
|
522 | 0 | } else if (UrumaApplicationWindow.class.isAssignableFrom(wh |
523 | |
.getWidgetClass())) { |
524 | |
|
525 | 0 | } else if (Widget.class.isAssignableFrom(wh.getWidgetClass())) { |
526 | |
|
527 | 0 | } else if (MenuManager.class.isAssignableFrom(wh.getWidgetClass())) { |
528 | |
|
529 | 0 | } else if (Control.class.isAssignableFrom(wh.getWidgetClass())) { |
530 | |
|
531 | |
} |
532 | |
|
533 | 0 | UIComponent uc = wh.getUiComponent(); |
534 | 0 | if (uc != null) { |
535 | 0 | html += HtmlTagUtil.createTrSub2("UIComponent id", uc.getId()); |
536 | 0 | html += HtmlTagUtil.createTr("Class Name", uc.getClass().getName()); |
537 | 0 | html += HtmlTagUtil.createTr("BasePath", uc.getBasePath()); |
538 | 0 | html += HtmlTagUtil.createTr("Location", uc.getLocation()); |
539 | 0 | html += HtmlTagUtil.createTr("Path", uc.getPath()); |
540 | 0 | html += HtmlTagUtil.createTr("style", uc.getStyle()); |
541 | 0 | html += HtmlTagUtil.createTr("renderer", uc.getRenderer() |
542 | |
.getClass().getName()); |
543 | |
} |
544 | 0 | } |
545 | |
|
546 | |
private String getSimpleName(final Object obj) { |
547 | 0 | if (obj != null) { |
548 | 0 | return obj.getClass().getSimpleName(); |
549 | |
} |
550 | 0 | return " "; |
551 | |
} |
552 | |
|
553 | |
|
554 | |
|
555 | |
|
556 | |
@EventListener(id = "template", type = EventListenerType.SELECTION) |
557 | |
public void doTemplate() { |
558 | |
|
559 | |
|
560 | |
|
561 | |
|
562 | 0 | html = HtmlTagUtil.createHeader(); |
563 | 0 | html += HtmlTagUtil.createH1("TemplateManager"); |
564 | |
|
565 | 0 | html += HtmlTagUtil.createTable(); |
566 | |
|
567 | 0 | TemplateManager templateManager = (TemplateManager) UrumaServiceUtil |
568 | |
.getService().getContainer() |
569 | |
.getComponent(TemplateManager.class); |
570 | 0 | List<Template> viewTemplates = templateManager |
571 | |
.getTemplates(ViewPartComponent.class); |
572 | |
|
573 | 0 | for (Template template : viewTemplates) { |
574 | 0 | html += HtmlTagUtil.createTrSub1("Path", template.getPath()); |
575 | 0 | html += HtmlTagUtil.createTr("Location", template.getLocation()); |
576 | 0 | html += HtmlTagUtil.createTr("BasePath", template.getBasePath()); |
577 | 0 | html += HtmlTagUtil.createTr("Extends", template.getExtends()); |
578 | |
|
579 | 0 | UIComponentContainer uic = template.getRootComponent(); |
580 | 0 | createChildTemplateManager(uic); |
581 | 0 | } |
582 | |
|
583 | 0 | html += HtmlTagUtil.closeTable(); |
584 | 0 | html += HtmlTagUtil.closeTable(); |
585 | 0 | } |
586 | |
|
587 | |
private void createChildTemplateManager(final Object uic) { |
588 | 0 | BeanDesc beanDesc = BeanDescFactory.getBeanDesc(uic.getClass()); |
589 | 0 | html += HtmlTagUtil.createTrSub2("ClassName", uic.getClass() |
590 | |
.getSimpleName()); |
591 | 0 | for (int i = 0; i < beanDesc.getFieldSize(); i++) { |
592 | 0 | Field filed = beanDesc.getField(i); |
593 | |
|
594 | 0 | String value = ""; |
595 | 0 | Object obj = null; |
596 | 0 | if (filed.isAccessible()) { |
597 | |
try { |
598 | 0 | obj = filed.get(uic); |
599 | 0 | if (obj != null) { |
600 | 0 | value = obj.getClass().getSimpleName(); |
601 | 0 | value += ": " + obj.toString(); |
602 | |
} else { |
603 | 0 | value = "null"; |
604 | |
} |
605 | 0 | } catch (IllegalArgumentException ignore) { |
606 | 0 | } catch (IllegalAccessException ignore) { |
607 | 0 | } |
608 | |
} |
609 | |
|
610 | 0 | html += HtmlTagUtil.createTr(filed.getName(), value); |
611 | 0 | if (obj instanceof List<?>) { |
612 | 0 | List<?> list = (List<?>) obj; |
613 | 0 | for (int j = 0; j < list.size(); j++) { |
614 | 0 | Object array_element = list.get(j); |
615 | |
|
616 | 0 | html += HtmlTagUtil.createTr("array_element", array_element |
617 | |
.toString()); |
618 | 0 | createChildTemplateManager(array_element); |
619 | |
} |
620 | |
} |
621 | |
} |
622 | 0 | } |
623 | |
|
624 | |
|
625 | |
|
626 | |
|
627 | |
@EventListener(id = "plugin", type = EventListenerType.SELECTION) |
628 | |
public void doPlugin() { |
629 | 0 | html = HtmlTagUtil.createHeader(); |
630 | 0 | html += "<pre>"; |
631 | 0 | html += ContributionBuilder.getContent().replaceAll("<", "<") |
632 | |
.replaceAll(">", ">"); |
633 | 0 | html += "</pre>"; |
634 | 0 | html += HtmlTagUtil.closeHeader(); |
635 | 0 | } |
636 | |
|
637 | |
} |