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 180543
Collapse All | Expand All

(-)a/editor/nbproject/project.xml (-1 / +1 lines)
Lines 162-168 Link Here
162
                    <build-prerequisite/>
162
                    <build-prerequisite/>
163
                    <compile-dependency/>
163
                    <compile-dependency/>
164
                    <run-dependency>
164
                    <run-dependency>
165
                        <specification-version>4.11</specification-version>
165
                        <specification-version>7.13</specification-version>
166
                    </run-dependency>
166
                    </run-dependency>
167
                </dependency>
167
                </dependency>
168
                <dependency>
168
                <dependency>
(-)a/editor/src/org/netbeans/modules/editor/impl/ActionsList.java (-1 / +4 lines)
Lines 16-21 Link Here
16
import java.util.logging.Logger;
16
import java.util.logging.Logger;
17
import javax.swing.Action;
17
import javax.swing.Action;
18
import javax.swing.JSeparator;
18
import javax.swing.JSeparator;
19
import org.openide.awt.AcceleratorBinding;
19
import org.openide.cookies.InstanceCookie;
20
import org.openide.cookies.InstanceCookie;
20
import org.openide.filesystems.FileObject;
21
import org.openide.filesystems.FileObject;
21
import org.openide.loaders.DataFolder;
22
import org.openide.loaders.DataFolder;
Lines 142-148 Link Here
142
            }
143
            }
143
            
144
            
