KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > web > core > syntax > settings > JspMultiSettingsInitializer


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.web.core.syntax.settings;
21
22 import org.netbeans.modules.web.core.syntax.settings.JspSettings;
23 import org.netbeans.modules.web.core.syntax.*;
24 import java.awt.Toolkit JavaDoc;
25 import java.awt.event.KeyEvent JavaDoc;
26 import java.awt.event.InputEvent JavaDoc;
27 import javax.swing.KeyStroke JavaDoc;
28 import java.util.*;
29 import org.netbeans.editor.Settings;
30 import org.netbeans.editor.SettingsUtil;
31 import org.netbeans.editor.SettingsNames;
32 import org.netbeans.editor.ext.html.HTMLSettingsInitializer;
33 import org.netbeans.editor.MultiKeyBinding;
34 import org.netbeans.editor.ext.java.JavaSettingsDefaults;
35 import org.netbeans.editor.ext.java.JavaSettingsNames;
36 import org.netbeans.modules.editor.java.JavaKit;
37
38 public class JspMultiSettingsInitializer extends Settings.AbstractInitializer {
39
40     /** Name assigned to initializer */
41     public static final String JavaDoc NAME = "jsp-multi-settings-initializer"; // NOI18N
42

43     private static final int ALT_MASK = System.getProperty("mrj.version") != null ?
44         InputEvent.CTRL_MASK : InputEvent.ALT_MASK;
45     
46     private static boolean isMac = System.getProperty("mrj.version") != null;
47     
48     public JspMultiSettingsInitializer() {
49         super(NAME);
50     }
51
52     public void updateSettingsMap (Class JavaDoc kitClass, Map settingsMap) {
53         int mask = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
54      
55     if (kitClass == JavaKit.class) {
56             settingsMap.put(JavaSettingsNames.INDENT_HOT_CHARS_ACCEPTOR,
57                     JavaSettingsDefaults.defaultIndentHotCharsAcceptor);
58         }
59         
60         // Jsp Settings
61
if (kitClass == JSPKit.class) {
62             SettingsUtil.updateListSetting(settingsMap, SettingsNames.KEY_BINDING_LIST,
63                     new MultiKeyBinding[] {
64                         new MultiKeyBinding(
65                            KeyStroke.getKeyStroke(KeyEvent.VK_O, ALT_MASK),
66                             JavaKit.gotoSourceAction
67                         ),
68                         new MultiKeyBinding(
69                             KeyStroke.getKeyStroke(KeyEvent.VK_G, ALT_MASK | (isMac ? InputEvent.SHIFT_MASK : 0)),
70                             org.netbeans.editor.ext.ExtKit.gotoDeclarationAction
71                         ),
72                         new MultiKeyBinding(
73                             KeyStroke.getKeyStroke(KeyEvent.VK_B,
74                             mask),
75                             JavaKit.gotoSuperImplementationAction
76                         )
77             }
78             );
79             
80             settingsMap.put(JavaSettingsNames.PAIR_CHARACTERS_COMPLETION,
81                         JavaSettingsDefaults.defaultPairCharactersCompletion);
82
83             //enable code folding
84
settingsMap.put(SettingsNames.CODE_FOLDING_ENABLE, JavaSettingsDefaults.defaultCodeFoldingEnable);
85             settingsMap.put(JspSettings.CODE_FOLDING_UPDATE_TIMEOUT, JspSettings.defaultCodeFoldingUpdateInterval);
86             settingsMap.put(JspSettings.CARET_SIMPLE_MATCH_BRACE, JspSettings.defaultCaretSimpleMatchBrace);
87             
88 // settingsMap.put (org.netbeans.editor.SettingsNames.ABBREV_MAP, getJSPAbbrevMap());
89

90             settingsMap.put(SettingsNames.IDENTIFIER_ACCEPTOR,
91                             HTMLSettingsInitializer.HTML_IDENTIFIER_ACCEPTOR);
92
93         }
94     }
95
96     Map getJSPAbbrevMap() {
97         Map jspAbbrevMap = new TreeMap ();
98         // <jsp:something tags
99
jspAbbrevMap.put ("jspu", "<jsp:useBean id=\"|\" type=\"\"/>"); // NOI18N
100
jspAbbrevMap.put ("jspg", "<jsp:getProperty name=\"|\" property=\"\"/>"); // NOI18N
101
jspAbbrevMap.put ("jsps", "<jsp:setProperty name=\"|\" property=\"\"/>"); // NOI18N
102
jspAbbrevMap.put ("jspi", "<jsp:include page=\"|\"/>"); // NOI18N
103
jspAbbrevMap.put ("jspf", "<jsp:forward page=\"|\"/>"); // NOI18N
104
jspAbbrevMap.put ("jspp", "<jsp:plugin type=\"|\" code=\"\" codebase=\"\">\n</jsp:plugin>"); // NOI18N
105
// taglib
106
jspAbbrevMap.put ("tglb", "<%@taglib uri=\"|\"%>"); // NOI18N
107
// <%@ page tags
108
jspAbbrevMap.put ("pg", "<%@page |%>"); // NOI18N
109
jspAbbrevMap.put ("pgl", "<%@page language=\"java\"%>"); // NOI18N
110
jspAbbrevMap.put ("pgex", "<%@page extends=\"|\"%>"); // NOI18N
111
jspAbbrevMap.put ("pgim", "<%@page import=\"|\"%>"); // NOI18N
112
jspAbbrevMap.put ("pgs", "<%@page session=\"false\"%>"); // NOI18N
113
jspAbbrevMap.put ("pgb", "<%@page buffer=\"|kb\"%>"); // NOI18N
114
jspAbbrevMap.put ("pga", "<%@page autoFlush=\"false\"%>"); // NOI18N
115
jspAbbrevMap.put ("pgin", "<%@page info=\"|\"%>"); // NOI18N
116
jspAbbrevMap.put ("pgit", "<%@page isThreadSafe=\"false\"%>"); // NOI18N
117
jspAbbrevMap.put ("pgerr", "<%@page errorPage=\"|\"%>"); // NOI18N
118
jspAbbrevMap.put ("pgc", "<%@page contentType=\"|\"%>"); // NOI18N
119
jspAbbrevMap.put ("pgie", "<%@page isErrorPage=\"true\"%>"); // NOI18N
120
// common java abbrevs
121
jspAbbrevMap.put ("rg", "request.getParameter(\"|\")"); // NOI18N
122
jspAbbrevMap.put ("sg", "session.getAttribute(\"|\")"); // NOI18N
123
jspAbbrevMap.put ("sp", "session.setAttribute(\"|\", )"); // NOI18N
124
jspAbbrevMap.put ("sr", "session.removeAttribute(\"|\")"); // NOI18N
125
jspAbbrevMap.put ("pcg", "pageContext.getAttribute(\"|\")");// NOI18N
126
jspAbbrevMap.put ("pcgn", "pageContext.getAttributeNamesInScope(|)");// NOI18N
127
jspAbbrevMap.put ("pcgs", "pageContext.getAttributesScope(\"|\")");// NOI18N
128
jspAbbrevMap.put ("pcr", "pageContext.removeAttribute(\"|\")");// NOI18N
129
jspAbbrevMap.put ("pcs", "pageContext.setAttribute(\"|\", )");// NOI18N
130
jspAbbrevMap.put ("ag", "application.getAttribute(\"|\")"); // NOI18N
131
jspAbbrevMap.put ("ap", "application.putAttribute(\"|\", )"); // NOI18N
132
jspAbbrevMap.put ("ar", "application.removeAttribute(\"|\")"); // NOI18N
133
jspAbbrevMap.put ("oup", "out.print(\"|\")"); // NOI18N
134
jspAbbrevMap.put ("oupl", "out.println(\"|\")"); // NOI18N
135
jspAbbrevMap.put ("cfgi", "config.getInitParameter(\"|\")");// NOI18N
136

137         return jspAbbrevMap;
138     }
139
140
141 }
142
143
Popular Tags