01: package org.osbl.client.wings.devtools;
02:
03: import org.wings.*;
04: import org.osbl.client.wings.shell.Client;
05:
06: import javax.swing.*;
07:
08: import java.awt.event.ActionEvent;
09:
10: /**
11: * TODO: document me!!!
12: * <p/>
13: * <code>ContainerColoringDevTool</code>.
14: * User: rro
15: * Date: 31.07.2006
16: * Time: 13:58:21
17: *
18: * @author Roman Rädle
19: * @version $Revision$
20: */
21: public class DumpClassNamesDevTool extends AbstractAction {
22:
23: DumpClassNamesDevTool.ColoringTreeWalker treeWalker = new DumpClassNamesDevTool.ColoringTreeWalker();
24:
25: /**
26: * Defines an <code>Action</code> object with a default
27: * description string and default icon.
28: */
29: public DumpClassNamesDevTool() {
30: putValue(Action.NAME, "Classnames");
31: putValue(Action.SHORT_DESCRIPTION,
32: "Dump class names to System.out");
33: }
34:
35: /**
36: * Invoked when an action occurs.
37: */
38: public void actionPerformed(ActionEvent e) {
39: SComponent content = Client.getInstance().getShownComponent();
40: treeWalker.walk(content);
41: }
42:
43: class ColoringTreeWalker implements ComponentTreeWalker {
44:
45: public boolean walk(SComponent c) {
46: walk(c, "");
47: return false;
48: }
49:
50: public boolean walk(SComponent c, String indent) {
51: System.out.println(indent + c.getClass().getName() + " "
52: + c.getName());
53:
54: indent += " ";
55: if (c instanceof SContainer) {
56: SContainer container = (SContainer) c;
57:
58: if (container.getComponentCount() > 0) {
59: for (SComponent child : container.getComponents()) {
60: walk(child, indent);
61: }
62: }
63: }
64: return false;
65: }
66: }
67: }
|