This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 49806
Collapse All | Expand All

(-)contrib/navigator/src/org/netbeans/modules/navigator/layer.xml (-1 / +1 lines)
Lines 39-45 Link Here
39
    </folder>
39
    </folder>
40
40
41
    <folder name="Shortcuts">
41
    <folder name="Shortcuts">
42
        <file name="DA-0.shadow">
42
        <file name="DO-0.shadow">
43
            <attr name="originalFile" stringvalue="Actions/Window/org-netbeans-modules-navigator-ShowNavigatorAction.instance"/>
43
            <attr name="originalFile" stringvalue="Actions/Window/org-netbeans-modules-navigator-ShowNavigatorAction.instance"/>
44
        </file>
44
        </file>
45
45
(-)contrib/options/optionscore/src/org/netbeans/modules/optionscore/resources/layer.xml (-1 / +1 lines)
Line 1 Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.0//EN" "http://www.netbeans.org/dtds/filesystem-1_0.dtd">
<!--
                Sun Public License Notice

The contents of this file are subject to the Sun Public License
Version 1.0 (the "License"). You may not use this file except in
compliance with the License. A copy of the License is available at
http://www.sun.com/

The Original Code is NetBeans. The Initial Developer of the Original
Code is Sun Microsystems, Inc. Portions Copyright 1997-2001 Sun
Microsystems, Inc. All Rights Reserved.
-->
<filesystem>

<folder name="Actions">
        <folder name="Edit">
            <file name="org-netbeans-modules-optionscore-ShowOptionsAction.instance"/>
        </folder>
    </folder>
    <folder name="Menu">
        <folder name="Edit">
            <file name="org-netbeans-modules-optionscore-ShowOptionsAction.instance"/>
        </folder>
    </folder>

    <folder name="Shortcuts">
        <file name="DA-P.shadow">
            <attr name="originalFile" stringvalue="Actions/Window/org-netbeans-modules-optionscore-ShowOptionsAction.instance"/>
        </file>

    </folder>
    
    <folder name="options">
        <folder name="models"/>
        <folder name="displayers"/>
    </folder>
</filesystem>
1
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.0//EN" "http://www.netbeans.org/dtds/filesystem-1_0.dtd">
<!--
                Sun Public License Notice

The contents of this file are subject to the Sun Public License
Version 1.0 (the "License"). You may not use this file except in
compliance with the License. A copy of the License is available at
http://www.sun.com/

The Original Code is NetBeans. The Initial Developer of the Original
Code is Sun Microsystems, Inc. Portions Copyright 1997-2001 Sun
Microsystems, Inc. All Rights Reserved.
-->
<filesystem>

<folder name="Actions">
        <folder name="Edit">
            <file name="org-netbeans-modules-optionscore-ShowOptionsAction.instance"/>
        </folder>
    </folder>
    <folder name="Menu">
        <folder name="Edit">
            <file name="org-netbeans-modules-optionscore-ShowOptionsAction.instance"/>
        </folder>
    </folder>

    <folder name="Shortcuts">
        <file name="DO-P.shadow">
            <attr name="originalFile" stringvalue="Actions/Window/org-netbeans-modules-optionscore-ShowOptionsAction.instance"/>
        </file>

    </folder>
    
    <folder name="options">
        <folder name="models"/>
        <folder name="displayers"/>
    </folder>
</filesystem>
(-)core/compiler/src/org/netbeans/core/compiler/resources/layer.xml (-1 / +1 lines)
Lines 79-85 Link Here
79
    </folder>
79
    </folder>
80
    
80
    
81
    <folder name="Shortcuts">
81
    <folder name="Shortcuts">
82
        <file name="SA-C.instance">
82
        <file name="SO-C.instance">
83
	    <attr name="instanceClass" stringvalue="org.netbeans.core.compiler.StopCompileAction"/>
83
	    <attr name="instanceClass" stringvalue="org.netbeans.core.compiler.StopCompileAction"/>
84
	</file>
84
	</file>
85
85
(-)core/src/org/netbeans/core/ShortcutsFolder.java (-10 / +72 lines)
Lines 56-62 Link Here
56
    private static final String KEYS_EXT = "keys"; // NOI18N
56
    private static final String KEYS_EXT = "keys"; // NOI18N
57
    
57
    
58
    /** Folder name under the system folder.*/
58
    /** Folder name under the system folder.*/
59
    static final String SHORTCUTS_FOLDER = "Shortcuts"; // NOI18N
59
    private static final String SHORTCUTS_FOLDER = "Shortcuts"; // NOI18N
60
60
61
    /** Info for old XML file.*/
61
    /** Info for old XML file.*/
62
    private static final String XML_BINDING = "Binding"; // NOI18N
62
    private static final String XML_BINDING = "Binding"; // NOI18N
Lines 421-426 Link Here
421
    public static void applyChanges(java.util.List changes) {
421
    public static void applyChanges(java.util.List changes) {
422
        FileObject fo = Repository.getDefault().getDefaultFileSystem()
422
        FileObject fo = Repository.getDefault().getDefaultFileSystem()
423
            .getRoot().getFileObject(SHORTCUTS_FOLDER);
423
            .getRoot().getFileObject(SHORTCUTS_FOLDER);
424
        
424
        DataFolder f = DataFolder.findFolder(fo);
425
        DataFolder f = DataFolder.findFolder(fo);
425
        Iterator it = changes.listIterator();
426
        Iterator it = changes.listIterator();
426
        while (it.hasNext()) {
427
        while (it.hasNext()) {
Lines 449-455 Link Here
449
                        String instanceName = r.instanceName();
450
                        String instanceName = r.instanceName();
450
                        ArrayList arr = new ArrayList ();
451
                        ArrayList arr = new ArrayList ();
451
                        arr.add (instanceName);
452
                        arr.add (instanceName);
452
                        arr.addAll (Arrays.asList (getPermutations (instanceName)));
453
                        arr.addAll (Arrays.asList (getPermutations (instanceName, (Utilities.getOperatingSystem() & Utilities.OS_MAC) !=0)));
453
                        for (Iterator iter = arr.iterator(); iter.hasNext(); ) {
454
                        for (Iterator iter = arr.iterator(); iter.hasNext(); ) {
454
                            String name = (String)iter.next ();
455
                            String name = (String)iter.next ();
455
                            DataObject[] ch = f.getChildren();
456
                            DataObject[] ch = f.getChildren();
Lines 471-480 Link Here
471
                        foAdd.setAttribute("originalFile", originalFilePath); // NOI18N
472
                        foAdd.setAttribute("originalFile", originalFilePath); // NOI18N
472
                    } else {
473
                    } else {
473
                        FileObject foRemove = root.getFileObject(r.instanceName(), "shadow"); // NOI18N
474
                        FileObject foRemove = root.getFileObject(r.instanceName(), "shadow"); // NOI18N
475
                        
474
                        if(foRemove != null) {
476
                        if(foRemove != null) {
475
                            foRemove.delete();
477
                            foRemove.delete();
476
                        }
478
                        }
477
                        String[] permutations = getPermutations(r.instanceName());
479
                        String[] permutations = getPermutations(r.instanceName(), (Utilities.getOperatingSystem() & Utilities.OS_MAC) != 0);
478
                        //We may be deleting a wildcard keystroke, and/or the
480
                        //We may be deleting a wildcard keystroke, and/or the
479
                        //order defined in the layer may not be the same as
481
                        //order defined in the layer may not be the same as
480
                        //what we were fed by the shortcuts editor, so search
482
                        //what we were fed by the shortcuts editor, so search
Lines 485-490 Link Here
485
                                foRemove.delete();
487
                                foRemove.delete();
486
                                break;
488
                                break;
487
                            }
489
                            }
490
                            
488
                        }
491
                        }
489
                    }
492
                    }
490
                }
493
                }
Lines 513-528 Link Here
513
     * hyphenation (M-AS-F5) is not supported.  It either is or it isn't.
516
     * hyphenation (M-AS-F5) is not supported.  It either is or it isn't.
514
     *
517
     *
515
     */
518
     */
516
    static String[] getPermutations (String name) {
519
    static String[] getPermutations (String name, boolean mac) {
517
        //IMPORTANT: THERE IS A COPY OF THE SAME CODE IN 
520
        //IMPORTANT: THERE IS A COPY OF THE SAME CODE IN 
518
        //org.netbeans.modules.editor.options.KeyBindingsMIMEOptionFile
521
        //org.netbeans.modules.editor.options.KeyBindingsMIMEOptionFile
519
        //ANY CHANGES MADE HERE SHOULD ALSO BE MADE THERE!
522
        //ANY CHANGES MADE HERE SHOULD ALSO BE MADE THERE!
520
        String key = KeyEvent.META_MASK == Toolkit.getDefaultToolkit().getMenuShortcutKeyMask() ?
523
        String key = mac ?
521
            "M" : "C"; //NOI18N
524
            "M" : "C"; //NOI18N
522
            
525
        
526
        String ctrlWildcard = "D"; //NOI18N
527
        
528
        String altKey = mac ?
529
            "C" : "A"; //NOI18N
530
        
531
        String altWildcard = "O"; //NOI18N
532
        
533
        
523
        int pos = name.lastIndexOf ("-"); //NOI18N
534
        int pos = name.lastIndexOf ("-"); //NOI18N
524
        String keyPart = name.substring (pos);
535
        String keyPart = name.substring (pos);
525
        String modsPart = Utilities.replaceString (name.substring (0, pos), "-", "");
536
        String modsPart = Utilities.replaceString (name.substring (0, pos), "-", ""); //NOI18N
526
        if (modsPart.length() > 1) {
537
        if (modsPart.length() > 1) {
527
            Collection perms = new HashSet(modsPart.length() * modsPart.length());
538
            Collection perms = new HashSet(modsPart.length() * modsPart.length());
528
            int idx = name.indexOf(key);
539
            int idx = name.indexOf(key);
Lines 530-555 Link Here
530
                //First, try with the wildcard key.  Remove all hyphens - we'll
541
                //First, try with the wildcard key.  Remove all hyphens - we'll
531
                //put them back later
542
                //put them back later
532
                StringBuffer sb = new StringBuffer(modsPart);
543
                StringBuffer sb = new StringBuffer(modsPart);
533
                sb.replace(idx, idx+1, "D");
544
                sb.replace(idx, idx+1, ctrlWildcard);
534
                perms.add (sb.toString() + keyPart);
545
                perms.add (sb.toString() + keyPart);
535
                getAllPossibleOrderings (sb.toString(), keyPart, perms);
546
                getAllPossibleOrderings (sb.toString(), keyPart, perms);
536
                createHyphenatedPermutation(sb.toString().toCharArray(), perms, keyPart);
547
                createHyphenatedPermutation(sb.toString().toCharArray(), perms, keyPart);
548
                idx = name.indexOf (altKey);
549
                if (idx != -1) {
550
                    sb.replace (idx, idx+1, altWildcard);
551
                    perms.add (sb.toString() + keyPart);
552
                    getAllPossibleOrderings (sb.toString(), keyPart, perms);
553
                    createHyphenatedPermutation(sb.toString().toCharArray(), perms, keyPart);
554
                } else {
555
                    idx = name.indexOf(altWildcard);
556
                    if (idx != -1) {
557
                        sb.replace (idx, idx+1, altKey);
558
                        perms.add (sb.toString() + keyPart);
559
                        getAllPossibleOrderings (sb.toString(), keyPart, perms);
560
                        createHyphenatedPermutation(sb.toString().toCharArray(), perms, keyPart);
561
                    }
562
                }                
537
            } else {
563
            } else {
538
                idx = name.indexOf ("D"); //NOI18N
564
                idx = name.indexOf (ctrlWildcard); //NOI18N
539
                if (idx != -1) {
565
                if (idx != -1) {
540
                    StringBuffer sb = new StringBuffer(modsPart);
566
                    StringBuffer sb = new StringBuffer(modsPart);
541
                    sb.replace(idx, idx+1, key);
567
                    sb.replace(idx, idx+1, key);
542
                    perms.add (sb.toString() + keyPart);
568
                    perms.add (sb.toString() + keyPart);
543
                    getAllPossibleOrderings (sb.toString(), keyPart, perms);
569
                    getAllPossibleOrderings (sb.toString(), keyPart, perms);
544
                    createHyphenatedPermutation(sb.toString().toCharArray(), perms, keyPart);
570
                    createHyphenatedPermutation(sb.toString().toCharArray(), perms, keyPart);
571
                    idx = name.indexOf (altKey);
572
                    if (idx != -1) {
573
                        sb.replace (idx, idx+1, altWildcard);
574
                        perms.add (sb.toString() + keyPart);
575
                        getAllPossibleOrderings (sb.toString(), keyPart, perms);
576
                    } else {
577
                        idx = name.indexOf(altWildcard);
578
                        if (idx != -1) {
579
                            sb.replace (idx, idx+1, altKey);
580
                            perms.add (sb.toString() + keyPart);
581
                            getAllPossibleOrderings (sb.toString(), keyPart, perms);
582
                            createHyphenatedPermutation(sb.toString().toCharArray(), perms, keyPart);
583
                        }
584
                    }                    
545
                }
585
                }
546
            }
586
            }
587
            
588
            idx = name.indexOf (altKey);
589
            if (idx != -1) {
590
                StringBuffer sb = new StringBuffer(modsPart);
591
                sb.replace (idx, idx+1, altWildcard);
592
                perms.add (sb.toString() + keyPart);
593
                getAllPossibleOrderings (sb.toString(), keyPart, perms);
594
                createHyphenatedPermutation(sb.toString().toCharArray(), perms, keyPart);
595
            } else {
596
                StringBuffer sb = new StringBuffer(modsPart);
597
                idx = name.indexOf(altWildcard);
598
                if (idx != -1) {
599
                    sb.replace (idx, idx+1, altKey);
600
                    perms.add (sb.toString() + keyPart);
601
                    getAllPossibleOrderings (sb.toString(), keyPart, perms);
602
                    createHyphenatedPermutation(sb.toString().toCharArray(), perms, keyPart);
603
                }
604
            }
605
            
547
            getAllPossibleOrderings (modsPart, keyPart, perms);
606
            getAllPossibleOrderings (modsPart, keyPart, perms);
548
            createHyphenatedPermutation(modsPart.toCharArray(), perms, keyPart);
607
            createHyphenatedPermutation(modsPart.toCharArray(), perms, keyPart);
549
            return (String[]) perms.toArray(new String[perms.size()]);
608
            return (String[]) perms.toArray(new String[perms.size()]);
550
        } else {
609
        } else {
551
            return key.equals (modsPart) ?
610
            return key.equals (modsPart) ?
552
                new String[] {"D" + keyPart} : new String[0];
611
                new String[] {ctrlWildcard + keyPart} : altKey.equals(modsPart) ?
612
                    new String[]{altWildcard + keyPart} : altWildcard.equals(modsPart) ? 
613
                    new String[] {altKey + keyPart} : 
614
                    new String[0];
553
        }
615
        }
554
    }
616
    }
555
    
617
    
