1 19 package org.netbeans.test.editor.app.core; 20 21 import org.w3c.dom.Element ; 22 23 import java.util.Collection ; 24 import java.util.Vector ; 25 import org.netbeans.test.editor.app.Main; 26 import org.netbeans.test.editor.app.core.actions.ActionRegistry; 27 import org.netbeans.test.editor.app.core.properties.BadPropertyNameException; 28 import org.netbeans.test.editor.app.core.properties.BooleanProperty; 29 import org.netbeans.test.editor.app.core.properties.Properties; 30 import org.netbeans.test.editor.app.gui.actions.TestDeleteAction; 31 import org.netbeans.test.editor.app.gui.actions.TreeNewType; 32 import org.openide.util.actions.SystemAction; 33 import org.openide.util.datatransfer.NewType; 34 39 public class TestSubTest extends Test { 40 41 public static final String OWNLOGGER="OwnLogger"; 42 43 44 public TestSubTest(int num,Logger logr) { 45 this("subTest"+Integer.toString(num)); 46 logger=logr; 47 } 48 49 public TestSubTest(String name) { 50 super(name); 51 } 52 53 public TestSubTest(Element node) { 54 super(node); 55 if (node.getAttribute(OWNLOGGER).equals("true")) { 56 logger = new Logger(Main.frame.getEditor()); 57 } else { 58 logger=null; 59 } 60 } 61 62 public Element toXML(Element node) { 63 super.toXML(node); 64 node.setAttribute(OWNLOGGER, (logger != owner.getLogger()) ? "true" : "false"); 65 return node; 66 } 67 68 public void fromXML(Element node) throws BadPropertyNameException { 69 super.fromXML(node); 70 if (node.getAttribute(OWNLOGGER).equals("true")) { 71 logger = new Logger(Main.frame.getEditor()); 72 } else { 73 logger=null; 74 } 75 } 76 77 public Properties getProperties() { 78 Properties ret=super.getProperties(); 79 ret.put(OWNLOGGER, new BooleanProperty((logger != getOwner().getLogger()))); 80 return ret; 81 } 82 83 public Object getProperty(String name) throws BadPropertyNameException { 84 if (name.compareTo(OWNLOGGER) == 0) { 85 return new BooleanProperty((logger != getOwner().getLogger())); 86 } else { 87 return super.getProperty(name); 88 } 89 } 90 91 public void setProperty(String name, Object value) throws BadPropertyNameException { 92 if (name.compareTo(OWNLOGGER) == 0) { 93 if (((BooleanProperty)(value)).getValue()) { 94 logger = new Logger(Main.frame.getEditor()); 95 } else { 96 logger=null; 97 } 98 } else { 99 super.setProperty(name, value); 100 } 101 } 102 103 public String getAuthor() { 104 return ((Test)owner).getAuthor(); 105 } 106 107 public String getVersion() { 108 return ((Test)owner).getVersion(); 109 } 110 111 public void setOwnLogger(boolean b) { 112 if (b && logger == owner.getLogger()) { 113 logger=new Logger(Main.frame.getEditor()); 114 firePropertyChange(OWNLOGGER,null,b ? Boolean.TRUE : Boolean.FALSE); 115 } else { 116 if (!b && logger != owner.getLogger()) { 117 logger=owner.getLogger(); 118 firePropertyChange(OWNLOGGER,null,b ? Boolean.TRUE : Boolean.FALSE); 119 } 120 } 121 } 122 123 public boolean getOwnLogger() { 124 return (logger != owner.getLogger()); 125 } 126 127 public void perform() { 128 Main.log("\nSub Test: "+getName()+" starts execution."); 129 isPerforming=true; 130 for(int i=0;i < getChildCount();i++) { 131 if (!isPerforming) break; 132 if (get(i) instanceof TestCallAction) { 133 ((TestCallAction)get(i)).performAndWait(); 134 } 135 } 136 isPerforming=false; 137 } 138 139 public boolean isPerfoming() { 140 return isPerforming; 141 } 142 143 public void stop() { 144 if (getLogger().isPerforming()) 145 getLogger().stopPerforming(); 146 isPerforming=false; 147 } 148 149 protected void registerNewTypes() { 150 ActionRegistry.getDefault().addRegisteredNewType(getClass(), TestStep.class); 151 ActionRegistry.getDefault().addRegisteredNewType(getClass(), TestCallAction.class); 152 } 153 } 154 | Popular Tags |