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

(-)core/src/org/netbeans/core/ShortcutsFolder.java (-6 / +68 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 470-475 Link Here
470
                        foAdd.setAttribute("originalFile", originalFilePath); // NOI18N
471
                        foAdd.setAttribute("originalFile", originalFilePath); // NOI18N
471
                    } else {
472
                    } else {
472
                        FileObject foRemove = root.getFileObject(r.instanceName(), "shadow"); // NOI18N
473
                        FileObject foRemove = root.getFileObject(r.instanceName(), "shadow"); // NOI18N
474
                        
473
                        if(foRemove != null) {
475
                        if(foRemove != null) {
474
                            foRemove.delete();
476
                            foRemove.delete();
475
                        }
477
                        }
Lines 484-489 Link Here
484
                                foRemove.delete();
486
                                foRemove.delete();
485
                                break;
487
                                break;
486
                            }
488
                            }
489
                            
487
                        }
490
                        }
488
                    }
491
                    }
489
                }
492
                }
Lines 518-527 Link Here
518
        //ANY CHANGES MADE HERE SHOULD ALSO BE MADE THERE!
521
        //ANY CHANGES MADE HERE SHOULD ALSO BE MADE THERE!
519
        String key = KeyEvent.META_MASK == Toolkit.getDefaultToolkit().getMenuShortcutKeyMask() ?
522
        String key = KeyEvent.META_MASK == Toolkit.getDefaultToolkit().getMenuShortcutKeyMask() ?
520
            "M" : "C"; //NOI18N
523
            "M" : "C"; //NOI18N
521
            
524
        
525
        String ctrlWildcard = "D"; //NOI18N
526
        
527
        String altKey = Utilities.getOperatingSystem() == Utilities.OS_MAC ?
528
            "C" : "A"; //NOI18N
529
        
530
        String altWildcard = "O"; //NOI18N
531
        
532
        
522
        int pos = name.lastIndexOf ("-"); //NOI18N
533
        int pos = name.lastIndexOf ("-"); //NOI18N
523
        String keyPart = name.substring (pos);
534
        String keyPart = name.substring (pos);
524
        String modsPart = Utilities.replaceString (name.substring (0, pos), "-", "");
535
        String modsPart = Utilities.replaceString (name.substring (0, pos), "-", ""); //NOI18N
525
        if (modsPart.length() > 1) {
536
        if (modsPart.length() > 1) {
526
            Collection perms = new HashSet(modsPart.length() * modsPart.length());
537
            Collection perms = new HashSet(modsPart.length() * modsPart.length());
527
            int idx = name.indexOf(key);
538
            int idx = name.indexOf(key);
Lines 529-554 Link Here
529
                //First, try with the wildcard key.  Remove all hyphens - we'll
540
                //First, try with the wildcard key.  Remove all hyphens - we'll
530
                //put them back later
541
                //put them back later
531
                StringBuffer sb = new StringBuffer(modsPart);
542
                StringBuffer sb = new StringBuffer(modsPart);
532
                sb.replace(idx, idx+1, "D");
543
                sb.replace(idx, idx+1, ctrlWildcard);
533
                perms.add (sb.toString() + keyPart);
544
                perms.add (sb.toString() + keyPart);
534
                getAllPossibleOrderings (sb.toString(), keyPart, perms);
545
                getAllPossibleOrderings (sb.toString(), keyPart, perms);
535
                createHyphenatedPermutation(sb.toString().toCharArray(), perms, keyPart);
546
                createHyphenatedPermutation(sb.toString().toCharArray(), perms, keyPart);
547
                idx = name.indexOf (altKey);
548
                if (idx != -1) {
549
                    sb.replace (idx, idx+1, altWildcard);
550
                    perms.add (sb.toString() + keyPart);
551
                    getAllPossibleOrderings (sb.toString(), keyPart, perms);
552
                    createHyphenatedPermutation(sb.toString().toCharArray(), perms, keyPart);
553
                } else {
554
                    idx = name.indexOf(altWildcard);
555
                    if (idx != -1) {
556
                        sb.replace (idx, idx+1, altKey);
557
                        perms.add (sb.toString() + keyPart);
558
                        getAllPossibleOrderings (sb.toString(), keyPart, perms);
559
                        createHyphenatedPermutation(sb.toString().toCharArray(), perms, keyPart);
560
                    }
561
                }                
536
            } else {
562
            } else {
537
                idx = name.indexOf ("D"); //NOI18N
563
                idx = name.indexOf (ctrlWildcard); //NOI18N
538
                if (idx != -1) {
564
                if (idx != -1) {
539
                    StringBuffer sb = new StringBuffer(modsPart);
565
                    StringBuffer sb = new StringBuffer(modsPart);
540
                    sb.replace(idx, idx+1, key);
566
                    sb.replace(idx, idx+1, key);
541
                    perms.add (sb.toString() + keyPart);
567
                    perms.add (sb.toString() + keyPart);
542
                    getAllPossibleOrderings (sb.toString(), keyPart, perms);
568
                    getAllPossibleOrderings (sb.toString(), keyPart, perms);
543
                    createHyphenatedPermutation(sb.toString().toCharArray(), perms, keyPart);
569
                    createHyphenatedPermutation(sb.toString().toCharArray(), perms, keyPart);
570
                    idx = name.indexOf (altKey);
571
                    if (idx != -1) {
572
                        sb.replace (idx, idx+1, altWildcard);
573
                        perms.add (sb.toString() + keyPart);
574
                        getAllPossibleOrderings (sb.toString(), keyPart, perms);
575
                    } else {
576
                        idx = name.indexOf(altWildcard);
577
                        if (idx != -1) {
578
                            sb.replace (idx, idx+1, altKey);
579
                            perms.add (sb.toString() + keyPart);
580
                            getAllPossibleOrderings (sb.toString(), keyPart, perms);
581
                            createHyphenatedPermutation(sb.toString().toCharArray(), perms, keyPart);
582
                        }
583
                    }                    
544
                }
584
                }
545
            }
585
            }