(-)core/src/org/netbeans/core/ShortcutsPanel.java (-6 lines)
Lines 60-71 Link Here
60
        shortcutsList.setSelectedIndices(new int[0]);
60
        shortcutsList.setSelectedIndices(new int[0]);
61
        updateButtons ();
61
        updateButtons ();
62
    }
62
    }
63
    
64
    public void addNotify() {
65
        super.addNotify();
66
        //Turn off remapping so keys will be read sanely
67
        System.setProperty ("nb.mac.swap.ctrl.and.alt", "false");
68
    }
69
63
70
    /** This method is called from within the constructor to
64
    /** This method is called from within the constructor to
71
     * initialize the form.
65
     * initialize the form.
(-)core/test/unit/src/org/netbeans/core/ShortcutsFolderTest.java (-10 / +226 lines)
Lines 18-23 Link Here
18
import java.io.File;
18
import java.io.File;
19
import java.io.IOException;
19
import java.io.IOException;
20
import java.lang.ref.WeakReference;
20
import java.lang.ref.WeakReference;
21
import java.lang.reflect.Field;
22
import java.lang.reflect.Method;
21
import java.util.Arrays;
23
import java.util.Arrays;
22
import java.util.Collection;
24
import java.util.Collection;
23
import java.util.Collections;
25
import java.util.Collections;
Lines 30-39 Link Here
30
import javax.swing.AbstractAction;
32
import javax.swing.AbstractAction;
31
import javax.swing.Action;
33
import javax.swing.Action;
32
import javax.swing.KeyStroke;
34
import javax.swing.KeyStroke;
35
import javax.swing.text.Keymap;
33
import junit.framework.*;
36
import junit.framework.*;
34
import org.netbeans.junit.*;
37
import org.netbeans.junit.*;
35
import org.openide.ErrorManager;
38
import org.openide.ErrorManager;
36
import org.openide.cookies.InstanceCookie;
39
import org.openide.cookies.InstanceCookie;
40
import org.openide.filesystems.FileLock;
37
import org.openide.filesystems.FileObject;
41
import org.openide.filesystems.FileObject;
38
import org.openide.filesystems.FileSystem;
42
import org.openide.filesystems.FileSystem;
39
import org.openide.filesystems.LocalFileSystem;
43
import org.openide.filesystems.LocalFileSystem;
Lines 63-77 Link Here
63
        super(s);
67
        super(s);
64
    }
68
    }
65
    
69
    
70
    ShortcutsFolder sf = null;
71
    FileSystem fs = null;
72
    FileObject fld = null;
73
    FileObject fo = null;
74
    
75
    static Repository repository = null;
76
    protected void setUp () {
77
        fs = createTestingFilesystem();
78
        fo = getFolderForShortcuts(fs);
79
        sf = createShortcutsFolder(fs);
80
        sf.waitShortcutsFinished();
81
    }
82
    
83
    protected void tearDown() {
84
        try {
85
            FileLock lock = fo.lock();
86
            fo.delete(lock);
87
            lock.releaseLock();
88
        } catch (Exception ioe) {
89
        }
90
        
91
        ShortcutsFolder.shortcutsFolder = null;
92
        sf = null;
93
        fs = null;
94
        fld = null;
95
        fo = null;
96
        try {
97
            if (dir.exists()) {
98
                File[] f = dir.listFiles();
99
                for (int i=0; i < f.length; i++) {
100
                    f[i].delete();
101
                }
102
                dir.delete();
103
            }
104
            dir = null;
105
            folderName = null;
106
            repository = null;
107
            
108
        } catch (Exception e) {
109
            throw new RuntimeException(e);
110
        }
111
    }
112
66
    public void testHyphenation (String s) {
113
    public void testHyphenation (String s) {
114
        System.out.println("testHyphenation");
67
        HashSet set = new HashSet();
115
        HashSet set = new HashSet();
68
        char[] c = new String("ABCD").toCharArray();
116
        char[] c = new String("ABCD").toCharArray();
69
        ShortcutsFolder.createHyphenatedPermutation (c, set, "-F5");
117
        ShortcutsFolder.createHyphenatedPermutation (c, set, "-F5");
70
        
118
        
71
        assertTrue (set.contains("A-B-C-D-F5"));
119
        assertTrue (set.contains("A-B-C-D-F5"));
72
    }
120
    }
73
    
121
   
74
    public void testPermutations () {
122
    public void testPermutations () {
123
        System.out.println("testPermutations");
75
        HashSet set = new HashSet();
124
        HashSet set = new HashSet();
76
        
125
        
77
        ShortcutsFolder.getAllPossibleOrderings("BANG", "-F5", set);
126
        ShortcutsFolder.getAllPossibleOrderings("BANG", "-F5", set);
Lines 89-94 Link Here
89
    }
138
    }
90
    
139
    
91
    public void testPermutationsIncludeHyphenatedVariants() {
140
    public void testPermutationsIncludeHyphenatedVariants() {
141
        System.out.println("testPermutationsIncludeHyphenatedVariants");
92
        HashSet set = new HashSet();
142
        HashSet set = new HashSet();
93
        
143
        
94
        ShortcutsFolder.getAllPossibleOrderings("BANG", "-F5", set);
144
        ShortcutsFolder.getAllPossibleOrderings("BANG", "-F5", set);
Lines 106-115 Link Here
106
    }
156
    }
107
    
157
    
108
    public void testPermutationsContainConvertedWildcard () {
158
    public void testPermutationsContainConvertedWildcard () {
109
        String targetChar = (Utilities.getOperatingSystem() & Utilities.OS_MAC) != 0
159
        doPermutationsContainConvertedWildcard (true);
160
        doPermutationsContainConvertedWildcard (false);
161
    }
162
    
163
    public void doPermutationsContainConvertedWildcard (boolean mac) {
164
        System.out.println("testPermutationsContainConvertedWildcard mac=" + mac);
165
        String targetChar = mac
110
            ? "M" : "C";
166
            ? "M" : "C";
111
        
167
        
112
        String[] s = ShortcutsFolder.getPermutations("DA-F5");
168
        String[] s = ShortcutsFolder.getPermutations("DA-F5", mac);
113
        HashSet set = new HashSet (Arrays.asList(s));
169
        HashSet set = new HashSet (Arrays.asList(s));
114
        set.add ("DA-F5"); //Permutations will not contain the passed value
170
        set.add ("DA-F5"); //Permutations will not contain the passed value
115
        
171
        
Lines 125-136 Link Here
125
                set.contains(permutations[i]));
181
                set.contains(permutations[i]));
126
        }
182
        }
127
    }
183
    }
128
184
    
129
    public void testPermutationsIncludeWildcardIfSpecifiedKeyIsToolkitAccelerator () {
185
    public void testPermutationsIncludeWildcardIfSpecifiedKeyIsToolkitAccelerator () {
130
        String targetChar = (Utilities.getOperatingSystem() & Utilities.OS_MAC) != 0
186
        doTestPermutationsIncludeWildcardIfSpecifiedKeyIsToolkitAccelerator(true);
187
        doTestPermutationsIncludeWildcardIfSpecifiedKeyIsToolkitAccelerator(false);
188
    }
189
190
    public void doTestPermutationsIncludeWildcardIfSpecifiedKeyIsToolkitAccelerator (boolean macintosh) {
191
        System.out.println("testPermutationsIncludeWildcardIfSpecifiedKeyIsToolkitAccelerator - mac=" + macintosh);
192
        String targetChar = macintosh
131
            ? "M" : "C";
193
            ? "M" : "C";
132
        
194
        
133
        String[] s = ShortcutsFolder.getPermutations(targetChar + "A-F5");
195
        String[] s = ShortcutsFolder.getPermutations(targetChar + "A-F5", macintosh);
134
        
196
        
135
        String[] permutations = new String[] {
197
        String[] permutations = new String[] {
136
            "A" + targetChar + "-F5", "A-" + targetChar + "-F5",
198
            "A" + targetChar + "-F5", "A-" + targetChar + "-F5",
Lines 147-160 Link Here
147
        }
209
        }
148
    } 
210
    } 
149
    
211
    
212
    public void testPermutationsContainConvertedAltWildcard () {
213
        doTestPermutationsContainConvertedAltWildcard (true);
214
        doTestPermutationsContainConvertedAltWildcard (false);
215
    }
216
    
217
    public void doTestPermutationsContainConvertedAltWildcard (boolean macintosh) {
218
        System.out.println("testPermutationsContainConvertedAltWildcard mac = " + macintosh);
219
        String cmdChar = macintosh
220
            ? "M" : "C";        
221
        
222
        String altKey = macintosh ?
223
            "C" : "A"; //NOI18N        
224
        
225
        String[] s = ShortcutsFolder.getPermutations("DO-F5", macintosh);
226
        HashSet set = new HashSet (Arrays.asList(s));
227
        set.add ("DO-F5"); //Permutations will not contain the passed value
228
        
229
        String[] permutations = new String[] {
230
            "OD-F5", 
231
            "O" + cmdChar + "-F5", 
232
            "DO-F5", 
233
            "D-O-F5",
234
            "O-D-F5", 
235
            altKey + "-D-F5", 
236
            altKey + "-" + cmdChar + "-F5", 
237
            altKey + "D-F5",
238
        };
239
        
240
        for (int i=0; i < permutations.length; i++) {
241
            assertTrue ("Permutation of D"+ altKey + "-F5 not generated:" 
242
                + permutations[i] + "; (generated:" + set + ")",
243
                set.contains(permutations[i]));
244
        }
245
    } 
246
247
    public void testDualWildcardPermutations() {
248
        doTestDualWildcardPermutations(true);
249
        doTestDualWildcardPermutations(false);
250
    }   
251
    
252
    public void doTestDualWildcardPermutations(boolean macintosh) {
253
        System.out.println("testDualWildcardPermutations mac=" + macintosh);
254
        String cmdChar = macintosh
255
            ? "M" : "C";        
256
        
257
        String altKey = macintosh ?
258
            "C" : "A"; //NOI18N        
259
        
260
        String[] s = ShortcutsFolder.getPermutations("OD-F5", macintosh);
261
        HashSet set = new HashSet (Arrays.asList(s));
262
        set.add ("OD-F5"); //Permutations will not contain the passed value
263
        
264
        String[] permutations = new String[] {
265
            "OD-F5", "O" + cmdChar + "-F5", "DO-F5", "D-O-F5",
266
            "O-D-F5", altKey + "-D-F5", altKey + "-" + cmdChar + "-F5", altKey + "D-F5",
267
            altKey + cmdChar + "-F5"
268
        };
269
        
270
        for (int i=0; i < permutations.length; i++) {
271
            assertTrue ("Permutation of OD-F5 not generated:" 
272
                + permutations[i] + "; (generated:" + set + ")",
273
                set.contains(permutations[i]));
274
        }
275
    }
276
    
277
    public void testOPermutationOfAlt () throws Exception {
278
        System.out.println("testOPermutationOfAlt");
279
//        FileSystem fs = createTestingFilesystem();
280
//        FileObject fo = getFolderForShortcuts(fs);
281
        
282
//        assertEquals (lastDir, repository.getDefaultFileSystem().getRoot().getPath());
283
        
284
        FileObject data1 = fo.createData("OD-F6.instance");
285
        assertNotNull(data1);
286
        data1.setAttribute("instanceClass", "org.netbeans.core.ShortcutsFolderTest$TestAction");
287
        
288
        FileObject data2 = fo.createData("OS-F6.instance");
289
        assertNotNull(data2);
290
        data2.setAttribute("instanceClass", "org.netbeans.core.ShortcutsFolderTest$TestAction");
291
        
292
        File file = new File (lastDir + folderName + File.separator + "OD-F6.instance");
293
        assertTrue ("Actual file not created: " + file.getPath(), file.exists());
294
295
        sf.refreshGlobalMap();
296
        
297
        DataObject ob = DataObject.find (data1);
298
        assertNotNull("Data object not found: " + data1.getPath(), ob);
299
        
300
        InstanceCookie ck = (InstanceCookie) ob.getCookie(InstanceCookie.class);
301
        Object obj = ck.instanceCreate();
302
        
303
        assertTrue ("InstanceCookie was not an instanceof TestAction - " + obj, obj instanceof TestAction);
304
        
305
        int mask = System.getProperty("mrj.version") == null ? KeyEvent.ALT_MASK :
306
            KeyEvent.CTRL_MASK;
307
        
308
        KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_F6, mask | Toolkit.getDefaultToolkit().getMenuShortcutKeyMask());
309
        Action action = (Action) obj;
310
        
311
        ShortcutsFolder.applyChanges(Arrays.asList(new Object[] {new ShortcutsFolder.ChangeRequest (stroke, action, false)}));
312
        
313
        ShortcutsFolder.refreshGlobalMap();
314
315
        FileObject now = fo.getFileObject ("OD-F6.instance");
316
        //XXX WTF??
317
        assertNull ("File object should be deleted - but is " + (now == null ? " null " : now.getPath()), now);
318
        
319
        assertFalse ("File still exists: " + lastDir + "OD-F6.instance", file.exists());
320
        
321
        file = new File (lastDir + "Shortcuts" + File.separator + "OS-F6.instance");
322
        assertTrue ("File should not have been deleted: " + file.getPath(), file.exists());
323
        
324
    }  
325
326
  
327
    
328
    private static String lastDir = null;
329
    private static File dir = null;
330
    private File getTempDir() {
331
        String outdir = System.getProperty("java.io.tmpdir"); //NOI18N
332
        if (!outdir.endsWith(File.separator)) {
333
            outdir += File.separator;
334
        }
335
        String dirname = Long.toHexString(System.currentTimeMillis());
336
        lastDir = outdir + dirname + File.separator;
337
        dir = new File (outdir + dirname);
338
        try {
339
            dir.mkdir();
340
        } catch (Exception ioe) {
341
            ioe.printStackTrace();
342
            fail ("Exception creating temporary dir for tests " + dirname + " - " + ioe.getMessage());
343
        }
344
        dir.deleteOnExit();
345
        
346
        return dir;
347
    }
348
    
150
    private FileSystem createTestingFilesystem () {
349
    private FileSystem createTestingFilesystem () {
151
        FileObject root = Repository.getDefault ().getDefaultFileSystem ().getRoot ();
350
        FileObject root = Repository.getDefault ().getDefaultFileSystem ().getRoot ();
152
        try {
351
        try {
352
            LocalFileSystem result = new LocalFileSystem();
353
            result.setRootDirectory(getTempDir());
354
            repository = new Repository (result);
355
            fixDefaultRepository();
356
            System.setProperty ("org.openide.util.Lookup", "org.netbeans.core.ShortcutsFolderTest$LKP");
153
            FileObject[] arr = root.getChildren ();
357
            FileObject[] arr = root.getChildren ();
154
            for (int i = 0; i < arr.length; i++) {
358
            for (int i = 0; i < arr.length; i++) {
155
                arr[i].delete ();
359
                arr[i].delete ();
156
            }
360
            }
157
            return root.getFileSystem ();
361
            return result;
158
        } catch (Exception e) {
362
        } catch (Exception e) {
159
            e.printStackTrace();
363
            e.printStackTrace();
160
            fail (e.getMessage());
364
            fail (e.getMessage());
Lines 162-173 Link Here
162
        return null;
366
        return null;
163
    }
367
    }
164
    
368
    
369
    private void fixDefaultRepository () {
370
        try {
371
            Class c = ClassLoader.getSystemClassLoader().loadClass("org.openide.filesystems.ExternalUtil");
372
            Method m = c.getDeclaredMethod ("setRepository", new Class[] {Repository.class});
373
            m.setAccessible(true);
374
            m.invoke (null, new Object[] { repository });
375
        } catch (Exception e) {
376
            throw new RuntimeException (e);
377
        }
378
    }
379
    
165
    private FileObject getFolderForShortcuts(FileSystem fs) {
380
    private FileObject getFolderForShortcuts(FileSystem fs) {
166
        FileObject result = null;
381
        FileObject result = null;
167
        try {
382
        try {
168
            result = fs.getRoot().getFileObject("Shortcuts");
383
            folderName = "Shortcuts";
384
            result = fs.getRoot().getFileObject(folderName);
169
            if (result == null) {
385
            if (result == null) {
170
                result = fs.getRoot().createFolder("Shortcuts");
386
                result = fs.getRoot().createFolder(folderName);
171
            }
387
            }
172
        } catch (Exception e) {
388
        } catch (Exception e) {
173
            e.printStackTrace();
389
            e.printStackTrace();
Lines 176-181 Link Here
176
        return result;
392
        return result;
177
    }
393
    }
178
    
394
    
395
    private String folderName = null;
179
    private ShortcutsFolder createShortcutsFolder(FileSystem fs) {
396
    private ShortcutsFolder createShortcutsFolder(FileSystem fs) {
180
        try {
397
        try {
181
            DataObject dob = DataObject.find(getFolderForShortcuts(fs));
398
            DataObject dob = DataObject.find(getFolderForShortcuts(fs));
Lines 219-225 Link Here
219
        ShortcutsFolder.applyChanges(Arrays.asList(new Object[] {new ShortcutsFolder.ChangeRequest (stroke, action, false)}));
436
        ShortcutsFolder.applyChanges(Arrays.asList(new Object[] {new ShortcutsFolder.ChangeRequest (stroke, action, false)}));
220
        
437
        
221
        ShortcutsFolder.refreshGlobalMap();
438
        ShortcutsFolder.refreshGlobalMap();
222
223
        FileObject now = fo.getFileObject ("AD-F5.instance");
439
        FileObject now = fo.getFileObject ("AD-F5.instance");
224
        assertNull ("File object should be deleted - ", now);
440
        assertNull ("File object should be deleted - ", now);
225
        
441
        
(-)core/ui/src/org/netbeans/core/ui/resources/layer.xml (-6 / +4 lines)
Lines 144-154 Link Here
144
	    </file>
144
	    </file>
145
            <attr name="Separator2.instance/org-openide-actions-FindAction.instance" boolvalue="true" />
145
            <attr name="Separator2.instance/org-openide-actions-FindAction.instance" boolvalue="true" />
146
            <file name="org-openide-actions-FindAction.instance"/>
146
            <file name="org-openide-actions-FindAction.instance"/>
147
            <attr name="org-openide-actions-FindAction.instance/ReplaceAction.shadow" boolvalue="true" />
147
            <attr name="org-openide-actions-FindAction.instance/org-openide-actions-ReplaceAction.instance" boolvalue="true" />
148
            <file name="ReplaceAction.shadow">
148
            <file name="org-openide-actions-ReplaceAction.instance"/>
149
                    <attr name="originalFile" stringvalue="Actions/Edit/org-openide-actions-ReplaceAction.instance"/>
149
            <attr name="org-openide-actions-ReplaceAction.instance/org-openide-actions-GotoAction.instance" boolvalue="true" />
150
            </file>
151
            <attr name="ReplaceAction.shadow/org-openide-actions-GotoAction.instance" boolvalue="true" />
152
            <file name="org-openide-actions-GotoAction.instance"/>
150
            <file name="org-openide-actions-GotoAction.instance"/>
153
        </folder>
151
        </folder>
154
        
152
        
Lines 304-310 Link Here
304
	</file>
302
	</file>
305
    
303
    
306
        <file name="C-H.shadow">
304
        <file name="C-H.shadow">
307
            <attr name="originalFile" stringvalue="Actions/Edit/org-openide-actions-ReplaceAction.instance"/>
305
	    <attr name="originalFile" stringvalue="Actions/Edit/org-openide-actions-ReplaceAction.instance"/>
308
	</file>
306
	</file>
309
307
310
        <file name="D-P.instance">
308
        <file name="D-P.instance">
(-)core/windows/src/org/netbeans/core/windows/ShortcutAndMenuKeyEventProcessor.java (-35 / +4 lines)
Lines 87-92 Link Here
87
    private char lastKeyChar;
87
    private char lastKeyChar;
88
    private boolean lastSampled = false;
88
    private boolean lastSampled = false;
89
    
89
    
90
    private static final boolean isMac = Utilities.getOperatingSystem() == 
91
        Utilities.OS_MAC;
92
    
90
    public boolean postProcessKeyEvent(KeyEvent ev) {
93
    public boolean postProcessKeyEvent(KeyEvent ev) {
91
        if (ev.isConsumed())
94
        if (ev.isConsumed())
92
            return false;
95
            return false;
Lines 107-112 Link Here
107
        if (mb == null)
110
        if (mb == null)
108
            return false;
111
            return false;
109
        boolean pressed = (ev.getID() == KeyEvent.KEY_PRESSED);
112
        boolean pressed = (ev.getID() == KeyEvent.KEY_PRESSED);
113
        
110
        boolean res = invokeProcessKeyBindingsForAllComponents(ev, mw, pressed);
114
        boolean res = invokeProcessKeyBindingsForAllComponents(ev, mw, pressed);
111
        
115
        
112
        if (res)
116
        if (res)
Lines 114-120 Link Here
114
        return res;
118
        return res;
115
    }
119
    }
116
120
117
    private static boolean wasMacSwap = false;
118
    public boolean dispatchKeyEvent(KeyEvent ev) {
121
    public boolean dispatchKeyEvent(KeyEvent ev) {
119
        // XXX(-ttran) Sun JDK 1.4 on Linux: pressing Alt key produces
122
        // XXX(-ttran) Sun JDK 1.4 on Linux: pressing Alt key produces
120
        // KeyEvent.VK_ALT, but Alt+<key> produces Meta+<key>
123
        // KeyEvent.VK_ALT, but Alt+<key> produces Meta+<key>
Lines 124-163 Link Here
124
                mods = (mods & ~ InputEvent.META_MASK) | InputEvent.ALT_MASK;
127
                mods = (mods & ~ InputEvent.META_MASK) | InputEvent.ALT_MASK;
125
                ev.setModifiers(mods);
128
                ev.setModifiers(mods);
126
            }
129
            }
127
        }
128
        
129
        if (Utilities.getOperatingSystem() == Utilities.OS_MAC) {
130
            boolean macSwap = Boolean.getBoolean (
131
                "nb.mac.swap.ctrl.and.alt"); //NOI18N
132
            if (macSwap) {
133
                //Allows international keyboards to use the Alt key as the Compose
134
                //key
135
                int mods = ev.getModifiers();
136
                System.setProperty ("lastKeyModifiers", Integer.toString(mods)); //NOI18N
137
                boolean isCtrl = (mods & InputEvent.CTRL_MASK) != 0;
138
                boolean isAlt = (mods & InputEvent.ALT_MASK) != 0;
139
                int code = ev.getKeyCode();
140
                boolean skip = code == KeyEvent.VK_UP || code == KeyEvent.VK_DOWN ||
141
                    code == KeyEvent.VK_RIGHT || code == KeyEvent.VK_LEFT || 
142
                    code == KeyEvent.VK_ENTER || code == KeyEvent.VK_SPACE;
143
                if (isCtrl != isAlt && !skip) {
144
                    if (isAlt) {
145
                        mods ^= InputEvent.ALT_MASK;
146
                        mods |= InputEvent.CTRL_MASK;
147
                    }
148
                    if (isCtrl) {
149
                        mods ^= InputEvent.CTRL_MASK;
150
                        mods |= InputEvent.ALT_MASK;
151
                    }
152
                    ev.setModifiers (mods);
153
                }
154
            }
155
            if (wasMacSwap != macSwap) {
156
                if (!macSwap) {
157
                    System.getProperties().remove ("lastKeyModifiers"); //NOI18N
158
                }
159
            }
160
            wasMacSwap = macSwap;
161
        }
130
        }
162
131
163
        if (ev.getID() == KeyEvent.KEY_PRESSED
132
        if (ev.getID() == KeyEvent.KEY_PRESSED
(-)debuggercore/src/org/netbeans/modules/debugger/resources/mf-layer.xml (-6 / +6 lines)
Lines 69-90 Link Here
69
    </folder>
69
    </folder>
70
70
71
    <folder name="Shortcuts">
71
    <folder name="Shortcuts">
72
        <file name="SA-6.shadow">
72
        <file name="SO-6.shadow">
73
            <attr name="originalFile" stringvalue="Actions/Window/Debug/org-netbeans-modules-debugger-ui-actions-SessionsViewAction.instance"/>
73
            <attr name="originalFile" stringvalue="Actions/Window/Debug/org-netbeans-modules-debugger-ui-actions-SessionsViewAction.instance"/>
74
        </file>
74
        </file>
75
        <file name="SA-7.shadow">
75
        <file name="SO-7.shadow">
76
            <attr name="originalFile" stringvalue="Actions/Window/Debug/org-netbeans-modules-debugger-ui-actions-ThreadsViewAction.instance"/>
76
            <attr name="originalFile" stringvalue="Actions/Window/Debug/org-netbeans-modules-debugger-ui-actions-ThreadsViewAction.instance"/>
77
        </file>
77
        </file>
78
        <file name="SA-3.shadow">
78
        <file name="SO-3.shadow">
79
            <attr name="originalFile" stringvalue="Actions/Window/Debug/org-netbeans-modules-debugger-ui-actions-CallStackViewAction.instance"/>
79
            <attr name="originalFile" stringvalue="Actions/Window/Debug/org-netbeans-modules-debugger-ui-actions-CallStackViewAction.instance"/>
80
        </file>
80
        </file>
81
        <file name="SA-1.shadow">
81
        <file name="SO-1.shadow">
82
            <attr name="originalFile" stringvalue="Actions/Window/Debug/org-netbeans-modules-debugger-ui-actions-LocalsViewAction.instance"/>
82
            <attr name="originalFile" stringvalue="Actions/Window/Debug/org-netbeans-modules-debugger-ui-actions-LocalsViewAction.instance"/>
83
        </file>
83
        </file>
84
        <file name="SA-2.shadow">
84
        <file name="SO-2.shadow">
85
            <attr name="originalFile" stringvalue="Actions/Window/Debug/org-netbeans-modules-debugger-ui-actions-WatchesViewAction.instance"/>
85
            <attr name="originalFile" stringvalue="Actions/Window/Debug/org-netbeans-modules-debugger-ui-actions-WatchesViewAction.instance"/>
86
        </file>
86
        </file>
87
        <file name="SA-5.shadow">
87
        <file name="SO-5.shadow">
88
            <attr name="originalFile" stringvalue="Actions/Window/Debug/org-netbeans-modules-debugger-ui-actions-BreakpointsViewAction.instance"/>
88
            <attr name="originalFile" stringvalue="Actions/Window/Debug/org-netbeans-modules-debugger-ui-actions-BreakpointsViewAction.instance"/>
89
        </file>
89
        </file>
90
    </folder>
90
    </folder>
(-)debuggerjpda/ui/src/org/netbeans/modules/debugger/jpda/resources/mf-layer.xml (-3 / +3 lines)
Lines 199-205 Link Here
199
        <file name="F4.shadow">
199
        <file name="F4.shadow">
200
            <attr name="originalFile" stringvalue="Actions/Debug/org-netbeans-modules-debugger-ui-actions-RunToCursorAction.instance"/>
200
            <attr name="originalFile" stringvalue="Actions/Debug/org-netbeans-modules-debugger-ui-actions-RunToCursorAction.instance"/>
201
        </file>
201
        </file>
202
        <file name="SA-F7.shadow">
202
        <file name="SO-F7.shadow">
203
            <attr name="originalFile" stringvalue="Actions/Debug/org-netbeans-modules-debugger-ui-actions-StepOutAction.instance"/>
203
            <attr name="originalFile" stringvalue="Actions/Debug/org-netbeans-modules-debugger-ui-actions-StepOutAction.instance"/>
204
        </file>
204
        </file>
205
        <file name="F7.shadow">
205
        <file name="F7.shadow">
Lines 220-229 Link Here
220
        <file name="DA-DOWN.shadow">
220
        <file name="DA-DOWN.shadow">
221
            <attr name="originalFile" stringvalue="Actions/Debug/org-netbeans-modules-debugger-ui-actions-MakeCallerCurrentAction.instance"/>
221
            <attr name="originalFile" stringvalue="Actions/Debug/org-netbeans-modules-debugger-ui-actions-MakeCallerCurrentAction.instance"/>
222
        </file>
222
        </file>
223
        <file name="SA-4.shadow">
223
        <file name="SO-4.shadow">
224
            <attr name="originalFile" stringvalue="Actions/Window/Debug/org-netbeans-modules-debugger-jpda-ui-actions-ClassesViewAction.instance"/>
224
            <attr name="originalFile" stringvalue="Actions/Window/Debug/org-netbeans-modules-debugger-jpda-ui-actions-ClassesViewAction.instance"/>
225
        </file>
225
        </file>
226
        <file name="SA-8.shadow">
226
        <file name="SO-8.shadow">
227
            <attr name="originalFile" stringvalue="Actions/Window/Debug/org-netbeans-modules-debugger-jpda-ui-actions-SourcesViewAction.instance"/>
227
            <attr name="originalFile" stringvalue="Actions/Window/Debug/org-netbeans-modules-debugger-jpda-ui-actions-SourcesViewAction.instance"/>
228
        </file>
228
        </file>
229
    </folder>
229
    </folder>
(-)editor/libsrc/org/netbeans/editor/BaseKit.java (-32 / +3 lines)
Lines 781-819 Link Here
781
                int mod = evt.getModifiers();
781
                int mod = evt.getModifiers();
782
                boolean ctrl = ((mod & ActionEvent.CTRL_MASK) != 0);
782
                boolean ctrl = ((mod & ActionEvent.CTRL_MASK) != 0);
783
                // On the mac, norwegian and french keyboards use Alt to do bracket characters.
783
                // On the mac, norwegian and french keyboards use Alt to do bracket characters.
784
                boolean alt = ((mod & ActionEvent.ALT_MASK) != 0);
784
                // This replicates Apple's modification DefaultEditorKit.DefaultKeyTypedAction
785
                boolean alt = isMac ? ((mod & ActionEvent.META_MASK) != 0) : 
786
                    ((mod & ActionEvent.ALT_MASK) != 0);
785
                
787
                
786
                if (isMac) {
787
                    boolean macSwap = Boolean.getBoolean (
788
                            "nb.mac.swap.ctrl.and.alt"); //NOI18N
789
790
                    if (alt && !macSwap) {
791
                        //Ugly, but without IDE-wide global keybinding registry, there
792
                        //simply is no way to find out if it's a character we want
793
                        //or not, so filter for commonly used characters and otherwise
794
                        //handle normally.  The problem is really Apple's, that they
795
                        //use Alt- as the compose key in some locales.  Eventually
796
                        //perhaps the applemenu module could detect this and provide alternate
797
                        //bindings with a line switch for all Alt- bindings.  For
798
                        //4.0, this will have to do.
799
                        //
800
                        //Original patch replicated what Apple does in DefaultKeyAction,
801
                        //(check META instead of ALT) but this broke all Alt- 
802
                        //shortcuts.  So we do it the ugly way.
803
                        //
804
                        //This *does* break Alt-8/9 key combinations on norwegian and
805
                        //french keyboards, but that's better than not being able to
806
                        //type brackets
807
                        String cmd = evt.getActionCommand();
808
                        alt &= !"{".equals(cmd) && !"}".equals(cmd) && !"[".equals(cmd) && //NOI18N
809
                            !"]".equals(cmd) && !"(".equals(cmd) && !")".equals(cmd); //NOI18N
810
                    } else if (macSwap) {
811
                        //Allow alt keys through if the flag is set - replicate
812
                        //Apple's hack in DefaultKeyAction.
813
                        alt = false;
814
                        ctrl = false;
815
                    }
816
                }
817
                
788
                
818
                if ((alt && !ctrl) || (ctrl && !alt)) {
789
                if ((alt && !ctrl) || (ctrl && !alt)) {
819
                    return;
790
                    return;
(-)editor/libsrc/org/netbeans/editor/SettingsDefaults.java (-17 / +20 lines)
Lines 211-216 Link Here
211
    //Default behavior on mac is that alt+arrows is word jumps
211
    //Default behavior on mac is that alt+arrows is word jumps
212
    private static final int WORD_SELECT_MASK = System.getProperty("mrj.version") == null ?
212
    private static final int WORD_SELECT_MASK = System.getProperty("mrj.version") == null ?
213
        InputEvent.CTRL_DOWN_MASK : InputEvent.ALT_DOWN_MASK;
213
        InputEvent.CTRL_DOWN_MASK : InputEvent.ALT_DOWN_MASK;
214
    
215
    private static final int ALT_MASK = System.getProperty("mrj.version") == null ?
216
        InputEvent.ALT_DOWN_MASK : InputEvent.CTRL_DOWN_MASK;
214
        
217
        
215
    public static MultiKeyBinding[] defaultKeyBindings
218
    public static MultiKeyBinding[] defaultKeyBindings
216
    = new MultiKeyBinding[] {
219
    = new MultiKeyBinding[] {
Lines 446-452 Link Here
446
          ),
449
          ),
447
          new MultiKeyBinding( //53
450
          new MultiKeyBinding( //53
448
              new KeyStroke[] {
451
              new KeyStroke[] {
449
                  KeyStroke.getKeyStroke(KeyEvent.VK_U, InputEvent.ALT_MASK),
452
                  KeyStroke.getKeyStroke(KeyEvent.VK_U, ALT_MASK),
450
                  KeyStroke.getKeyStroke(KeyEvent.VK_E, 0),
453
                  KeyStroke.getKeyStroke(KeyEvent.VK_E, 0),
451
              },
454
              },
452
              BaseKit.endWordAction
455
              BaseKit.endWordAction
Lines 488-494 Link Here
488
              BaseKit.findSelectionAction
491
              BaseKit.findSelectionAction
489
          ),
492
          ),
490
          new MultiKeyBinding( //63
493
          new MultiKeyBinding( //63
491
              KeyStroke.getKeyStroke(KeyEvent.VK_H, InputEvent.ALT_MASK | InputEvent.SHIFT_MASK),
494
              KeyStroke.getKeyStroke(KeyEvent.VK_H, ALT_MASK | InputEvent.SHIFT_MASK),
492
              BaseKit.toggleHighlightSearchAction
495
              BaseKit.toggleHighlightSearchAction
493
          ),
496
          ),
494
          new MultiKeyBinding( //64
497
          new MultiKeyBinding( //64
Lines 518-553 Link Here
518
521
519
          new MultiKeyBinding( //70
522
          new MultiKeyBinding( //70
520
              new KeyStroke[] {
523
              new KeyStroke[] {
521
                  KeyStroke.getKeyStroke(KeyEvent.VK_U, InputEvent.ALT_MASK),
524
                  KeyStroke.getKeyStroke(KeyEvent.VK_U, ALT_MASK),
522
                  KeyStroke.getKeyStroke(KeyEvent.VK_T, 0),
525
                  KeyStroke.getKeyStroke(KeyEvent.VK_T, 0),
523
              },
526
              },
524
              BaseKit.adjustWindowTopAction
527
              BaseKit.adjustWindowTopAction
525
          ),
528
          ),
526
          new MultiKeyBinding( //71
529
          new MultiKeyBinding( //71
527
              new KeyStroke[] {
530
              new KeyStroke[] {
528
                  KeyStroke.getKeyStroke(KeyEvent.VK_U, InputEvent.ALT_MASK),
531
                  KeyStroke.getKeyStroke(KeyEvent.VK_U, ALT_MASK),
529
                  KeyStroke.getKeyStroke(KeyEvent.VK_M, 0),
532
                  KeyStroke.getKeyStroke(KeyEvent.VK_M, 0),
530
              },
533
              },
531
              BaseKit.adjustWindowCenterAction
534
              BaseKit.adjustWindowCenterAction
532
          ),
535
          ),
533
          new MultiKeyBinding( //72
536
          new MultiKeyBinding( //72
534
              new KeyStroke[] {
537
              new KeyStroke[] {
535
                  KeyStroke.getKeyStroke(KeyEvent.VK_U, InputEvent.ALT_MASK),
538
                  KeyStroke.getKeyStroke(KeyEvent.VK_U, ALT_MASK),
536
                  KeyStroke.getKeyStroke(KeyEvent.VK_B, 0),
539
                  KeyStroke.getKeyStroke(KeyEvent.VK_B, 0),
537
              },
540
              },
538
              BaseKit.adjustWindowBottomAction
541
              BaseKit.adjustWindowBottomAction
539
          ),
542
          ),
540
543
541
          new MultiKeyBinding( //73
544
          new MultiKeyBinding( //73
542
              KeyStroke.getKeyStroke(KeyEvent.VK_T, InputEvent.SHIFT_MASK | InputEvent.ALT_MASK),
545
              KeyStroke.getKeyStroke(KeyEvent.VK_T, InputEvent.SHIFT_MASK | ALT_MASK),
543
              BaseKit.adjustCaretTopAction
546
              BaseKit.adjustCaretTopAction
544
          ),
547
          ),
545
          new MultiKeyBinding( //74
548
          new MultiKeyBinding( //74
546
              KeyStroke.getKeyStroke(KeyEvent.VK_M, InputEvent.SHIFT_MASK | InputEvent.ALT_MASK),
549
              KeyStroke.getKeyStroke(KeyEvent.VK_M, InputEvent.SHIFT_MASK | ALT_MASK),
547
              BaseKit.adjustCaretCenterAction
550
              BaseKit.adjustCaretCenterAction
548
          ),
551
          ),
549
          new MultiKeyBinding( //75
552
          new MultiKeyBinding( //75
550
              KeyStroke.getKeyStroke(KeyEvent.VK_B, InputEvent.SHIFT_MASK | InputEvent.ALT_MASK),
553
              KeyStroke.getKeyStroke(KeyEvent.VK_B, InputEvent.SHIFT_MASK | ALT_MASK),
551
              BaseKit.adjustCaretBottomAction
554
              BaseKit.adjustCaretBottomAction
552
          ),
555
          ),
553
556
Lines 556-597 Link Here
556
              BaseKit.formatAction
559
              BaseKit.formatAction
557
          ),
560
          ),
558
          new MultiKeyBinding( //77
561
          new MultiKeyBinding( //77
559
              KeyStroke.getKeyStroke(KeyEvent.VK_J, InputEvent.ALT_MASK),
562
              KeyStroke.getKeyStroke(KeyEvent.VK_J, ALT_MASK),
560
              BaseKit.selectIdentifierAction
563
              BaseKit.selectIdentifierAction
561
          ),
564
          ),
562
          new MultiKeyBinding( //78
565
          new MultiKeyBinding( //78
563
              KeyStroke.getKeyStroke(KeyEvent.VK_K, InputEvent.ALT_MASK),
566
              KeyStroke.getKeyStroke(KeyEvent.VK_K, ALT_MASK),
564
              BaseKit.jumpListPrevAction
567
              BaseKit.jumpListPrevAction
565
          ),
568
          ),
566
          new MultiKeyBinding( //79
569
          new MultiKeyBinding( //79
567
              KeyStroke.getKeyStroke(KeyEvent.VK_L, InputEvent.ALT_MASK),
570
              KeyStroke.getKeyStroke(KeyEvent.VK_L, ALT_MASK),
568
              BaseKit.jumpListNextAction
571
              BaseKit.jumpListNextAction
569
          ),
572
          ),
570
          new MultiKeyBinding( //80
573
          new MultiKeyBinding( //80
571
              KeyStroke.getKeyStroke(KeyEvent.VK_K, InputEvent.SHIFT_MASK | InputEvent.ALT_MASK),
574
              KeyStroke.getKeyStroke(KeyEvent.VK_K, InputEvent.SHIFT_MASK | ALT_MASK),
572
              BaseKit.jumpListPrevComponentAction
575
              BaseKit.jumpListPrevComponentAction
573
          ),
576
          ),
574
          new MultiKeyBinding( //81
577
          new MultiKeyBinding( //81
575
              KeyStroke.getKeyStroke(KeyEvent.VK_L, InputEvent.SHIFT_MASK | InputEvent.ALT_MASK),
578
              KeyStroke.getKeyStroke(KeyEvent.VK_L, InputEvent.SHIFT_MASK | ALT_MASK),
576
              BaseKit.jumpListNextComponentAction
579
              BaseKit.jumpListNextComponentAction
577
          ),
580
          ),
578
          new MultiKeyBinding( //82
581
          new MultiKeyBinding( //82
579
              new KeyStroke[] {
582
              new KeyStroke[] {
580
                  KeyStroke.getKeyStroke(KeyEvent.VK_U, InputEvent.ALT_MASK),
583
                  KeyStroke.getKeyStroke(KeyEvent.VK_U, ALT_MASK),
581
                  KeyStroke.getKeyStroke(KeyEvent.VK_U, 0),
584
                  KeyStroke.getKeyStroke(KeyEvent.VK_U, 0),
582
              },
585
              },
583
              BaseKit.toUpperCaseAction
586
              BaseKit.toUpperCaseAction
584
          ),
587
          ),
585
          new MultiKeyBinding( //83
588
          new MultiKeyBinding( //83
586
              new KeyStroke[] {
589
              new KeyStroke[] {
587
                  KeyStroke.getKeyStroke(KeyEvent.VK_U, InputEvent.ALT_MASK),
590
                  KeyStroke.getKeyStroke(KeyEvent.VK_U, ALT_MASK),
588
                  KeyStroke.getKeyStroke(KeyEvent.VK_L, 0),
591
                  KeyStroke.getKeyStroke(KeyEvent.VK_L, 0),
589
              },
592
              },
590
              BaseKit.toLowerCaseAction
593
              BaseKit.toLowerCaseAction
591
          ),
594
          ),
592
          new MultiKeyBinding( //84
595
          new MultiKeyBinding( //84
593
              new KeyStroke[] {
596
              new KeyStroke[] {
594
                  KeyStroke.getKeyStroke(KeyEvent.VK_U, InputEvent.ALT_MASK),
597
                  KeyStroke.getKeyStroke(KeyEvent.VK_U, ALT_MASK),
595
                  KeyStroke.getKeyStroke(KeyEvent.VK_R, 0),
598
                  KeyStroke.getKeyStroke(KeyEvent.VK_R, 0),
596
              },
599
              },
597
              BaseKit.switchCaseAction
600
              BaseKit.switchCaseAction
Lines 669-675 Link Here
669
          ),
672
          ),
670
          
673
          
671
          new MultiKeyBinding( //98
674
          new MultiKeyBinding( //98
672
              KeyStroke.getKeyStroke(KeyEvent.VK_Q, InputEvent.ALT_MASK | InputEvent.SHIFT_MASK),
675
              KeyStroke.getKeyStroke(KeyEvent.VK_Q, ALT_MASK | InputEvent.SHIFT_MASK),
673
              "dump-view-hierarchy" // NOI18N
676
              "dump-view-hierarchy" // NOI18N
674
          )
677
          )
675
          
678
          
(-)editor/libsrc/org/netbeans/editor/ext/ExtKit.java (-24 lines)
Lines 15-21 Link Here
15
15
16
import java.awt.Rectangle;
16
import java.awt.Rectangle;
17
import java.awt.event.ActionEvent;
17
import java.awt.event.ActionEvent;
18
import java.awt.event.InputEvent;
19
import java.io.IOException;
18
import java.io.IOException;
20
import java.util.List;
19
import java.util.List;
21
import java.util.Iterator;
20
import java.util.Iterator;
Lines 405-439 Link Here
405
        }
404
        }
406
405
407
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
406
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
408
            //Hack: On the mac, we provide an action to globally swap
409
            //Ctrl and Alt, so Alt can be used as a control character.  But
410
            //Goto is bound to Ctrl-G even on mac, so we need to suppress it,
411
            //or Alt-G when swapped will not insert an international character.
412
            //We provide the alternate binding AS-G so Goto can work even in
413
            //swapped mode.  See 
414
            //org.netbeans.core.windows.ShortcutKeyAndMenuEventProcessor
415
            
416
            if (isMac) {
417
                String lastMods = System.getProperty("lastKeyModifiers"); //NOI18N
418
                if (lastMods != null) {
419
                    try {
420
                        int mods = Integer.parseInt(lastMods);
421
                        if ((mods & InputEvent.ALT_MASK) != 0) {
422
                            return;
423
                        }
424
                    } catch (NumberFormatException e) {
425
                        //do nothing
426
                    }
427
                }
428
            }
429
            
430
            if (target != null) {
407
            if (target != null) {
431
                new GotoDialogSupport().showGotoDialog(new KeyEventBlocker(target, false));
408
                new GotoDialogSupport().showGotoDialog(new KeyEventBlocker(target, false));
432
            }
409
            }
433
        }
410
        }
434
411
435
    }
412
    }
436
    private static final boolean isMac = System.getProperty("mrj.version") != null; //NOI18N
437
413
438
    /** Action to go to the declaration of the variable under the caret.
414
    /** Action to go to the declaration of the variable under the caret.
439
    */
