KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > test > editor > app > core > TestSubTest


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 package org.netbeans.test.editor.app.core;
20
21 import org.w3c.dom.Element JavaDoc;
22
23 import java.util.Collection JavaDoc;
24 import java.util.Vector JavaDoc;
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 /**
35  *
36  * @author ehucka
37  * @version
38  */

39 public class TestSubTest extends Test {
40     
41     public static final String JavaDoc OWNLOGGER="OwnLogger";
42     
43     /** Creates new TestSubTest */
44     public TestSubTest(int num,Logger logr) {
45         this("subTest"+Integer.toString(num));
46         logger=logr;
47     }
48     
49     public TestSubTest(String JavaDoc name) {
50         super(name);
51     }
52     
53     public TestSubTest(Element JavaDoc 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 JavaDoc toXML(Element JavaDoc node) {
63         super.toXML(node);
64         node.setAttribute(OWNLOGGER, (logger != owner.getLogger()) ? "true" : "false");
65         return node;
66     }
67     
68     public void fromXML(Element JavaDoc 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 JavaDoc getProperty(String JavaDoc 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 JavaDoc name, Object JavaDoc 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 JavaDoc getAuthor() {
104         return ((Test)owner).getAuthor();
105     }
106     
107     public String JavaDoc 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