144
            if (toAdd instanceof Action) {
145
            if (toAdd instanceof Action) {
145
                actions.add((Action) toAdd);
146
                Action action = (Action) toAdd;
147
                actions.add(action);
148
                AcceleratorBinding.setAccelerator(action, item);
146
            } else if (isSeparator(toAdd)) {
149
            } else if (isSeparator(toAdd)) {
147
                if (prohibitSeparatorsAndActionNames) {
150
                if (prohibitSeparatorsAndActionNames) {
148
                    if (LOG.isLoggable(Level.INFO)) {
151
                    if (LOG.isLoggable(Level.INFO)) {
(-)a/o.n.core/manifest.mf (-1 / +1 lines)
Lines 4-7 Link Here
4
OpenIDE-Module-Layer: org/netbeans/core/resources/mf-layer.xml
4
OpenIDE-Module-Layer: org/netbeans/core/resources/mf-layer.xml
5
AutoUpdate-Show-In-Client: false
5
AutoUpdate-Show-In-Client: false
6
AutoUpdate-Essential-Module: true
6
AutoUpdate-Essential-Module: true
7
OpenIDE-Module-Specification-Version: 3.18
7
OpenIDE-Module-Specification-Version: 3.19
(-)a/o.n.core/nbproject/project.xml (-1 / +1 lines)
Lines 131-137 Link Here
131
                    <build-prerequisite/>
131
                    <build-prerequisite/>
132
                    <compile-dependency/>
132
                    <compile-dependency/>
133
                    <run-dependency>
133
                    <run-dependency>
134
                        <specification-version>5.1</specification-version>
134
                        <specification-version>7.13</specification-version>
135
                    </run-dependency>
135
                    </run-dependency>
136
                </dependency>
136
                </dependency>
137
                <dependency>
137
                <dependency>
(-)a/o.n.core/src/org/netbeans/core/NbKeymap.java (-6 / +21 lines)
Lines 59-64 Link Here
59
import javax.swing.Action;
59
import javax.swing.Action;
60
import javax.swing.KeyStroke;
60
import javax.swing.KeyStroke;
61
import javax.swing.text.Keymap;
61
import javax.swing.text.Keymap;
62
import org.openide.awt.AcceleratorBinding;
62
import org.openide.awt.StatusDisplayer;
63
import org.openide.awt.StatusDisplayer;
63
import org.openide.cookies.InstanceCookie;
64
import org.openide.cookies.InstanceCookie;
64
import org.openide.filesystems.FileAttributeEvent;
65
import org.openide.filesystems.FileAttributeEvent;
Lines 71-76 Link Here
71
import org.openide.loaders.DataObject;
72
import org.openide.loaders.DataObject;
72
import org.openide.loaders.DataObjectNotFoundException;
73
import org.openide.loaders.DataObjectNotFoundException;
73
import org.openide.loaders.DataShadow;
74
import org.openide.loaders.DataShadow;
75
import org.openide.util.Lookup;
74
import org.openide.util.Utilities;
76
import org.openide.util.Utilities;
75
import org.openide.util.actions.SystemAction;
77
import org.openide.util.actions.SystemAction;
76
import org.openide.util.lookup.ServiceProvider;
78
import org.openide.util.lookup.ServiceProvider;
Lines 334-351 Link Here
334
    }
336
    }
335
337
336
    public KeyStroke[] getKeyStrokesForAction(Action a) {
338
    public KeyStroke[] getKeyStrokesForAction(Action a) {
337
        FileObject definingFile = (FileObject) a.getValue("definingFile"); // cf. o.o.awt.Toolbar.setAccelerator
339
        return new KeyStroke[0];
338
        if (definingFile == null) {
340
    }
339
            LOG.log(Level.FINE, "no defining file known for {0}", id(a));
341
340
            return new KeyStroke[0];
342
    KeyStroke keyStrokeForAction(Action a, FileObject definingFile) {
341
        }
342
        String id = idForFile(definingFile);
343
        String id = idForFile(definingFile);
343
        bindings();
344
        bindings();
344
        action2Id.put(a, id);
345
        action2Id.put(a, id);
345
        KeyStroke k = id2Stroke.get(id);
346
        KeyStroke k = id2Stroke.get(id);
346
        LOG.log(Level.FINE, "found keystroke {0} for {1} with ID {2}", new Object[] {k, id(a), id});
347
        LOG.log(Level.FINE, "found keystroke {0} for {1} with ID {2}", new Object[] {k, id(a), id});
347
        return k != null ? new KeyStroke[] {k} : new KeyStroke[0];
348
        return k;
348
    }
349
    }
350
351
    @ServiceProvider(service=AcceleratorBinding.class)
352
    public static final class AcceleratorBindingImpl extends AcceleratorBinding {
353
        protected @Override KeyStroke keyStrokeForAction(Action action, FileObject definingFile) {
354
            Keymap km = Lookup.getDefault().lookup(Keymap.class);
355
            if (km instanceof NbKeymap) {
356
                return ((NbKeymap) km).keyStrokeForAction(action, definingFile);
357
            } else {
358
                LOG.log(Level.WARNING, "unexpected keymap: {0}", km);
359
                return null;
360
            }
361
        }
362
    }
363
349
    /**
364
    /**
350
     * Traverses shadow files to origin.
365
     * Traverses shadow files to origin.
351
     * Returns impl class name if that is obvious (common for SystemAction's);
366
     * Returns impl class name if that is obvious (common for SystemAction's);
(-)a/o.n.core/test/unit/src/org/netbeans/core/NbKeymapTest.java (-12 / +8 lines)
Lines 46-53 Link Here
46
import java.awt.event.KeyEvent;
46
import java.awt.event.KeyEvent;
47
import java.io.IOException;
47
import java.io.IOException;
48
import java.io.OutputStream;
48
import java.io.OutputStream;
49
import java.util.Arrays;
50
import java.util.Collections;
51
import java.util.concurrent.atomic.AtomicReference;
49
import java.util.concurrent.atomic.AtomicReference;
52
import javax.swing.AbstractAction;
50
import javax.swing.AbstractAction;
53
import javax.swing.Action;
51
import javax.swing.Action;
Lines 92-104 Link Here
92
        return FileUtil.createFolder(FileUtil.getConfigRoot(), path);
90
        return FileUtil.createFolder(FileUtil.getConfigRoot(), path);
93
    }
91
    }
94
92
95
    private void assertMapping(Keymap km, KeyStroke stroke, FileObject presenterDefinition, String actionName) throws Exception {
93
    private void assertMapping(NbKeymap km, KeyStroke stroke, FileObject presenterDefinition, String actionName) throws Exception {
96
        Action a = km.getAction(stroke);
94
        Action a = km.getAction(stroke);
97
        assertNotNull("for " + stroke, a);
95
        assertNotNull("for " + stroke, a);
98
        assertEquals(actionName, a.getValue(Action.NAME));
96
        assertEquals(actionName, a.getValue(Action.NAME));
99
        a.putValue("definingFile", presenterDefinition);
100
        assertEquals("for " + stroke + " from " + presenterDefinition.getPath(),
97
        assertEquals("for " + stroke + " from " + presenterDefinition.getPath(),
101
                Collections.singletonList(stroke), Arrays.asList(km.getKeyStrokesForAction(a)));
98
                stroke, km.keyStrokeForAction(a, presenterDefinition));
102
    }
99
    }
103
    
100
    
104
    public void testAcceleratorMapping() throws Exception {
101
    public void testAcceleratorMapping() throws Exception {
Lines 119-125 Link Here
119
        FileObject menuitem2 = DataShadow.create(menu, "whatever2", DataObject.find(def2)).getPrimaryFile();
116
        FileObject menuitem2 = DataShadow.create(menu, "whatever2", DataObject.find(def2)).getPrimaryFile();
120
        FileObject menuitem3 = DataShadow.create(menu, "whatever3", DataObject.find(def3)).getPrimaryFile();
117
        FileObject menuitem3 = DataShadow.create(menu, "whatever3", DataObject.find(def3)).getPrimaryFile();
121
        FileObject menuitem4 = DataShadow.create(menu, "whatever4", DataObject.find(def4)).getPrimaryFile();
118
        FileObject menuitem4 = DataShadow.create(menu, "whatever4", DataObject.find(def4)).getPrimaryFile();
122
        Keymap km = new NbKeymap();
119
        NbKeymap km = new NbKeymap();
123
        assertMapping(km, KeyStroke.getKeyStroke(KeyEvent.VK_1, 0), menuitem1, "one");
120
        assertMapping(km, KeyStroke.getKeyStroke(KeyEvent.VK_1, 0), menuitem1, "one");
124
        assertMapping(km, KeyStroke.getKeyStroke(KeyEvent.VK_2, 0), menuitem2, "two");
121
        assertMapping(km, KeyStroke.getKeyStroke(KeyEvent.VK_2, 0), menuitem2, "two");
125
        assertMapping(km, KeyStroke.getKeyStroke(KeyEvent.VK_3, 0), menuitem3, "DummySystemAction1");
122
        assertMapping(km, KeyStroke.getKeyStroke(KeyEvent.VK_3, 0), menuitem3, "DummySystemAction1");
Lines 132-138 Link Here
132
        DataFolder shortcuts = DataFolder.findFolder(makeFolder("Shortcuts"));
129
        DataFolder shortcuts = DataFolder.findFolder(makeFolder("Shortcuts"));
133
        DataShadow.create(shortcuts, "C-V", DataObject.find(def));
130
        DataShadow.create(shortcuts, "C-V", DataObject.find(def));
134
        DataShadow.create(shortcuts, "PASTE", DataObject.find(def));
131
        DataShadow.create(shortcuts, "PASTE", DataObject.find(def));
135
        Keymap km = new NbKeymap();
132
        NbKeymap km = new NbKeymap();
136
        assertMapping(km, KeyStroke.getKeyStroke(KeyEvent.VK_V, KeyEvent.CTRL_MASK), def, "paste");
133
        assertMapping(km, KeyStroke.getKeyStroke(KeyEvent.VK_V, KeyEvent.CTRL_MASK), def, "paste");
137
    }
134
    }
138
135
Lines 147-153 Link Here
147
        DataFolder netbeans = DataFolder.findFolder(makeFolder("Keymaps/NetBeans"));
144
        DataFolder netbeans = DataFolder.findFolder(makeFolder("Keymaps/NetBeans"));
148
        DataShadow.create(netbeans, "C-F5", DataObject.find(def1));
145
        DataShadow.create(netbeans, "C-F5", DataObject.find(def1));
149
        DataShadow.create(netbeans, "F5", DataObject.find(def2));
146
        DataShadow.create(netbeans, "F5", DataObject.find(def2));
150
        Keymap km = new NbKeymap();
147
        NbKeymap km = new NbKeymap();
151
        assertMapping(km, KeyStroke.getKeyStroke(KeyEvent.VK_F5, KeyEvent.CTRL_MASK), def1, "start");
148
        assertMapping(km, KeyStroke.getKeyStroke(KeyEvent.VK_F5, KeyEvent.CTRL_MASK), def1, "start");
152
        assertMapping(km, KeyStroke.getKeyStroke(KeyEvent.VK_F5, 0), def2, "continue");
149
        assertMapping(km, KeyStroke.getKeyStroke(KeyEvent.VK_F5, 0), def2, "continue");
153
    }
150
    }
Lines 162-168 Link Here
162
    }
159
    }
163
160
164
    public void testAbstractModifiers() throws Exception {
161
    public void testAbstractModifiers() throws Exception {
165
        Keymap km = new NbKeymap();
162
        NbKeymap km = new NbKeymap();
166
        FileObject inst1 = make("Shortcuts/D-1.instance");
163
        FileObject inst1 = make("Shortcuts/D-1.instance");
167
        inst1.setAttribute("instanceCreate", new DummyAction("one"));
164
        inst1.setAttribute("instanceCreate", new DummyAction("one"));
168
        FileObject inst2 = make("Shortcuts/O-1.instance");
165
        FileObject inst2 = make("Shortcuts/O-1.instance");
Lines 190-196 Link Here
190
        def.setAttribute("instanceCreate", a);
187
        def.setAttribute("instanceCreate", a);
191
        DataShadow.create(DataFolder.findFolder(makeFolder("Keymaps/NetBeans")), "C-A", DataObject.find(def));
188
        DataShadow.create(DataFolder.findFolder(makeFolder("Keymaps/NetBeans")), "C-A", DataObject.find(def));
192
        DataShadow.create(DataFolder.findFolder(makeFolder("Keymaps/Eclipse")), "C-B", DataObject.find(def));
189
        DataShadow.create(DataFolder.findFolder(makeFolder("Keymaps/Eclipse")), "C-B", DataObject.find(def));
193
        Keymap km = new NbKeymap();
190
        NbKeymap km = new NbKeymap();
194
        assertMapping(km, KeyStroke.getKeyStroke(KeyEvent.VK_A, KeyEvent.CTRL_MASK), def, "one");
191
        assertMapping(km, KeyStroke.getKeyStroke(KeyEvent.VK_A, KeyEvent.CTRL_MASK), def, "one");
195
        assertEquals(null, a.getValue(Action.ACCELERATOR_KEY));
192
        assertEquals(null, a.getValue(Action.ACCELERATOR_KEY));
196
        FileUtil.getConfigFile("Keymaps").setAttribute("currentKeymap", "Eclipse");
193
        FileUtil.getConfigFile("Keymaps").setAttribute("currentKeymap", "Eclipse");
Lines 264-271 Link Here
264
        FileObject def = make("Menu/x.shadow");
261
        FileObject def = make("Menu/x.shadow");
265
        def.setAttribute("originalFile", "Action/nonexistent.instance");
262
        def.setAttribute("originalFile", "Action/nonexistent.instance");
266
        Action a = new DummyAction("x");
263
        Action a = new DummyAction("x");
267
        a.putValue("definingFile", def);
264
        new NbKeymap().keyStrokeForAction(a, def);
268
        new NbKeymap().getKeyStrokesForAction(a);
269
    }
265
    }
270
266
271
    private static final class DummyAction extends AbstractAction {
267
    private static final class DummyAction extends AbstractAction {
(-)a/openide.loaders/apichanges.xml (+16 lines)
Lines 106-111 Link Here
106
<!-- ACTUAL CHANGES BEGIN HERE: -->
106
<!-- ACTUAL CHANGES BEGIN HERE: -->
107
107
108
  <changes>
108
  <changes>
109
      <change id="AcceleratorBinding">
110
          <api name="awt"/>
111
          <summary>Added <code>AcceleratorBinding</code></summary>
112
          <version major="7" minor="13"/>
113
          <date day="20" month="2" year="2010"/>
114
          <author login="jglick"/>
115
          <compatibility addition="yes"/>
116
          <description>
117
              <p>
118
                  Added a new class to help with action accelerators.
119
                  Should not be used by typical modules.
120
              </p>
121
          </description>
122
          <class package="org.openide.awt" name="AcceleratorBinding"/>
123
          <issue number="180543"/>
124
      </change>
109
     <change id="XMLDataObject.subclass">
125
     <change id="XMLDataObject.subclass">
110
        <api name="loaders"/>
126
        <api name="loaders"/>
111
        <summary>New constructor of XMLDataObject</summary>
127
        <summary>New constructor of XMLDataObject</summary>
(-)a/openide.loaders/manifest.mf (-1 / +1 lines)
Lines 1-6 Link Here
1
Manifest-Version: 1.0
1
Manifest-Version: 1.0
2
OpenIDE-Module: org.openide.loaders
2
OpenIDE-Module: org.openide.loaders
3
OpenIDE-Module-Specification-Version: 7.12
3
OpenIDE-Module-Specification-Version: 7.13
4
OpenIDE-Module-Localizing-Bundle: org/openide/loaders/Bundle.properties
4
OpenIDE-Module-Localizing-Bundle: org/openide/loaders/Bundle.properties
5
OpenIDE-Module-Provides: org.netbeans.modules.templates.v1_0
5
OpenIDE-Module-Provides: org.netbeans.modules.templates.v1_0
6
AutoUpdate-Essential-Module: true
6
AutoUpdate-Essential-Module: true
(-)a/openide.loaders/src/org/openide/awt/AcceleratorBinding.java (+89 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of either the GNU
7
 * General Public License Version 2 only ("GPL") or the Common
8
 * Development and Distribution License("CDDL") (collectively, the
9
 * "License"). You may not use this file except in compliance with the
10
 * License. You can obtain a copy of the License at
11
 * http://www.netbeans.org/cddl-gplv2.html
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
 * specific language governing permissions and limitations under the
14
 * License.  When distributing the software, include this License Header
15
 * Notice in each file and include the License file at
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
17
 * particular file as subject to the "Classpath" exception as provided
18
 * by Sun in the GPL Version 2 section of the License file that
19
 * accompanied this code. If applicable, add the following below the
20
 * License Header, with the fields enclosed by brackets [] replaced by
21
 * your own identifying information:
22
 * "Portions Copyrighted [year] [name of copyright owner]"
23
 *
24
 * If you wish your version of this file to be governed by only the CDDL
25
 * or only the GPL Version 2, indicate your decision by adding
26
 * "[Contributor] elects to include this software in this distribution
27
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
28
 * single choice of license, a recipient has the option to distribute
29
 * your version of this file under either the CDDL, the GPL Version 2 or
30
 * to extend the choice of license to its licensees as provided above.
31
 * However, if you add GPL Version 2 code and therefore, elected the GPL
32
 * Version 2 license, then the option applies only if the new code is
33
 * made subject to such option by the copyright holder.
34
 *
35
 * Contributor(s):
36
 *
37
 * Portions Copyrighted 2010 Sun Microsystems, Inc.
38
 */
39
40
package org.openide.awt;
41
42
import javax.swing.Action;
43
import javax.swing.KeyStroke;
44
import javax.swing.text.Keymap;
45
import org.openide.filesystems.FileObject;
46
import org.openide.util.Lookup;
47
48
/**
49
 * Permits accelerators to be set on actions based on global registrations.
50
 * This class is only intended for use from NetBeans infrastructure code:
51
 * that which either reads shortcut definitions (i.e. the global {@link Keymap});
52
 * or which loads actions into presenters (e.g. {@link Toolbar}).
53
 * @since org.openide.loaders 7.13
54
 */
55
public abstract class AcceleratorBinding {
56
57
    /**
58
     * Subclass constructor. Only certain implementations are permitted.
59
     */
60
    protected AcceleratorBinding() {
61
        assert getClass().getName().equals("org.netbeans.core.NbKeymap$AcceleratorBindingImpl") : this;
62
    }
63
64
    /**
65
     * Finds a keystroke for an action.
66
     * @param action an action
67
     * @param definingFile an instance file which defines the action
68
     * @return a keystroke or null
69
     */
70
    protected abstract KeyStroke keyStrokeForAction(Action action, FileObject definingFile);
71
72
    /**
73
     * Associates an {@link Action#ACCELERATOR_KEY} with an action based on a declared shortcut.
74
     * If an instance of {@link AcceleratorBinding} can be found in default lookup,
75
     * it will be used to determine the binding. Otherwise nothing is done.
76
     * @param action an action defined in layers
77
     * @param definingFile instance file defining the action
78
     */
79
    public static void setAccelerator(Action action, FileObject definingFile) {
80
        for (AcceleratorBinding bnd : Lookup.getDefault().lookupAll(AcceleratorBinding.class)) {
81
            KeyStroke key = bnd.keyStrokeForAction(action, definingFile);
82
            if (key != null) {
83
                action.putValue(Action.ACCELERATOR_KEY, key);
84
                break;
85
            }
86
        }
87
    }
88
89
}
(-)a/openide.loaders/src/org/openide/awt/DynaMenuModel.java (-1 / +4 lines)
Lines 86-92 Link Here
86
        while (it.hasNext()) {
86
        while (it.hasNext()) {
87
            Object obj = it.next();
87
            Object obj = it.next();
88
            if (obj instanceof Action) {
88
            if (obj instanceof Action) {
89
                Toolbar.setAccelerator((Action) obj, cookiesToFiles.get(obj));
89
                FileObject file = cookiesToFiles.get(obj);
90
                if (file != null) {
91
                    AcceleratorBinding.setAccelerator((Action) obj, file);
92
                }
90
            }
93
            }
91
            if (obj instanceof Presenter.Menu) {
94
            if (obj instanceof Presenter.Menu) {
92
                // does this still apply??
95
                // does this still apply??
(-)a/openide.loaders/src/org/openide/awt/Toolbar.java (-25 / +2 lines)
Lines 58-75 Link Here
58
import javax.swing.JComponent;
58
import javax.swing.JComponent;
59
import javax.swing.JSeparator;
59
import javax.swing.JSeparator;
60
import javax.swing.JToolBar;
60
import javax.swing.JToolBar;
61
import javax.swing.KeyStroke;
62
import javax.swing.UIManager;
61
import javax.swing.UIManager;
63
import javax.swing.plaf.metal.MetalLookAndFeel;
62
import javax.swing.plaf.metal.MetalLookAndFeel;
64
import javax.swing.text.Keymap;
65
import org.netbeans.modules.openide.loaders.DataObjectAccessor;
63
import org.netbeans.modules.openide.loaders.DataObjectAccessor;
66
import org.openide.cookies.InstanceCookie;
64
import org.openide.cookies.InstanceCookie;
67
import org.openide.filesystems.FileObject;
68
import org.openide.loaders.DataFolder;
65
import org.openide.loaders.DataFolder;
69
import org.openide.loaders.DataObject;
66
import org.openide.loaders.DataObject;
70
import org.openide.loaders.FolderInstance;
67
import org.openide.loaders.FolderInstance;
71
import org.openide.util.ImageUtilities;
68
import org.openide.util.ImageUtilities;
72
import org.openide.util.Lookup;
73
import org.openide.util.Task;
69
import org.openide.util.Task;
74
import org.openide.util.actions.Presenter;
70
import org.openide.util.actions.Presenter;
75
71
Lines 411-417 Link Here
411
407
412
                    if (obj instanceof Presenter.Toolbar) {
408
                    if (obj instanceof Presenter.Toolbar) {
413
                        if (obj instanceof Action && file != null) {
409
                        if (obj instanceof Action && file != null) {
414
                            setAccelerator((Action)obj, file.getPrimaryFile());
410
                            AcceleratorBinding.setAccelerator((Action)obj, file.getPrimaryFile());
415
                        }
411
                        }
416
                        obj = ((Presenter.Toolbar) obj).getToolbarPresenter();
412
                        obj = ((Presenter.Toolbar) obj).getToolbarPresenter();
417
                    }
413
                    }
Lines 447-453 Link Here
447
                        b.putClientProperty("file", file);
443
                        b.putClientProperty("file", file);
448
                        org.openide.awt.Toolbar.this.add(b);
444
                        org.openide.awt.Toolbar.this.add(b);
449
                        if (file != null) {
445
                        if (file != null) {
450
                            setAccelerator(a, file.getPrimaryFile());
446
                            AcceleratorBinding.setAccelerator(a, file.getPrimaryFile());
451
                        }
447
                        }
452
                        continue;
448
                        continue;
453
                    }
449
                    }
Lines 481-505 Link Here
481
477
482
    } // end of inner class Folder
478
    } // end of inner class Folder
483
479
484
    static void setAccelerator(Action a, FileObject file) {
485
        if (file == null) {
486
            return;
487
        }
488
        a.putValue("definingFile", file); // cf. o.n.core.NbKeymap.getKeyStrokesForAction
489
        KeyStroke[] keys;
490
        try {
491
            assert a.getValue("definingFile") == file : a.getClass() + " violated Action.putValue contract";
492
            Keymap keymap = Lookup.getDefault().lookup(Keymap.class);
493
            keys = keymap != null ? keymap.getKeyStrokesForAction(a) : new KeyStroke[0];
494
            assert keys != null : keymap;
495
        } finally {
496
            a.putValue("definingFile", null);
497
        }
498
        if (keys.length > 0) {
499
            a.putValue(Action.ACCELERATOR_KEY, keys[0]);
500
        }
501
    }
502
503
    @Override
480
    @Override
504
    public void setUI(javax.swing.plaf.ToolBarUI ui) {
481
    public void setUI(javax.swing.plaf.ToolBarUI ui) {
505
        super.setUI(ui);
482
        super.setUI(ui);

Return to bug 180543