01: package logconfig;
02:
03: import org.dom4j.Node;
04: import org.wings.SComponent;
05: import org.wings.SIcon;
06: import org.wings.STree;
07: import org.wings.SURLIcon;
08: import org.wings.tree.SDefaultTreeCellRenderer;
09:
10: public class DomRenderer extends SDefaultTreeCellRenderer {
11:
12: private static final long serialVersionUID = 3989712479939412419L;
13:
14: private static final SURLIcon LEAF_ICON = new SURLIcon(
15: "../images/leaf_node.png");
16:
17: public SComponent getTreeCellRendererComponent(STree tree,
18: Object value, boolean selected, boolean expanded,
19: boolean leaf, int row, boolean hasFocus) {
20:
21: super .getTreeCellRendererComponent(tree, value, selected,
22: expanded, leaf, row, hasFocus);
23:
24: Node domNode = (Node) value;
25: // String type = domNode.getNodeTypeName().substring(0, 1);
26: StringBuffer output = new StringBuffer(" ").append(domNode
27: .getName());
28: if (domNode.getNodeType() == Node.ATTRIBUTE_NODE) {
29: output.append("=\"").append(domNode.getText()).append("\"");
30: }
31: setText(output.toString());
32: setToolTipText(null);
33: return this ;
34: }
35:
36: public SIcon getLeafIcon() {
37: return LEAF_ICON;
38: }
39:
40: }
|