586
            
587
            idx = name.indexOf (altKey);
588
            if (idx != -1) {
589
                StringBuffer sb = new StringBuffer(modsPart);
590
                sb.replace (idx, idx+1, altWildcard);
591
                perms.add (sb.toString() + keyPart);
592
                getAllPossibleOrderings (sb.toString(), keyPart, perms);
593
                createHyphenatedPermutation(sb.toString().toCharArray(), perms, keyPart);
594
            } else {
595
                StringBuffer sb = new StringBuffer(modsPart);
596
                idx = name.indexOf(altWildcard);
597
                if (idx != -1) {
598
                    sb.replace (idx, idx+1, altKey);
599
                    perms.add (sb.toString() + keyPart);
600
                    getAllPossibleOrderings (sb.toString(), keyPart, perms);
601
                    createHyphenatedPermutation(sb.toString().toCharArray(), perms, keyPart);
602
                }
603
            }
604
            
546
            getAllPossibleOrderings (modsPart, keyPart, perms);
605
            getAllPossibleOrderings (modsPart, keyPart, perms);
547
            createHyphenatedPermutation(modsPart.toCharArray(), perms, keyPart);
606
            createHyphenatedPermutation(modsPart.toCharArray(), perms, keyPart);
548
            return (String[]) perms.toArray(new String[perms.size()]);
607
            return (String[]) perms.toArray(new String[perms.size()]);
549
        } else {
608
        } else {
550
            return key.equals (modsPart) ?
609
            return key.equals (modsPart) ?
551
                new String[] {"D" + keyPart} : new String[0];
610
                new String[] {ctrlWildcard + keyPart} : altKey.equals(modsPart) ?
611
                    new String[]{altWildcard + keyPart} : altWildcard.equals(modsPart) ? 
612
                    new String[] {altKey + keyPart} : 
613
                    new String[0];
552
        }
614
        }
553
    }
615
    }
554
    
616
    
(-)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 / +207 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
        kmap = new NbKeymap();
78
        fs = createTestingFilesystem();
79
        fo = getFolderForShortcuts(fs);
80
        sf = createShortcutsFolder(fs);
81
        sf.waitShortcutsFinished();
82
    }
83
    
84
    protected void tearDown() {
85
        try {
86
            FileLock lock = fo.lock();
87
            fo.delete(lock);
88
            lock.releaseLock();
89
        } catch (Exception ioe) {
90
        }
91
        
92
        ShortcutsFolder.shortcutsFolder = null;
93
        sf = null;
94
        fs = null;
95
        fld = null;
96
        fo = null;
97
        try {
98
            if (dir.exists()) {
99
                File[] f = dir.listFiles();
100
                for (int i=0; i < f.length; i++) {
101
                    f[i].delete();
102
                }
103
                dir.delete();
104
            }
105
            dir = null;
106
            folderName = null;
107
            repository = null;
108
            
109
        } catch (Exception e) {
110
            throw new RuntimeException(e);
111
        }
112
    }
