1 19 20 package org.netbeans.modules.editor.java; 21 22 import java.awt.Toolkit ; 23 import java.awt.event.KeyEvent ; 24 import java.awt.event.InputEvent ; 25 import java.util.Map ; 26 import java.util.HashMap ; 27 import java.util.ArrayList ; 28 import java.util.Arrays ; 29 import javax.swing.KeyStroke ; 30 import org.netbeans.editor.BaseKit; 31 import org.netbeans.editor.MultiKeyBinding; 32 import org.netbeans.editor.Settings; 33 import org.netbeans.editor.SettingsUtil; 34 import org.netbeans.editor.SettingsNames; 35 import org.netbeans.editor.ext.ExtSettingsNames; 36 import org.openide.actions.SaveAction; 37 import org.openide.actions.CutAction; 38 import org.openide.actions.CopyAction; 39 import org.openide.actions.PasteAction; 40 import org.openide.actions.DeleteAction; 41 import org.openide.actions.NewAction; 42 import org.openide.actions.ToolsAction; 43 import org.openide.actions.PropertiesAction; 44 import org.openide.windows.TopComponent; 45 import org.netbeans.editor.ext.ExtSettingsDefaults; 46 import org.netbeans.editor.ext.java.JavaSettingsDefaults; 47 import org.netbeans.editor.ext.java.JavaSettingsNames; 48 49 55 56 public class NbJavaSettingsInitializer extends Settings.AbstractInitializer { 57 58 public static final String NAME = "nb-java-settings-initializer"; 60 public NbJavaSettingsInitializer() { 61 super(NAME); 62 } 63 64 private static final int ALT_MASK = System.getProperty("mrj.version") != null ? 65 InputEvent.CTRL_MASK : InputEvent.ALT_MASK; 66 67 74 public void updateSettingsMap(Class kitClass, Map settingsMap) { 75 76 if (kitClass == JavaKit.class) { 77 78 SettingsUtil.updateListSetting(settingsMap, SettingsNames.KEY_BINDING_LIST, getJavaKeyBindings()); 79 80 SettingsUtil.updateListSetting(settingsMap, SettingsNames.KEY_BINDING_LIST, 81 new MultiKeyBinding[] { 82 new MultiKeyBinding( 83 KeyStroke.getKeyStroke(KeyEvent.VK_O, ALT_MASK), 84 JavaKit.gotoSourceAction 85 ), 86 new MultiKeyBinding( 87 KeyStroke.getKeyStroke(KeyEvent.VK_F1, ALT_MASK), 88 JavaKit.gotoHelpAction 89 ), 90 } 91 ); 92 93 96 settingsMap.put(ExtSettingsNames.SHOW_DEPRECATED_MEMBERS, 97 ExtSettingsDefaults.defaultShowDeprecatedMembers); 98 99 settingsMap.put(SettingsNames.CODE_FOLDING_ENABLE, JavaSettingsDefaults.defaultCodeFoldingEnable); 100 settingsMap.put(JavaSettingsNames.CODE_FOLDING_COLLAPSE_METHOD, JavaSettingsDefaults.defaultCodeFoldingCollapseMethod); 101 settingsMap.put(JavaSettingsNames.CODE_FOLDING_COLLAPSE_INNERCLASS, JavaSettingsDefaults.defaultCodeFoldingCollapseInnerClass); 102 settingsMap.put(JavaSettingsNames.CODE_FOLDING_COLLAPSE_IMPORT, JavaSettingsDefaults.defaultCodeFoldingCollapseImport); 103 settingsMap.put(JavaSettingsNames.CODE_FOLDING_COLLAPSE_JAVADOC, JavaSettingsDefaults.defaultCodeFoldingCollapseJavadoc); 104 settingsMap.put(JavaSettingsNames.CODE_FOLDING_COLLAPSE_INITIAL_COMMENT, JavaSettingsDefaults.defaultCodeFoldingCollapseInitialComment); 105 106 } 107 108 } 109 110 public MultiKeyBinding[] getJavaKeyBindings() { 111 int mask = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(); 112 boolean isMac = System.getProperty("mrj.version") != null; 113 return new MultiKeyBinding[] { 114 new MultiKeyBinding( 115 new KeyStroke [] { 116 KeyStroke.getKeyStroke(KeyEvent.VK_U, ALT_MASK), 117 KeyStroke.getKeyStroke(KeyEvent.VK_G, 0) 118 }, 119 JavaKit.makeGetterAction 120 ), 121 new MultiKeyBinding( 122 new KeyStroke [] { 123 KeyStroke.getKeyStroke(KeyEvent.VK_U, ALT_MASK), 124 KeyStroke.getKeyStroke(KeyEvent.VK_S, 0) 125 }, 126 JavaKit.makeSetterAction 127 ), 128 new MultiKeyBinding( 129 new KeyStroke [] { 130 KeyStroke.getKeyStroke(KeyEvent.VK_U, ALT_MASK), 131 KeyStroke.getKeyStroke(KeyEvent.VK_I, 0) 132 }, 133 JavaKit.makeIsAction 134 ), 135 new MultiKeyBinding( 136 KeyStroke.getKeyStroke(KeyEvent.VK_I, 137 ALT_MASK | InputEvent.SHIFT_MASK), 138 JavaKit.fastImportAction 139 ), 140 new MultiKeyBinding( 141 KeyStroke.getKeyStroke(KeyEvent.VK_B, 142 mask), 143 JavaKit.gotoSuperImplementationAction 144 ), 145 new MultiKeyBinding( 146 KeyStroke.getKeyStroke(KeyEvent.VK_F, 147 ALT_MASK | InputEvent.SHIFT_MASK), 148 JavaKit.fixImportsAction 149 ), 150 new MultiKeyBinding( 156 KeyStroke.getKeyStroke(KeyEvent.VK_G, ALT_MASK | (isMac ? InputEvent.SHIFT_MASK : 0)), 157 org.netbeans.editor.ext.ExtKit.gotoDeclarationAction 158 ), 159 new MultiKeyBinding( 160 KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 161 mask | InputEvent.SHIFT_MASK), 162 JavaKit.javaDocShowAction 163 ), 164 165 new MultiKeyBinding( 166 KeyStroke.getKeyStroke(KeyEvent.VK_S, 167 InputEvent.SHIFT_MASK | ALT_MASK), 168 JavaKit.selectNextElementAction 169 ), 170 171 new MultiKeyBinding( 172 KeyStroke.getKeyStroke(KeyEvent.VK_A, 173 InputEvent.SHIFT_MASK | ALT_MASK), 174 JavaKit.selectPreviousElementAction 175 ) 176 177 }; 178 } 179 180 } 181 | Popular Tags |