1 19 20 package org.netbeans.modules.java.editor.options; 21 22 import java.util.Enumeration ; 23 import java.util.List ; 24 import org.netbeans.editor.ext.ExtSettingsNames; 25 import org.netbeans.editor.ext.java.JavaSettingsNames; 26 import org.netbeans.modules.editor.java.JavaKit; 27 import org.netbeans.modules.editor.java.JavaIndentEngine; 28 import org.netbeans.modules.editor.options.OptionSupport; 29 import org.openide.ServiceType; 30 import org.openide.util.HelpCtx; 31 import org.netbeans.modules.editor.NbEditorUtilities; 32 import java.awt.Color ; 33 import java.awt.Dimension ; 34 import java.util.HashMap ; 35 import java.util.Map ; 36 import java.util.MissingResourceException ; 37 import org.netbeans.editor.SettingsNames; 38 import org.netbeans.modules.editor.options.BaseOptions; 39 import org.openide.util.NbBundle; 40 41 47 public class JavaOptions extends BaseOptions { 48 49 public static final String JAVA = "java"; 51 public static final String COMPLETION_AUTO_POPUP_PROP = "completionAutoPopup"; 53 public static final String COMPLETION_CASE_SENSITIVE_PROP = "completionCaseSensitive"; 55 public static final String COMPLETION_NATURAL_SORT_PROP = "completionNaturalSort"; 57 public static final String COMPLETION_AUTO_POPUP_DELAY_PROP = "completionAutoPopupDelay"; 59 public static final String FORMAT_SPACE_BEFORE_PARENTHESIS_PROP = "formatSpaceBeforeParenthesis"; 61 public static final String FORMAT_COMPOUND_BRACKET_ADD_NL_PROP = "formatCompoundBracketAddNL"; 63 public static final String FAST_IMPORT_SELECTION_PROP = "fastImportSelection"; 65 private static final String HELP_ID = "editing.editor.java"; 67 public static final String JAVADOC_BGCOLOR = "javaDocBGColor"; 69 public static final String JAVADOC_AUTO_POPUP_DELAY_PROP = "javaDocAutoPopupDelay"; 71 public static final String JAVADOC_PREFERRED_SIZE_PROP = "javaDocPreferredSize"; 73 public static final String JAVADOC_AUTO_POPUP_PROP = "javaDocAutoPopup"; 75 public static final String SHOW_DEPRECATED_MEMBERS_PROP = "showDeprecatedMembers"; 77 public static final String COMPLETION_INSTANT_SUBSTITUTION_PROP = "completionInstantSubstitution"; 79 public static final String FAST_IMPORT_PACKAGE_PROP = "fastImportPackage"; 81 public static final String GOTO_CLASS_CASE_SENSITIVE_PROP = "gotoClassCaseSensitive"; 83 public static final String GOTO_CLASS_SHOW_INNER_CLASSES_PROP = "gotoClassShowInnerClasses"; 85 public static final String GOTO_CLASS_SHOW_LIBRARY_CLASSES_PROP = "gotoClassShowLibraryClasses"; 87 static final String [] JAVA_PROP_NAMES = OptionSupport.mergeStringArrays(BaseOptions.BASE_PROP_NAMES, new String [] { 88 COMPLETION_AUTO_POPUP_PROP, 89 COMPLETION_CASE_SENSITIVE_PROP, 90 COMPLETION_AUTO_POPUP_DELAY_PROP, 91 FORMAT_SPACE_BEFORE_PARENTHESIS_PROP, 92 FORMAT_COMPOUND_BRACKET_ADD_NL_PROP, 93 JAVADOC_BGCOLOR, 94 JAVADOC_PREFERRED_SIZE_PROP, 96 JAVADOC_AUTO_POPUP_PROP, 97 SHOW_DEPRECATED_MEMBERS_PROP, 98 COMPLETION_INSTANT_SUBSTITUTION_PROP, 99 COMPLETION_NATURAL_SORT_PROP, 100 FAST_IMPORT_PACKAGE_PROP, 101 GOTO_CLASS_CASE_SENSITIVE_PROP, 102 GOTO_CLASS_SHOW_INNER_CLASSES_PROP, 103 GOTO_CLASS_SHOW_LIBRARY_CLASSES_PROP, 104 CODE_FOLDING_PROPS_PROP 105 }); 106 107 static final long serialVersionUID =-7951549840240159575L; 108 109 public JavaOptions() { 110 this(JavaKit.class, JAVA); 111 } 112 113 public JavaOptions(Class kitClass, String typeName) { 114 super(kitClass, typeName); 115 } 116 117 122 public void setFormatSpaceBeforeParenthesis(boolean v) { 123 setSettingBoolean(JavaSettingsNames.JAVA_FORMAT_SPACE_BEFORE_PARENTHESIS, v, 124 FORMAT_SPACE_BEFORE_PARENTHESIS_PROP); 125 126 } 129 130 135 public void setFormatCompoundBracketAddNL(boolean v) { 136 setSettingBoolean(JavaSettingsNames.JAVA_FORMAT_NEWLINE_BEFORE_BRACE, v, 137 FORMAT_COMPOUND_BRACKET_ADD_NL_PROP); 138 139 } 142 143 154 155 public boolean getCompletionAutoPopup() { 156 return getSettingBoolean(ExtSettingsNames.COMPLETION_AUTO_POPUP); 157 } 158 public void setCompletionAutoPopup(boolean v) { 159 setSettingBoolean(ExtSettingsNames.COMPLETION_AUTO_POPUP, v, 160 COMPLETION_AUTO_POPUP_PROP); 161 } 162 163 public boolean getCompletionCaseSensitive() { 164 return getSettingBoolean(ExtSettingsNames.COMPLETION_CASE_SENSITIVE); 165 } 166 public void setCompletionCaseSensitive(boolean v) { 167 setSettingBoolean(ExtSettingsNames.COMPLETION_CASE_SENSITIVE, v, 168 COMPLETION_CASE_SENSITIVE_PROP); 169 } 170 171 public boolean getCompletionInstantSubstitution() { 172 return getSettingBoolean(ExtSettingsNames.COMPLETION_INSTANT_SUBSTITUTION); 173 } 174 public void setCompletionInstantSubstitution(boolean v) { 175 setSettingBoolean(ExtSettingsNames.COMPLETION_INSTANT_SUBSTITUTION, v, 176 COMPLETION_INSTANT_SUBSTITUTION_PROP); 177 } 178 179 public int getCompletionAutoPopupDelay() { 180 return getSettingInteger(ExtSettingsNames.COMPLETION_AUTO_POPUP_DELAY); 181 } 182 public void setCompletionAutoPopupDelay(int delay) { 183 if (delay < 0) { 184 NbEditorUtilities.invalidArgument("MSG_NegativeValue"); return; 186 } 187 setSettingInteger(ExtSettingsNames.COMPLETION_AUTO_POPUP_DELAY, delay, 188 COMPLETION_AUTO_POPUP_DELAY_PROP); 189 } 190 191 204 205 public boolean getJavaDocAutoPopup() { 206 return getSettingBoolean(ExtSettingsNames.JAVADOC_AUTO_POPUP); 207 } 208 public void setJavaDocAutoPopup(boolean auto) { 209 setSettingBoolean(ExtSettingsNames.JAVADOC_AUTO_POPUP, auto, 210 JAVADOC_AUTO_POPUP_PROP); 211 } 212 213 public Color getJavaDocBGColor() { 214 return (Color )getSettingValue(ExtSettingsNames.JAVADOC_BG_COLOR); 215 } 216 public void setJavaDocBGColor(Color c) { 217 setSettingValue(ExtSettingsNames.JAVADOC_BG_COLOR, c, 218 JAVADOC_BGCOLOR); 219 } 220 221 public Dimension getJavaDocPreferredSize() { 222 return (Dimension )getSettingValue(ExtSettingsNames.JAVADOC_PREFERRED_SIZE); 223 } 224 public void setJavaDocPreferredSize(Dimension d) { 225 setSettingValue(ExtSettingsNames.JAVADOC_PREFERRED_SIZE, d, 226 JAVADOC_PREFERRED_SIZE_PROP); 227 } 228 229 public boolean getShowDeprecatedMembers() { 230 return getSettingBoolean(ExtSettingsNames.SHOW_DEPRECATED_MEMBERS); 231 } 232 public void setShowDeprecatedMembers(boolean v) { 233 setSettingBoolean(ExtSettingsNames.SHOW_DEPRECATED_MEMBERS, v, 234 SHOW_DEPRECATED_MEMBERS_PROP); 235 } 236 237 public boolean getCompletionNaturalSort() { 238 return getSettingBoolean(ExtSettingsNames.COMPLETION_NATURAL_SORT); 239 } 240 public void setCompletionNaturalSort(boolean v) { 241 setSettingBoolean(ExtSettingsNames.COMPLETION_NATURAL_SORT, v, 242 COMPLETION_NATURAL_SORT_PROP); 243 } 244 245 public int getFastImportSelection() { 246 return getSettingInteger(ExtSettingsNames.FAST_IMPORT_SELECTION); 247 } 248 public void setFastImportSelection(int sel) { 249 setSettingInteger(ExtSettingsNames.FAST_IMPORT_SELECTION, sel, 250 FAST_IMPORT_SELECTION_PROP); 251 } 252 253 public boolean getGotoClassCaseSensitive() { 254 return getSettingBoolean(JavaSettingsNames.GOTO_CLASS_CASE_SENSITIVE); 255 } 256 public void setGotoClassCaseSensitive(boolean v) { 257 setSettingBoolean(JavaSettingsNames.GOTO_CLASS_CASE_SENSITIVE, v, GOTO_CLASS_CASE_SENSITIVE_PROP); 258 } 259 260 public boolean getGotoClassShowInnerClasses() { 261 return getSettingBoolean(JavaSettingsNames.GOTO_CLASS_SHOW_INNER_CLASSES); 262 } 263 public void setGotoClassShowInnerClasses(boolean v) { 264 setSettingBoolean(JavaSettingsNames.GOTO_CLASS_SHOW_INNER_CLASSES, v, GOTO_CLASS_SHOW_INNER_CLASSES_PROP); 265 } 266 267 public boolean getGotoClassShowLibraryClasses() { 268 return getSettingBoolean(JavaSettingsNames.GOTO_CLASS_SHOW_LIBRARY_CLASSES); 269 } 270 public void setGotoClassShowLibraryClasses(boolean v) { 271 setSettingBoolean(JavaSettingsNames.GOTO_CLASS_SHOW_LIBRARY_CLASSES, v, GOTO_CLASS_SHOW_LIBRARY_CLASSES_PROP); 272 } 273 274 protected Class getDefaultIndentEngineClass() { 275 return JavaIndentEngine.class; 276 } 277 278 public HelpCtx getHelpCtx () { 279 return new HelpCtx (HELP_ID); 280 } 281 282 public Map getCodeFoldingProps(){ 283 Map map = new HashMap (super.getCodeFoldingProps()); 284 285 Boolean val = (Boolean )getSettingValue(JavaSettingsNames.CODE_FOLDING_COLLAPSE_METHOD); 286 map.put(JavaSettingsNames.CODE_FOLDING_COLLAPSE_METHOD, val); 287 288 val = (Boolean )getSettingValue(JavaSettingsNames.CODE_FOLDING_COLLAPSE_INNERCLASS); 289 map.put(JavaSettingsNames.CODE_FOLDING_COLLAPSE_INNERCLASS, val); 290 291 val = (Boolean )getSettingValue(JavaSettingsNames.CODE_FOLDING_COLLAPSE_IMPORT); 292 map.put(JavaSettingsNames.CODE_FOLDING_COLLAPSE_IMPORT, val); 293 294 val = (Boolean )getSettingValue(JavaSettingsNames.CODE_FOLDING_COLLAPSE_JAVADOC); 295 map.put(JavaSettingsNames.CODE_FOLDING_COLLAPSE_JAVADOC, val); 296 297 val = (Boolean )getSettingValue(JavaSettingsNames.CODE_FOLDING_COLLAPSE_INITIAL_COMMENT); 298 map.put(JavaSettingsNames.CODE_FOLDING_COLLAPSE_INITIAL_COMMENT, val); 299 300 return map; 301 } 302 303 public void setCodeFoldingProps(Map props){ 304 String name = SettingsNames.CODE_FOLDING_ENABLE; 305 setSettingValue(name, props.get(name)); 306 name = JavaSettingsNames.CODE_FOLDING_COLLAPSE_METHOD; 307 setSettingValue(name, props.get(name)); 308 name = JavaSettingsNames.CODE_FOLDING_COLLAPSE_INNERCLASS; 309 setSettingValue(name, props.get(name)); 310 name = JavaSettingsNames.CODE_FOLDING_COLLAPSE_IMPORT; 311 setSettingValue(name, props.get(name)); 312 name = JavaSettingsNames.CODE_FOLDING_COLLAPSE_JAVADOC; 313 setSettingValue(name, props.get(name)); 314 name = JavaSettingsNames.CODE_FOLDING_COLLAPSE_INITIAL_COMMENT; 315 setSettingValue(name, props.get(name)); 316 } 317 318 321 protected String getString(String key) { 322 try { 323 return NbBundle.getMessage(JavaOptions.class, key); 324 } catch (MissingResourceException e) { 325 return super.getString(key); 326 } 327 } 328 329 330 } 331 | Popular Tags |