KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > editor > ext > java > JavaSettingsInitializer


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

19
20 package org.netbeans.editor.ext.java;
21
22 import java.awt.Color JavaDoc;
23 import java.awt.Font JavaDoc;
24 import java.awt.event.KeyEvent JavaDoc;
25 import java.awt.event.InputEvent JavaDoc;
26 import java.util.Map JavaDoc;
27 import java.util.HashMap JavaDoc;
28 import java.util.TreeMap JavaDoc;
29 import org.netbeans.editor.Coloring;
30 import org.netbeans.editor.Settings;
31 import org.netbeans.editor.SettingsUtil;
32 import org.netbeans.editor.SettingsNames;
33 import org.netbeans.editor.SettingsDefaults;
34 import org.netbeans.editor.MultiKeyBinding;
35 import org.netbeans.editor.BaseKit;
36 import org.netbeans.editor.TokenContext;
37 import org.netbeans.editor.TokenContextPath;
38 import org.netbeans.editor.ext.ExtSettingsNames;
39
40 /**
41 * Extended settings for Java.
42 *
43 * @author Miloslav Metelka
44 * @version 1.00
45 */

46
47 public class JavaSettingsInitializer extends Settings.AbstractInitializer {
48
49     /** Name assigned to initializer */
50     public static final String JavaDoc NAME = "java-settings-initializer"; // NOI18N
51

52     private Class JavaDoc javaKitClass;
53
54     /** Construct new java-settings-initializer.
55     * @param javaKitClass the real kit class for which the settings are created.
56     * It's unknown here so it must be passed to this constructor.
57     */

58     public JavaSettingsInitializer(Class JavaDoc javaKitClass) {
59         super(NAME);
60         this.javaKitClass = javaKitClass;
61     }
62
63     /** Update map filled with the settings.
64     * @param kitClass kit class for which the settings are being updated.
65     * It is always non-null value.
66     * @param settingsMap map holding [setting-name, setting-value] pairs.
67     * The map can be empty if this is the first initializer
68     * that updates it or if no previous initializers updated it.
69     */

70     public void updateSettingsMap(Class JavaDoc kitClass, Map JavaDoc settingsMap) {
71
72         // Update java colorings
73
if (kitClass == BaseKit.class) {
74
75             new JavaSettingsDefaults.JavaTokenColoringInitializer().updateSettingsMap(kitClass, settingsMap);
76             new JavaSettingsDefaults.JavaLayerTokenColoringInitializer().updateSettingsMap(kitClass, settingsMap);
77
78         }
79
80         if (kitClass == javaKitClass) {
81
82             SettingsUtil.updateListSetting(settingsMap, SettingsNames.KEY_BINDING_LIST,
83                 JavaSettingsDefaults.getJavaKeyBindings());
84
85             SettingsUtil.updateListSetting(settingsMap, SettingsNames.TOKEN_CONTEXT_LIST,
86                 new TokenContext[] {
87                     JavaTokenContext.context,
88                     JavaLayerTokenContext.context
89                 }
90             );
91
92             settingsMap.put(SettingsNames.ABBREV_MAP, JavaSettingsDefaults.getJavaAbbrevMap());
93
94             settingsMap.put(SettingsNames.MACRO_MAP, JavaSettingsDefaults.getJavaMacroMap());
95
96             settingsMap.put(ExtSettingsNames.CARET_SIMPLE_MATCH_BRACE,
97                             JavaSettingsDefaults.defaultCaretSimpleMatchBrace);
98
99             settingsMap.put(ExtSettingsNames.HIGHLIGHT_MATCH_BRACE,
100                             JavaSettingsDefaults.defaultHighlightMatchBrace);
101
102             settingsMap.put(SettingsNames.IDENTIFIER_ACCEPTOR,
103                             JavaSettingsDefaults.defaultIdentifierAcceptor);
104
105             settingsMap.put(SettingsNames.ABBREV_RESET_ACCEPTOR,
106                             JavaSettingsDefaults.defaultAbbrevResetAcceptor);
107
108             settingsMap.put(SettingsNames.WORD_MATCH_MATCH_CASE,
109                             JavaSettingsDefaults.defaultWordMatchMatchCase);
110
111             settingsMap.put(SettingsNames.WORD_MATCH_STATIC_WORDS,
112                             JavaSettingsDefaults.defaultWordMatchStaticWords);
113
114             // Formatting settings
115
settingsMap.put(JavaSettingsNames.JAVA_FORMAT_SPACE_BEFORE_PARENTHESIS,
116                             JavaSettingsDefaults.defaultJavaFormatSpaceBeforeParenthesis);
117
118             settingsMap.put(JavaSettingsNames.JAVA_FORMAT_SPACE_AFTER_COMMA,
119                             JavaSettingsDefaults.defaultJavaFormatSpaceAfterComma);
120
121             settingsMap.put(JavaSettingsNames.JAVA_FORMAT_NEWLINE_BEFORE_BRACE,
122                             JavaSettingsDefaults.defaultJavaFormatNewlineBeforeBrace);
123
124             settingsMap.put(JavaSettingsNames.JAVA_FORMAT_LEADING_SPACE_IN_COMMENT,
125                             JavaSettingsDefaults.defaultJavaFormatLeadingSpaceInComment);
126
127             settingsMap.put(JavaSettingsNames.JAVA_FORMAT_LEADING_STAR_IN_COMMENT,
128                             JavaSettingsDefaults.defaultJavaFormatLeadingStarInComment);
129
130             settingsMap.put(JavaSettingsNames.INDENT_HOT_CHARS_ACCEPTOR,
131                             JavaSettingsDefaults.defaultIndentHotCharsAcceptor);
132
133             settingsMap.put(ExtSettingsNames.REINDENT_WITH_TEXT_BEFORE,
134                             Boolean.FALSE);
135
136         settingsMap.put(JavaSettingsNames.PAIR_CHARACTERS_COMPLETION,
137                 JavaSettingsDefaults.defaultPairCharactersCompletion);
138
139             settingsMap.put(JavaSettingsNames.GOTO_CLASS_CASE_SENSITIVE,
140                             JavaSettingsDefaults.defaultGotoClassCaseSensitive);
141
142             settingsMap.put(JavaSettingsNames.GOTO_CLASS_SHOW_INNER_CLASSES,
143                             JavaSettingsDefaults.defaultGotoClassShowInnerClasses);
144
145             settingsMap.put(JavaSettingsNames.GOTO_CLASS_SHOW_LIBRARY_CLASSES,
146                             JavaSettingsDefaults.defaultGotoClassShowLibraryClasses);
147         }
148
149     }
150
151 }
152
Popular Tags