KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > junit > output > TestsuiteNodeChildren


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
20 package org.netbeans.modules.junit.output;
21
22 import java.util.Collection JavaDoc;
23 import java.util.Collections JavaDoc;
24 import java.util.Iterator JavaDoc;
25 import org.openide.nodes.Children;
26 import org.openide.nodes.Node;
27
28 /**
29  *
30  * @author Marian Petras
31  */

32 final class TestsuiteNodeChildren extends Children.Keys<Report.Testcase> {
33
34     /** */
35     private static final Node[] EMPTY_NODE_ARRAY = new Node[0];
36
37     /** */
38     private final Report report;
39     /** */
40     private boolean filtered;
41     /** */
42     private boolean live = true; //PENDING - temporary (should be false)
43

44     /*
45      * PENDING - threading, sychronization
46      */

47     
48     /**
49      * Creates a new instance of TestsuiteNodeChildren
50      */

51     TestsuiteNodeChildren(final Report report, final boolean filtered) {
52         this.report = report;
53         this.filtered = filtered;
54     }
55     
56     /**
57      */

58     protected void addNotify() {
59         super.addNotify();
60         
61         if (live) {
62             setKeys(report.getTests());
63         }
64         //live = true; //PENDING
65
}
66     
67     /**
68      */

69     protected void removeNotify() {
70         super.removeNotify();
71         
72         final Collection JavaDoc<Report.Testcase> emptySet = Collections.emptySet();
73         setKeys(emptySet);
74         //live = false; //PENDING
75
}
76     
77     /**
78      */

79     protected Node[] createNodes(final Report.Testcase testcase) {
80         if (filtered && (testcase.trouble == null)) {
81             return EMPTY_NODE_ARRAY;
82         }
83         return new Node[] {new TestMethodNode(testcase)};
84     }
85     
86     /**
87      */

88     void setFiltered(final boolean filtered) {
89         if (filtered == this.filtered) {
90             return;
91         }
92         this.filtered = filtered;
93         
94         if ((report.errors + report.failures) == report.totalTests) {
95             return;
96         }
97                 
98         if (isInitialized()) {
99             for (Report.Testcase testcase : report.getTests()) {
100                 if (testcase.trouble == null) {
101                     refreshKey(testcase);
102                 }
103             }
104         }
105     }
106     
107 }
108
Popular Tags