01: package org.enhydra.jawe.components;
02:
03: import javax.swing.tree.DefaultMutableTreeNode;
04:
05: import org.enhydra.jawe.JaWEManager;
06: import org.enhydra.shark.xpdl.XMLAttribute;
07: import org.enhydra.shark.xpdl.XMLCollection;
08: import org.enhydra.shark.xpdl.XMLElement;
09: import org.enhydra.shark.xpdl.XMLSimpleElement;
10:
11: /**
12: * Used to handle events in TreeView tree.
13: *
14: * @author Zoran Milakovic
15: */
16: public class XPDLTreeNode extends DefaultMutableTreeNode {
17:
18: public XPDLTreeNode() {
19: super ("XPDL");
20: }
21:
22: public XPDLTreeNode(XMLElement el) {
23: super (el);
24: }
25:
26: public XMLElement getXPDLElement() {
27: if (userObject instanceof XMLElement) {
28: return (XMLElement) userObject;
29: }
30:
31: return null;
32: }
33:
34: public String toString() {
35: if (userObject instanceof XMLElement) {
36: XMLElement el = (XMLElement) userObject;
37: String label = el.toName();
38: String detail = JaWEManager.getInstance()
39: .getDisplayNameGenerator().getDisplayName(el);
40: String disp = label;
41: if (detail != null && detail.equals("")) {
42: if (el instanceof XMLAttribute
43: || el instanceof XMLSimpleElement) {
44: disp += ":";
45: } else {
46:
47: }
48: } else {
49: if (el instanceof XMLAttribute
50: || el instanceof XMLSimpleElement) {
51: disp += ": " + detail;
52: } else if (el instanceof XMLCollection) {
53: if (getChildCount() > 0)
54: disp += " - " + getChildCount();
55: } else {
56: disp += " - " + detail;
57: }
58: }
59: return disp;
60: }
61:
62: return userObject.toString();
63: }
64: }
|