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;
015:
016: import java.util.Map;
017:
018: /**
019: * Initializer for the editor settings. This initializer contains the default
020: * values for the majority of the base-level settings. The constants defined
021: * here are used also internally as the default values for the editor in cases
022: * the user enters an invalid value into some setting that would break the
023: * editor functionality.
024: *
025: * @author Miloslav Metelka
026: * @version 1.00
027: */
028:
029: public class BaseSettingsInitializer extends
030: Settings.AbstractInitializer {
031:
032: /** Name assigned to initializer */
033: public static final String NAME = "base-settings-initializer";
034:
035: public BaseSettingsInitializer() {
036: super (NAME);
037: }
038:
039: /**
040: * Update map filled with the settings.
041: *
042: * @param kitClass
043: * kit class for which the settings are being updated. It is
044: * always non-null value.
045: * @param settingsMap
046: * map holding [setting-name, setting-value] pairs. The map can
047: * be empty if this is the first initializer that updates it or
048: * if no previous initializers updated it.
049: */
050: public void updateSettingsMap(Class kitClass, Map settingsMap) {
051:
052: // ------------------------ BaseKit Settings
053: // --------------------------------------
054: if (kitClass == BaseKit.class) {
055: settingsMap.put(SettingsNames.TAB_SIZE,
056: SettingsDefaults.defaultTabSize);
057: settingsMap.put(SettingsNames.EXPAND_TABS,
058: SettingsDefaults.defaultExpandTabs);
059: settingsMap.put(SettingsNames.SPACES_PER_TAB,
060: SettingsDefaults.defaultSpacesPerTab);
061:
062: settingsMap.put(SettingsNames.CARET_TYPE_INSERT_MODE,
063: SettingsDefaults.defaultCaretTypeInsertMode);
064: settingsMap.put(SettingsNames.CARET_TYPE_OVERWRITE_MODE,
065: SettingsDefaults.defaultCaretTypeOverwriteMode);
066: settingsMap.put(SettingsNames.CARET_ITALIC_INSERT_MODE,
067: SettingsDefaults.defaultCaretItalicInsertMode);
068: settingsMap.put(SettingsNames.CARET_ITALIC_OVERWRITE_MODE,
069: SettingsDefaults.defaultCaretItalicOverwriteMode);
070: settingsMap.put(SettingsNames.CARET_COLOR_INSERT_MODE,
071: SettingsDefaults.defaultCaretColorInsertMode);
072: settingsMap.put(SettingsNames.CARET_COLOR_OVERWRITE_MODE,
073: SettingsDefaults.defaultCaretColorOvwerwriteMode);
074: settingsMap.put(SettingsNames.CARET_BLINK_RATE,
075: SettingsDefaults.defaultCaretBlinkRate);
076:
077: settingsMap.put(SettingsNames.MACRO_MAP,
078: SettingsDefaults.defaultMacroMap);
079: settingsMap.put(SettingsNames.ABBREV_MAP,
080: SettingsDefaults.defaultAbbrevMap);
081: settingsMap.put(SettingsNames.ABBREV_EXPAND_ACCEPTOR,
082: SettingsDefaults.defaultAbbrevExpandAcceptor);
083: settingsMap.put(
084: SettingsNames.ABBREV_ADD_TYPED_CHAR_ACCEPTOR,
085: SettingsDefaults.defaultAbbrevAddTypedCharAcceptor);
086: settingsMap.put(SettingsNames.ABBREV_RESET_ACCEPTOR,
087: SettingsDefaults.defaultAbbrevResetAcceptor);
088:
089: settingsMap.put(SettingsNames.LINE_NUMBER_VISIBLE,
090: SettingsDefaults.defaultLineNumberVisible);
091: settingsMap.put(SettingsNames.PRINT_LINE_NUMBER_VISIBLE,
092: SettingsDefaults.defaultPrintLineNumberVisible);
093:
094: settingsMap.put(SettingsNames.LINE_HEIGHT_CORRECTION,
095: SettingsDefaults.defaultLineHeightCorrection);
096: settingsMap.put(SettingsNames.LINE_NUMBER_MARGIN,
097: SettingsDefaults.defaultLineNumberMargin);
098: settingsMap.put(SettingsNames.TEXT_LEFT_MARGIN_WIDTH,
099: SettingsDefaults.defaultTextLeftMarginWidth);
100: settingsMap.put(SettingsNames.SCROLL_JUMP_INSETS,
101: SettingsDefaults.defaultScrollJumpInsets);
102: settingsMap.put(SettingsNames.SCROLL_FIND_INSETS,
103: SettingsDefaults.defaultScrollFindInsets);
104: settingsMap.put(SettingsNames.COMPONENT_SIZE_INCREMENT,
105: SettingsDefaults.defaultComponentSizeIncrement);
106:
107: settingsMap.put(SettingsNames.STATUS_BAR_VISIBLE,
108: SettingsDefaults.defaultStatusBarVisible);
109: settingsMap.put(SettingsNames.STATUS_BAR_CARET_DELAY,
110: SettingsDefaults.defaultStatusBarCaretDelay);
111:
112: settingsMap.put(SettingsNames.TEXT_LIMIT_LINE_VISIBLE,
113: SettingsDefaults.defaultTextLimitLineVisible);
114: settingsMap.put(SettingsNames.TEXT_LIMIT_LINE_COLOR,
115: SettingsDefaults.defaultTextLimitLineColor);
116: settingsMap.put(SettingsNames.TEXT_LIMIT_WIDTH,
117: SettingsDefaults.defaultTextLimitWidth);
118:
119: settingsMap.put(SettingsNames.HOME_KEY_COLUMN_ONE,
120: SettingsDefaults.defaultHomeKeyColumnOne);
121: settingsMap.put(SettingsNames.WORD_MOVE_NEWLINE_STOP,
122: SettingsDefaults.defaultWordMoveNewlineStop);
123: settingsMap.put(SettingsNames.INPUT_METHODS_ENABLED,
124: SettingsDefaults.defaultInputMethodsEnabled);
125: settingsMap.put(SettingsNames.FIND_HIGHLIGHT_SEARCH,
126: SettingsDefaults.defaultFindHighlightSearch);
127: settingsMap.put(SettingsNames.FIND_INC_SEARCH,
128: SettingsDefaults.defaultFindIncSearch);
129: settingsMap.put(SettingsNames.FIND_BACKWARD_SEARCH,
130: SettingsDefaults.defaultFindBackwardSearch);
131: settingsMap.put(SettingsNames.FIND_WRAP_SEARCH,
132: SettingsDefaults.defaultFindWrapSearch);
133: settingsMap.put(SettingsNames.FIND_MATCH_CASE,
134: SettingsDefaults.defaultFindMatchCase);
135: settingsMap.put(SettingsNames.FIND_WHOLE_WORDS,
136: SettingsDefaults.defaultFindWholeWords);
137: settingsMap.put(SettingsNames.FIND_REG_EXP,
138: SettingsDefaults.defaultFindRegExp);
139: settingsMap.put(SettingsNames.FIND_HISTORY_SIZE,
140: SettingsDefaults.defaultFindHistorySize);
141: settingsMap.put(SettingsNames.WORD_MATCH_SEARCH_LEN,
142: SettingsDefaults.defaultWordMatchSearchLen);
143: settingsMap.put(SettingsNames.WORD_MATCH_WRAP_SEARCH,
144: SettingsDefaults.defaultWordMatchWrapSearch);
145: settingsMap.put(SettingsNames.WORD_MATCH_MATCH_ONE_CHAR,
146: SettingsDefaults.defaultWordMatchMatchOneChar);
147: settingsMap.put(SettingsNames.WORD_MATCH_MATCH_CASE,
148: SettingsDefaults.defaultWordMatchMatchCase);
149: settingsMap.put(SettingsNames.WORD_MATCH_SMART_CASE,
150: SettingsDefaults.defaultWordMatchSmartCase);
151: settingsMap.put(SettingsNames.IDENTIFIER_ACCEPTOR,
152: SettingsDefaults.defaultIdentifierAcceptor);
153: settingsMap.put(SettingsNames.WHITESPACE_ACCEPTOR,
154: SettingsDefaults.defaultWhitespaceAcceptor);
155:
156: // Base key-bindings
157: SettingsUtil.updateListSetting(settingsMap,
158: SettingsNames.KEY_BINDING_LIST,
159: SettingsDefaults.defaultKeyBindings);
160:
161: // Base colorings
162: SettingsUtil.setColoring(settingsMap,
163: SettingsNames.DEFAULT_COLORING,
164: SettingsDefaults.defaultColoring);
165:
166: SettingsUtil.setColoring(settingsMap,
167: SettingsNames.LINE_NUMBER_COLORING,
168: SettingsDefaults.defaultLineNumberColoring);
169:
170: SettingsUtil.setColoring(settingsMap,
171: SettingsNames.BOOKMARK_COLORING,
172: SettingsDefaults.defaultBookmarkColoring);
173:
174: SettingsUtil.setColoring(settingsMap,
175: SettingsNames.GUARDED_COLORING,
176: SettingsDefaults.defaultGuardedColoring);
177:
178: SettingsUtil.setColoring(settingsMap,
179: SettingsNames.SELECTION_COLORING,
180: SettingsDefaults.defaultSelectionColoring);
181:
182: SettingsUtil.setColoring(settingsMap,
183: SettingsNames.HIGHLIGHT_SEARCH_COLORING,
184: SettingsDefaults.defaultHighlightSearchColoring);
185:
186: SettingsUtil.setColoring(settingsMap,
187: SettingsNames.INC_SEARCH_COLORING,
188: SettingsDefaults.defaultIncSearchColoring);
189:
190: SettingsUtil.setColoring(settingsMap,
191: SettingsNames.STATUS_BAR_COLORING,
192: SettingsDefaults.defaultStatusBarColoring);
193:
194: SettingsUtil.setColoring(settingsMap,
195: SettingsNames.STATUS_BAR_BOLD_COLORING,
196: SettingsDefaults.defaultStatusBarBoldColoring);
197:
198: // List of the colorings for all the kits
199: SettingsUtil.updateListSetting(settingsMap,
200: SettingsNames.COLORING_NAME_LIST,
201: SettingsDefaults.defaultColoringNames);
202:
203: /*
204: * This was removed because document now uses this algorithm by
205: * default. Providing an explicit value for the setting means that
206: * the default algorithm should be overriden. Although the
207: * substituter below seems OK it doesn't reflect possible custom
208: * indent engines that can be provided by the IDE.
209: *
210: *
211: * settingsMap.put(SettingsNames.INDENT_SHIFT_WIDTH, // substitute
212: * new Settings.Evaluator() { public Object getValue(Class
213: * kitClass2, String settingName) { Object ret; if
214: * (SettingsUtil.getBoolean(kitClass2, SettingsNames.EXPAND_TABS,
215: * false)) { ret = Settings.getValue(kitClass2,
216: * SettingsNames.SPACES_PER_TAB); } else { // don't expand tabs ret =
217: * Settings.getValue(kitClass2, SettingsNames.TAB_SIZE); } return
218: * ret; } } );
219: */
220:
221: /*
222: * WARNING! The following settings should be changed with care as
223: * there are some dependencies among the values of these settings.
224: * If the values are wrong the editor may work in a wrong way in
225: * some circumstances. The EditorDebug.checkSettings(kitClass)
226: * should be run in some DOC_INSTALL_ACTION_LIST action to ensure
227: * that the changed values are correct.
228: */
229: settingsMap.put(SettingsNames.READ_BUFFER_SIZE,
230: SettingsDefaults.defaultReadBufferSize);
231: settingsMap.put(SettingsNames.WRITE_BUFFER_SIZE,
232: SettingsDefaults.defaultWriteBufferSize);
233: settingsMap.put(SettingsNames.READ_MARK_DISTANCE,
234: SettingsDefaults.defaultReadMarkDistance);
235: settingsMap.put(SettingsNames.MARK_DISTANCE,
236: SettingsDefaults.defaultMarkDistance);
237: settingsMap.put(SettingsNames.MAX_MARK_DISTANCE,
238: SettingsDefaults.defaultMaxMarkDistance);
239: settingsMap.put(SettingsNames.MIN_MARK_DISTANCE,
240: SettingsDefaults.defaultMinMarkDistance);
241: settingsMap.put(SettingsNames.SYNTAX_UPDATE_BATCH_SIZE,
242: SettingsDefaults.defaultSyntaxUpdateBatchSize);
243: settingsMap.put(SettingsNames.LINE_BATCH_SIZE,
244: SettingsDefaults.defaultLineBatchSize);
245:
246: }
247: }
248:
249: }
|