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