001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.editor.ext;
043:
044: import java.awt.Color;
045: import java.awt.Dimension;
046: import java.awt.event.InputEvent;
047: import java.awt.event.KeyEvent;
048: import java.util.Arrays;
049: import java.util.List;
050: import java.util.ArrayList;
051: import java.util.Map;
052: import java.util.HashMap;
053: import javax.swing.KeyStroke;
054: import javax.swing.text.JTextComponent;
055: import org.netbeans.editor.Coloring;
056: import org.netbeans.editor.Settings;
057: import org.netbeans.editor.SettingsUtil;
058: import org.netbeans.editor.SettingsNames;
059: import org.netbeans.editor.BaseKit;
060: import org.netbeans.editor.MultiKeyBinding;
061:
062: /**
063: * Initializer for the extended editor settings.
064: *
065: * @author Miloslav Metelka
066: * @version 1.00
067: */
068:
069: public class ExtSettingsInitializer extends
070: Settings.AbstractInitializer {
071:
072: public static final String NAME = "ext-settings-initializer"; // NOI18N
073:
074: public ExtSettingsInitializer() {
075: super (NAME);
076: }
077:
078: /** Update map filled with the settings.
079: * @param kitClass kit class for which the settings are being updated.
080: * It is always non-null value.
081: * @param settingsMap map holding [setting-name, setting-value] pairs.
082: * The map can be empty if this is the first initializer
083: * that updates it or if no previous initializers updated it.
084: */
085: public void updateSettingsMap(Class kitClass, Map settingsMap) {
086:
087: // ------------------------ BaseKit Settings --------------------------------------
088: // if (kitClass == BaseKit.class) {
089: // // Add key-bindings
090: // SettingsUtil.updateListSetting(settingsMap, SettingsNames.KEY_BINDING_LIST,
091: // ExtSettingsDefaults.defaultExtKeyBindings);
092: // }
093:
094: // ------------------------ ExtKit Settings --------------------------------------
095: if (kitClass == ExtKit.class) {
096:
097: // List of the additional colorings
098: SettingsUtil
099: .updateListSetting(
100: settingsMap,
101: SettingsNames.COLORING_NAME_LIST,
102: new String[] {
103: ExtSettingsNames.HIGHLIGHT_CARET_ROW_COLORING,
104: ExtSettingsNames.HIGHLIGHT_MATCH_BRACE_COLORING, });
105:
106: // ExtCaret highlighting options
107: settingsMap.put(ExtSettingsNames.HIGHLIGHT_CARET_ROW,
108: ExtSettingsDefaults.defaultHighlightCaretRow);
109: settingsMap.put(ExtSettingsNames.HIGHLIGHT_MATCH_BRACE,
110: ExtSettingsDefaults.defaultHighlightMatchBrace);
111:
112: // ExtCaret highlighting colorings
113: SettingsUtil
114: .setColoring(
115: settingsMap,
116: ExtSettingsNames.HIGHLIGHT_CARET_ROW_COLORING,
117: ExtSettingsDefaults.defaultHighlightCaretRowColoring);
118: SettingsUtil
119: .setColoring(
120: settingsMap,
121: ExtSettingsNames.HIGHLIGHT_MATCH_BRACE_COLORING,
122: ExtSettingsDefaults.defaultHighlightMatchBraceColoring);
123:
124: // Popup menu default action names
125: String[] popupMenuActionNames = new String[] {
126: BaseKit.cutAction, BaseKit.copyAction,
127: BaseKit.pasteAction, null,
128: BaseKit.removeSelectionAction };
129:
130: List pml = (List) settingsMap
131: .get(ExtSettingsNames.POPUP_MENU_ACTION_NAME_LIST);
132: if (pml == null || pml.indexOf(BaseKit.cutAction) == -1) {
133: SettingsUtil.updateListSetting(settingsMap,
134: ExtSettingsNames.POPUP_MENU_ACTION_NAME_LIST,
135: popupMenuActionNames);
136:
137: SettingsUtil
138: .updateListSetting(
139: settingsMap,
140: ExtSettingsNames.DIALOG_POPUP_MENU_ACTION_NAME_LIST,
141: popupMenuActionNames);
142: }
143:
144: settingsMap.put(ExtSettingsNames.POPUP_MENU_ENABLED,
145: Boolean.TRUE);
146:
147: settingsMap.put(ExtSettingsNames.FAST_IMPORT_PACKAGE,
148: ExtSettingsDefaults.defaultFastImportPackage);
149:
150: // Completion settings
151: settingsMap.put(ExtSettingsNames.COMPLETION_AUTO_POPUP,
152: ExtSettingsDefaults.defaultCompletionAutoPopup);
153:
154: settingsMap.put(ExtSettingsNames.COMPLETION_CASE_SENSITIVE,
155: ExtSettingsDefaults.defaultCompletionCaseSensitive);
156:
157: settingsMap.put(ExtSettingsNames.COMPLETION_NATURAL_SORT,
158: ExtSettingsDefaults.defaultCompletionNaturalSort);
159:
160: settingsMap
161: .put(
162: ExtSettingsNames.COMPLETION_INSTANT_SUBSTITUTION,
163: ExtSettingsDefaults.defaultCompletionInstantSubstitution);
164:
165: settingsMap
166: .put(
167: ExtSettingsNames.COMPLETION_AUTO_POPUP_DELAY,
168: ExtSettingsDefaults.defaultCompletionAutoPopupDelay);
169:
170: settingsMap.put(ExtSettingsNames.COMPLETION_REFRESH_DELAY,
171: ExtSettingsDefaults.defaultCompletionRefreshDelay);
172:
173: settingsMap.put(ExtSettingsNames.COMPLETION_PANE_MIN_SIZE,
174: ExtSettingsDefaults.defaultCompletionPaneMinSize);
175:
176: settingsMap.put(ExtSettingsNames.COMPLETION_PANE_MAX_SIZE,
177: ExtSettingsDefaults.defaultCompletionPaneMaxSize);
178:
179: // re-indentation settings
180: settingsMap.put(ExtSettingsNames.REINDENT_WITH_TEXT_BEFORE,
181: Boolean.TRUE);
182:
183: settingsMap.put(ExtSettingsNames.JAVADOC_BG_COLOR,
184: ExtSettingsDefaults.defaultJavaDocBGColor);
185:
186: settingsMap.put(ExtSettingsNames.JAVADOC_AUTO_POPUP_DELAY,
187: ExtSettingsDefaults.defaultJavaDocAutoPopupDelay);
188:
189: settingsMap.put(ExtSettingsNames.JAVADOC_PREFERRED_SIZE,
190: ExtSettingsDefaults.defaultJavaDocPreferredSize);
191:
192: settingsMap.put(ExtSettingsNames.JAVADOC_AUTO_POPUP,
193: ExtSettingsDefaults.defaultJavaDocAutoPopup);
194:
195: }
196:
197: }
198:
199: }
|