KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > junit > JUnitSettings


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-2007 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.junit;
21
22 import java.util.prefs.Preferences JavaDoc;
23 import org.openide.nodes.BeanNode;
24 import org.openide.util.HelpCtx;
25 import org.openide.util.NbBundle;
26 import org.openide.util.NbPreferences;
27
28 /** Options for JUnit module, control behavior of test creation and execution.
29  *
30  * @author vstejskal
31  * @author Marian Petras
32  * @version 1.0
33  */

34 public class JUnitSettings {
35     private static final JUnitSettings INSTANCE = new JUnitSettings();
36     
37     /** prefix for names of generated test classes */
38     static final String JavaDoc TEST_CLASSNAME_PREFIX = NbBundle.getMessage(
39             JUnitSettings.class,
40             "PROP_test_classname_prefix"); //NOI18N
41
/** suffix for names of generated test classes */
42     static final String JavaDoc TEST_CLASSNAME_SUFFIX = NbBundle.getMessage(
43             JUnitSettings.class,
44             "PROP_test_classname_suffix"); //NOI18N
45
/** prefix for names of generated test suites */
46     static final String JavaDoc SUITE_CLASSNAME_PREFIX = NbBundle.getMessage(
47             JUnitSettings.class,
48             "PROP_suite_classname_prefix"); //NOI18N
49
/** suffix for names of generated test suites */
50     static final String JavaDoc SUITE_CLASSNAME_SUFFIX = NbBundle.getMessage(
51             JUnitSettings.class,
52             "PROP_suite_classname_suffix"); //NOI18N
53
/** should it be possible to create tests for tests? */
54     static final boolean GENERATE_TESTS_FROM_TEST_CLASSES = NbBundle.getMessage(
55             JUnitSettings.class,
56             "PROP_generate_tests_from_test_classes").equals("true"); //NOI18N
57
/** generate method setUp() by default? */
58     static final boolean DEFAULT_GENERATE_SETUP = NbBundle.getMessage(
59             JUnitSettings.class,
60             "PROP_generate_setUp_default").equals("true"); //NOI18N
61
/** generate method tearDown() by default? */
62     static final boolean DEFAULT_GENERATE_TEARDOWN = NbBundle.getMessage(
63             JUnitSettings.class,
64             "PROP_generate_tearDown_default").equals("true"); //NOI18N
65

66     // XXX this property has to go too - will not work any longer, need some src -> test query
67
private static final String JavaDoc PROP_FILE_SYSTEM = "fileSystem";
68     public static final String JavaDoc PROP_MEMBERS_PUBLIC = "membersPublic";
69     public static final String JavaDoc PROP_MEMBERS_PROTECTED = "membersProtected";
70     public static final String JavaDoc PROP_MEMBERS_PACKAGE = "membersPackage";
71     public static final String JavaDoc PROP_BODY_COMMENTS = "bodyComments";
72     public static final String JavaDoc PROP_BODY_CONTENT = "bodyContent";
73     public static final String JavaDoc PROP_JAVADOC = "javaDoc";
74     public static final String JavaDoc PROP_GENERATE_EXCEPTION_CLASSES = "generateExceptionClasses";
75     public static final String JavaDoc PROP_GENERATE_ABSTRACT_IMPL = "generateAbstractImpl";
76     public static final String JavaDoc PROP_GENERATE_SUITE_CLASSES = "generateSuiteClasses";
77     
78     public static final String JavaDoc PROP_INCLUDE_PACKAGE_PRIVATE_CLASSES = "includePackagePrivateClasses";
79     public static final String JavaDoc PROP_GENERATE_MAIN_METHOD = "generateMainMethod";
80     public static final String JavaDoc PROP_GENERATE_MAIN_METHOD_BODY = "generateMainMethodBody";
81     public static final String JavaDoc PROP_GENERATE_SETUP = "generateSetUp";
82     public static final String JavaDoc PROP_GENERATE_TEARDOWN = "generateTearDown";
83     public static final String JavaDoc PROP_ROOT_SUITE_CLASSNAME = "rootSuiteClassName";
84     
85     public String JavaDoc displayName () {
86         return NbBundle.getMessage (JUnitSettings.class, "LBL_junit_settings");
87     }
88
89     public HelpCtx getHelpCtx () {
90         return new HelpCtx(JUnitSettings.class);
91     }
92
93     private static Preferences JavaDoc getPreferences() {
94         return NbPreferences.forModule(JUnitSettings.class);
95     }
96
97     /** Default instance of this system option, for the convenience of associated classes. */
98     public static JUnitSettings getDefault () {
99         return INSTANCE;
100     }
101
102     public boolean isMembersPublic() {
103         return getPreferences().getBoolean(PROP_MEMBERS_PUBLIC,true);
104     }
105
106     public void setMembersPublic(boolean newVal) {
107         getPreferences().putBoolean(PROP_MEMBERS_PUBLIC,newVal);
108     }
109
110     public boolean isMembersProtected() {
111         return getPreferences().getBoolean(PROP_MEMBERS_PROTECTED,true);
112     }
113
114     public void setMembersProtected(boolean newVal) {
115         getPreferences().putBoolean(PROP_MEMBERS_PROTECTED,newVal);
116     }
117
118     public boolean isMembersPackage() {
119         return getPreferences().getBoolean(PROP_MEMBERS_PACKAGE,true);
120     }
121
122     public void setMembersPackage(boolean newVal) {
123         getPreferences().putBoolean(PROP_MEMBERS_PACKAGE,newVal);
124     }
125
126     public boolean isBodyComments() {
127         return getPreferences().getBoolean(PROP_BODY_COMMENTS,true);
128         
129     }
130
131     public void setBodyComments(boolean newVal) {
132         getPreferences().putBoolean(PROP_BODY_COMMENTS,newVal);
133     }
134
135     public boolean isBodyContent() {
136         return getPreferences().getBoolean(PROP_BODY_CONTENT,true);
137     }
138
139     public void setBodyContent(boolean newVal) {
140         getPreferences().putBoolean(PROP_BODY_CONTENT,newVal);
141     }
142
143     public boolean isJavaDoc() {
144         return getPreferences().getBoolean(PROP_JAVADOC,true);
145     }
146
147     public void setJavaDoc(boolean newVal) {
148         getPreferences().putBoolean(PROP_JAVADOC,newVal);
149     }
150    
151     public boolean isGenerateExceptionClasses() {
152         return getPreferences().getBoolean(PROP_GENERATE_EXCEPTION_CLASSES,true);
153     }
154
155     public void setGenerateExceptionClasses(boolean newVal) {
156         getPreferences().putBoolean(PROP_GENERATE_EXCEPTION_CLASSES,newVal);
157     }
158     
159    
160     public boolean isGenerateAbstractImpl() {
161      return getPreferences().getBoolean(PROP_GENERATE_ABSTRACT_IMPL,true);
162     }
163
164     public void setGenerateAbstractImpl(boolean newVal) {
165         getPreferences().putBoolean(PROP_GENERATE_ABSTRACT_IMPL,newVal);
166     }
167
168     public boolean isGenerateSuiteClasses() {
169         return getPreferences().getBoolean(PROP_GENERATE_SUITE_CLASSES,true);
170     }
171
172     public void setGenerateSuiteClasses(boolean newVal) {
173         getPreferences().putBoolean(PROP_GENERATE_SUITE_CLASSES,newVal);
174     }
175
176     
177     public boolean isIncludePackagePrivateClasses() {
178         return getPreferences().getBoolean(PROP_INCLUDE_PACKAGE_PRIVATE_CLASSES,true);
179     }
180
181     public void setIncludePackagePrivateClasses(boolean newVal) {
182         getPreferences().putBoolean(PROP_INCLUDE_PACKAGE_PRIVATE_CLASSES,newVal);
183     }
184     
185     public boolean isGenerateMainMethod() {
186         return getPreferences().getBoolean(PROP_GENERATE_MAIN_METHOD,true);
187     }
188
189     public void setGenerateMainMethod(boolean newVal) {
190         getPreferences().putBoolean(PROP_GENERATE_MAIN_METHOD,newVal);
191     }
192     
193     public boolean isGenerateSetUp() {
194         return getPreferences().getBoolean(PROP_GENERATE_SETUP,true);
195     }
196
197     public void setGenerateSetUp(boolean newVal) {
198         getPreferences().putBoolean(PROP_GENERATE_SETUP,newVal);
199     }
200     
201     public boolean isGenerateTearDown() {
202         return getPreferences().getBoolean(PROP_GENERATE_TEARDOWN,true);
203     }
204
205     public void setGenerateTearDown(boolean newVal) {
206         getPreferences().putBoolean(PROP_GENERATE_TEARDOWN,newVal);
207     }
208     
209     public String JavaDoc getGenerateMainMethodBody() {
210         return getPreferences().get(PROP_GENERATE_MAIN_METHOD_BODY,
211                 NbBundle.getMessage(JUnitSettings.class, "PROP_generate_main_method_body_default_value"));
212     }
213
214     public void setGenerateMainMethodBody(String JavaDoc newVal) {
215         getPreferences().put(PROP_GENERATE_MAIN_METHOD_BODY,newVal);
216     }
217     
218     public String JavaDoc getRootSuiteClassName() {
219         return getPreferences().get(PROP_ROOT_SUITE_CLASSNAME,
220                 NbBundle.getMessage(JUnitSettings.class, "PROP_root_suite_classname_default_value"));
221     }
222
223     public void setRootSuiteClassName(String JavaDoc newVal) {
224         getPreferences().put(PROP_ROOT_SUITE_CLASSNAME,newVal);
225     }
226     
227     private static BeanNode createViewNode() throws java.beans.IntrospectionException JavaDoc {
228         return new BeanNode<JUnitSettings>(JUnitSettings.getDefault());
229     }
230 }
231
Popular Tags