1 19 20 package org.netbeans.test.web; 21 22 import java.io.File ; 23 import java.util.Arrays ; 24 import javax.swing.JComboBox ; 25 import org.netbeans.jellytools.Bundle; 26 import org.netbeans.jellytools.OptionsOperator; 27 import org.netbeans.jellytools.ProjectsTabOperator; 28 import org.netbeans.jellytools.RuntimeTabOperator; 29 import org.netbeans.jellytools.modules.debugger.BreakpointsWindowOperator; 30 import org.netbeans.jellytools.modules.j2ee.nodes.J2eeServerNode; 31 import org.netbeans.jellytools.nodes.Node; 32 import org.netbeans.jemmy.operators.JComboBoxOperator; 33 import org.netbeans.jemmy.operators.JLabelOperator; 34 35 39 public class Util { 40 41 42 public Util() { 43 } 44 45 public static String dumpProjectView(String project) { 46 try { Thread.currentThread().sleep(3000); } 48 catch (InterruptedException e) {} 49 StringBuffer buff = new StringBuffer (); 50 Node node = new ProjectsTabOperator().getProjectRootNode(project); 51 dumpNode(node, buff, 0); 52 return buff.toString(); 53 } 54 55 56 private static void dumpNode(Node node, StringBuffer buff, int level) { 57 for (int i=0; i<level; i++) 58 buff.append("."); 59 buff.append("+ "); 60 buff.append(node.getText()); 63 if (!node.isLeaf() && node.getText().indexOf('.') < 0) { 64 buff.append(" "); 65 boolean wasCollapsed = node.isCollapsed(); 66 buff.append("\n"); 67 String nodes[] = node.getChildren(); 68 for (int i=0; i<nodes.length; i++) { 69 Node child = new Node(node, nodes[i]); 71 if (child.getPath().equals(node.getPath())) { 73 continue; 75 } 76 dumpNode(child, buff, level+1); 77 } 78 if (wasCollapsed) node.collapse(); 79 } else { 80 buff.append("\n"); 81 } 82 } 83 84 public static String dumpFiles(File file) { 85 StringBuffer buff = new StringBuffer (); 88 dumpFiles(file, buff, 0); 89 return buff.toString(); 90 } 91 92 private static void dumpFiles(File file, StringBuffer buff, int level) { 93 for (int i=0; i<level; i++) 94 buff.append("."); 95 buff.append(file.getName()); 96 buff.append("\n"); 97 if (file.isDirectory()) { 98 String files[] = file.list(); 99 Arrays.sort(files); 100 for (int i=0; i<files.length; i++) { 101 dumpFiles(new File (file,files[i]), buff, level+1); 102 } 103 } 104 } 105 106 public static void setSwingBrowser() { 107 OptionsOperator optionsOper = OptionsOperator.invoke(); 109 optionsOper.selectGeneral(); 110 String webBrowserLabel = Bundle.getStringTrimmed( 112 "org.netbeans.modules.options.general.Bundle", 113 "CTL_Web_Browser"); 114 JLabelOperator jloWebBrowser = new JLabelOperator(optionsOper, webBrowserLabel); 115 String swingBrowserLabel = Bundle.getString( 117 "org.netbeans.core.ui.Bundle", 118 "Services/Browsers/SwingBrowser.ser"); 119 new JComboBoxOperator((JComboBox )jloWebBrowser.getLabelFor()). 120 selectItem(swingBrowserLabel); 121 optionsOper.ok(); 122 } 123 124 public static void deleteAllBreakpoints() { 125 BreakpointsWindowOperator bwo = BreakpointsWindowOperator.invoke(); 126 bwo.deleteAll(); 127 bwo.close(); 128 } 129 130 public static void stopTomcat() { 131 getServerNode().stop();; 132 } 133 134 public static void startTomcat() { 135 getServerNode().start(); 136 137 } 138 139 private static final J2eeServerNode getServerNode() { 140 RuntimeTabOperator.invoke(); 141 return new J2eeServerNode("Bundled Tomcat"); 142 } 143 } 144 | Popular Tags |