1 19 package org.netbeans.test.editor.app.core; 20 21 import java.util.ArrayList ; 22 import org.netbeans.test.editor.app.core.TestGroup; 23 import org.w3c.dom.Element ; 24 25 import java.util.Collection ; 26 import java.util.Vector ; 27 import org.netbeans.test.editor.app.core.actions.ActionRegistry; 28 import org.netbeans.test.editor.app.core.cookies.LoggingCookie; 29 import org.netbeans.test.editor.app.core.cookies.PackCookie; 30 import org.netbeans.test.editor.app.core.cookies.PerformCookie; 31 import org.netbeans.test.editor.app.gui.actions.TestDeleteAction; 32 import org.netbeans.test.editor.app.gui.actions.TestPackAction; 33 import org.netbeans.test.editor.app.gui.actions.TreeNewType; 34 35 40 public class TestStep extends TestGroup { 41 42 43 public TestStep(int num) { 44 this("step"+Integer.toString(num)); 45 } 46 47 public TestStep(String name) { 48 super(name); 49 } 50 51 public TestStep(Element node) { 52 super(node); 53 } 54 55 public Element toXML(Element node) { 56 return super.toXML(node); 57 } 58 59 public void startLogging() { 60 System.err.println("Start Logging"); 61 getLogger().clear(); 62 getLogger().startLogging(); 63 } 64 65 public void stopLogging() { 66 System.err.println("Stop Logging"); 67 getLogger().stopLogging(); 68 TestNode[] nodes=getLogger().saveActions(this); 69 getLogger().clear(); 70 firePropertyChange(ADD_CHILDS,null,nodes); 71 } 72 73 public boolean isLogging() { 74 return getLogger().isLogging(); 75 } 76 77 public void perform() { 78 isPerforming=true; 79 for(int i=0;i < getChildCount();i++) { 80 if (!isPerforming) break; 81 get(i).perform(); 82 } 83 isPerforming=false; 84 } 85 86 public void stop() { 87 isPerforming=false; 88 } 89 90 public void delete() { 91 TestNode n; 92 TestCallAction ca; 93 94 for(int i=0;i < owner.getChildCount();i++) { 95 n=owner.get(i); 96 if (n instanceof TestCallAction) { 97 ca=(TestCallAction)n; 98 if (name.compareTo(ca.getToCall()) == 0) { 99 ca.setToCall(""); 100 } 101 if (name.compareTo(ca.getToSet()) == 0) { 102 ca.setToSet(""); 103 } 104 } 105 } 106 owner.remove(this); 107 } 108 109 public boolean isPacked() { 110 TestNode tn; 111 for (int i=0;i < getChildCount();i++) { 112 tn=(TestNode)(get(i)); 113 if (tn instanceof TestLogAction && tn.getName().compareTo(TestStringAction.STRINGED_NAME) == 0) { 114 return false; 115 } 116 } 117 return true; 118 } 119 120 public void pack() { 121 TestAction[] tas=TestStringAction.generate(getChildNodes()); 122 removeAll(); 123 addNodes(tas); 124 } 125 126 protected void registerNewTypes() { 127 ActionRegistry.getDefault().addRegisteredNewType(getClass(), TestLogAction.class); 128 ActionRegistry.getDefault().addRegisteredNewType(getClass(), TestStringAction.class); 129 ActionRegistry.getDefault().addRegisteredNewType(getClass(), TestCompletionAction.class); 130 ActionRegistry.getDefault().addRegisteredNewType(getClass(), TestSetKitAction.class); 131 ActionRegistry.getDefault().addRegisteredNewType(getClass(), TestSetIEAction.class); 132 ActionRegistry.getDefault().addRegisteredNewType(getClass(), TestSetJavaIEAction.class); 133 ActionRegistry.getDefault().addRegisteredNewType(getClass(), TestSetCompletionAction.class); 134 ActionRegistry.getDefault().addRegisteredNewType(getClass(), TestAddAbbreviationAction.class); 135 } 136 137 protected void registerCookies() { 138 getCookieSet().put(PerformCookie.class,new PerformCookie() { 139 public void perform() { 140 TestStep.this.perform(); 141 } 142 143 public boolean isPerforming() { 144 return TestStep.this.isPerforming; 145 } 146 }); 147 getCookieSet().put(LoggingCookie.class,new LoggingCookie() { 148 public void start() { 149 TestStep.this.startLogging(); 150 } 151 public void stop() { 152 TestStep.this.stopLogging(); 153 } 154 public boolean isLogging() { 155 return TestStep.this.isLogging(); 156 } 157 }); 158 getCookieSet().put(PackCookie.class,new PackCookie() { 159 public void pack() { 160 TestStep.this.pack(); 161 } 162 public boolean isPacked() { 163 return TestStep.this.isPacked(); 164 } 165 }); 166 } 167 } 168 | Popular Tags |