1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 package org.coach.actor.componentBrowser; 26 27 import javax.swing.tree.*; 28 import org.omg.CORBA.*; 29 import org.omg.Components.*; 30 31 class ComponentNode extends DefaultMutableTreeNode { 32 protected static org.omg.CORBA.ORB orb; 33 protected boolean explored = false; 34 protected boolean leaf = true; 35 protected String name = ""; 36 protected org.omg.CORBA.Object obj; 37 38 39 public ComponentNode(String name) { 40 this.name = name; 41 setUserObject(this); 42 } 43 44 public ComponentNode(String name, org.omg.CORBA.Object obj) { 45 this.name = name; 46 this.obj = obj; 47 leaf = false; 48 setUserObject(this); 49 } 50 51 private ComponentNode(String name, org.omg.CORBA.Object obj, boolean leaf) { 52 this.name = name; 53 this.obj = obj; 54 this.leaf = leaf; 55 setUserObject(this); 56 } 57 58 public static void setOrb(org.omg.CORBA.ORB o) { 59 orb = o; 60 } 61 62 public boolean getAllowsChildren() { 63 return !leaf; 64 } 65 66 public boolean isLeaf() { 67 return leaf; 68 } 69 70 public void explore() { 71 explore(false); 72 } 73 74 public boolean isExplored() { 75 return explored; 76 } 77 78 public String toString() { 79 return name; 80 } 81 82 public String getIor() { 83 String ior = "not an object!"; 84 org.omg.CORBA.Object obj = getObject(); 85 if (obj != null) { 86 try { 87 ior = orb.object_to_string(obj); 88 } catch (Exception e) { 89 e.printStackTrace(); 90 } 91 } 92 return ior; 93 } 94 95 public org.omg.CORBA.Object getObject() { 96 if (obj != null) { 97 return obj; 98 } 99 if (leaf) { 100 try { 101 ComponentNode p = (ComponentNode)getParent(); 102 CCMObject c = (CCMObject)p.getObject(); 103 obj = c.provide_facet(name); 104 return obj; 105 } catch (Exception e) { 106 e.printStackTrace(); 107 } 108 } 109 return null; 110 } 111 112 public boolean ping() { 113 if (obj == null) { 114 getObject(); 115 } 116 if (obj != null) { 117 try { 118 obj._is_a("dummy"); 119 } catch (Exception e) { 120 return false; 121 } 122 return true; 123 } 124 return false; 125 } 126 127 public void explore(boolean force) { 128 if(!leaf && (!isExplored() || force)) { 129 removeAllChildren(); 130 try { 131 add(new ComponentNode(name, obj, true)); 132 FacetDescription[] facetDescription = ((CCMObject)obj).get_all_facets(); 133 for(int i = 0; i < facetDescription.length; i++) { 134 add(new ComponentNode(facetDescription[i].name)); 135 } 136 137 142 } catch (Exception e) { 143 e.printStackTrace(); 144 } 145 146 explored = true; 147 } 148 } 149 } 150 | Popular Tags |