415
    */
(-)editor/libsrc/org/netbeans/editor/ext/ExtSettingsDefaults.java (-13 / +3 lines)
Lines 73-79 Link Here
73
    public static final Dimension defaultJavaDocPreferredSize = new Dimension(500, 300);    
73
    public static final Dimension defaultJavaDocPreferredSize = new Dimension(500, 300);    
74
    public static final Boolean defaultJavaDocAutoPopup = Boolean.TRUE;
74
    public static final Boolean defaultJavaDocAutoPopup = Boolean.TRUE;
75
    private static int MENU_MASK = java.awt.Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
75
    private static int MENU_MASK = java.awt.Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
76
    private static boolean IS_MAC = System.getProperty("mrj.version") != null;
76
    
77
    
77
    
78
    public static final MultiKeyBinding[] defaultExtKeyBindings
78
    public static final MultiKeyBinding[] defaultExtKeyBindings
79
    = new MultiKeyBinding[] {
79
    = new MultiKeyBinding[] {
Lines 91-119 Link Here
91
              ExtKit.findAction
91
              ExtKit.findAction
92
          ),
92
          ),
93
          new MultiKeyBinding(
93
          new MultiKeyBinding(
94
              KeyStroke.getKeyStroke(IS_MAC ? KeyEvent.VK_R : KeyEvent.VK_H, MENU_MASK),
94
              KeyStroke.getKeyStroke(KeyEvent.VK_H, MENU_MASK),
95
              ExtKit.replaceAction
95
              ExtKit.replaceAction
96
          ),
96
          ),