113
66
    public void testHyphenation (String s) {
114
    public void testHyphenation (String s) {
115
        System.out.println("testHyphenation");
67
        HashSet set = new HashSet();
116
        HashSet set = new HashSet();
68
        char[] c = new String("ABCD").toCharArray();
117
        char[] c = new String("ABCD").toCharArray();
69
        ShortcutsFolder.createHyphenatedPermutation (c, set, "-F5");
118
        ShortcutsFolder.createHyphenatedPermutation (c, set, "-F5");
70
        
119
        
71
        assertTrue (set.contains("A-B-C-D-F5"));
120
        assertTrue (set.contains("A-B-C-D-F5"));
72
    }
121
    }
73
    
122
   
74
    public void testPermutations () {
123
    public void testPermutations () {
124
        System.out.println("testPermutations");
75
        HashSet set = new HashSet();
125
        HashSet set = new HashSet();
76
        
126
        
77
        ShortcutsFolder.getAllPossibleOrderings("BANG", "-F5", set);
127
        ShortcutsFolder.getAllPossibleOrderings("BANG", "-F5", set);
Lines 89-94 Link Here
89
    }
139
    }
90
    
140
    
91
    public void testPermutationsIncludeHyphenatedVariants() {
141
    public void testPermutationsIncludeHyphenatedVariants() {
142
        System.out.println("testPermutationsIncludeHyphenatedVariants");
92
        HashSet set = new HashSet();
143
        HashSet set = new HashSet();
93
        
144
        
94
        ShortcutsFolder.getAllPossibleOrderings("BANG", "-F5", set);
145
        ShortcutsFolder.getAllPossibleOrderings("BANG", "-F5", set);
Lines 106-111 Link Here
106
    }
157
    }
107
    
158
    
108
    public void testPermutationsContainConvertedWildcard () {
159
    public void testPermutationsContainConvertedWildcard () {
160
        System.out.println("testPermutationsContainConvertedWildcard ");
109
        String targetChar = (Utilities.getOperatingSystem() & Utilities.OS_MAC) != 0
161
        String targetChar = (Utilities.getOperatingSystem() & Utilities.OS_MAC) != 0
110
            ? "M" : "C";
162
            ? "M" : "C";
111
        
163
        
Lines 127-132 Link Here
127
    }
179
    }
128
180
129
    public void testPermutationsIncludeWildcardIfSpecifiedKeyIsToolkitAccelerator () {
181
    public void testPermutationsIncludeWildcardIfSpecifiedKeyIsToolkitAccelerator () {
182
        System.out.println("testPermutationsIncludeWildcardIfSpecifiedKeyIsToolkitAccelerator ");
130
        String targetChar = (Utilities.getOperatingSystem() & Utilities.OS_MAC) != 0
183
        String targetChar = (Utilities.getOperatingSystem() & Utilities.OS_MAC) != 0
131
            ? "M" : "C";
184
            ? "M" : "C";
132
        
185
        
Lines 147-160 Link Here
147
        }
200
        }
148
    } 
201
    } 
149
    
202
    
203
    public void testPermutationsContainConvertedAltWildcard () {
204
        System.out.println("testPermutationsContainConvertedWildcard");
205
        String cmdChar = (Utilities.getOperatingSystem() & Utilities.OS_MAC) != 0
206
            ? "M" : "C";        
207
        
208
        String altKey = Utilities.getOperatingSystem() == Utilities.OS_MAC ?
209
            "C" : "A"; //NOI18N        
210
        
211
        String[] s = ShortcutsFolder.getPermutations("DO-F5");
212
        HashSet set = new HashSet (Arrays.asList(s));
213
        set.add ("DO-F5"); //Permutations will not contain the passed value
214
        
215
        String[] permutations = new String[] {
216
            "OD-F5", 
217
            "O" + cmdChar + "-F5", 
218
            "DO-F5", 
219
            "D-O-F5",
220
            "O-D-F5", 
221
            altKey + "-D-F5", 
222
            altKey + "-" + cmdChar + "-F5", 
223
            altKey + "D-F5",
224
        };
225
        
226
        for (int i=0; i < permutations.length; i++) {
227
            assertTrue ("Permutation of D"+ altKey + "-F5 not generated:" 
228
                + permutations[i] + "; (generated:" + set + ")",
229
                set.contains(permutations[i]));
230
        }
231
    } 
232
    
