1 19 20 package org.netbeans.modules.junit; 21 22 import java.util.prefs.Preferences ; 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 34 public class JUnitSettings { 35 private static final JUnitSettings INSTANCE = new JUnitSettings(); 36 37 38 static final String TEST_CLASSNAME_PREFIX = NbBundle.getMessage( 39 JUnitSettings.class, 40 "PROP_test_classname_prefix"); 42 static final String TEST_CLASSNAME_SUFFIX = NbBundle.getMessage( 43 JUnitSettings.class, 44 "PROP_test_classname_suffix"); 46 static final String SUITE_CLASSNAME_PREFIX = NbBundle.getMessage( 47 JUnitSettings.class, 48 "PROP_suite_classname_prefix"); 50 static final String SUITE_CLASSNAME_SUFFIX = NbBundle.getMessage( 51 JUnitSettings.class, 52 "PROP_suite_classname_suffix"); 54 static final boolean GENERATE_TESTS_FROM_TEST_CLASSES = NbBundle.getMessage( 55 JUnitSettings.class, 56 "PROP_generate_tests_from_test_classes").equals("true"); 58 static final boolean DEFAULT_GENERATE_SETUP = NbBundle.getMessage( 59 JUnitSettings.class, 60 "PROP_generate_setUp_default").equals("true"); 62 static final boolean DEFAULT_GENERATE_TEARDOWN = NbBundle.getMessage( 63 JUnitSettings.class, 64 "PROP_generate_tearDown_default").equals("true"); 66 private static final String PROP_FILE_SYSTEM = "fileSystem"; 68 public static final String PROP_MEMBERS_PUBLIC = "membersPublic"; 69 public static final String PROP_MEMBERS_PROTECTED = "membersProtected"; 70 public static final String PROP_MEMBERS_PACKAGE = "membersPackage"; 71 public static final String PROP_BODY_COMMENTS = "bodyComments"; 72 public static final String PROP_BODY_CONTENT = "bodyContent"; 73 public static final String PROP_JAVADOC = "javaDoc"; 74 public static final String PROP_GENERATE_EXCEPTION_CLASSES = "generateExceptionClasses"; 75 public static final String PROP_GENERATE_ABSTRACT_IMPL = "generateAbstractImpl"; 76 public static final String PROP_GENERATE_SUITE_CLASSES = "generateSuiteClasses"; 77 78 public static final String PROP_INCLUDE_PACKAGE_PRIVATE_CLASSES = "includePackagePrivateClasses"; 79 public static final String PROP_GENERATE_MAIN_METHOD = "generateMainMethod"; 80 public static final String PROP_GENERATE_MAIN_METHOD_BODY = "generateMainMethodBody"; 81 public static final String PROP_GENERATE_SETUP = "generateSetUp"; 82 public static final String PROP_GENERATE_TEARDOWN = "generateTearDown"; 83 public static final String PROP_ROOT_SUITE_CLASSNAME = "rootSuiteClassName"; 84 85 public String 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 getPreferences() { 94 return NbPreferences.forModule(JUnitSettings.class); 95 } 96 97 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 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 newVal) { 215 getPreferences().put(PROP_GENERATE_MAIN_METHOD_BODY,newVal); 216 } 217 218 public String 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 newVal) { 224 getPreferences().put(PROP_ROOT_SUITE_CLASSNAME,newVal); 225 } 226 227 private static BeanNode createViewNode() throws java.beans.IntrospectionException { 228 return new BeanNode<JUnitSettings>(JUnitSettings.getDefault()); 229 } 230 } 231 | Popular Tags |