97
          new MultiKeyBinding(
97
          new MultiKeyBinding(
98
              KeyStroke.getKeyStroke(KeyEvent.VK_G, InputEvent.CTRL_MASK),
98
              KeyStroke.getKeyStroke(KeyEvent.VK_G, InputEvent.CTRL_MASK),
99
              ExtKit.gotoAction
99
              ExtKit.gotoAction
100
          ),
100
          ),
101
          //Next entry is to handle suppression of Ctrl-G on mac when 
102
          //ctrl and alt are swapped (alt is the compose key for international
103
          //keyboards on mac, so we allow swapping of Alt and G keys via a
104
          //shortcut so users have full use of their keyboard when necessary.
105
          //In swap mode, this binding is actually invoked on Ctrl-Shift-G,
106
          //not Alt-Shift-G.  Wish there were a better way to solve it.
107
          new MultiKeyBinding(
108
              KeyStroke.getKeyStroke(KeyEvent.VK_G, InputEvent.ALT_MASK | InputEvent.SHIFT_MASK),
109
              ExtKit.gotoAction
110
          ),
111
          new MultiKeyBinding(
101
          new MultiKeyBinding(
112
              KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, InputEvent.CTRL_MASK),
102
              KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, InputEvent.CTRL_MASK),
113
              ExtKit.completionShowAction
