1 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 ; 25 import java.awt.event.KeyEvent ; 26 import java.awt.event.InputEvent ; 27 import javax.swing.KeyStroke ; 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 41 public static final String NAME = "jsp-multi-settings-initializer"; 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 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 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 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 90 settingsMap.put(SettingsNames.IDENTIFIER_ACCEPTOR, 91 HTMLSettingsInitializer.HTML_IDENTIFIER_ACCEPTOR); 92 93 } 94 } 95 96 Map getJSPAbbrevMap() { 97 Map jspAbbrevMap = new TreeMap (); 98 jspAbbrevMap.put ("jspu", "<jsp:useBean id=\"|\" type=\"\"/>"); jspAbbrevMap.put ("jspg", "<jsp:getProperty name=\"|\" property=\"\"/>"); jspAbbrevMap.put ("jsps", "<jsp:setProperty name=\"|\" property=\"\"/>"); jspAbbrevMap.put ("jspi", "<jsp:include page=\"|\"/>"); jspAbbrevMap.put ("jspf", "<jsp:forward page=\"|\"/>"); jspAbbrevMap.put ("jspp", "<jsp:plugin type=\"|\" code=\"\" codebase=\"\">\n</jsp:plugin>"); jspAbbrevMap.put ("tglb", "<%@taglib uri=\"|\"%>"); jspAbbrevMap.put ("pg", "<%@page |%>"); jspAbbrevMap.put ("pgl", "<%@page language=\"java\"%>"); jspAbbrevMap.put ("pgex", "<%@page extends=\"|\"%>"); jspAbbrevMap.put ("pgim", "<%@page import=\"|\"%>"); jspAbbrevMap.put ("pgs", "<%@page session=\"false\"%>"); jspAbbrevMap.put ("pgb", "<%@page buffer=\"|kb\"%>"); jspAbbrevMap.put ("pga", "<%@page autoFlush=\"false\"%>"); jspAbbrevMap.put ("pgin", "<%@page info=\"|\"%>"); jspAbbrevMap.put ("pgit", "<%@page isThreadSafe=\"false\"%>"); jspAbbrevMap.put ("pgerr", "<%@page errorPage=\"|\"%>"); jspAbbrevMap.put ("pgc", "<%@page contentType=\"|\"%>"); jspAbbrevMap.put ("pgie", "<%@page isErrorPage=\"true\"%>"); jspAbbrevMap.put ("rg", "request.getParameter(\"|\")"); jspAbbrevMap.put ("sg", "session.getAttribute(\"|\")"); jspAbbrevMap.put ("sp", "session.setAttribute(\"|\", )"); jspAbbrevMap.put ("sr", "session.removeAttribute(\"|\")"); jspAbbrevMap.put ("pcg", "pageContext.getAttribute(\"|\")"); jspAbbrevMap.put ("pcgn", "pageContext.getAttributeNamesInScope(|)"); jspAbbrevMap.put ("pcgs", "pageContext.getAttributesScope(\"|\")"); jspAbbrevMap.put ("pcr", "pageContext.removeAttribute(\"|\")"); jspAbbrevMap.put ("pcs", "pageContext.setAttribute(\"|\", )"); jspAbbrevMap.put ("ag", "application.getAttribute(\"|\")"); jspAbbrevMap.put ("ap", "application.putAttribute(\"|\", )"); jspAbbrevMap.put ("ar", "application.removeAttribute(\"|\")"); jspAbbrevMap.put ("oup", "out.print(\"|\")"); jspAbbrevMap.put ("oupl", "out.println(\"|\")"); jspAbbrevMap.put ("cfgi", "config.getInitParameter(\"|\")"); 137 return jspAbbrevMap; 138 } 139 140 141 } 142 143 | Popular Tags |