1 19 20 package org.netbeans.jellytools.modules.xml.catalog.nodes; 21 22 import java.lang.reflect.Constructor ; 23 import javax.swing.tree.TreePath ; 24 import org.netbeans.jellytools.RuntimeTabOperator; 25 import org.netbeans.jellytools.nodes.Node; 26 import org.netbeans.jemmy.operators.JTreeOperator; 27 28 30 public abstract class AbstractNode extends Node { 31 private static RuntimeTabOperator runtimeTabOperator; 32 33 36 public AbstractNode(JTreeOperator tree, String treePath) { 37 super(tree, treePath); 38 } 39 40 43 public AbstractNode(JTreeOperator tree, TreePath treePath) { 44 super(tree, treePath); 45 } 46 47 50 public AbstractNode(Node parent, String treePath) { 51 super(parent, treePath); 52 } 53 54 58 public boolean containsChild(String displayName) { 59 String [] drivers = this.getChildren(); 60 for (int i = 0 ; i < drivers.length ; i++) { 61 if (displayName.equals(drivers[i]) ) { 62 return true; 63 } 64 } 65 return false; 66 } 67 68 73 public Node getChild(String displayName, Class clazz) { 74 if (!Node.class.isAssignableFrom(clazz)) { 75 throw new IllegalArgumentException (clazz + " is not instance of org.netbeans.jellytools.nodes.Node"); 76 } 77 if (!this.containsChild(displayName) ) { 78 return null; 79 } 80 Node node = null; 81 try { 82 Constructor constructor = clazz.getConstructor(new Class [] {Node.class, String .class}); 83 node = (Node) constructor.newInstance(new Object [] {this, displayName}); 84 } catch (Exception ex) { 85 throw new RuntimeException ("Cannot instantiate " + clazz, ex); 86 } 87 return node; 88 } 89 90 public static synchronized RuntimeTabOperator getRuntimeTab() { 91 if (runtimeTabOperator == null) { 92 RuntimeTabOperator.invoke(); 93 runtimeTabOperator = new RuntimeTabOperator(); 94 } 95 if (!runtimeTabOperator.isVisible()) { 96 runtimeTabOperator.invoke(); 97 } 98 return runtimeTabOperator; 99 } 100 } 101 | Popular Tags |