103
              ExtKit.completionShowAction
114
          ),
104
          ),
115
          new MultiKeyBinding( // Japanese Solaris uses CTRL+SPACE for IM
105
          new MultiKeyBinding( // Japanese Solaris uses CTRL+SPACE for IM
116
              KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SLASH, MENU_MASK),
106
              KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SLASH, InputEvent.CTRL_MASK),
117
              ExtKit.completionShowAction
107
              ExtKit.completionShowAction
118
          ),
108
          ),
119
          new MultiKeyBinding(
109
          new MultiKeyBinding(
(-)editor/src/org/netbeans/modules/editor/java/NbJavaSettingsInitializer.java (-11 / +15 lines)
Lines 55-60 Link Here
55
        super(NAME);
55
        super(NAME);
56
    }
56
    }
57
57
58
    private static final int ALT_MASK = System.getProperty("mrj.version") != null ?
59
        InputEvent.CTRL_MASK : InputEvent.ALT_MASK;
60
58
    /** Update map filled with the settings.
61
    /** Update map filled with the settings.
59
    * @param kitClass kit class for which the settings are being updated.
62
    * @param kitClass kit class for which the settings are being updated.
60
    *   It is always non-null value.
63
    *   It is always non-null value.
Lines 71-81 Link Here
71
            SettingsUtil.updateListSetting(settingsMap, SettingsNames.KEY_BINDING_LIST,
74
            SettingsUtil.updateListSetting(settingsMap, SettingsNames.KEY_BINDING_LIST,
72
                                           new MultiKeyBinding[] {
75
                                           new MultiKeyBinding[] {
73
                                               new MultiKeyBinding(
76
                                               new MultiKeyBinding(
74
                                                   KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.ALT_MASK),
77
                                                   KeyStroke.getKeyStroke(KeyEvent.VK_O, ALT_MASK),
75
                                                   JavaKit.gotoSourceAction
78
                                                   JavaKit.gotoSourceAction
76
                                               ),
79
                                               ),
77
                                               new MultiKeyBinding(
80
                                               new MultiKeyBinding(
78
                                                   KeyStroke.getKeyStroke(KeyEvent.VK_F1, InputEvent.ALT_MASK),
81
                                                   KeyStroke.getKeyStroke(KeyEvent.VK_F1, ALT_MASK),
79
                                                   JavaKit.gotoHelpAction
82
                                                   JavaKit.gotoHelpAction
80
                                               ),
83
                                               ),
81
                                           }
84
                                           }
Lines 100-130 Link Here
100
103
101
    public MultiKeyBinding[] getJavaKeyBindings() {
104
    public MultiKeyBinding[] getJavaKeyBindings() {
102
        int mask = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
105
        int mask = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
106
        boolean isMac = System.getProperty("mrj.version") != null;
103
        return new MultiKeyBinding[] {
107
        return new MultiKeyBinding[] {
104
                   new MultiKeyBinding(
108
                   new MultiKeyBinding(
105
                       new KeyStroke[] {
109
                       new KeyStroke[] {
106
                           KeyStroke.getKeyStroke(KeyEvent.VK_U, InputEvent.ALT_MASK),
110
                           KeyStroke.getKeyStroke(KeyEvent.VK_U, ALT_MASK),
107
                           KeyStroke.getKeyStroke(KeyEvent.VK_G, 0)
111
                           KeyStroke.getKeyStroke(KeyEvent.VK_G, 0)
108
                       },
112
                       },
109
                       JavaKit.makeGetterAction
113
                       JavaKit.makeGetterAction
110
                   ),
114
                   ),
111
                   new MultiKeyBinding(
115
                   new MultiKeyBinding(
112
                       new KeyStroke[] {
116
                       new KeyStroke[] {
113
                           KeyStroke.getKeyStroke(KeyEvent.VK_U, InputEvent.ALT_MASK),
117
                           KeyStroke.getKeyStroke(KeyEvent.VK_U, ALT_MASK),
114
                           KeyStroke.getKeyStroke(KeyEvent.VK_S, 0)
118
                           KeyStroke.getKeyStroke(KeyEvent.VK_S, 0)
115
                       },
119
                       },
116
                       JavaKit.makeSetterAction
120
                       JavaKit.makeSetterAction
117
                   ),
121
                   ),
118
                   new MultiKeyBinding(
122
                   new MultiKeyBinding(
119
                       new KeyStroke[] {
123
                       new KeyStroke[] {
120
                           KeyStroke.getKeyStroke(KeyEvent.VK_U, InputEvent.ALT_MASK),
124
                           KeyStroke.getKeyStroke(KeyEvent.VK_U, ALT_MASK),
121
                           KeyStroke.getKeyStroke(KeyEvent.VK_I, 0)
125
                           KeyStroke.getKeyStroke(KeyEvent.VK_I, 0)
122
                       },
126
                       },
123
                       JavaKit.makeIsAction
127
                       JavaKit.makeIsAction
124
                   ),
128
                   ),
125
                   new MultiKeyBinding(
129
                   new MultiKeyBinding(
126
                       KeyStroke.getKeyStroke(KeyEvent.VK_I,
130
                       KeyStroke.getKeyStroke(KeyEvent.VK_I,
127
                           InputEvent.ALT_MASK | InputEvent.SHIFT_MASK),
131
                           ALT_MASK | InputEvent.SHIFT_MASK),
128
                       JavaKit.fastImportAction
132
                       JavaKit.fastImportAction
129
                   ),
133
                   ),
130
                   new MultiKeyBinding(
134
                   new MultiKeyBinding(
Lines 134-149 Link Here
134
                   ),
138
                   ),
135
                   new MultiKeyBinding(
139
                   new MultiKeyBinding(
136
                       KeyStroke.getKeyStroke(KeyEvent.VK_F,
140
                       KeyStroke.getKeyStroke(KeyEvent.VK_F,
137
                           InputEvent.ALT_MASK | InputEvent.SHIFT_MASK),
141
                           ALT_MASK | InputEvent.SHIFT_MASK),
138
                       JavaKit.fixImportsAction
142
                       JavaKit.fixImportsAction
139
                   ),
143
                   ),
140
//                   new MultiKeyBinding(
144
//                   new MultiKeyBinding(
141
//                       KeyStroke.getKeyStroke(KeyEvent.VK_S,
145
//                       KeyStroke.getKeyStroke(KeyEvent.VK_S,
142
//                           InputEvent.ALT_MASK | mask),
146
//                           ALT_MASK | mask),
143
//                       JavaKit.tryCatchAction
147
//                       JavaKit.tryCatchAction
144
//                       ),
148
//                       ),
145
                   new MultiKeyBinding(
149
                   new MultiKeyBinding(
146
                       KeyStroke.getKeyStroke(KeyEvent.VK_G, InputEvent.ALT_MASK),
150
                       KeyStroke.getKeyStroke(KeyEvent.VK_G, ALT_MASK | (isMac ? InputEvent.SHIFT_MASK : 0)),
147
                       org.netbeans.editor.ext.ExtKit.gotoDeclarationAction
151
                       org.netbeans.editor.ext.ExtKit.gotoDeclarationAction
148
                   ),
152
                   ),
149
                   new MultiKeyBinding(
153
                   new MultiKeyBinding(
Lines 154-166 Link Here
154
                   
158
                   
155
                   new MultiKeyBinding(
159
                   new MultiKeyBinding(
156
                       KeyStroke.getKeyStroke(KeyEvent.VK_S,
160
                       KeyStroke.getKeyStroke(KeyEvent.VK_S,
157
                           InputEvent.SHIFT_MASK | InputEvent.ALT_MASK),
161
                           InputEvent.SHIFT_MASK | ALT_MASK),
158
                       JavaKit.selectNextElementAction
162
                       JavaKit.selectNextElementAction
159
                   ),
163
                   ),
160
                   
164
                   
161
                   new MultiKeyBinding(
165
                   new MultiKeyBinding(
162
                       KeyStroke.getKeyStroke(KeyEvent.VK_A,
166
                       KeyStroke.getKeyStroke(KeyEvent.VK_A,
163
                           InputEvent.SHIFT_MASK | InputEvent.ALT_MASK),
167
                           InputEvent.SHIFT_MASK | ALT_MASK),
164
                       JavaKit.selectPreviousElementAction
168
                       JavaKit.selectPreviousElementAction
165
                   )
169
                   )
166
                   
170
                   
(-)editor/src/org/netbeans/modules/editor/options/KeyBindingsMIMEOptionFile.java (-6 / +66 lines)
Lines 271-284 Link Here
271
     *
271
     *
272
     */
272
     */
273
    static String[] getPermutations (String name) {
273
    static String[] getPermutations (String name) {
274
        //IMPORTANT: THIS IS A COPY OF THE SAME CODE IN org.netbeans.core.ShortcutsFolder.
274
        //IMPORTANT: THERE IS A COPY OF THE SAME CODE IN 
275
        //org.netbeans.core.ShortcutsFolder (it has unit tests there)
275
        //ANY CHANGES MADE HERE SHOULD ALSO BE MADE THERE!
276
        //ANY CHANGES MADE HERE SHOULD ALSO BE MADE THERE!
276
        String key = KeyEvent.META_MASK == Toolkit.getDefaultToolkit().getMenuShortcutKeyMask() ?
277
        String key = KeyEvent.META_MASK == Toolkit.getDefaultToolkit().getMenuShortcutKeyMask() ?
277
            "M" : "C"; //NOI18N
278
            "M" : "C"; //NOI18N
278
            
279
        
280
        String ctrlWildcard = "D"; //NOI18N
281
        
282
        String altKey = System.getProperty ("mrj.version") != null ?
283
            "C" : "A"; //NOI18N
284
        
285
        String altWildcard = "O"; //NOI18N
286
        
287
        
279
        int pos = name.lastIndexOf ("-"); //NOI18N
288
        int pos = name.lastIndexOf ("-"); //NOI18N
280
        String keyPart = name.substring (pos);
289
        String keyPart = name.substring (pos);
281
        String modsPart = org.openide.util.Utilities.replaceString (name.substring (0, pos), "-", "");
290
        String modsPart = org.openide.util.Utilities.replaceString (name.substring (0, pos), "-", ""); //NOI18N
282
        if (modsPart.length() > 1) {
291
        if (modsPart.length() > 1) {
283
            Collection perms = new HashSet(modsPart.length() * modsPart.length());
292
            Collection perms = new HashSet(modsPart.length() * modsPart.length());
284
            int idx = name.indexOf(key);
293
            int idx = name.indexOf(key);
Lines 286-311 Link Here
286
                //First, try with the wildcard key.  Remove all hyphens - we'll
295
                //First, try with the wildcard key.  Remove all hyphens - we'll
287
                //put them back later
296
                //put them back later
288
                StringBuffer sb = new StringBuffer(modsPart);
297
                StringBuffer sb = new StringBuffer(modsPart);
289
                sb.replace(idx, idx+1, "D");
298
                sb.replace(idx, idx+1, ctrlWildcard);
290
                perms.add (sb.toString() + keyPart);
299
                perms.add (sb.toString() + keyPart);
291
                getAllPossibleOrderings (sb.toString(), keyPart, perms);
300
                getAllPossibleOrderings (sb.toString(), keyPart, perms);
292
                createHyphenatedPermutation(sb.toString().toCharArray(), perms, keyPart);
301
                createHyphenatedPermutation(sb.toString().toCharArray(), perms, keyPart);
302
                idx = name.indexOf (altKey);
303
                if (idx != -1) {
304
                    sb.replace (idx, idx+1, altWildcard);
305
                    perms.add (sb.toString() + keyPart);
306
                    getAllPossibleOrderings (sb.toString(), keyPart, perms);
307
                    createHyphenatedPermutation(sb.toString().toCharArray(), perms, keyPart);
308
                } else {
309
                    idx = name.indexOf(altWildcard);
310
                    if (idx != -1) {
311
                        sb.replace (idx, idx+1, altKey);
312
                        perms.add (sb.toString() + keyPart);
313
                        getAllPossibleOrderings (sb.toString(), keyPart, perms);
314
                        createHyphenatedPermutation(sb.toString().toCharArray(), perms, keyPart);
315
                    }
316
                }                
293
            } else {
317
            } else {
294
                idx = name.indexOf ("D"); //NOI18N
318
                idx = name.indexOf (ctrlWildcard); //NOI18N
295
                if (idx != -1) {
319
                if (idx != -1) {
296
                    StringBuffer sb = new StringBuffer(modsPart);
320
                    StringBuffer sb = new StringBuffer(modsPart);
297
                    sb.replace(idx, idx+1, key);
321
                    sb.replace(idx, idx+1, key);
298
                    perms.add (sb.toString() + keyPart);
322
                    perms.add (sb.toString() + keyPart);
299
                    getAllPossibleOrderings (sb.toString(), keyPart, perms);
323
                    getAllPossibleOrderings (sb.toString(), keyPart, perms);
300
                    createHyphenatedPermutation(sb.toString().toCharArray(), perms, keyPart);
324
                    createHyphenatedPermutation(sb.toString().toCharArray(), perms, keyPart);
325
                    idx = name.indexOf (altKey);
326
                    if (idx != -1) {
327
                        sb.replace (idx, idx+1, altWildcard);
328
                        perms.add (sb.toString() + keyPart);
329
                        getAllPossibleOrderings (sb.toString(), keyPart, perms);
330
                    } else {
331
                        idx = name.indexOf(altWildcard);
332
                        if (idx != -1) {
333
                            sb.replace (idx, idx+1, altKey);
334
                            perms.add (sb.toString() + keyPart);
335
                            getAllPossibleOrderings (sb.toString(), keyPart, perms);
336
                            createHyphenatedPermutation(sb.toString().toCharArray(), perms, keyPart);
337
                        }
338
                    }                    
339
                }
340
            }
341
            
342
            idx = name.indexOf (altKey);
343
            if (idx != -1) {
344
                StringBuffer sb = new StringBuffer(modsPart);
345
                sb.replace (idx, idx+1, altWildcard);
346
                perms.add (sb.toString() + keyPart);
347
                getAllPossibleOrderings (sb.toString(), keyPart, perms);
348
                createHyphenatedPermutation(sb.toString().toCharArray(), perms, keyPart);
349
            } else {
350
                StringBuffer sb = new StringBuffer(modsPart);
351
                idx = name.indexOf(altWildcard);
352
                if (idx != -1) {
353
                    sb.replace (idx, idx+1, altKey);
354
                    perms.add (sb.toString() + keyPart);
355
                    getAllPossibleOrderings (sb.toString(), keyPart, perms);
356
                    createHyphenatedPermutation(sb.toString().toCharArray(), perms, keyPart);
301
                }
357
                }
302
            }
358
            }
359
            
303
            getAllPossibleOrderings (modsPart, keyPart, perms);
360
            getAllPossibleOrderings (modsPart, keyPart, perms);
304
            createHyphenatedPermutation(modsPart.toCharArray(), perms, keyPart);
361
            createHyphenatedPermutation(modsPart.toCharArray(), perms, keyPart);
305
            return (String[]) perms.toArray(new String[perms.size()]);
362
            return (String[]) perms.toArray(new String[perms.size()]);
306
        } else {
363
        } else {
307
            return key.equals (modsPart) ?
364
            return key.equals (modsPart) ?
308
                new String[] {"D" + keyPart} : new String[0];
365
                new String[] {ctrlWildcard + keyPart} : altKey.equals(modsPart) ?
366
                    new String[]{altWildcard + keyPart} : altWildcard.equals(modsPart) ? 
367
                    new String[] {altKey + keyPart} : 
368
                    new String[0];
309
        }
369
        }
