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

(-)a/bugtracking/src/org/netbeans/modules/bugtracking/util/FindTypesSupport.java (-2 / +2 lines)
Lines 339-349 Link Here
339
//                        add(new JMenuItem(new AbstractAction("Find in projects") {
339
//                        add(new JMenuItem(new AbstractAction("Find in projects") {
340
//                            @Override
340
//                            @Override
341
//                            public void actionPerformed(ActionEvent e) {
341
//                            public void actionPerformed(ActionEvent e) {
342
//                                FindInFilesAction a = (FindInFilesAction) FileUtil.getConfigObject("Actions/Edit/org-netbeans-modules-search-FindInFilesAction.instance", Action.class);
342
//                                Action a = Actions.forID("Edit", "org.netbeans.modules.search.FindInFilesAction");
343
//                                if(a instanceof ContextAwareAction) {
343
//                                if(a instanceof ContextAwareAction) {
344
////                                    a = ((ContextAwareAction)a).createContextAwareInstance(Lookups.singleton(ctx));
344
////                                    a = ((ContextAwareAction)a).createContextAwareInstance(Lookups.singleton(ctx));
345
//                                }            
345
//                                }            
346
//                                a.performAction();
346
//                                a.actionPerformed(null);
347
//                            }
347
//                            }
348
//                        }));
348
//                        }));
349
                    } catch(Exception ex) {
349
                    } catch(Exception ex) {
(-)a/git/src/org/netbeans/modules/git/Annotator.java (+1 lines)
Lines 248-253 Link Here
248
        if(accelerate) {
248
        if(accelerate) {
249
            action = Utils.getAcceleratedAction(ACTIONS_PATH_PREFIX + name + ".instance");
249
            action = Utils.getAcceleratedAction(ACTIONS_PATH_PREFIX + name + ".instance");
250
        } else {
250
        } else {
251
            // or use Actions.forID
251
            action = (Action) FileUtil.getConfigObject(ACTIONS_PATH_PREFIX + name + ".instance", Action.class);
252
            action = (Action) FileUtil.getConfigObject(ACTIONS_PATH_PREFIX + name + ".instance", Action.class);
252
        }
253
        }
253
        if(action instanceof ContextAwareAction) {
254
        if(action instanceof ContextAwareAction) {
(-)a/maven/nbproject/project.xml (-1 / +1 lines)
Lines 285-291 Link Here
285
                    <build-prerequisite/>
285
                    <build-prerequisite/>
286
                    <compile-dependency/>
286
                    <compile-dependency/>
287
                    <run-dependency>
287
                    <run-dependency>
288
                        <specification-version>7.22</specification-version>
288
                        <specification-version>7.42</specification-version>
289
                    </run-dependency>
289
                    </run-dependency>
290
                </dependency>
290
                </dependency>
291
                <dependency>
291
                <dependency>
(-)a/maven/src/org/netbeans/modules/maven/newproject/ExistingWizardIterator.java (-2 / +2 lines)
Lines 55-61 Link Here
55
import org.netbeans.modules.maven.api.archetype.ArchetypeWizards;
55
import org.netbeans.modules.maven.api.archetype.ArchetypeWizards;
56
import static org.netbeans.modules.maven.newproject.Bundle.*;
56
import static org.netbeans.modules.maven.newproject.Bundle.*;
57
import org.openide.WizardDescriptor;
57
import org.openide.WizardDescriptor;
58
import org.openide.filesystems.FileUtil;
58
import org.openide.awt.Actions;
59
import org.openide.util.NbBundle.Messages;
59
import org.openide.util.NbBundle.Messages;
60
import org.openide.util.RequestProcessor;
60
import org.openide.util.RequestProcessor;
61
61
Lines 107-113 Link Here
107
    }
107
    }
108
    
108
    
109
    private void tryOpenProject() {
109
    private void tryOpenProject() {
110
        final Action act = FileUtil.getConfigObject("Actions/Project/org-netbeans-modules-project-ui-OpenProject.instance", Action.class); //NOI18N
110
        final Action act = Actions.forID("Project", "org.netbeans.modules.project.ui.OpenProject"); //NOI18N
111
        if (act != null) {
111
        if (act != null) {
112
            SwingUtilities.invokeLater(new Runnable() {
112
            SwingUtilities.invokeLater(new Runnable() {
113
                public void run() {
113
                public void run() {
(-)a/mercurial/nbproject/project.xml (-1 / +1 lines)
Lines 153-159 Link Here
153
                    <build-prerequisite/>
153
                    <build-prerequisite/>
154
                    <compile-dependency/>
154
                    <compile-dependency/>
155
                    <run-dependency>
155
                    <run-dependency>
156
                        <specification-version>6.8</specification-version>
156
                        <specification-version>7.42</specification-version>
157
                    </run-dependency>
157
                    </run-dependency>
158
                </dependency>
158
                </dependency>
159
                <dependency>
159
                <dependency>
(-)a/mercurial/src/org/netbeans/modules/mercurial/MercurialAnnotator.java (-2 / +2 lines)
Lines 88-94 Link Here
88
import org.netbeans.modules.mercurial.ui.update.UpdateAction;
88
import org.netbeans.modules.mercurial.ui.update.UpdateAction;
89
import org.netbeans.modules.mercurial.util.HgUtils;
89
import org.netbeans.modules.mercurial.util.HgUtils;
90
import org.netbeans.modules.versioning.util.SystemActionBridge;
90
import org.netbeans.modules.versioning.util.SystemActionBridge;
91
import org.openide.filesystems.FileUtil;
91
import org.openide.awt.Actions;
92
import org.openide.util.ContextAwareAction;
92
import org.openide.util.ContextAwareAction;
93
import org.openide.util.ImageUtilities;
93
import org.openide.util.ImageUtilities;
94
import org.openide.util.Lookup;
94
import org.openide.util.Lookup;
Lines 370-376 Link Here
370
        } else {
370
        } else {
371
            Lookup context = ctx.getElements();
371
            Lookup context = ctx.getElements();
372
            if (noneVersioned){
372
            if (noneVersioned){
373
                Action a = (Action) FileUtil.getConfigObject("Actions/Mercurial/org-netbeans-modules-mercurial-ui-create-CreateAction.instance", Action.class);
373
                Action a = Actions.forID("Mercurial", "org.netbeans.modules.mercurial.ui.create.CreateAction");
374
                if(a instanceof ContextAwareAction) {
374
                if(a instanceof ContextAwareAction) {
375
                    a = ((ContextAwareAction)a).createContextAwareInstance(Lookups.singleton(ctx));
375
                    a = ((ContextAwareAction)a).createContextAwareInstance(Lookups.singleton(ctx));
376
                }            
376
                }            
(-)a/openide.awt/apichanges.xml (+26 lines)
Lines 50-55 Link Here
50
<apidef name="awt">AWT API</apidef>
50
<apidef name="awt">AWT API</apidef>
51
</apidefs>
51
</apidefs>
52
<changes>
52
<changes>
53
    <change id="Actions.forID">
54
        <api name="awt"/>
55
        <summary>Added <code>Actions.forID</code></summary>
56
        <version major="7" minor="42"/>
57
        <date year="2012" month="1" day="6"/>
58
        <author login="jglick"/>
59
        <compatibility addition="yes" source="compatible">
60
            <p>
61
                Calls to <code>FileUtil.getConfigObject</code> or similar should be reviewed.
62
            </p>
63
            <p>
64
                Modules with a dependency only on <code>org.openide.loaders</code>
65
                but not <code>org.openide.awt</code> must add the latter dep in
66
                order to use <code>AcceleratorBinding</code>.
67
            </p>
68
        </compatibility>
69
        <description>
70
            <p>
71
                Added a utility method <code>Actions.forID</code>.
72
                Also moved <code>AcceleratorBinding</code> down into the <code>org.openide.awt</code>
73
                module (keeping the same FQN and signature).
74
            </p>
75
        </description>
76
        <class package="org.openide.awt" name="Actions"/>
77
        <issue number="205798"/>
78
    </change>
53
    <change id="ActionRegistration.lazy">
79
    <change id="ActionRegistration.lazy">
54
        <api name="awt"/>
80
        <api name="awt"/>
55
        <summary>Added <code>lazy</code> attribute to <code>ActionRegistration</code></summary>
81
        <summary>Added <code>lazy</code> attribute to <code>ActionRegistration</code></summary>
(-)a/openide.awt/manifest.mf (-1 / +1 lines)
Lines 2-6 Link Here
2
OpenIDE-Module: org.openide.awt
2
OpenIDE-Module: org.openide.awt
3
OpenIDE-Module-Localizing-Bundle: org/openide/awt/Bundle.properties
3
OpenIDE-Module-Localizing-Bundle: org/openide/awt/Bundle.properties
4
AutoUpdate-Essential-Module: true
4
AutoUpdate-Essential-Module: true
5
OpenIDE-Module-Specification-Version: 7.41
5
OpenIDE-Module-Specification-Version: 7.42
6
6
(-)a/openide.loaders/src/org/openide/awt/AcceleratorBinding.java (-4 / +1 lines)
Lines 56-69 Link Here
56
 * This class is only intended for use from NetBeans infrastructure code:
56
 * This class is only intended for use from NetBeans infrastructure code:
57
 * that which either reads shortcut definitions (i.e. the global {@link Keymap});
57
 * that which either reads shortcut definitions (i.e. the global {@link Keymap});
58
 * or which loads actions into presenters (e.g. {@link Toolbar}).
58
 * or which loads actions into presenters (e.g. {@link Toolbar}).
59
 * @since org.openide.loaders 7.13
59
 * @since org.openide.loaders 7.13 but moved down to org.openide.awt 7.42
60
 */
60
 */
61
public abstract class AcceleratorBinding {
61
public abstract class AcceleratorBinding {
62
    private static final Iter ALL = new Iter();
62
    private static final Iter ALL = new Iter();
63
63
64
    static void init() {
65
    }
66
67
    /**
64
    /**
68
     * Subclass constructor. Only certain implementations are permitted.
65
     * Subclass constructor. Only certain implementations are permitted.
69
     */
66
     */
(-)a/openide.awt/src/org/openide/awt/ActionID.java (+1 lines)
Lines 56-61 Link Here
56
 * @author Jaroslav Tulach <jtulach@netbeans.org>
56
 * @author Jaroslav Tulach <jtulach@netbeans.org>
57
 * @since 7.26
57
 * @since 7.26
58
 * @see ActionRegistration
58
 * @see ActionRegistration
59
 * @see Actions#forID
59
 */
60
 */
60
@Retention(RetentionPolicy.SOURCE)
61
@Retention(RetentionPolicy.SOURCE)
61
@Target({ElementType.TYPE, ElementType.FIELD, ElementType.METHOD})
62
@Target({ElementType.TYPE, ElementType.FIELD, ElementType.METHOD})
(-)a/openide.awt/src/org/openide/awt/Actions.java (+29 lines)
Lines 81-89 Link Here
81
import org.netbeans.api.actions.Openable;
81
import org.netbeans.api.actions.Openable;
82
import org.netbeans.api.actions.Printable;
82
import org.netbeans.api.actions.Printable;
83
import org.netbeans.api.actions.Viewable;
83
import org.netbeans.api.actions.Viewable;
84
import org.openide.filesystems.FileObject;
85
import org.openide.filesystems.FileUtil;
84
import org.openide.util.ContextAwareAction;
86
import org.openide.util.ContextAwareAction;
85
import org.openide.util.ImageUtilities;
87
import org.openide.util.ImageUtilities;
86
import org.openide.util.LookupListener;
88
import org.openide.util.LookupListener;
89
import org.openide.util.Utilities;
87
import org.openide.util.WeakListeners;
90
import org.openide.util.WeakListeners;
88
import org.openide.util.actions.BooleanStateAction;
91
import org.openide.util.actions.BooleanStateAction;
89
import org.openide.util.actions.SystemAction;
92
import org.openide.util.actions.SystemAction;
Lines 716-721 Link Here
716
        }
719
        }
717
        throw new IllegalStateException(type);
720
        throw new IllegalStateException(type);
718
    }
721
    }
722
723
    /**
724
     * Locates a specific action programmatically.
725
     * The action will typically have been registered using {@link ActionRegistration}.
726
     * <p>Normally an {@link ActionReference} will suffice to insert the action
727
     * into various UI elements (typically using {@link Utilities#actionsForPath}),
728
     * but in special circumstances you may need to find a single known action.
729
     * This method is just a shortcut for using {@link FileUtil#getConfigObject}
730
     * with the correct arguments, plus using {@link AcceleratorBinding#setAccelerator}.
731
     * @param category as in {@link ActionID#category}
732
     * @param id as in {@link ActionID#id}
733
     * @return the action registered under that ID, or null
734
     * @since 7.42
735
     */
736
    public static Action forID(String category, String id) {
737
        String path = "Actions/" + category + "/" + id.replace('.', '-') + ".instance";
738
        Action a = FileUtil.getConfigObject(path, Action.class);
739
        if (a == null) {
740
            return null;
741
        }
742
        FileObject def = FileUtil.getConfigFile(path);
743
        if (def != null) {
744
            AcceleratorBinding.setAccelerator(a, def);
745
        }
746
        return a;
747
    }
719
    
748
    
720
    /** Extracts help from action.
749
    /** Extracts help from action.
721
     */
750
     */
(-)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.33
3
OpenIDE-Module-Specification-Version: 7.34
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
OpenIDE-Module-Layer: org/netbeans/modules/openide/loaders/layer.xml
6
OpenIDE-Module-Layer: org/netbeans/modules/openide/loaders/layer.xml
(-)a/openide.loaders/nbproject/project.xml (-1 / +1 lines)
Lines 98-104 Link Here
98
                    <build-prerequisite/>
98
                    <build-prerequisite/>
99
                    <compile-dependency/>
99
                    <compile-dependency/>
100
                    <run-dependency>
100
                    <run-dependency>
101
                        <specification-version>7.33</specification-version>
101
                        <specification-version>7.42</specification-version>
102
                    </run-dependency>
102
                    </run-dependency>
103
                </dependency>
103
                </dependency>
104
                <dependency>
104
                <dependency>
(-)a/openide.loaders/src/org/openide/awt/MenuBar.java (-1 / +5 lines)
Lines 127-133 Link Here
127
127
128
    static final long serialVersionUID =-4721949937356581268L;
128
    static final long serialVersionUID =-4721949937356581268L;
129
    static {
129
    static {
130
        AcceleratorBinding.init();
130
        try {
131
            Class.forName(AcceleratorBinding.class.getName());
132
        } catch (ClassNotFoundException x) {
133
            throw new ExceptionInInitializerError(x);
134
        }
131
    }
135
    }
132
136
133
    /** Don't call this constructor or this class will not get
137
    /** Don't call this constructor or this class will not get
(-)a/openide.loaders/src/org/openide/awt/Toolbar.java (-1 / +5 lines)
Lines 101-107 Link Here
101
    
101
    
102
    static final long serialVersionUID = 5011742660516204764L;
102
    static final long serialVersionUID = 5011742660516204764L;
103
    static {
103
    static {
104
        AcceleratorBinding.init();
104
        try {
105
            Class.forName(AcceleratorBinding.class.getName());
106
        } catch (ClassNotFoundException x) {
107
            throw new ExceptionInInitializerError(x);
108
        }
105
    }
109
    }
106
110
107
    /** Create a new Toolbar with empty name. */
111
    /** Create a new Toolbar with empty name. */
(-)a/openide.loaders/test/unit/src/org/openide/loaders/SavableDataObjectTest.java (-6 / +5 lines)
Lines 49-54 Link Here
49
import org.netbeans.junit.MockServices;
49
import org.netbeans.junit.MockServices;
50
import org.netbeans.junit.NbTestCase;
50
import org.netbeans.junit.NbTestCase;
51
import org.netbeans.spi.actions.AbstractSavable;
51
import org.netbeans.spi.actions.AbstractSavable;
52
import org.openide.awt.Actions;
52
import org.openide.filesystems.FileObject;
53
import org.openide.filesystems.FileObject;
53
import org.openide.filesystems.FileUtil;
54
import org.openide.filesystems.FileUtil;
54
import org.openide.util.ContextAwareAction;
55
import org.openide.util.ContextAwareAction;
Lines 102-115 Link Here
102
    
103
    
103
    
104
    
104
    private static ContextAwareAction findSaveAction() {
105
    private static ContextAwareAction findSaveAction() {
105
        FileObject fo = FileUtil.getConfigFile("Actions/System/org-openide-actions-SaveAction.instance");
106
        Action a = Actions.forID("System", "org.openide.actions.SaveAction");
106
        assertNotNull("File found", fo);
107
        assertTrue(a instanceof ContextAwareAction);
107
        Object obj = fo.getAttribute("instanceCreate");
108
        return (ContextAwareAction) a;
108
        assertTrue("action found: " + obj, obj instanceof ContextAwareAction);
109
        return (ContextAwareAction)obj;
110
    }
109
    }
111
    private static Action findSaveAllAction() {
110
    private static Action findSaveAllAction() {
112
        Action a = FileUtil.getConfigObject("Actions/System/org-openide-actions-SaveAllAction.instance", Action.class);
111
        Action a = Actions.forID("System", "org.openide.actions.SaveAllAction");
113
        assertNotNull("action found: " + a, a);
112
        assertNotNull("action found: " + a, a);
114
        return a;
113
        return a;
115
    }
114
    }
(-)a/projectui/nbproject/project.xml (-1 / +1 lines)
Lines 142-148 Link Here
142
                    <build-prerequisite/>
142
                    <build-prerequisite/>
143
                    <compile-dependency/>
143
                    <compile-dependency/>
144
                    <run-dependency>
144
                    <run-dependency>
145
                        <specification-version>7.22</specification-version>
145
                        <specification-version>7.42</specification-version>
146
                    </run-dependency>
146
                    </run-dependency>
147
                </dependency>
147
                </dependency>
148
                <dependency>
148
                <dependency>
(-)a/projectui/src/org/netbeans/modules/project/ui/actions/Actions.java (-2 / +1 lines)
Lines 51-57 Link Here
51
import org.netbeans.modules.project.uiapi.ActionsFactory;
51
import org.netbeans.modules.project.uiapi.ActionsFactory;
52
import org.netbeans.spi.project.ActionProvider;
52
import org.netbeans.spi.project.ActionProvider;
53
import org.netbeans.spi.project.ui.support.ProjectActionPerformer;
53
import org.netbeans.spi.project.ui.support.ProjectActionPerformer;
54
import org.openide.filesystems.FileUtil;
55
import org.openide.util.ContextAwareAction;
54
import org.openide.util.ContextAwareAction;
56
import org.openide.util.Exceptions;
55
import org.openide.util.Exceptions;
57
import org.openide.util.ImageUtilities;
56
import org.openide.util.ImageUtilities;
Lines 236-242 Link Here
236
            null );
235
            null );
237
236
238
        try {
237
        try {
239
            final Action delete = FileUtil.getConfigObject("Actions/Edit/org-openide-actions-DeleteAction.instance", Action.class);
238
            final Action delete = org.openide.awt.Actions.forID("Edit", "org.openide.actions.DeleteAction");
240
            a.putValue(Action.ACCELERATOR_KEY, delete.getValue(Action.ACCELERATOR_KEY));
239
            a.putValue(Action.ACCELERATOR_KEY, delete.getValue(Action.ACCELERATOR_KEY));
241
            delete.addPropertyChangeListener(new PropertyChangeListener() {
240
            delete.addPropertyChangeListener(new PropertyChangeListener() {
242
                public @Override void propertyChange(PropertyChangeEvent evt) {
241
                public @Override void propertyChange(PropertyChangeEvent evt) {
(-)a/subversion/nbproject/project.xml (-1 / +1 lines)
Lines 181-187 Link Here
181
                    <build-prerequisite/>
181
                    <build-prerequisite/>
182
                    <compile-dependency/>
182
                    <compile-dependency/>
183
                    <run-dependency>
183
                    <run-dependency>
184
                        <specification-version>7.35</specification-version>
184
                        <specification-version>7.42</specification-version>
185
                    </run-dependency>
185
                    </run-dependency>
186
                </dependency>
186
                </dependency>
187
                <dependency>
187
                <dependency>
(-)a/subversion/src/org/netbeans/modules/subversion/Annotator.java (-4 / +2 lines)
Lines 83-91 Link Here
83
import org.netbeans.modules.subversion.ui.lock.LockAction;
83
import org.netbeans.modules.subversion.ui.lock.LockAction;
84
import org.netbeans.modules.subversion.ui.lock.UnlockAction;
84
import org.netbeans.modules.subversion.ui.lock.UnlockAction;
85
import org.netbeans.modules.subversion.ui.properties.VersioningInfoAction;
85
import org.netbeans.modules.subversion.ui.properties.VersioningInfoAction;
86
import org.openide.awt.AcceleratorBinding;
86
import org.openide.awt.Actions;
87
import org.openide.filesystems.FileObject;
88
import org.openide.filesystems.FileUtil;
89
import org.openide.util.ContextAwareAction;
87
import org.openide.util.ContextAwareAction;
90
import org.openide.util.ImageUtilities;
88
import org.openide.util.ImageUtilities;
91
import org.openide.util.lookup.Lookups;
89
import org.openide.util.lookup.Lookups;
Lines 480-486 Link Here
480
            ResourceBundle loc = NbBundle.getBundle(Annotator.class);
478
            ResourceBundle loc = NbBundle.getBundle(Annotator.class);
481
            Lookup context = ctx.getElements();
479
            Lookup context = ctx.getElements();
482
            if (noneVersioned) {
480
            if (noneVersioned) {
483
                Action a = FileUtil.getConfigObject("Actions/Subversion/org-netbeans-modules-subversion-ui-project-ImportAction.instance", Action.class);
481
                Action a = Actions.forID("Subversion", "org.netbeans.modules.subversion.ui.project.ImportAction");
484
                if(a instanceof ContextAwareAction) {
482
                if(a instanceof ContextAwareAction) {
485
                    a = ((ContextAwareAction)a).createContextAwareInstance(Lookups.singleton(ctx));
483
                    a = ((ContextAwareAction)a).createContextAwareInstance(Lookups.singleton(ctx));
486
                }            
484
                }            
(-)a/versioning.util/src/org/netbeans/modules/versioning/util/Utils.java (+1 lines)
Lines 1538-1543 Link Here
1538
    }
1538
    }
1539
    
1539
    
1540
    public static Action getAcceleratedAction(String path) {
1540
    public static Action getAcceleratedAction(String path) {
1541
        // or use Actions.forID
1541
        Action a = FileUtil.getConfigObject(path, Action.class);
1542
        Action a = FileUtil.getConfigObject(path, Action.class);
1542
        FileObject fo = FileUtil.getConfigFile(path);
1543
        FileObject fo = FileUtil.getConfigFile(path);
1543
        if(fo != null) {
1544
        if(fo != null) {

Return to bug 205798