KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > editor > ext > ExtSettingsInitializer


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;
21
22 import java.awt.Color JavaDoc;
23 import java.awt.Dimension JavaDoc;
24 import java.awt.event.InputEvent JavaDoc;
25 import java.awt.event.KeyEvent JavaDoc;
26 import java.util.Arrays JavaDoc;
27 import java.util.List JavaDoc;
28 import java.util.ArrayList JavaDoc;
29 import java.util.Map JavaDoc;
30 import java.util.HashMap JavaDoc;
31 import javax.swing.KeyStroke JavaDoc;
32 import javax.swing.text.JTextComponent JavaDoc;
33 import org.netbeans.editor.Coloring;
34 import org.netbeans.editor.Settings;
35 import org.netbeans.editor.SettingsUtil;
36 import org.netbeans.editor.SettingsNames;
37 import org.netbeans.editor.BaseKit;
38 import org.netbeans.editor.MultiKeyBinding;
39
40 /**
41 * Initializer for the extended editor settings.
42 *
43 * @author Miloslav Metelka
44 * @version 1.00
45 */

46
47 public class ExtSettingsInitializer extends Settings.AbstractInitializer {
48
49     public static final String JavaDoc NAME = "ext-settings-initializer"; // NOI18N
50

51     public ExtSettingsInitializer() {
52         super(NAME);
53     }
54
55     /** Update map filled with the settings.
56     * @param kitClass kit class for which the settings are being updated.
57     * It is always non-null value.
58     * @param settingsMap map holding [setting-name, setting-value] pairs.
59     * The map can be empty if this is the first initializer
60     * that updates it or if no previous initializers updated it.
61     */

62     public void updateSettingsMap(Class JavaDoc kitClass, Map JavaDoc settingsMap) {
63
64         // ------------------------ BaseKit Settings --------------------------------------
65
// if (kitClass == BaseKit.class) {
66
// // Add key-bindings
67
// SettingsUtil.updateListSetting(settingsMap, SettingsNames.KEY_BINDING_LIST,
68
// ExtSettingsDefaults.defaultExtKeyBindings);
69
// }
70

71         // ------------------------ ExtKit Settings --------------------------------------
72
if (kitClass == ExtKit.class) {
73
74             // List of the additional colorings
75
SettingsUtil.updateListSetting(settingsMap, SettingsNames.COLORING_NAME_LIST,
76                                            new String JavaDoc[] {
77                                                ExtSettingsNames.HIGHLIGHT_CARET_ROW_COLORING,
78                                                ExtSettingsNames.HIGHLIGHT_MATCH_BRACE_COLORING,
79                                            }
80                                           );
81
82             // ExtCaret highlighting options
83
settingsMap.put(ExtSettingsNames.HIGHLIGHT_CARET_ROW,
84                             ExtSettingsDefaults.defaultHighlightCaretRow);
85             settingsMap.put(ExtSettingsNames.HIGHLIGHT_MATCH_BRACE,
86                             ExtSettingsDefaults.defaultHighlightMatchBrace);
87
88             // ExtCaret highlighting colorings
89
SettingsUtil.setColoring(settingsMap, ExtSettingsNames.HIGHLIGHT_CARET_ROW_COLORING,
90                                      ExtSettingsDefaults.defaultHighlightCaretRowColoring);
91             SettingsUtil.setColoring(settingsMap, ExtSettingsNames.HIGHLIGHT_MATCH_BRACE_COLORING,
92                                      ExtSettingsDefaults.defaultHighlightMatchBraceColoring);
93
94             // Popup menu default action names
95
String JavaDoc[] popupMenuActionNames
96                 = new String JavaDoc[] {
97                     BaseKit.cutAction,
98                     BaseKit.copyAction,
99                     BaseKit.pasteAction,
100                     null,
101                     BaseKit.removeSelectionAction
102                 };
103
104             
105             List JavaDoc pml = (List JavaDoc)settingsMap.get(ExtSettingsNames.POPUP_MENU_ACTION_NAME_LIST);
106             if (pml == null || pml.indexOf(BaseKit.cutAction) == -1) {
107                 SettingsUtil.updateListSetting(settingsMap,
108                     ExtSettingsNames.POPUP_MENU_ACTION_NAME_LIST, popupMenuActionNames);
109
110                 SettingsUtil.updateListSetting(settingsMap,
111                     ExtSettingsNames.DIALOG_POPUP_MENU_ACTION_NAME_LIST, popupMenuActionNames);
112             }
113                                           
114             settingsMap.put(ExtSettingsNames.POPUP_MENU_ENABLED, Boolean.TRUE);
115
116             settingsMap.put(ExtSettingsNames.FAST_IMPORT_PACKAGE,
117                             ExtSettingsDefaults.defaultFastImportPackage);
118             
119             // Completion settings
120
settingsMap.put(ExtSettingsNames.COMPLETION_AUTO_POPUP,
121                             ExtSettingsDefaults.defaultCompletionAutoPopup);
122
123             settingsMap.put(ExtSettingsNames.COMPLETION_CASE_SENSITIVE,
124                             ExtSettingsDefaults.defaultCompletionCaseSensitive);
125
126             settingsMap.put(ExtSettingsNames.COMPLETION_NATURAL_SORT,
127                             ExtSettingsDefaults.defaultCompletionNaturalSort);
128             
129             settingsMap.put(ExtSettingsNames.COMPLETION_INSTANT_SUBSTITUTION,
130                             ExtSettingsDefaults.defaultCompletionInstantSubstitution);
131
132             settingsMap.put(ExtSettingsNames.COMPLETION_AUTO_POPUP_DELAY,
133                             ExtSettingsDefaults.defaultCompletionAutoPopupDelay);
134
135             settingsMap.put(ExtSettingsNames.COMPLETION_REFRESH_DELAY,
136                             ExtSettingsDefaults.defaultCompletionRefreshDelay);
137
138             settingsMap.put(ExtSettingsNames.COMPLETION_PANE_MIN_SIZE,
139                             ExtSettingsDefaults.defaultCompletionPaneMinSize);
140
141             settingsMap.put(ExtSettingsNames.COMPLETION_PANE_MAX_SIZE,
142                             ExtSettingsDefaults.defaultCompletionPaneMaxSize);
143
144             // re-indentation settings
145
settingsMap.put(ExtSettingsNames.REINDENT_WITH_TEXT_BEFORE,
146                             Boolean.TRUE);
147             
148             settingsMap.put(ExtSettingsNames.JAVADOC_BG_COLOR,
149                             ExtSettingsDefaults.defaultJavaDocBGColor);
150             
151             settingsMap.put(ExtSettingsNames.JAVADOC_AUTO_POPUP_DELAY,
152                             ExtSettingsDefaults.defaultJavaDocAutoPopupDelay);
153             
154             settingsMap.put(ExtSettingsNames.JAVADOC_PREFERRED_SIZE,
155                             ExtSettingsDefaults.defaultJavaDocPreferredSize);
156             
157             settingsMap.put(ExtSettingsNames.JAVADOC_AUTO_POPUP,
158                             ExtSettingsDefaults.defaultJavaDocAutoPopup);
159             
160         }
161
162     }
163
164 }
165
Popular Tags