233
    public void testDualWildcardPermutations() {
234
        System.out.println("testDualWildcardPermutations");
235
        String cmdChar = (Utilities.getOperatingSystem() & Utilities.OS_MAC) != 0
236
            ? "M" : "C";        
237
        
238
        String altKey = Utilities.getOperatingSystem() == Utilities.OS_MAC ?
239
            "C" : "A"; //NOI18N        
240
        
241
        String[] s = ShortcutsFolder.getPermutations("OD-F5");
242
        HashSet set = new HashSet (Arrays.asList(s));
243
        set.add ("OD-F5"); //Permutations will not contain the passed value
244
        
245
        String[] permutations = new String[] {
246
            "OD-F5", "O" + cmdChar + "-F5", "DO-F5", "D-O-F5",
247
            "O-D-F5", altKey + "-D-F5", altKey + "-" + cmdChar + "-F5", altKey + "D-F5",
248
            altKey + cmdChar + "-F5"
249
        };
250
        
251
        for (int i=0; i < permutations.length; i++) {
252
            assertTrue ("Permutation of OD-F5 not generated:" 
253
                + permutations[i] + "; (generated:" + set + ")",
254
                set.contains(permutations[i]));
255
        }
256
    }
257
    
258
    public void testOPermutationOfAlt () throws Exception {
259
        System.out.println("testOPermutationOfAlt");
260
//        FileSystem fs = createTestingFilesystem();
261
//        FileObject fo = getFolderForShortcuts(fs);
262
        
263
//        assertEquals (lastDir, repository.getDefaultFileSystem().getRoot().getPath());
264
        
265
        FileObject data1 = fo.createData("OD-F6.instance");
266
        assertNotNull(data1);
267
        data1.setAttribute("instanceClass", "org.netbeans.core.ShortcutsFolderTest$TestAction");
268
        
269
        FileObject data2 = fo.createData("OS-F6.instance");
270
        assertNotNull(data2);
271
        data2.setAttribute("instanceClass", "org.netbeans.core.ShortcutsFolderTest$TestAction");
272
        
273
        File file = new File (lastDir + folderName + File.separator + "OD-F6.instance");
274
        assertTrue ("Actual file not created: " + file.getPath(), file.exists());
275
276
        sf.refreshGlobalMap();
277
        
278
        DataObject ob = DataObject.find (data1);
279
        assertNotNull("Data object not found: " + data1.getPath(), ob);
280
        
281
        InstanceCookie ck = (InstanceCookie) ob.getCookie(InstanceCookie.class);
282
        Object obj = ck.instanceCreate();
283
        
284
        assertTrue ("InstanceCookie was not an instanceof TestAction - " + obj, obj instanceof TestAction);
285
        
286
        int mask = System.getProperty("mrj.version") == null ? KeyEvent.ALT_MASK :
287
            KeyEvent.CTRL_MASK;
288
        
289
        KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_F6, mask | Toolkit.getDefaultToolkit().getMenuShortcutKeyMask());
290
        Action action = (Action) obj;
291
        
292
        ShortcutsFolder.applyChanges(Arrays.asList(new Object[] {new ShortcutsFolder.ChangeRequest (stroke, action, false)}));
293
        
294
        ShortcutsFolder.refreshGlobalMap();
295
296
        FileObject now = fo.getFileObject ("OD-F6.instance");
297
        //XXX WTF??
298
        assertNull ("File object should be deleted - but is " + (now == null ? " null " : now.getPath()), now);
299
        
300
        assertFalse ("File still exists: " + lastDir + "OD-F6.instance", file.exists());
301
        
302
        file = new File (lastDir + "Shortcuts" + File.separator + "OS-F6.instance");
303
        assertTrue ("File should not have been deleted: " + file.getPath(), file.exists());
304
        
305
    }  
306
307
  
308
    
309
    private static String lastDir = null;
310
    private static File dir = null;
311
    private File getTempDir() {
312
        String outdir = System.getProperty("java.io.tmpdir"); //NOI18N
313
        if (!outdir.endsWith(File.separator)) {
314
            outdir += File.separator;
315
        }
316
        String dirname = Long.toHexString(System.currentTimeMillis());
317
        lastDir = outdir + dirname + File.separator;
318
        dir = new File (outdir + dirname);
319
        try {
320
            dir.mkdir();
321
        } catch (Exception ioe) {
322
            ioe.printStackTrace();
323
            fail ("Exception creating temporary dir for tests " + dirname + " - " + ioe.getMessage());
324
        }
325
        dir.deleteOnExit();
326
        
327
        return dir;
328
    }
