1 19 package org.netbeans.modules.gsf; 20 21 import java.awt.event.InputEvent ; 22 import java.awt.event.KeyEvent ; 23 import java.util.Map ; 24 import java.util.TreeMap ; 25 26 import javax.swing.KeyStroke ; 27 28 import org.netbeans.editor.BaseKit; 29 import org.netbeans.editor.MultiKeyBinding; 30 import org.netbeans.editor.Settings; 31 import org.netbeans.editor.SettingsNames; 32 import org.netbeans.editor.SettingsUtil; 33 import org.netbeans.editor.TokenCategory; 34 import org.netbeans.editor.TokenContext; 35 import org.netbeans.editor.TokenContextPath; 36 import org.netbeans.editor.ext.ExtKit; 37 38 39 47 public class GsfEditorSettings extends Settings.AbstractInitializer { 48 public static final Boolean defaultCodeFoldingEnable = Boolean.TRUE; 49 50 private static final String SETTINGS_NAME = "gls-editor-settings-initializer"; 53 public GsfEditorSettings() { 54 super(SETTINGS_NAME); 55 } 56 57 public void updateSettingsMap(Class kitClass, Map settingsMap) { 58 if (kitClass == null) { 59 return; 60 } 61 62 if (kitClass == GsfEditorKitFactory.GsfEditorKit.class) { 63 SettingsUtil.updateListSetting(settingsMap, SettingsNames.KEY_BINDING_LIST, 64 getGenericKeyBindings()); 65 66 settingsMap.put(SettingsNames.ABBREV_MAP, getDefaultAbbreviations()); 67 68 settingsMap.put(SettingsNames.CODE_FOLDING_ENABLE, defaultCodeFoldingEnable); 69 70 settingsMap.put(SettingsNames.SPACES_PER_TAB, Integer.valueOf(2)); 74 75 } 94 } 95 96 public static MultiKeyBinding[] getGenericKeyBindings() { 97 int MENU_MASK = java.awt.Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(); 98 99 return new MultiKeyBinding[] { 100 new MultiKeyBinding(new KeyStroke [] { 101 KeyStroke.getKeyStroke(KeyEvent.VK_J, MENU_MASK), 102 KeyStroke.getKeyStroke(KeyEvent.VK_D, 0) 103 }, "macro-debug-var" ), 105 new MultiKeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_T, 106 MENU_MASK | InputEvent.SHIFT_MASK), ExtKit.commentAction), 107 new MultiKeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_D, 108 MENU_MASK | InputEvent.SHIFT_MASK), ExtKit.uncommentAction) 109 }; 110 } 111 112 private static Map getDefaultAbbreviations() { 113 Map abbreviations = new TreeMap (); 114 115 117 abbreviations.put("case", "case ${CONDITION default=\"condition1\"}\n when ${CONDITION1 default=\"condition1\"}\n\n when ${CONDITION2 default=\"condition1\"}\n\nend\n"); 119 abbreviations.put("def", "def ${NAME default=\"method\"}\n ${cursor}\nend\n"); 120 abbreviations.put("class", "class ${NAME default=\"cls\"}\n ${cursor}\nend\n"); 121 abbreviations.put("module", "module ${NAME default=\"mod\"}\n ${cursor}\nend\n"); 122 abbreviations.put("do", "do |${VAR newVarName default=\"var\"}|\n ${cursor}\nend\n"); 123 abbreviations.put("if", "if ${CONDITION default=\"condition\"}\n ${cursor}\nend\n"); 124 abbreviations.put("ifelse", "if ${CONDITION default=\"condition\"}\n ${cursor}\nelse\n\nend\n"); 125 126 return abbreviations; 127 } 128 } 129 | Popular Tags |