1 19 20 package org.netbeans.modules.java.ui.nodes.elements; 21 22 import org.openide.util.NbBundle; 23 24 32 public final class SourceOptions { 33 34 private static final byte T_INITIALIZER = 0; 35 private static final byte T_FIELD = 1; 36 private static final byte T_CONSTRUCTOR = 2; 37 private static final byte T_METHOD = 3; 38 private static final byte T_CLASS = 4; 39 private static final byte T_INTERFACE = 5; 40 private static final byte T_ENUM = 6; 41 private static final byte T_CONSTANT = 7; 42 private static final byte T_ANNOTATION_TYPE = 8; 43 private static final byte T_ANNOTATION_TYPE_METHOD = 9; 44 45 46 static final String [] PROP_NAMES = { 47 "initializerElementFormat", "fieldElementFormat", "constructorElementFormat", "methodElementFormat", "classElementFormat", "interfaceElementFormat", "enumElementFormat", "constantElementFormat", "annTypeElementFormat", "annTypeMethodElementFormat", }; 53 54 55 private static final ElementFormat[] DEFAULT_FORMATS_SHORT = new ElementFormat[PROP_NAMES.length]; 56 57 58 private static final ElementFormat[] DEFAULT_FORMATS_LONG = new ElementFormat[PROP_NAMES.length]; 59 private static final SourceOptions INSTANCE = new SourceOptions(); 60 61 private static void loadDefaultFormats() { 62 synchronized (SourceOptions.class) { 63 if (DEFAULT_FORMATS_SHORT[0] != null) 64 return; 65 for (int i = 0; i < PROP_NAMES.length; i++) { 66 DEFAULT_FORMATS_SHORT[i] = new ElementFormat(getString("SHORT_" + PROP_NAMES[i])); DEFAULT_FORMATS_LONG[i] = new ElementFormat(getString("LONG_" + PROP_NAMES[i])); } 69 } 70 } 71 72 73 public static final String PROP_INITIALIZER_FORMAT = PROP_NAMES[T_INITIALIZER]; 74 75 76 public static final String PROP_FIELD_FORMAT = PROP_NAMES[T_FIELD]; 77 78 79 public static final String PROP_CONSTRUCTOR_FORMAT = PROP_NAMES[T_CONSTRUCTOR]; 80 81 82 public static final String PROP_METHOD_FORMAT = PROP_NAMES[T_METHOD]; 83 84 85 public static final String PROP_CLASS_FORMAT = PROP_NAMES[T_CLASS]; 86 87 88 public static final String PROP_INTERFACE_FORMAT = PROP_NAMES[T_INTERFACE]; 89 90 91 public static final String PROP_ENUM_FORMAT = PROP_NAMES[T_ENUM]; 92 93 94 public static final String PROP_CONSTANT_FORMAT = PROP_NAMES[T_CONSTANT]; 95 96 97 public static final String PROP_ANNOTATION_TYPE_FORMAT = PROP_NAMES[T_ANNOTATION_TYPE]; 98 99 100 public static final String PROP_ANNOTATION_TYPE_METHOD_FORMAT = PROP_NAMES[T_ANNOTATION_TYPE_METHOD]; 101 102 103 public static final String PROP_CATEGORIES_USAGE = "categoriesUsage"; 105 106 private static boolean categories = true; 107 108 static final long serialVersionUID = 1; 109 110 private SourceOptions() { 111 } 112 113 115 public static SourceOptions getInstance() { 116 return INSTANCE; 117 } 118 119 122 public ElementFormat getInitializerElementFormat() { 123 return getElementFormat(T_INITIALIZER); 124 } 125 126 private ElementFormat getElementFormat(int type) { 127 loadDefaultFormats(); 128 return DEFAULT_FORMATS_SHORT[type]; 129 } 130 131 134 public ElementFormat getFieldElementFormat() { 135 return getElementFormat(T_FIELD); 136 } 137 138 141 public ElementFormat getConstructorElementFormat() { 142 return getElementFormat(T_CONSTRUCTOR); 143 } 144 145 148 public ElementFormat getMethodElementFormat() { 149 return getElementFormat(T_METHOD); 150 } 151 152 155 public ElementFormat getClassElementFormat() { 156 return getElementFormat(T_CLASS); 157 } 158 159 162 public ElementFormat getInterfaceElementFormat() { 163 return getElementFormat(T_INTERFACE); 164 } 165 166 169 public ElementFormat getEnumElementFormat() { 170 return getElementFormat(T_ENUM); 171 } 172 173 176 public ElementFormat getConstantElementFormat() { 177 return getElementFormat(T_CONSTANT); 178 } 179 180 183 public ElementFormat getAnnTypeElementFormat() { 184 return getElementFormat(T_ANNOTATION_TYPE); 185 } 186 187 190 public ElementFormat getAnnTypeMethodElementFormat() { 191 return getElementFormat(T_ANNOTATION_TYPE_METHOD); 192 } 193 194 196 199 public ElementFormat getInitializerElementLongFormat() { 200 loadDefaultFormats(); 201 return DEFAULT_FORMATS_LONG[T_INITIALIZER]; 202 } 203 204 207 public ElementFormat getFieldElementLongFormat() { 208 loadDefaultFormats(); 209 return DEFAULT_FORMATS_LONG[T_FIELD]; 210 } 211 212 215 public ElementFormat getConstructorElementLongFormat() { 216 loadDefaultFormats(); 217 return DEFAULT_FORMATS_LONG[T_CONSTRUCTOR]; 218 } 219 220 223 public ElementFormat getMethodElementLongFormat() { 224 loadDefaultFormats(); 225 return DEFAULT_FORMATS_LONG[T_METHOD]; 226 } 227 228 231 public ElementFormat getClassElementLongFormat() { 232 loadDefaultFormats(); 233 return DEFAULT_FORMATS_LONG[T_CLASS]; 234 } 235 236 239 public ElementFormat getInterfaceElementLongFormat() { 240 loadDefaultFormats(); 241 return DEFAULT_FORMATS_LONG[T_INTERFACE]; 242 } 243 244 247 public ElementFormat getEnumElementLongFormat() { 248 loadDefaultFormats(); 249 return DEFAULT_FORMATS_LONG[T_ENUM]; 250 } 251 252 255 public ElementFormat getConstantElementLongFormat() { 256 loadDefaultFormats(); 257 return DEFAULT_FORMATS_LONG[T_CONSTANT]; 258 } 259 260 263 public ElementFormat getAnnTypeElementLongFormat() { 264 loadDefaultFormats(); 265 return DEFAULT_FORMATS_LONG[T_ANNOTATION_TYPE]; 266 } 267 268 271 public ElementFormat getAnnTypeMethodElementLongFormat() { 272 loadDefaultFormats(); 273 return DEFAULT_FORMATS_LONG[T_ANNOTATION_TYPE_METHOD]; 274 } 275 277 282 public void setCategoriesUsage(boolean cat) { 283 categories = cat; 284 } 285 286 291 public boolean getCategoriesUsage() { 292 return categories; 293 } 294 295 297 private static String getString(String key) { 298 return NbBundle.getMessage(SourceOptions.class, key); 299 } 300 } 301 | Popular Tags |