KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > editor > BaseSettingsInitializer


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;
21
22 import java.util.Map JavaDoc;
23
24 /**
25 * Initializer for the editor settings. This initializer contains
26 * the default values for the majority of the base-level settings.
27 * The constants defined here are used also internally
28 * as the default values for the editor in cases
29 * the user enters an invalid value into some setting that
30 * would break the editor functionality.
31 *
32 * @author Miloslav Metelka
33 * @version 1.00
34 */

35
36 public class BaseSettingsInitializer extends Settings.AbstractInitializer {
37
38     /** Name assigned to initializer */
39     public static final String JavaDoc NAME = "base-settings-initializer"; // NOI18N
40

41     public BaseSettingsInitializer() {
42         super(NAME);
43     }
44
45     /** Update map filled with the settings.
46     * @param kitClass kit class for which the settings are being updated.
47     * It is always non-null value.
48     * @param settingsMap map holding [setting-name, setting-value] pairs.
49     * The map can be empty if this is the first initializer
50     * that updates it or if no previous initializers updated it.
51     */

52     public void updateSettingsMap(Class JavaDoc kitClass, Map JavaDoc settingsMap) {
53
54         // ------------------------ BaseKit Settings --------------------------------------
55
if (kitClass == BaseKit.class) {
56             settingsMap.put(SettingsNames.TAB_SIZE, SettingsDefaults.defaultTabSize);
57             settingsMap.put(SettingsNames.EXPAND_TABS, SettingsDefaults.defaultExpandTabs);
58             settingsMap.put(SettingsNames.SPACES_PER_TAB, SettingsDefaults.defaultSpacesPerTab);
59
60             settingsMap.put(SettingsNames.CARET_TYPE_INSERT_MODE, SettingsDefaults.defaultCaretTypeInsertMode);
61             settingsMap.put(SettingsNames.CARET_TYPE_OVERWRITE_MODE, SettingsDefaults.defaultCaretTypeOverwriteMode);
62             settingsMap.put(SettingsNames.CARET_ITALIC_INSERT_MODE, SettingsDefaults.defaultCaretItalicInsertMode);
63             settingsMap.put(SettingsNames.CARET_ITALIC_OVERWRITE_MODE, SettingsDefaults.defaultCaretItalicOverwriteMode);
64             settingsMap.put(SettingsNames.CARET_COLOR_INSERT_MODE, SettingsDefaults.defaultCaretColorInsertMode);
65             settingsMap.put(SettingsNames.CARET_COLOR_OVERWRITE_MODE, SettingsDefaults.defaultCaretColorOvwerwriteMode);
66             settingsMap.put(SettingsNames.CARET_BLINK_RATE, SettingsDefaults.defaultCaretBlinkRate);
67
68             settingsMap.put(SettingsNames.MACRO_MAP, SettingsDefaults.defaultMacroMap );
69             settingsMap.put(SettingsNames.ABBREV_MAP, SettingsDefaults.defaultAbbrevMap );
70             settingsMap.put(SettingsNames.ABBREV_EXPAND_ACCEPTOR, SettingsDefaults.defaultAbbrevExpandAcceptor);
71             settingsMap.put(SettingsNames.ABBREV_ADD_TYPED_CHAR_ACCEPTOR, SettingsDefaults.defaultAbbrevAddTypedCharAcceptor);
72             settingsMap.put(SettingsNames.ABBREV_RESET_ACCEPTOR, SettingsDefaults.defaultAbbrevResetAcceptor);
73
74             settingsMap.put(SettingsNames.LINE_NUMBER_VISIBLE, SettingsDefaults.defaultLineNumberVisible);
75
76             settingsMap.put(SettingsNames.LINE_HEIGHT_CORRECTION, SettingsDefaults.defaultLineHeightCorrection);
77             settingsMap.put(SettingsNames.TEXT_LEFT_MARGIN_WIDTH, SettingsDefaults.defaultTextLeftMarginWidth);
78             settingsMap.put(SettingsNames.MARGIN, SettingsDefaults.defaultMargin);
79             settingsMap.put(SettingsNames.SCROLL_JUMP_INSETS, SettingsDefaults.defaultScrollJumpInsets);
80             settingsMap.put(SettingsNames.SCROLL_FIND_INSETS, SettingsDefaults.defaultScrollFindInsets);
81             settingsMap.put(SettingsNames.COMPONENT_SIZE_INCREMENT, SettingsDefaults.defaultComponentSizeIncrement);
82
83             settingsMap.put(SettingsNames.STATUS_BAR_VISIBLE, SettingsDefaults.defaultStatusBarVisible);
84             settingsMap.put(SettingsNames.STATUS_BAR_CARET_DELAY, SettingsDefaults.defaultStatusBarCaretDelay);
85
86             settingsMap.put(SettingsNames.TEXT_LIMIT_LINE_VISIBLE, SettingsDefaults.defaultTextLimitLineVisible);
87             settingsMap.put(SettingsNames.TEXT_LIMIT_LINE_COLOR, SettingsDefaults.defaultTextLimitLineColor);
88             settingsMap.put(SettingsNames.TEXT_LIMIT_WIDTH, SettingsDefaults.defaultTextLimitWidth);
89
90             settingsMap.put(SettingsNames.HOME_KEY_COLUMN_ONE, SettingsDefaults.defaultHomeKeyColumnOne);
91             settingsMap.put(SettingsNames.WORD_MOVE_NEWLINE_STOP, SettingsDefaults.defaultWordMoveNewlineStop);
92             settingsMap.put(SettingsNames.INPUT_METHODS_ENABLED, SettingsDefaults.defaultInputMethodsEnabled);
93             settingsMap.put(SettingsNames.FIND_HIGHLIGHT_SEARCH, SettingsDefaults.defaultFindHighlightSearch);
94             settingsMap.put(SettingsNames.FIND_INC_SEARCH, SettingsDefaults.defaultFindIncSearch);
95             settingsMap.put(SettingsNames.FIND_BACKWARD_SEARCH, SettingsDefaults.defaultFindBackwardSearch);
96             settingsMap.put(SettingsNames.FIND_WRAP_SEARCH, SettingsDefaults.defaultFindWrapSearch);
97             settingsMap.put(SettingsNames.FIND_MATCH_CASE, SettingsDefaults.defaultFindMatchCase);
98             settingsMap.put(SettingsNames.FIND_WHOLE_WORDS, SettingsDefaults.defaultFindWholeWords);
99             settingsMap.put(SettingsNames.FIND_REG_EXP, SettingsDefaults.defaultFindRegExp);
100             settingsMap.put(SettingsNames.FIND_HISTORY_SIZE, SettingsDefaults.defaultFindHistorySize);
101             settingsMap.put(SettingsNames.WORD_MATCH_SEARCH_LEN, SettingsDefaults.defaultWordMatchSearchLen);
102             settingsMap.put(SettingsNames.WORD_MATCH_WRAP_SEARCH, SettingsDefaults.defaultWordMatchWrapSearch);
103             settingsMap.put(SettingsNames.WORD_MATCH_MATCH_ONE_CHAR, SettingsDefaults.defaultWordMatchMatchOneChar);
104             settingsMap.put(SettingsNames.WORD_MATCH_MATCH_CASE, SettingsDefaults.defaultWordMatchMatchCase);
105             settingsMap.put(SettingsNames.WORD_MATCH_SMART_CASE, SettingsDefaults.defaultWordMatchSmartCase);
106             settingsMap.put(SettingsNames.IDENTIFIER_ACCEPTOR, SettingsDefaults.defaultIdentifierAcceptor);
107             settingsMap.put(SettingsNames.WHITESPACE_ACCEPTOR, SettingsDefaults.defaultWhitespaceAcceptor);
108             settingsMap.put(SettingsNames.CODE_FOLDING_ENABLE, SettingsDefaults.defaultCodeFoldingEnable);
109             
110             // Base key-bindings
111
// SettingsUtil.updateListSetting(settingsMap,
112
// SettingsNames.KEY_BINDING_LIST, SettingsDefaults.defaultKeyBindings);
113

114             // Base colorings
115
SettingsUtil.setColoring(settingsMap,
116                                      SettingsNames.DEFAULT_COLORING, SettingsDefaults.defaultColoring);
117
118             SettingsUtil.setColoring(settingsMap,
119                                      SettingsNames.LINE_NUMBER_COLORING, SettingsDefaults.defaultLineNumberColoring);
120             
121             SettingsUtil.setColoring(settingsMap,
122                                      SettingsNames.GUARDED_COLORING, SettingsDefaults.defaultGuardedColoring);
123             
124             SettingsUtil.setColoring(settingsMap,
125                                      SettingsNames.CODE_FOLDING_COLORING, SettingsDefaults.defaultCodeFoldingColoring);
126
127             SettingsUtil.setColoring(settingsMap,
128                                      SettingsNames.CODE_FOLDING_BAR_COLORING, SettingsDefaults.defaultCodeFoldingBarColoring);
129             
130             SettingsUtil.setColoring(settingsMap,
131                                      SettingsNames.SELECTION_COLORING, SettingsDefaults.defaultSelectionColoring);
132
133             SettingsUtil.setColoring(settingsMap,
134                                      SettingsNames.HIGHLIGHT_SEARCH_COLORING, SettingsDefaults.defaultHighlightSearchColoring);
135
136             SettingsUtil.setColoring(settingsMap,
137                                      SettingsNames.INC_SEARCH_COLORING, SettingsDefaults.defaultIncSearchColoring);
138
139             SettingsUtil.setColoring(settingsMap,
140                                      SettingsNames.BLOCK_SEARCH_COLORING, SettingsDefaults.defaultblockSearchColoring);
141
142             SettingsUtil.setColoring(settingsMap,
143                                      SettingsNames.STATUS_BAR_COLORING, SettingsDefaults.defaultStatusBarColoring);
144
145             SettingsUtil.setColoring(settingsMap,
146                                      SettingsNames.STATUS_BAR_BOLD_COLORING, SettingsDefaults.defaultStatusBarBoldColoring);
147
148             // List of the colorings for all the kits
149
SettingsUtil.updateListSetting(settingsMap,
150                                            SettingsNames.COLORING_NAME_LIST, SettingsDefaults.defaultColoringNames);
151
152 /* This was removed because document now uses this algorithm by default.
153  * Providing an explicit value for the setting means that the default
154  * algorithm should be overriden. Although the substituter below seems OK
155  * it doesn't reflect possible custom indent engines that can be provided by the IDE.
156
157
158             settingsMap.put(SettingsNames.INDENT_SHIFT_WIDTH, // substitute
159                             new Settings.Evaluator() {
160                                 public Object getValue(Class kitClass2, String settingName) {
161                                     Object ret;
162                                     if (SettingsUtil.getBoolean(kitClass2, SettingsNames.EXPAND_TABS, false)) {
163                                         ret = Settings.getValue(kitClass2, SettingsNames.SPACES_PER_TAB);
164                                     } else { // don't expand tabs
165                                         ret = Settings.getValue(kitClass2, SettingsNames.TAB_SIZE);
166                                     }
167                                     return ret;
168                                 }
169                             }
170                            );
171  */

172
173             /* WARNING!
174             * The following settings should be changed with care as there are some
175             * dependencies among the values of these settings. If the values are wrong
176             * the editor may work in a wrong way in some circumstances.
177             * The EditorDebug.checkSettings(kitClass) should be run
178             * in some DOC_INSTALL_ACTION_LIST action to ensure that
179             * the changed values are correct.
180             */

181             settingsMap.put(SettingsNames.READ_BUFFER_SIZE, SettingsDefaults.defaultReadBufferSize);
182             settingsMap.put(SettingsNames.WRITE_BUFFER_SIZE, SettingsDefaults.defaultWriteBufferSize);
183             settingsMap.put(SettingsNames.READ_MARK_DISTANCE, SettingsDefaults.defaultReadMarkDistance);
184             settingsMap.put(SettingsNames.MARK_DISTANCE, SettingsDefaults.defaultMarkDistance);
185             settingsMap.put(SettingsNames.MAX_MARK_DISTANCE, SettingsDefaults.defaultMaxMarkDistance);
186             settingsMap.put(SettingsNames.MIN_MARK_DISTANCE, SettingsDefaults.defaultMinMarkDistance);
187             settingsMap.put(SettingsNames.SYNTAX_UPDATE_BATCH_SIZE, SettingsDefaults.defaultSyntaxUpdateBatchSize);
188             settingsMap.put(SettingsNames.LINE_BATCH_SIZE, SettingsDefaults.defaultLineBatchSize);
189
190         }
191     }
192
193 }
194
Popular Tags