329
    
150
    private FileSystem createTestingFilesystem () {
330
    private FileSystem createTestingFilesystem () {
151
        FileObject root = Repository.getDefault ().getDefaultFileSystem ().getRoot ();
331
        FileObject root = Repository.getDefault ().getDefaultFileSystem ().getRoot ();
152
        try {
332
        try {
333
            LocalFileSystem result = new LocalFileSystem();
334
            result.setRootDirectory(getTempDir());
335
            repository = new Repository (result);
336
            fixDefaultRepository();
337
            System.setProperty ("org.openide.util.Lookup", "org.netbeans.core.ShortcutsFolderTest$LKP");
153
            FileObject[] arr = root.getChildren ();
338
            FileObject[] arr = root.getChildren ();
154
            for (int i = 0; i < arr.length; i++) {
339
            for (int i = 0; i < arr.length; i++) {
155
                arr[i].delete ();
340
                arr[i].delete ();
156
            }
341
            }
157
            return root.getFileSystem ();
342
            return result;
158
        } catch (Exception e) {
343
        } catch (Exception e) {
159
            e.printStackTrace();
344
            e.printStackTrace();
160
            fail (e.getMessage());
345
            fail (e.getMessage());
Lines 162-173 Link Here
162
        return null;
347
        return null;
163
    }
348
    }
164
    
349
    
350
    private void fixDefaultRepository () {
351
        try {
352
            Class c = ClassLoader.getSystemClassLoader().loadClass("org.openide.filesystems.ExternalUtil");
353
            Method m = c.getDeclaredMethod ("setRepository", new Class[] {Repository.class});
354
            m.setAccessible(true);
355
            m.invoke (null, new Object[] { repository });
356
        } catch (Exception e) {
357
            throw new RuntimeException (e);
358
        }
359
    }
360
    
165
    private FileObject getFolderForShortcuts(FileSystem fs) {
361
    private FileObject getFolderForShortcuts(FileSystem fs) {
166
        FileObject result = null;
362
        FileObject result = null;
167
        try {
363
        try {
168
            result = fs.getRoot().getFileObject("Shortcuts");
364
            folderName = "Shortcuts";
365
            result = fs.getRoot().getFileObject(folderName);
169
            if (result == null) {
366
            if (result == null) {
170
                result = fs.getRoot().createFolder("Shortcuts");
367
                result = fs.getRoot().createFolder(folderName);
171
            }
368
            }
172
        } catch (Exception e) {
369
        } catch (Exception e) {
173
            e.printStackTrace();
370
            e.printStackTrace();
Lines 176-181 Link Here
176
        return result;
373
        return result;
177
    }
374
    }
178
    
375
    
376
    private String folderName = null;
179
    private ShortcutsFolder createShortcutsFolder(FileSystem fs) {
377
    private ShortcutsFolder createShortcutsFolder(FileSystem fs) {
180
        try {
378
        try {
181
            DataObject dob = DataObject.find(getFolderForShortcuts(fs));
379
            DataObject dob = DataObject.find(getFolderForShortcuts(fs));
Lines 202-221 Link Here
202
        data2.setAttribute("instanceClass", "org.netbeans.core.ShortcutsFolderTest$TestAction");
400
        data2.setAttribute("instanceClass", "org.netbeans.core.ShortcutsFolderTest$TestAction");
203
        
401
        
204
        ShortcutsFolder sf = createShortcutsFolder(fs);
402
        ShortcutsFolder sf = createShortcutsFolder(fs);
205
        System.err.println("Created shortcuts folder " + sf);
206
        
403
        
207
        sf.waitShortcutsFinished();
404
        sf.waitShortcutsFinished();
208
        
405
        
209
        DataObject ob = DataObject.find (data1);
406
        DataObject ob = DataObject.find (data1);
210
        assertNotNull("Data object not found: " + data1.getPath(), ob);
407
        assertNotNull("Data object not found: " + data1.getPath(), ob);
211
        System.err.println("Found data object " + data1);
212
        
408
        
213
        InstanceCookie ck = (InstanceCookie) ob.getCookie(InstanceCookie.class);
409
        InstanceCookie ck = (InstanceCookie) ob.getCookie(InstanceCookie.class);
214
        Object obj = ck.instanceCreate();
410
        Object obj = ck.instanceCreate();
215
        
411
        
216
        assertTrue ("InstanceCookie was not an instanceof TestAction - " + obj, obj instanceof TestAction);
412
        assertTrue ("InstanceCookie was not an instanceof TestAction - " + obj, obj instanceof TestAction);
217
        
413
        
218
        System.err.println("Got an instance: " + obj);
219
        
414
        
220
        KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_F5, KeyEvent.ALT_MASK | Toolkit.getDefaultToolkit().getMenuShortcutKeyMask());
415
        KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_F5, KeyEvent.ALT_MASK | Toolkit.getDefaultToolkit().getMenuShortcutKeyMask());
221
        Action action = (Action) obj;
416
        Action action = (Action) obj;
Lines 223-229 Link Here
223
        ShortcutsFolder.applyChanges(Arrays.asList(new Object[] {new ShortcutsFolder.ChangeRequest (stroke, action, false)}));
418
        ShortcutsFolder.applyChanges(Arrays.asList(new Object[] {new ShortcutsFolder.ChangeRequest (stroke, action, false)}));
224
        
419
        
225
        ShortcutsFolder.refreshGlobalMap();
420
        ShortcutsFolder.refreshGlobalMap();
226
227
        FileObject now = fo.getFileObject ("AD-F5.instance");
421
        FileObject now = fo.getFileObject ("AD-F5.instance");
228
        assertNull ("File object should be deleted - ", now);
422
        assertNull ("File object should be deleted - ", now);
229
        
423
        
Lines 234-239 Link Here
234
        public void actionPerformed (ActionEvent ae) {}
428
        public void actionPerformed (ActionEvent ae) {}
235
    }
429
    }
236
    
430
    
431
    static NbKeymap kmap = null;
237
    public static class LKP extends Lookup {
432
    public static class LKP extends Lookup {
238
        private javax.swing.text.Keymap keymap = new NbKeymap ();
433
        private javax.swing.text.Keymap keymap = new NbKeymap ();
239
        
434
        
Lines 241-248 Link Here
241
            if (ErrorManager.class == clazz) {
436
            if (ErrorManager.class == clazz) {
242
                return new EM();
437
                return new EM();
243
            }
438
            }
244
            if (javax.swing.text.Keymap.class == clazz) {
439
            if (Keymap.class == clazz) {
245
                return keymap;
440
                return kmap;
246
            }
441
            }
247
            return null;
442
            return null;
248
        }
443
        }
Lines 252-257 Link Here
252
                public Collection allInstances() {
447
                public Collection allInstances() {
253
                    if (tpl.getType() == ErrorManager.class) {
448
                    if (tpl.getType() == ErrorManager.class) {
254
                        return Arrays.asList(new Object[] { new EM()});
449
                        return Arrays.asList(new Object[] { new EM()});
450
                    } else if (tpl.getType() == Keymap.class) {
451
                        return Arrays.asList(new Object[] {kmap});
255
                    } else {
452
                    } else {
256
                        return Collections.EMPTY_LIST;
453
                        return Collections.EMPTY_LIST;
257
                    }
454
                    }
(-)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 780-818 Link Here
780
                int mod = evt.getModifiers();
780
                int mod = evt.getModifiers();
781
                boolean ctrl = ((mod & ActionEvent.CTRL_MASK) != 0);
781
                boolean ctrl = ((mod & ActionEvent.CTRL_MASK) != 0);
782
                // On the mac, norwegian and french keyboards use Alt to do bracket characters.
782
                // On the mac, norwegian and french keyboards use Alt to do bracket characters.
783
                boolean alt = ((mod & ActionEvent.ALT_MASK) != 0);
783
                // This replicates Apple's modification DefaultEditorKit.DefaultKeyTypedAction
784
                boolean alt = isMac ? ((mod & ActionEvent.META_MASK) != 0) : 
785
                    ((mod & ActionEvent.ALT_MASK) != 0);
784
                
786
                
785
                if (isMac) {
786
                    boolean macSwap = Boolean.getBoolean (
787
                            "nb.mac.swap.ctrl.and.alt"); //NOI18N
788
789
                    if (alt && !macSwap) {
790
                        //Ugly, but without IDE-wide global keybinding registry, there
791
                        //simply is no way to find out if it's a character we want
792
                        //or not, so filter for commonly used characters and otherwise
793
                        //handle normally.  The problem is really Apple's, that they
794
                        //use Alt- as the compose key in some locales.  Eventually
795
                        //perhaps the applemenu module could detect this and provide alternate
796
                        //bindings with a line switch for all Alt- bindings.  For
797
                        //4.0, this will have to do.
798
                        //
799
                        //Original patch replicated what Apple does in DefaultKeyAction,
800
                        //(check META instead of ALT) but this broke all Alt- 
801
                        //shortcuts.  So we do it the ugly way.
802
                        //
803
                        //This *does* break Alt-8/9 key combinations on norwegian and
804
                        //french keyboards, but that's better than not being able to
805
                        //type brackets
806
                        String cmd = evt.getActionCommand();
807
                        alt &= !"{".equals(cmd) && !"}".equals(cmd) && !"[".equals(cmd) && //NOI18N
808
                            !"]".equals(cmd) && !"(".equals(cmd) && !")".equals(cmd); //NOI18N
809
                    } else if (macSwap) {
810
                        //Allow alt keys through if the flag is set - replicate
811
                        //Apple's hack in DefaultKeyAction.
812
                        alt = false;
813
                        ctrl = false;
814
                    }
815
                }
816
                
787
                
817
                if ((alt && !ctrl) || (ctrl && !alt)) {
788
                if ((alt && !ctrl) || (ctrl && !alt)) {
818
                    return;
789
                    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 398-432 Link Here
398
        }
397
        }
399
398
400
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
399
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
401
            //Hack: On the mac, we provide an action to globally swap
402
            //Ctrl and Alt, so Alt can be used as a control character.  But
403
            //Goto is bound to Ctrl-G even on mac, so we need to suppress it,
404
            //or Alt-G when swapped will not insert an international character.
405
            //We provide the alternate binding AS-G so Goto can work even in
406
            //swapped mode.  See 
407
            //org.netbeans.core.windows.ShortcutKeyAndMenuEventProcessor
408
            
409
            if (isMac) {
410
                String lastMods = System.getProperty("lastKeyModifiers"); //NOI18N
411
                if (lastMods != null) {
412
                    try {
413
                        int mods = Integer.parseInt(lastMods);
414
                        if ((mods & InputEvent.ALT_MASK) != 0) {
415
                            return;
416
                        }
417
                    } catch (NumberFormatException e) {
418
                        //do nothing
419
                    }
420
                }
421
            }
422
            
423
            if (target != null) {
400
            if (target != null) {
424
                new GotoDialogSupport().showGotoDialog(new KeyEventBlocker(target, false));
401
                new GotoDialogSupport().showGotoDialog(new KeyEventBlocker(target, false));
425
            }
402
            }
426
        }
403
        }
427
404
428
    }
405
    }
429
    private static final boolean isMac = System.getProperty("mrj.version") != null; //NOI18N
430
406
431
    /** Action to go to the declaration of the variable under the caret.
407
    /** Action to go to the declaration of the variable under the caret.
432
    */
408
    */
(-)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_A,
160
                       KeyStroke.getKeyStroke(KeyEvent.VK_A,
157
                           mask | InputEvent.ALT_MASK),
161
                           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
                           mask | InputEvent.ALT_MASK | InputEvent.SHIFT_MASK),
167
                           mask | ALT_MASK | InputEvent.SHIFT_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 (-9 / +9 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="A-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="DA-A"/>
22
    <bind actionName="select-element-next" key="DO-A"/>
23
    <bind actionName="select-element-previous" key="DAS-A"/>
23
    <bind actionName="select-element-previous" key="DOS-A"/>
24
</bindings>
24
</bindings>
(-)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/DefaultKeyBindings.xml (+24 lines)
Added Link Here
1
<?xml version="1.0"?>
2
<!DOCTYPE bindings PUBLIC "-//NetBeans//DTD Editor KeyBindings settings 1.0//EN"
3
                          "http://www.netbeans.org/dtds/EditorKeyBindings-1_0.dtd">
4
5
  <!-- IMPORTANT:  To handle Apple-specific keybindings, there is another copy of
6
     this file, with minor diffs, in ide/applemenu.  Any changes made here should
7
     be made there too -->                            
8
<bindings>
9
    <bind actionName="goto-source" key="O-O"/>
10
    <bind actionName="fast-import" key="OS-I"/>
11
    <bind actionName="fix-imports" key="OS-F"/>
12
13
    <bind actionName="goto-super-implementation" key="D-B"/>
14
    <bind actionName="goto-declaration" key="OS-G"/>    
15
    <bind actionName="comment" key="DS-T"/>
16
    <bind actionName="goto-help" key="O-F1"/>
17
    <bind actionName="make-is" key="O-U$I"/>
18
    <bind actionName="make-getter" key="O-U$G"/>
19
    <bind actionName="macro-debug-var" key="D-J$D"/>
20
    <bind actionName="uncomment" key="DS-D"/>
21
    <bind actionName="make-setter" key="O-U$S"/>
22
    <bind actionName="select-element-next" key="DO-A"/>
23
    <bind actionName="select-element-previous" key="DOS-A"/>
24
</bindings>
(-)ide/applemenu/src/org/netbeans/modules/applemenu/SwapCtrlAltAction.java (-84 lines)
Removed Link Here
1
/*
2
 *                 Sun Public License Notice
3
 * 
4
 * The contents of this file are subject to the Sun Public License
5
 * Version 1.0 (the "License"). You may not use this file except in
6
 * compliance with the License. A copy of the License is available at
7
 * http://www.sun.com/
8
 * 
9
 * The Original Code is NetBeans. The Initial Developer of the Original
10
 * Code is Sun Microsystems, Inc. Portions Copyright 1997-2003 Sun
11
 * Microsystems, Inc. All Rights Reserved.
12
 */
13
/*
14
 * SwapCtrlAltAction.java
15
 *
16
 * Created on October 1, 2004, 1:48 PM
17
 */
18
19
package org.netbeans.modules.applemenu;
20
21
import org.openide.awt.StatusDisplayer;
22
import org.openide.util.HelpCtx;
23
import org.openide.util.NbBundle;
24
import org.openide.util.actions.BooleanStateAction;
25
26
/**
27
 * Apple uses Alt- as the compose key on international keyboards.  This causes
28
 * a bunch of conflicts with key bindings.  There are low level patches in the
29
 * editor and window system to swap Ctrl- and Alt- if a system property is set
30
 * to true.  
31
 * <p>
32
 * This action toggles the system property <code>nb.mac.swap.ctrl.and.alt</code>,
33
 * so that international keyboard users can switch between having alt bindings
34
 * and having full use of Alt as a compose key on the mac.
35
 * <p>
36
 * In a perfect world, we would simply not have any Alt- bindings on the mac, and
37
 * use Ctrl as an appropriate substitute.  Currently, that is not a realistic
38
 * option, as there is no way to detect when an international keyboard is 
39
 * present, and using Alt- for bindings on U.S. keyboards is very likely the
40
 * most intuitive choice (not to mention the docs issues it would cause).
41
 *
42
 * @author Tim Boudreau
43
 * @see org.netbeans.core.windows.ShortcutAndMenuKeyEventProcessor#dispatchKeyEvent
44
 * @see org.netbeans.editor.BaseKit.DefaultKeyTypedAction#actionPerformed
45
 */
46
public class SwapCtrlAltAction extends BooleanStateAction {
47
    private static final String PROP_KEY = "nb.mac.swap.ctrl.and.alt"; //NOI18N
48
    
49
    /** Creates a new instance of SwapCtrlAltAction */
50
    public SwapCtrlAltAction() {
51
        
52
    }
53
    
54
    public void actionPerformed (java.awt.event.ActionEvent ev) {
55
        super.actionPerformed (ev);
56
        boolean hasProp = propSet();
57
        if (hasProp) {
58
            System.setProperty(PROP_KEY, "false"); //NOI18N
59
            StatusDisplayer.getDefault().setStatusText(NbBundle.getMessage(
60
                SwapCtrlAltAction.class, "MSG_NotSwapped")); //NOI18N
61
        } else {
62
            System.setProperty(PROP_KEY, "true"); //NOI18N
63
            StatusDisplayer.getDefault().setStatusText(NbBundle.getMessage(
64
                SwapCtrlAltAction.class, "MSG_Swapped")); //NOI18N
65
        }
66
    }
67
    
68
    private boolean propSet () {
69
        return Boolean.getBoolean (PROP_KEY);
70
    }
71
    
72
    protected void initialize () {
73
        super.initialize();
74
        putProperty(PROP_BOOLEAN_STATE, propSet() ? Boolean.TRUE : Boolean.FALSE);
75
    }
76
    
77
    public HelpCtx getHelpCtx() {
78
        return HelpCtx.DEFAULT_HELP;
79
    }
80
    
81
    public String getName() {
82
        return NbBundle.getMessage (SwapCtrlAltAction.class, "LBL_SwapCtrlAlt"); //NOI18N
83
    }
84
}
(-)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>
(-)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;
(-)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>

Return to bug 49806