001: /*
002: * Sun Public License Notice
003: *
004: * The contents of this file are subject to the Sun Public License
005: * Version 1.0 (the "License"). You may not use this file except in
006: * compliance with the License. A copy of the License is available at
007: * http://www.sun.com/
008: *
009: * The Original Code is NetBeans. The Initial Developer of the Original
010: * Code is Sun Microsystems, Inc. Portions Copyright 1997-2000 Sun
011: * Microsystems, Inc. All Rights Reserved.
012: */
013:
014: package org.netbeans.editor.ext.java;
015:
016: import java.util.Map;
017:
018: import org.netbeans.editor.BaseKit;
019: import org.netbeans.editor.Settings;
020: import org.netbeans.editor.SettingsNames;
021: import org.netbeans.editor.SettingsUtil;
022: import org.netbeans.editor.TokenContext;
023: import org.netbeans.editor.ext.ExtSettingsNames;
024:
025: /**
026: * Extended settings for Java.
027: *
028: * @author Miloslav Metelka
029: * @version 1.00
030: */
031:
032: public class JavaSettingsInitializer extends
033: Settings.AbstractInitializer {
034:
035: /** Name assigned to initializer */
036: public static final String NAME = "java-settings-initializer";
037:
038: private Class javaKitClass;
039:
040: /**
041: * Construct new java-settings-initializer.
042: *
043: * @param javaKitClass
044: * the real kit class for which the settings are created. It's
045: * unknown here so it must be passed to this constructor.
046: */
047: public JavaSettingsInitializer(Class javaKitClass) {
048: super (NAME);
049: this .javaKitClass = javaKitClass;
050: }
051:
052: /**
053: * Update map filled with the settings.
054: *
055: * @param kitClass
056: * kit class for which the settings are being updated. It is
057: * always non-null value.
058: * @param settingsMap
059: * map holding [setting-name, setting-value] pairs. The map can
060: * be empty if this is the first initializer that updates it or
061: * if no previous initializers updated it.
062: */
063: public void updateSettingsMap(Class kitClass, Map settingsMap) {
064:
065: // Update java colorings
066: if (kitClass == BaseKit.class) {
067:
068: new JavaSettingsDefaults.JavaTokenColoringInitializer()
069: .updateSettingsMap(kitClass, settingsMap);
070: new JavaSettingsDefaults.JavaLayerTokenColoringInitializer()
071: .updateSettingsMap(kitClass, settingsMap);
072:
073: }
074:
075: if (kitClass == javaKitClass) {
076:
077: SettingsUtil.updateListSetting(settingsMap,
078: SettingsNames.KEY_BINDING_LIST,
079: JavaSettingsDefaults.getJavaKeyBindings());
080:
081: SettingsUtil.updateListSetting(settingsMap,
082: SettingsNames.TOKEN_CONTEXT_LIST,
083: new TokenContext[] { JavaTokenContext.context,
084: JavaLayerTokenContext.context });
085:
086: settingsMap.put(SettingsNames.ABBREV_MAP,
087: JavaSettingsDefaults.getJavaAbbrevMap());
088:
089: settingsMap.put(SettingsNames.MACRO_MAP,
090: JavaSettingsDefaults.getJavaMacroMap());
091:
092: settingsMap.put(ExtSettingsNames.CARET_SIMPLE_MATCH_BRACE,
093: JavaSettingsDefaults.defaultCaretSimpleMatchBrace);
094:
095: settingsMap.put(ExtSettingsNames.HIGHLIGHT_MATCH_BRACE,
096: JavaSettingsDefaults.defaultHighlightMatchBrace);
097:
098: settingsMap.put(SettingsNames.IDENTIFIER_ACCEPTOR,
099: JavaSettingsDefaults.defaultIdentifierAcceptor);
100:
101: settingsMap.put(SettingsNames.ABBREV_RESET_ACCEPTOR,
102: JavaSettingsDefaults.defaultAbbrevResetAcceptor);
103:
104: settingsMap.put(SettingsNames.WORD_MATCH_MATCH_CASE,
105: JavaSettingsDefaults.defaultWordMatchMatchCase);
106:
107: settingsMap.put(SettingsNames.WORD_MATCH_STATIC_WORDS,
108: JavaSettingsDefaults.defaultWordMatchStaticWords);
109:
110: // Formatting settings
111: settingsMap
112: .put(
113: JavaSettingsNames.JAVA_FORMAT_SPACE_BEFORE_PARENTHESIS,
114: JavaSettingsDefaults.defaultJavaFormatSpaceBeforeParenthesis);
115:
116: settingsMap
117: .put(
118: JavaSettingsNames.JAVA_FORMAT_SPACE_AFTER_COMMA,
119: JavaSettingsDefaults.defaultJavaFormatSpaceAfterComma);
120:
121: settingsMap
122: .put(
123: JavaSettingsNames.JAVA_FORMAT_NEWLINE_BEFORE_BRACE,
124: JavaSettingsDefaults.defaultJavaFormatNewlineBeforeBrace);
125:
126: settingsMap
127: .put(
128: JavaSettingsNames.JAVA_FORMAT_LEADING_SPACE_IN_COMMENT,
129: JavaSettingsDefaults.defaultJavaFormatLeadingSpaceInComment);
130:
131: settingsMap
132: .put(
133: JavaSettingsNames.JAVA_FORMAT_LEADING_STAR_IN_COMMENT,
134: JavaSettingsDefaults.defaultJavaFormatLeadingStarInComment);
135:
136: settingsMap.put(
137: JavaSettingsNames.INDENT_HOT_CHARS_ACCEPTOR,
138: JavaSettingsDefaults.defaultIndentHotCharsAcceptor);
139:
140: settingsMap.put(ExtSettingsNames.REINDENT_WITH_TEXT_BEFORE,
141: Boolean.FALSE);
142: }
143:
144: }
145:
146: }
|