310
    }
370
    }
311
    
371
    
(-)editor/src/org/netbeans/modules/editor/resources/layer.xml (-1 / +1 lines)
Lines 93-99 Link Here
93
    </folder>
93
    </folder>
94
94
95
    <folder name="Shortcuts">
95
    <folder name="Shortcuts">
96
        <file name="AS-O.shadow">
96
        <file name="OS-O.shadow">
97
	    <attr name="originalFile" stringvalue="Actions/Edit/org-netbeans-modules-editor-java-JavaFastOpenAction.instance"/>
97
	    <attr name="originalFile" stringvalue="Actions/Edit/org-netbeans-modules-editor-java-JavaFastOpenAction.instance"/>
98
        </file>
98
        </file>
99
    </folder>
99
    </folder>
(-)editor/src/org/netbeans/modules/editor/resources/XMLs/DefaultGlobalKeyBindings.xml (-18 / +15 lines)
Lines 12-24 Link Here
12
    <bind actionName="undo" key="UNDO"/>
12
    <bind actionName="undo" key="UNDO"/>
13
    <bind actionName="paste-from-clipboard" key="PASTE"/>
13
    <bind actionName="paste-from-clipboard" key="PASTE"/>
14
    <bind actionName="cut-to-clipboard" key="CUT"/>
14
    <bind actionName="cut-to-clipboard" key="CUT"/>
15
    <bind actionName="adjust-window-center" key="A-U$M"/>
15
    <bind actionName="adjust-window-center" key="O-U$M"/>
16
    <bind actionName="to-lower-case" key="A-U$L"/>
16
    <bind actionName="to-lower-case" key="O-U$L"/>
17
    <bind actionName="caret-backward" key="LEFT"/>
17
    <bind actionName="caret-backward" key="LEFT"/>
18
    <bind actionName="selection-page-up" key="S-PAGE_UP"/>
18
    <bind actionName="selection-page-up" key="S-PAGE_UP"/>
19
    <bind actionName="caret-end-word" key="A-U$E"/>
19
    <bind actionName="caret-end-word" key="O-U$E"/>
20
    <bind actionName="caret-previous-word" key="C-LEFT"/>
20
    <bind actionName="caret-previous-word" key="C-LEFT"/>
21
    <bind actionName="adjust-window-bottom" key="A-U$B"/>
21
    <bind actionName="adjust-window-bottom" key="O-U$B"/>
22
    <bind actionName="caret-forward" key="RIGHT"/>
22
    <bind actionName="caret-forward" key="RIGHT"/>
23
    <bind actionName="selection-begin" key="DS-HOME"/>
23
    <bind actionName="selection-begin" key="DS-HOME"/>
24
    <bind actionName="undo" key="D-Z"/>
24
    <bind actionName="undo" key="D-Z"/>
Lines 42-64 Link Here
42
    <bind actionName="shift-line-left" key="D-D"/>
42
    <bind actionName="shift-line-left" key="D-D"/>
43
    <bind actionName="copy-to-clipboard" key="D-C"/>
43
    <bind actionName="copy-to-clipboard" key="D-C"/>
44
    <bind actionName="select-all" key="D-A"/>
44
    <bind actionName="select-all" key="D-A"/>
45
    <bind actionName="jump-list-next" key="A-L"/>
45
    <bind actionName="jump-list-next" key="O-L"/>
46
    <bind actionName="copy-to-clipboard" key="D-INSERT"/>
46
    <bind actionName="copy-to-clipboard" key="D-INSERT"/>
47
    <bind actionName="jump-list-prev" key="A-K"/>
47
    <bind actionName="jump-list-prev" key="O-K"/>
48
    <bind actionName="select-identifier" key="A-J"/>
48
    <bind actionName="select-identifier" key="O-J"/>
49
    <bind actionName="delete-previous" key="BACK_SPACE"/>
49
    <bind actionName="delete-previous" key="BACK_SPACE"/>
50
    <bind actionName="selection-page-down" key="S-PAGE_DOWN"/>
50
    <bind actionName="selection-page-down" key="S-PAGE_DOWN"/>
51
    <bind actionName="selection-end-line" key="S-END"/>
51
    <bind actionName="selection-end-line" key="S-END"/>
52
    <bind actionName="adjust-caret-top" key="AS-T"/>
52
    <bind actionName="adjust-caret-top" key="OS-T"/>
53
    <bind actionName="caret-end" key="D-END"/>
53
    <bind actionName="caret-end" key="D-END"/>
54
    <bind actionName="find-next" key="F3"/>
54
    <bind actionName="find-next" key="F3"/>
55
    <bind actionName="bookmark-next" key="F2"/>
55
    <bind actionName="bookmark-next" key="F2"/>
56
    <bind actionName="adjust-caret-center" key="AS-M"/>
56
    <bind actionName="adjust-caret-center" key="OS-M"/>
57
    <bind actionName="selection-forward" key="S-RIGHT"/>
57
    <bind actionName="selection-forward" key="S-RIGHT"/>
58
    <bind actionName="jump-list-next-component" key="AS-L"/>
58
    <bind actionName="jump-list-next-component" key="OS-L"/>
59
    <bind actionName="jump-list-prev-component" key="AS-K"/>
59
    <bind actionName="jump-list-prev-component" key="OS-K"/>
60
    <bind actionName="toggle-highlight-search" key="AS-H"/>
60
    <bind actionName="toggle-highlight-search" key="OS-H"/>
61
    <bind actionName="adjust-caret-bottom" key="AS-B"/>
61
    <bind actionName="adjust-caret-bottom" key="OS-B"/>
62
    <bind actionName="abbrev-reset" key="S-SPACE"/>
62
    <bind actionName="abbrev-reset" key="S-SPACE"/>
63
    <bind actionName="selection-backward" key="S-LEFT"/>
63
    <bind actionName="selection-backward" key="S-LEFT"/>
64
    <bind actionName="insert-tab" key="TAB"/>
64
    <bind actionName="insert-tab" key="TAB"/>
Lines 87-95 Link Here
87
    <bind actionName="selection-end" key="DS-END"/>
87
    <bind actionName="selection-end" key="DS-END"/>
88
    <bind actionName="toggle-typing-mode" key="INSERT"/>
88
    <bind actionName="toggle-typing-mode" key="INSERT"/>
89
    <bind actionName="caret-down" key="KP_DOWN"/>
89
    <bind actionName="caret-down" key="KP_DOWN"/>
90
    <bind actionName="to-upper-case" key="A-U$U"/>
90
    <bind actionName="to-upper-case" key="O-U$U"/>
91
    <bind actionName="adjust-window-top" key="A-U$T"/>
91
    <bind actionName="adjust-window-top" key="A-U$T"/>
92
    <bind actionName="switch-case" key="A-U$R"/>
92
    <bind actionName="switch-case" key="O-U$R"/>
93
    <bind actionName="selection-begin-line" key="S-HOME"/>
93
    <bind actionName="selection-begin-line" key="S-HOME"/>
94
    <bind actionName="remove-tab" key="S-TAB"/>
94
    <bind actionName="remove-tab" key="S-TAB"/>
95
    <bind actionName="completion-show" key="C-SPACE"/>
95
    <bind actionName="completion-show" key="C-SPACE"/>
Lines 97-105 Link Here
97
    <bind actionName="escape" key="ESCAPE"/>
97
    <bind actionName="escape" key="ESCAPE"/>
98
    <bind actionName="find" key="D-F"/>
98
    <bind actionName="find" key="D-F"/>
99
    <bind actionName="goto" key="C-G"/>
99
    <bind actionName="goto" key="C-G"/>
100
    <!-- Mac binding for when Ctrl & Alt swapped - we suppress C-G so Alt-G
101
      will produce a valid character -->
102
    <bind actionName="goto" key="AS-G"/>
103
    <bind actionName="match-brace" key="D-OPEN_BRACKET"/>
100
    <bind actionName="match-brace" key="D-OPEN_BRACKET"/>
104
    <bind actionName="replace" key="C-H"/>
101
    <bind actionName="replace" key="C-H"/>
105
    <bind actionName="selection-match-brace" key="DS-B"/>
102
    <bind actionName="selection-match-brace" key="DS-B"/>
(-)editor/src/org/netbeans/modules/editor/resources/XMLs/DefaultKeyBindings.xml (-10 / +10 lines)
Lines 6-24 Link Here
6
     this file, with minor diffs, in ide/applemenu.  Any changes made here should
6
     this file, with minor diffs, in ide/applemenu.  Any changes made here should
7
     be made there too -->                            
7
     be made there too -->                            
8
<bindings>
8
<bindings>
9
    <bind actionName="goto-source" key="A-O"/>
9
    <bind actionName="goto-source" key="O-O"/>
10
    <bind actionName="fast-import" key="AS-I"/>
10
    <bind actionName="fast-import" key="OS-I"/>
11
    <bind actionName="fix-imports" key="AS-F"/>
11
    <bind actionName="fix-imports" key="OS-F"/>
12
12
13
    <bind actionName="goto-super-implementation" key="D-B"/>
13
    <bind actionName="goto-super-implementation" key="D-B"/>
14
    <bind actionName="goto-declaration" key="A-G"/>    
14
    <bind actionName="goto-declaration" key="O-G"/>    
15
    <bind actionName="comment" key="DS-T"/>
15
    <bind actionName="comment" key="DS-T"/>
16
    <bind actionName="goto-help" key="A-F1"/>
16
    <bind actionName="goto-help" key="O-F1"/>
17
    <bind actionName="make-is" key="A-U$I"/>
17
    <bind actionName="make-is" key="O-U$I"/>
18
    <bind actionName="make-getter" key="A-U$G"/>
18
    <bind actionName="make-getter" key="O-U$G"/>
19
    <bind actionName="macro-debug-var" key="D-J$D"/>
19
    <bind actionName="macro-debug-var" key="D-J$D"/>
20
    <bind actionName="uncomment" key="DS-D"/>
20
    <bind actionName="uncomment" key="DS-D"/>
21
    <bind actionName="make-setter" key="A-U$S"/>
21
    <bind actionName="make-setter" key="O-U$S"/>
22
    <bind actionName="select-element-next" key="AS-S"/>
22
    <bind actionName="select-element-next" key="OS-S"/>
23
    <bind actionName="select-element-previous" key="AS-A"/>
23
    <bind actionName="select-element-previous" key="OS-A"/>
24
</bindings>
24
</bindings>
(-)form/src/org/netbeans/modules/form/resources/layer.xml (-1 / +3 lines)
Lines 460-466 Link Here
460
    </folder>
460
    </folder>
461
461
462
    <folder name="Shortcuts">
462
    <folder name="Shortcuts">
463
        <file name="D-R.instance">
463
        <!-- Bind explicitly to Ctrl-R, not D-R for Command on mac - Command-R
464
             is already bound to Replace -->
465
        <file name="C-R.instance">
464
            <attr name="instanceClass" stringvalue="org.netbeans.modules.form.actions.ReloadAction"/>
466
            <attr name="instanceClass" stringvalue="org.netbeans.modules.form.actions.ReloadAction"/>
465
        </file>
467
        </file>
466
        
468
        
(-)ide/applemenu/src/org/netbeans/modules/applemenu/Bundle.properties (-3 lines)
Lines 18-23 Link Here
18
    and moves some standard menu items there - Tools | Options becomes \
18
    and moves some standard menu items there - Tools | Options becomes \
19
    Preferences, Help | About becomes about, File | Exit becomes Quit.
19
    Preferences, Help | About becomes about, File | Exit becomes Quit.
20
20
21
LBL_SwapCtrlAlt=Swap Ctrl and Alt
22
MSG_Swapped=Ctrl and Alt swapped
23
MSG_NotSwapped=Ctrl and Alt swapping off
(-)ide/applemenu/src/org/netbeans/modules/applemenu/DefaultGlobalKeyBindings.xml (-17 / +17 lines)
Lines 34-46 Link Here
34
    <bind actionName="undo" key="UNDO"/>
