KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > editor > plain > NbPlainSettingsInitializer


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.modules.editor.plain;
21
22 import java.awt.Color JavaDoc;
23 import java.awt.Font JavaDoc;
24 import java.util.Map JavaDoc;
25 import java.util.HashMap JavaDoc;
26 import org.netbeans.editor.BaseKit;
27 import org.netbeans.editor.Coloring;
28 import org.netbeans.editor.Settings;
29 import org.netbeans.editor.SettingsUtil;
30 import org.netbeans.editor.TokenCategory;
31 import org.netbeans.editor.TokenContextPath;
32 import org.netbeans.editor.ext.plain.PlainSyntax;
33 import org.netbeans.editor.ext.plain.PlainTokenContext;
34
35 /**
36 * Settings for plain kit
37 *
38 * @author Miloslav Metelka
39 * @version 1.00
40 */

41
42 public class NbPlainSettingsInitializer extends Settings.AbstractInitializer {
43
44     public static final String JavaDoc NAME = "nb-plain-settings-initializer"; // NOI18N
45

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

57     public void updateSettingsMap(Class JavaDoc kitClass, Map JavaDoc settingsMap) {
58
59         if (kitClass == BaseKit.class) {
60
61             new PlainTokenColoringInitializer().updateSettingsMap(kitClass, settingsMap);
62
63         }
64
65
66         if (kitClass == PlainKit.class) {
67
68
69         }
70
71     }
72
73     static class PlainTokenColoringInitializer
74     extends SettingsUtil.TokenColoringInitializer {
75
76         Coloring emptyColoring = new Coloring(null, null, null);
77
78         public PlainTokenColoringInitializer() {
79             super(PlainTokenContext.context);
80         }
81
82         public Object JavaDoc getTokenColoring(TokenContextPath tokenContextPath,
83         TokenCategory tokenIDOrCategory, boolean printingSet) {
84             if (!printingSet) {
85                 switch (tokenIDOrCategory.getNumericID()) {
86                     case PlainTokenContext.TEXT_ID:
87                         return emptyColoring;
88                 }
89
90             } else { // printing set
91
switch (tokenIDOrCategory.getNumericID()) {
92                     default:
93                          return SettingsUtil.defaultPrintColoringEvaluator;
94                 }
95
96             }
97
98             return null;
99
100         }
101
102     }
103
104 }
105
Popular Tags