34
    <bind actionName="undo" key="UNDO"/>
35
    <bind actionName="paste-from-clipboard" key="PASTE"/>
35
    <bind actionName="paste-from-clipboard" key="PASTE"/>
36
    <bind actionName="cut-to-clipboard" key="CUT"/>
36
    <bind actionName="cut-to-clipboard" key="CUT"/>
37
    <bind actionName="adjust-window-center" key="A-U$M"/>
37
    <bind actionName="adjust-window-center" key="O-U$M"/>
38
    <bind actionName="to-lower-case" key="A-U$L"/>
38
    <bind actionName="to-lower-case" key="O-U$L"/>
39
    <bind actionName="caret-backward" key="LEFT"/>
39
    <bind actionName="caret-backward" key="LEFT"/>
40
    <bind actionName="selection-page-up" key="S-PAGE_UP"/>
40
    <bind actionName="selection-page-up" key="S-PAGE_UP"/>
41
    <bind actionName="caret-end-word" key="A-U$E"/>
41
    <bind actionName="caret-end-word" key="O-U$E"/>
42
<!--    <bind actionName="caret-previous-word" key="S-LEFT"/> -->
42
<!--    <bind actionName="caret-previous-word" key="S-LEFT"/> -->
43
    <bind actionName="adjust-window-bottom" key="A-U$B"/>
43
    <bind actionName="adjust-window-bottom" key="O-U$B"/>
44
    <bind actionName="caret-forward" key="RIGHT"/>
44
    <bind actionName="caret-forward" key="RIGHT"/>
45
    <bind actionName="selection-begin" key="DS-HOME"/>
45
    <bind actionName="selection-begin" key="DS-HOME"/>
46
    <bind actionName="undo" key="D-Z"/>
46
    <bind actionName="undo" key="D-Z"/>
Lines 64-86 Link Here
64
    <bind actionName="shift-line-left" key="D-D"/>
64
    <bind actionName="shift-line-left" key="D-D"/>
65
    <bind actionName="copy-to-clipboard" key="D-C"/>
65
    <bind actionName="copy-to-clipboard" key="D-C"/>
66
    <bind actionName="select-all" key="D-A"/>
66
    <bind actionName="select-all" key="D-A"/>
67
    <bind actionName="jump-list-next" key="A-L"/>
67
    <bind actionName="jump-list-next" key="O-L"/>
68
    <bind actionName="copy-to-clipboard" key="D-INSERT"/>
68
    <bind actionName="copy-to-clipboard" key="D-INSERT"/>
69
    <bind actionName="jump-list-prev" key="A-K"/>
69
    <bind actionName="jump-list-prev" key="O-K"/>
70
    <bind actionName="select-identifier" key="A-J"/>
70
    <bind actionName="select-identifier" key="O-J"/>
71
    <bind actionName="delete-previous" key="BACK_SPACE"/>
71
    <bind actionName="delete-previous" key="BACK_SPACE"/>
72
    <bind actionName="selection-page-down" key="S-PAGE_DOWN"/>
72
    <bind actionName="selection-page-down" key="S-PAGE_DOWN"/>
73
    <bind actionName="selection-end-line" key="S-END"/>
73
    <bind actionName="selection-end-line" key="S-END"/>
74
    <bind actionName="adjust-caret-top" key="AS-T"/>
74
    <bind actionName="adjust-caret-top" key="OS-T"/>
75
    <bind actionName="caret-end" key="D-END"/>
75
    <bind actionName="caret-end" key="D-END"/>
76
<!--    <bind actionName="find-next" key="F3"/> -->
76
<!--    <bind actionName="find-next" key="F3"/> -->
77
    <bind actionName="bookmark-next" key="F2"/>
77
    <bind actionName="bookmark-next" key="F2"/>
78
    <bind actionName="adjust-caret-center" key="AS-M"/>
78
    <bind actionName="adjust-caret-center" key="OS-M"/>
79
    <bind actionName="selection-forward" key="S-RIGHT"/>
79
    <bind actionName="selection-forward" key="S-RIGHT"/>
80
    <bind actionName="jump-list-next-component" key="AS-L"/>
80
    <bind actionName="jump-list-next-component" key="OS-L"/>
81
    <bind actionName="jump-list-prev-component" key="AS-K"/>
81
    <bind actionName="jump-list-prev-component" key="OS-K"/>
82
    <bind actionName="toggle-highlight-search" key="AS-H"/>
82
    <bind actionName="toggle-highlight-search" key="OS-H"/>
83
    <bind actionName="adjust-caret-bottom" key="AS-B"/>
83
    <bind actionName="adjust-caret-bottom" key="OS-B"/>
84
    <bind actionName="abbrev-reset" key="S-SPACE"/>
84
    <bind actionName="abbrev-reset" key="S-SPACE"/>
85
    <bind actionName="selection-backward" key="S-LEFT"/>
85
    <bind actionName="selection-backward" key="S-LEFT"/>
86
    <bind actionName="insert-tab" key="TAB"/>
86
    <bind actionName="insert-tab" key="TAB"/>
Lines 109-117 Link Here
109
    <bind actionName="selection-end" key="DS-END"/>
109
    <bind actionName="selection-end" key="DS-END"/>
110
    <bind actionName="toggle-typing-mode" key="INSERT"/>
110
    <bind actionName="toggle-typing-mode" key="INSERT"/>
111
    <bind actionName="caret-down" key="KP_DOWN"/>
111
    <bind actionName="caret-down" key="KP_DOWN"/>
112
    <bind actionName="to-upper-case" key="A-U$U"/>
112
    <bind actionName="to-upper-case" key="O-U$U"/>
113
    <bind actionName="adjust-window-top" key="A-U$T"/>
113
    <bind actionName="adjust-window-top" key="O-U$T"/>
114
    <bind actionName="switch-case" key="A-U$R"/>
114
    <bind actionName="switch-case" key="O-U$R"/>
115
    <bind actionName="selection-begin-line" key="S-HOME"/>
115
    <bind actionName="selection-begin-line" key="S-HOME"/>
116
    <bind actionName="remove-tab" key="S-TAB"/>
116
    <bind actionName="remove-tab" key="S-TAB"/>
117
    <bind actionName="completion-show" key="C-SPACE"/>
117
    <bind actionName="completion-show" key="C-SPACE"/>
Lines 120-126 Link Here
120
    <bind actionName="find" key="D-F"/>
120
    <bind actionName="find" key="D-F"/>
121
    <bind actionName="goto" key="C-G"/>
121
    <bind actionName="goto" key="C-G"/>
122
    <bind actionName="match-brace" key="D-OPEN_BRACKET"/>
122
    <bind actionName="match-brace" key="D-OPEN_BRACKET"/>
123
    <bind actionName="replace" key="D-R"/>
123
    <bind actionName="replace" key="C-H"/>
124
    <bind actionName="selection-match-brace" key="DS-B"/>
124
    <bind actionName="selection-match-brace" key="DS-B"/>
125
    <bind actionName="shift-insert-break" key="S-ENTER"/>
125
    <bind actionName="shift-insert-break" key="S-ENTER"/>
126
    <bind actionName="show-popup-menu" key="S-F10"/>
126
    <bind actionName="show-popup-menu" key="S-F10"/>
(-)ide/applemenu/src/org/netbeans/modules/applemenu/layer.xml (-9 / +7 lines)
Lines 34-44 Link Here
34
            <file name="org-netbeans-core-actions-AboutAction.instance_hidden"/>
34
            <file name="org-netbeans-core-actions-AboutAction.instance_hidden"/>
35
        </folder>
35
        </folder>
36
        
36
        
37
-->
37
-->        
38
        <folder name="Tools">
39
            <file name="org-netbeans-modules-applemenu-SwapCtrlAltAction.instance"/>
40
        </folder>
41
42
    </folder>
38
    </folder>
43
    
39
    
44
    <folder name="Shortcuts">
40
    <folder name="Shortcuts">
Lines 64-77 Link Here
64
        <file name="M-R.instance">
60
        <file name="M-R.instance">
65
	    <attr name="instanceClass" stringvalue="org.openide.actions.ReplaceAction"/>
61
	    <attr name="instanceClass" stringvalue="org.openide.actions.ReplaceAction"/>
66
        </file>
62
        </file>
63
        
64
        <file name="C-H.shadow_hidden"/>
67
65
68
        <file name="D-BACK_QUOTE.shadow_hidden"/>
66
        <file name="D-BACK_QUOTE.shadow_hidden"/>
69
        
67
        
70
        <file name="C-H.shadow_hidden"/>
68
        <file name="OS-G.instance">
69
	    <attr name="instanceClass" stringvalue="org.openide.actions.GotoAction"/>
70
	</file>
71
        
71
        
72
        <file name="MS-BACK_SLASH.instance">
73
            <attr name="instanceClass" stringvalue="org.netbeans.modules.applemenu.SwapCtrlAltAction"/>
74
        </file>
75
    </folder>
72
    </folder>
76
73
77
    <folder name="Editors">
74
    <folder name="Editors">
Lines 79-84 Link Here
79
            <folder name="base">
76
            <folder name="base">
80
                <folder name="Defaults">
77
                <folder name="Defaults">
81
                    <file name="keybindings.xml" url="DefaultGlobalKeyBindings.xml"/>
78
                    <file name="keybindings.xml" url="DefaultGlobalKeyBindings.xml"/>
79
                    <file name="keybindings.xml" url="DefaultKeyBindings.xml"/> 
82
                </folder>
80
                </folder>
83
            </folder>
81
            </folder>
84
        </folder>
82
        </folder>
(-)junit/src/org/netbeans/modules/junit/resources/layer.xml (-2 / +2 lines)
Lines 80-89 Link Here
80
80
81
    <!-- shortcuts -->
81
    <!-- shortcuts -->
82
    <folder name="Shortcuts">
82
    <folder name="Shortcuts">
83
        <file name="DA-J.instance">
83
        <file name="DO-J.instance">
84
	    <attr name="instanceClass" stringvalue="org.netbeans.modules.junit.CreateTestAction"/>
84
	    <attr name="instanceClass" stringvalue="org.netbeans.modules.junit.CreateTestAction"/>
85
	</file>
85
	</file>
86
        <file name="DA-K.instance">
86
        <file name="DO-K.instance">
87
	    <attr name="instanceClass" stringvalue="org.netbeans.modules.junit.OpenTestAction"/>
87
	    <attr name="instanceClass" stringvalue="org.netbeans.modules.junit.OpenTestAction"/>
88
	</file>
88
	</file>
89
    </folder>
89
    </folder>
(-)openide/loaders/src/org/openide/awt/MenuBar.java (-1 / +107 lines)
Lines 16-24 Link Here
16
import java.awt.Component;
16
import java.awt.Component;
17
import java.awt.EventQueue;
17
import java.awt.EventQueue;
18
import java.awt.event.*;
18
import java.awt.event.*;
19
import java.awt.event.KeyEvent;
19
import java.io.*;
20
import java.io.*;
20
import java.util.*;
21
import java.util.*;
21
import javax.swing.*;
22
import javax.swing.*;
23
import javax.swing.KeyStroke;
22
24
23
import org.openide.ErrorManager;
25
import org.openide.ErrorManager;
24
import org.openide.loaders.*;
26
import org.openide.loaders.*;
Lines 26-31 Link Here
26
import org.openide.filesystems.FileObject;
28
import org.openide.filesystems.FileObject;
27
import org.openide.filesystems.Repository;
29
import org.openide.filesystems.Repository;
28
import org.openide.nodes.*;
30
import org.openide.nodes.*;
31
import org.openide.util.Utilities;
29
import org.openide.util.actions.Presenter;
32
import org.openide.util.actions.Presenter;
30
import org.openide.util.*;
33
import org.openide.util.*;
31
34
Lines 73-79 Link Here
73
     * If the parameter is null, default menu folder is obtained.
76
     * If the parameter is null, default menu folder is obtained.
74
     */
77
     */
75
    public MenuBar(DataFolder folder) {
78
    public MenuBar(DataFolder folder) {
76
        super();
79
        this();
77
        setBorder (javax.swing.BorderFactory.createEmptyBorder());
80
        setBorder (javax.swing.BorderFactory.createEmptyBorder());
78
        DataFolder theFolder = folder;
81
        DataFolder theFolder = folder;
79
        if (theFolder == null) {
82
        if (theFolder == null) {
Lines 100-105 Link Here
100
        }
103
        }
101
        super.addImpl (c, constraint, idx);
104
        super.addImpl (c, constraint, idx);
102
    }
105
    }
106
    
107
    /**
108
     * Overridden to handle mac conversion from Alt to Ctrl and vice versa so
109
     * Alt can be used as the compose character on international keyboards.
110
     */
111
    protected boolean processKeyBinding(KeyStroke ks,
112
                                    KeyEvent e,
113
                                    int condition,
114
                                    boolean pressed) {
115
        if (Utilities.getOperatingSystem() == Utilities.OS_MAC) {
116
            int mods = e.getModifiers();
117
            boolean isCtrl = (mods & KeyEvent.CTRL_MASK) != 0;
118
            boolean isAlt = (mods & KeyEvent.ALT_MASK) != 0;
119
            if (isAlt) {
120
                return false;
121
            }
122
            if (isAlt && !isCtrl) {
123
                mods = mods & ~ KeyEvent.ALT_MASK;
124
                mods = mods & ~ KeyEvent.ALT_DOWN_MASK;
125
                mods |= KeyEvent.CTRL_MASK;
126
                mods |= KeyEvent.CTRL_DOWN_MASK;
127
            } else if (!isAlt && isCtrl) {
128
                mods = mods & ~ KeyEvent.CTRL_MASK;
129
                mods = mods & ~ KeyEvent.CTRL_DOWN_MASK;
130
                mods |= KeyEvent.ALT_MASK;
131
                mods |= KeyEvent.ALT_DOWN_MASK;
132
            } else if (!isAlt && !isCtrl) {
133
                return super.processKeyBinding (ks, e, condition, pressed);
134
            }
135
            
136
            KeyEvent newEvent = new MarkedKeyEvent ((Component) e.getSource(), e.getID(), 
137
                e.getWhen(), mods, e.getKeyCode(), e.getKeyChar(), 
138
                e.getKeyLocation());
139
            
140
            KeyStroke newStroke = e.getID() == KeyEvent.KEY_TYPED ?
141
                KeyStroke.getKeyStroke (ks.getKeyChar(), mods) :
142
                KeyStroke.getKeyStroke (ks.getKeyCode(), mods, 
143
                !ks.isOnKeyRelease());
144
            
145
            boolean result = super.processKeyBinding (newStroke, newEvent, 
146
                condition, pressed);
147
            
148
            if (newEvent.isConsumed()) {
149
                e.consume();
150
            }
151
            return result;
152
        } else {
153
            return super.processKeyBinding (ks, e, condition, pressed);
154
        }                     
155
    }    
103
156
104
    /** Blocks until the menubar is completely created. */
157
    /** Blocks until the menubar is completely created. */
105
    public void waitFinished () {
158
    public void waitFinished () {
Lines 295-300 Link Here
295
        }
348
        }
296
349
297
    }
350
    }
351
    
352
    /**
353
     * A marker class to allow different processing of remapped key events
354
     * on mac - allows them to be recognized by LazyMenu. 
355
     */
356
    private static final class MarkedKeyEvent extends KeyEvent {
357
        public MarkedKeyEvent (Component c, int id, 
358
                    long when, int mods, int code, char kchar, 
359
                    int loc) {
360
            super(c, id, when, mods, code, kchar, loc);
361
        }
362
    }
298
363
299
    /** Menu based on the folder content whith lazy items creation. */
364
    /** Menu based on the folder content whith lazy items creation. */
300
    private static class LazyMenu extends JMenuPlus implements NodeListener, Runnable {
365
    private static class LazyMenu extends JMenuPlus implements NodeListener, Runnable {
Lines 313-318 Link Here
313
	    updateProps();
378
	    updateProps();
314
379
315
        }
380
        }
381
        
382
        protected boolean processKeyBinding(KeyStroke ks,
383
                                        KeyEvent e,
384
                                        int condition,
385
                                        boolean pressed) {
386
            if (Utilities.getOperatingSystem() == Utilities.OS_MAC) {
387
                int mods = e.getModifiers();
388
                boolean isCtrl = (mods & KeyEvent.CTRL_MASK) != 0;
389
                boolean isAlt = (mods & KeyEvent.ALT_MASK) != 0;
390
                if (isAlt && (e instanceof MarkedKeyEvent)) {
391
                    mods = mods & ~ KeyEvent.CTRL_MASK;
392
                    mods = mods & ~ KeyEvent.CTRL_DOWN_MASK;
393
                    mods |= KeyEvent.ALT_MASK;
394
                    mods |= KeyEvent.ALT_DOWN_MASK;
395
                    
396
                    KeyEvent newEvent = new MarkedKeyEvent (
397
                        (Component) e.getSource(), e.getID(), 
398
                        e.getWhen(), mods, e.getKeyCode(), e.getKeyChar(), 
399
                        e.getKeyLocation());
400
                    
401
                    KeyStroke newStroke = e.getID() == KeyEvent.KEY_TYPED ?
402
                        KeyStroke.getKeyStroke (ks.getKeyChar(), mods) :
403
                        KeyStroke.getKeyStroke (ks.getKeyCode(), mods, 
404
                        !ks.isOnKeyRelease());
405
                    
406
                    boolean result = super.processKeyBinding (newStroke, 
407
                        newEvent, condition, pressed);
408
                    
409
                    if (newEvent.isConsumed()) {
410
                        e.consume();
411
                    }
412
                    return result;
413
                } else if (!isAlt) {
414
                    return super.processKeyBinding (ks, e, condition, pressed);
415
                } else {
416
                    return false;
417
                }
418
            } else {
419
                return super.processKeyBinding (ks, e, condition, pressed);
420
            }                     
421
        }            
316
422
317
	private void updateProps() {
423
	private void updateProps() {
318
            // set the text and be aware of mnemonics
424
            // set the text and be aware of mnemonics
(-)openide/src/org/openide/util/Utilities.java (-6 / +41 lines)
Lines 1218-1223 Link Here
1218
    * <LI> <code>S</code> stands for the Shift key
1218
    * <LI> <code>S</code> stands for the Shift key
1219
    * <LI> <code>M</code> stands for the Meta key
1219
    * <LI> <code>M</code> stands for the Meta key
1220
    * </UL>
1220
    * </UL>
1221
    * The format also supports two wildcard codes, to support differences in
1222
    * platforms.  These are the preferred choices for registering keystrokes,
1223
    * since platform conflicts will automatically be handled:
1224
    * <UL>
1225
    * <LI> <code>D</code> stands for the default menu accelerator - the Control
1226
    *  key on most platforms, the Command (meta) key on Macintosh</LI>
1227
    * <LI> <code>O</code> stands for the alternate accelerator - the Alt key on
1228
    *  most platforms, the Ctrl key on Macintosh (Macintosh uses Alt as a 
1229
    *  secondary shift key for composing international characters - if you bind
1230
    *  Alt-8 to an action, a mac user with a French keyboard will not be able
1231
    *  to type the <code>[</code> character, which is a significant handicap</LI>
1232
    * </UL>
1233
    * If you use the wildcard characters, and specify a key which will conflict
1234
    * with keys the operating system consumes, it will be mapped to whichever
1235
    * choice can work - for example, on Macintosh, Command-Q is always consumed
1236
    * by the operating system, so <code>D-Q</code> will always map to Control-Q.
1237
    * <p> 
1221
    * Every modifier before the hyphen must be pressed.
1238
    * Every modifier before the hyphen must be pressed.
1222
    * <em>identifier</EM> can be any text constant from {@link KeyEvent} but
1239
    * <em>identifier</EM> can be any text constant from {@link KeyEvent} but
1223
    * without the leading <code>VK_</code> characters. So {@link KeyEvent#VK_ENTER} is described as
1240
    * without the leading <code>VK_</code> characters. So {@link KeyEvent#VK_ENTER} is described as
Lines 1252-1261 Link Here
1252
                } else {
1269
                } else {
1253
                    // last text must be the key code
1270
                    // last text must be the key code
1254
                    Integer i = (Integer)names.get (el);
1271
                    Integer i = (Integer)names.get (el);
1255
                    boolean wildcard = (needed & WILDCARD_MASK) != 0;
1272
                    boolean wildcard = (needed & CTRL_WILDCARD_MASK) != 0;
1256
                    //Strip out the explicit mask - KeyStroke won't know
1273
                    //Strip out the explicit mask - KeyStroke won't know
1257
                    //what to do with it
1274
                    //what to do with it
1258
                    needed = needed & ~WILDCARD_MASK;
1275
                    needed = needed & ~CTRL_WILDCARD_MASK;
1276
                    
1277
                    boolean macAlt = (needed & ALT_WILDCARD_MASK) != 0;
1278
                    needed = needed & ~ALT_WILDCARD_MASK;
1259
                    
1279
                    
1260
                    if (i != null) {
1280
                    if (i != null) {
1261
                        //#26854 - Default accelerator should be Command on mac
1281
                        //#26854 - Default accelerator should be Command on mac
Lines 1268-1273 Link Here
1268
                                }
1288
                                }
1269
                            }
1289
                            }
1270
                        }
1290
                        }
1291
                        if (macAlt) {
1292
                            if (getOperatingSystem() == OS_MAC) {
1293
                                needed |= KeyEvent.CTRL_MASK;
1294
                            } else {
1295
                                needed |= KeyEvent.ALT_MASK;
1296
                            }
1297
                        }
1271
                        return KeyStroke.getKeyStroke (i.intValue (), needed);
1298
                        return KeyStroke.getKeyStroke (i.intValue (), needed);
1272
                    } else {
1299
                    } else {
1273
                        return null;
1300
                        return null;
Lines 1322-1328 Link Here
1322
        return (KeyStroke[])arr.toArray (new KeyStroke[arr.size ()]);
1349
        return (KeyStroke[])arr.toArray (new KeyStroke[arr.size ()]);
1323
    }
1350
    }
1324
1351
1325
    private static final int WILDCARD_MASK = 32768;
1352
    private static final int CTRL_WILDCARD_MASK = 32768;
1353
    private static final int ALT_WILDCARD_MASK = CTRL_WILDCARD_MASK * 2;
1326
1354
1327
    /** Adds characters for modifiers to the buffer.
1355
    /** Adds characters for modifiers to the buffer.
1328
    * @param buf buffer to add to
1356
    * @param buf buffer to add to
Lines 1348-1357 Link Here
1348
            buf.append("M"); // NOI18N
1376
            buf.append("M"); // NOI18N
1349
            b = true;
1377
            b = true;
1350
        }
1378
        }
1351
        if ((modif & WILDCARD_MASK) != 0) {
1379
        if ((modif & CTRL_WILDCARD_MASK) != 0) {
1352
            buf.append("D");
1380
            buf.append("D");
1353
            b = true;
1381
            b = true;
1354
        }
1382
        }
1383
        if ((modif & ALT_WILDCARD_MASK) != 0) {
1384
            buf.append("O");
1385
            b = true;
1386
        }
1355
1387
1356
        return b;
1388
        return b;
1357
    }
1389
    }
Lines 1378-1387 Link Here
1378
                m |= KeyEvent.SHIFT_MASK;
1410
                m |= KeyEvent.SHIFT_MASK;
1379
                break;
1411
                break;
1380
            case 'D':
1412
            case 'D':
1381
                m |= WILDCARD_MASK;
1413
                m |= CTRL_WILDCARD_MASK;
1414
                break;
1415
            case 'O':
1416
                m |= ALT_WILDCARD_MASK;
1382
                break;
1417
                break;
1383
            default:
1418
            default:
1384
                throw new NoSuchElementException ();
1419
                throw new NoSuchElementException (s);
1385
            }
1420
            }
1386
        }
1421
        }
1387
        return m;
1422
        return m;
(-)projects/projectui/src/org/netbeans/modules/project/ui/resources/layer.xml (-1 / +1 lines)
Lines 543-549 Link Here
543
            <attr name="originalFile" stringvalue="Actions/Project/org-netbeans-modules-project-ui-DebugMainProject.instance"/>
543
            <attr name="originalFile" stringvalue="Actions/Project/org-netbeans-modules-project-ui-DebugMainProject.instance"/>
544
	</file>
544
	</file>
545
                     
545
                     
546
        <file name="A-F6.shadow">
546
        <file name="O-F6.shadow">
547
            <attr name="originalFile" stringvalue="Actions/Project/org-netbeans-modules-project-ui-TestProject.instance"/>
547
            <attr name="originalFile" stringvalue="Actions/Project/org-netbeans-modules-project-ui-TestProject.instance"/>
548
	</file> 
548
	</file> 
549
        
549
        
(-)refactoring/src/org/netbeans/modules/refactoring/resources/mf-layer.xml (-3 / +3 lines)
Lines 59-71 Link Here
59
    </folder>
59
    </folder>
60
  
60
  
61
  <folder name="Shortcuts">
61
  <folder name="Shortcuts">
62
    <file name="A-F7.shadow">
62
    <file name="O-F7.shadow">
63
        <attr name="originalFile" stringvalue="Actions/Refactoring/org-netbeans-modules-refactoring-ui-WhereUsedAction.instance"/>
63
        <attr name="originalFile" stringvalue="Actions/Refactoring/org-netbeans-modules-refactoring-ui-WhereUsedAction.instance"/>
64
    </file>
64
    </file>
65
    <file name="AS-R.shadow">
65
    <file name="OS-R.shadow">
66
        <attr name="originalFile" stringvalue="Actions/Refactoring/org-netbeans-modules-refactoring-ui-RenameAction.instance"/>
66
        <attr name="originalFile" stringvalue="Actions/Refactoring/org-netbeans-modules-refactoring-ui-RenameAction.instance"/>
67
    </file>
67
    </file>
68
    <file name="AS-V.shadow">
68
    <file name="OS-V.shadow">
69
        <attr name="originalFile" stringvalue="Actions/Refactoring/org-netbeans-modules-refactoring-ui-MoveClassAction.instance"/>
69
        <attr name="originalFile" stringvalue="Actions/Refactoring/org-netbeans-modules-refactoring-ui-MoveClassAction.instance"/>
70
    </file>
70
    </file>
71
  </folder>
71
  </folder>
(-)tasklist/compiler/src/org/netbeans/modules/tasklist/compiler/mf-layer.xml (-2 / +2 lines)
Lines 25-34 Link Here
25
    </folder>
25
    </folder>
26
    
26
    
27
    <folder name="Shortcuts">
27
    <folder name="Shortcuts">
28
        <file name="AS-C.instance">
28
        <file name="OS-C.instance">
29
            <attr name="instanceClass" stringvalue="org.netbeans.modules.tasklist.compiler.StopCompileAction"/>
29
            <attr name="instanceClass" stringvalue="org.netbeans.modules.tasklist.compiler.StopCompileAction"/>
30
        </file>
30
        </file>
31
        <file name="DA-F4.instance">
31
        <file name="DO-F4.instance">
32
            <attr name="instanceClass" stringvalue="org.netbeans.modules.tasklist.compiler.ShowBuildErrorsAction"/>
32
            <attr name="instanceClass" stringvalue="org.netbeans.modules.tasklist.compiler.ShowBuildErrorsAction"/>
33
        </file>
33
        </file>
34
    </folder>
34
    </folder>
(-)utilities/project/src/org/netbeans/modules/search/project/layer.xml (-1 / +1 lines)
Lines 33-39 Link Here
33
    </folder> <!-- Menu -->
33
    </folder> <!-- Menu -->
34
    
34
    
35
    <folder name="Shortcuts">
35
    <folder name="Shortcuts">
36
        <file name="CS-P.shadow">
36
        <file name="DS-P.shadow">
37
            <attr name="originalFile" stringvalue="Actions/Edit/org-netbeans-modules-search-project-ProjectsSearchAction.instance"/>
37
            <attr name="originalFile" stringvalue="Actions/Edit/org-netbeans-modules-search-project-ProjectsSearchAction.instance"/>
38
        </file>
38
        </file>
39
    </folder>
39
    </folder>
(-)xml/tools/src/org/netbeans/modules/xml/tools/resources/mf-layer.xml (-2 / +2 lines)
Lines 88-97 Link Here
88
    </folder> <!-- xml -->
88
    </folder> <!-- xml -->
89
89
90
    <folder name="Shortcuts">
90
    <folder name="Shortcuts">
91
        <file name="A-F9.instance">
91
        <file name="O-F9.instance">
92
	    <attr name="instanceClass" stringvalue="org.netbeans.modules.xml.tools.actions.CheckAction"/>
92
	    <attr name="instanceClass" stringvalue="org.netbeans.modules.xml.tools.actions.CheckAction"/>
93
	</file>
93
	</file>
94
        <file name="A-S-F9.instance">
94
        <file name="O-S-F9.instance">
95
	    <attr name="instanceClass" stringvalue="org.netbeans.modules.xml.tools.actions.ValidateAction"/>
95
	    <attr name="instanceClass" stringvalue="org.netbeans.modules.xml.tools.actions.ValidateAction"/>
96
	</file>        
96
	</file>        
97
    </folder> <!-- Shortcuts -->
97
    </folder> <!-- Shortcuts -->
(-)xml/xsl/src/org/netbeans/modules/xsl/resources/mf-layer.xml (-1 / +1 lines)
Lines 64-70 Link Here
64
    </folder>
64
    </folder>
65
65
66
    <folder name="Shortcuts">
66
    <folder name="Shortcuts">
67
        <file name="C-A-T.instance">
67
        <file name="DO-T.instance">
68
            <attr name="instanceClass" stringvalue="org.netbeans.modules.xsl.actions.TransformAction"/>
68
            <attr name="instanceClass" stringvalue="org.netbeans.modules.xsl.actions.TransformAction"/>
69
        </file>
69
        </file>
70
    </folder> <!-- Shortcuts -->
70
    </folder> <!-- Shortcuts -->

Return to bug 49806