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

(-)a/core.startup/src/org/netbeans/core/startup/ManifestSection.java (+1 lines)
Lines 268-273 Link Here
268
            // no section tag
268
            // no section tag
269
            return null;
269
            return null;
270
        } else if (sectionName.equalsIgnoreCase("Action")) { // NOI18N
270
        } else if (sectionName.equalsIgnoreCase("Action")) { // NOI18N
271
            warnObsolete(sectionName, module);
271
            return new ActionSection(name, module);
272
            return new ActionSection(name, module);
272
        } else if (sectionName.equalsIgnoreCase("Option")) { // NOI18N
273
        } else if (sectionName.equalsIgnoreCase("Option")) { // NOI18N
273
            warnObsolete(sectionName, module);
274
            warnObsolete(sectionName, module);
(-)a/diff/manifest.mf (-7 lines)
Lines 4-13 Link Here
4
OpenIDE-Module-Implementation-Version: 42
4
OpenIDE-Module-Implementation-Version: 42
5
OpenIDE-Module-Layer: org/netbeans/modules/diff/mf-layer.xml
5
OpenIDE-Module-Layer: org/netbeans/modules/diff/mf-layer.xml
6
AutoUpdate-Show-In-Client: false
6
AutoUpdate-Show-In-Client: false
7
8
Name: org/netbeans/modules/diff/DiffAction.class
9
OpenIDE-Module-Class: Action
10
11
Name: org/netbeans/modules/diff/PatchAction.class
12
OpenIDE-Module-Class: Action
13
(-)a/diff/nbproject/project.xml (-1 / +1 lines)
Lines 173-179 Link Here
173
                    <build-prerequisite/>
173
                    <build-prerequisite/>
174
                    <compile-dependency/>
174
                    <compile-dependency/>
175
                    <run-dependency>
175
                    <run-dependency>
176
                        <specification-version>6.2</specification-version>
176
                        <specification-version>6.15</specification-version>
177
                    </run-dependency>
177
                    </run-dependency>
178
                </dependency>
178
                </dependency>
179
                <dependency>
179
                <dependency>
(-)a/diff/src/org/netbeans/modules/diff/mf-layer.xml (+14 lines)
Lines 49-54 Link Here
49
          <file name="org-netbeans-modules-diff-PatchAction.instance"/>
49
          <file name="org-netbeans-modules-diff-PatchAction.instance"/>
50
      </folder>
50
      </folder>
51
  </folder>
51
  </folder>
52
  <folder name="UI">
53
      <folder name="ToolActions">
54
          <folder name="Files">
55
              <file name="org-netbeans-modules-diff-PatchAction.shadow">
56
                  <attr name="position" intvalue="100"/>
57
                  <attr name="originalFile" stringvalue="Actions/Tools/org-netbeans-modules-diff-PatchAction.instance"/>
58
              </file>
59
              <file name="org-netbeans-modules-diff-DiffAction.shadow">
60
                  <attr name="position" intvalue="200"/>
61
                  <attr name="originalFile" stringvalue="Actions/Tools/org-netbeans-modules-diff-DiffAction.instance"/>
62
              </file>
63
          </folder>
64
      </folder>
65
  </folder>
52
    
66
    
53
    <folder name="Services">
67
    <folder name="Services">
54
        <folder name="DiffProviders">
68
        <folder name="DiffProviders">
(-)a/favorites/manifest.mf (-4 lines)
Lines 5-11 Link Here
5
OpenIDE-Module-Layer: org/netbeans/modules/favorites/resources/layer.xml
5
OpenIDE-Module-Layer: org/netbeans/modules/favorites/resources/layer.xml
6
AutoUpdate-Show-In-Client: false
6
AutoUpdate-Show-In-Client: false
7
AutoUpdate-Essential-Module: true
7
AutoUpdate-Essential-Module: true
8
9
Name: org/netbeans/modules/favorites/Actions$Add.class
10
OpenIDE-Module-Class: Action
11
(-)a/favorites/nbproject/project.xml (-1 / +1 lines)
Lines 60-66 Link Here
60
                    <build-prerequisite/>
60
                    <build-prerequisite/>
61
                    <compile-dependency/>
61
                    <compile-dependency/>
62
                    <run-dependency>
62
                    <run-dependency>
63
                        <specification-version>6.2</specification-version>
63
                        <specification-version>6.15</specification-version>
64
                    </run-dependency>
64
                    </run-dependency>
65
                </dependency>
65
                </dependency>
66
                <dependency>
66
                <dependency>
(-)a/favorites/src/org/netbeans/modules/favorites/resources/layer.xml (+11 lines)
Lines 92-97 Link Here
92
            </file>
92
            </file>
93
            </folder>
93
            </folder>
94
    </folder>
94
    </folder>
95
96
  <folder name="UI">
97
      <folder name="ToolActions">
98
          <folder name="Files">
99
              <file name="org-netbeans-modules-favorites-Add.shadow">
100
                  <attr name="position" intvalue="300"/>
101
                  <attr name="originalFile" stringvalue="Actions/Window/org-netbeans-modules-favorites-Add.instance"/>
102
              </file>
103
          </folder>
104
      </folder>
105
  </folder>
95
    
106
    
96
    <!-- default workspaces, frames and their layout defined by core-->
107
    <!-- default workspaces, frames and their layout defined by core-->
97
    <folder name="Windows2">
108
    <folder name="Windows2">
(-)a/form/manifest.mf (-3 lines)
Lines 10-15 Link Here
10
  org.openide.modules.InstalledFileLocator
10
  org.openide.modules.InstalledFileLocator
11
OpenIDE-Module-Layer: org/netbeans/modules/form/resources/layer.xml
11
OpenIDE-Module-Layer: org/netbeans/modules/form/resources/layer.xml
12
AutoUpdate-Show-In-Client: false
12
AutoUpdate-Show-In-Client: false
13
14
Name: org/netbeans/modules/form/actions/InstallToPaletteAction.class
15
OpenIDE-Module-Class: Action
(-)a/form/nbproject/project.xml (-1 / +1 lines)
Lines 247-253 Link Here
247
                    <build-prerequisite/>
247
                    <build-prerequisite/>
248
                    <compile-dependency/>
248
                    <compile-dependency/>
249
                    <run-dependency>
249
                    <run-dependency>
250
                        <specification-version>6.2</specification-version>
250
                        <specification-version>6.15</specification-version>
251
                    </run-dependency>
251
                    </run-dependency>
252
                </dependency>
252
                </dependency>
253
                <dependency>
253
                <dependency>
(-)a/form/src/org/netbeans/modules/form/resources/layer.xml (+10 lines)
Lines 117-122 Link Here
117
        </folder>
117
        </folder>
118
    </folder>
118
    </folder>
119
119
120
    <folder name="UI">
121
        <folder name="ToolActions">
122
            <folder name="Java">
123
                <file name="org-netbeans-modules-form-actions-InstallToPaletteAction.shadow">
124
                    <attr name="originalFile" stringvalue="Actions/Form/org-netbeans-modules-form-actions-InstallToPaletteAction.instance"/>
125
                </file>
126
            </folder>
127
        </folder>
128
    </folder>
129
120
    <folder name="Menu">
130
    <folder name="Menu">
121
        <folder name="Window">
131
        <folder name="Window">
122
            <folder name="Navigator">
132
            <folder name="Navigator">
(-)a/j2ee.sun.appsrv81/manifest.mf (-3 lines)
Lines 7-12 Link Here
7
OpenIDE-Module: org.netbeans.modules.j2ee.sun.appsrv81/1
7
OpenIDE-Module: org.netbeans.modules.j2ee.sun.appsrv81/1
8
OpenIDE-Module-Provides: org.netbeans.modules.serverplugins.javaee
8
OpenIDE-Module-Provides: org.netbeans.modules.serverplugins.javaee
9
OpenIDE-Module-Recommends: org.netbeans.modules.identity.kit
9
OpenIDE-Module-Recommends: org.netbeans.modules.identity.kit
10
11
Name: org/netbeans/modules/j2ee/sun/ide/j2ee/runtime/actions/RunASVerifierAction.class
12
OpenIDE-Module-Class: Action
(-)a/j2ee.sun.appsrv81/nbproject/project.xml (-1 / +1 lines)
Lines 264-270 Link Here
264
                    <build-prerequisite/>
264
                    <build-prerequisite/>
265
                    <compile-dependency/>
265
                    <compile-dependency/>
266
                    <run-dependency>
266
                    <run-dependency>
267
                        <specification-version>6.2</specification-version>
267
                        <specification-version>6.15</specification-version>
268
                    </run-dependency>
268
                    </run-dependency>
269
                </dependency>
269
                </dependency>
270
                <dependency>
270
                <dependency>
(-)a/j2ee.sun.appsrv81/src/org/netbeans/modules/j2ee/sun/ide/j2ee/layer.xml (+10 lines)
Lines 309-314 Link Here
309
                <attr name="serverNodeHidden" boolvalue="true"/>
309
                <attr name="serverNodeHidden" boolvalue="true"/>
310
                <attr name="wizardMessage" bundlevalue="org.netbeans.modules.j2ee.sun.ide.Bundle#CTL_InfoWizard"/>
310
                <attr name="wizardMessage" bundlevalue="org.netbeans.modules.j2ee.sun.ide.Bundle#CTL_InfoWizard"/>
311
            </file>
311
            </file>
312
            <file name="org-netbeans-modules-j2ee-sun-ide-j2ee-runtime-actions-RunASVerifierAction.instance"/>
312
        </folder>        
313
        </folder>        
313
    </folder>
314
    </folder>
314
    <folder name="Servers">
315
    <folder name="Servers">
Lines 323-328 Link Here
323
        </folder>
324
        </folder>
324
    </folder>
325
    </folder>
325
326
327
    <folder name="UI">
328
        <folder name="ToolActions">
329
            <folder name="Java">
330
                <file name="org-netbeans-modules-j2ee-sun-ide-j2ee-runtime-actions-RunASVerifierAction.shadow">
331
                    <attr name="originalFile" stringvalue="Actions/Help/org-netbeans-modules-j2ee-sun-ide-j2ee-runtime-actions-RunASVerifierAction.instance"/>
332
                </file>
333
            </folder>
334
        </folder>
335
    </folder>
326
336
327
  <!--folder name="Menu">
337
  <!--folder name="Menu">
328
        <folder name="Tools">
338
        <folder name="Tools">
(-)a/java.hints/manifest.mf (-3 lines)
Lines 4-9 Link Here
4
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/java/hints/resources/Bundle.properties
4
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/java/hints/resources/Bundle.properties
5
OpenIDE-Module-Layer: org/netbeans/modules/java/hints/resources/layer.xml
5
OpenIDE-Module-Layer: org/netbeans/modules/java/hints/resources/layer.xml
6
AutoUpdate-Show-In-Client: false
6
AutoUpdate-Show-In-Client: false
7
8
Name: org/netbeans/modules/java/hints/analyzer/AnalyzeFolder$ToolsAction.class
9
OpenIDE-Module-Class: Action
(-)a/java.hints/nbproject/project.xml (-1 / +1 lines)
Lines 313-319 Link Here
313
                    <build-prerequisite/>
313
                    <build-prerequisite/>
314
                    <compile-dependency/>
314
                    <compile-dependency/>
315
                    <run-dependency>
315
                    <run-dependency>
316
                        <specification-version>6.12</specification-version>
316
                        <specification-version>6.15</specification-version>
317
                    </run-dependency>
317
                    </run-dependency>
318
                </dependency>
318
                </dependency>
319
                <dependency>
319
                <dependency>
(-)a/java.hints/src/org/netbeans/modules/java/hints/resources/layer.xml (+9 lines)
Lines 86-91 Link Here
86
            </folder>
86
            </folder>
87
        </folder>
87
        </folder>
88
    </folder>
88
    </folder>
89
    <folder name="UI">
90
        <folder name="ToolActions">
91
            <folder name="Java">
92
                <file name="org-netbeans-modules-java-hints-analyzer-AnalyzeFolder.shadow">
93
                    <attr name="originalFile" stringvalue="Actions/Source/org-netbeans-modules-java-hints-analyzer-AnalyzeFolder.instance"/>
94
                </file>
95
            </folder>
96
        </folder>
97
    </folder>
89
    <folder name="Editors">
98
    <folder name="Editors">
90
        <folder name="text">
99
        <folder name="text">
91
            <folder name="x-java">
100
            <folder name="x-java">
(-)a/junit/manifest.mf (-4 lines)
Lines 5-11 Link Here
5
OpenIDE-Module-Specification-Version: 2.35
5
OpenIDE-Module-Specification-Version: 2.35
6
OpenIDE-Module-Needs: javax.script.ScriptEngine.freemarker
6
OpenIDE-Module-Needs: javax.script.ScriptEngine.freemarker
7
AutoUpdate-Show-In-Client: false
7
AutoUpdate-Show-In-Client: false
8
9
Name: org/netbeans/modules/junit/CreateTestAction.class
10
OpenIDE-Module-Class: Action
11
(-)a/junit/nbproject/project.xml (+6 lines)
Lines 198-203 Link Here
198
                    </run-dependency>
198
                    </run-dependency>
199
                </dependency>
199
                </dependency>
200
                <dependency>
200
                <dependency>
201
                    <code-name-base>org.openide.actions</code-name-base>
202
                    <run-dependency>
203
                        <specification-version>6.15</specification-version>
204
                    </run-dependency>
205
                </dependency>
206
                <dependency>
201
                    <code-name-base>org.openide.awt</code-name-base>
207
                    <code-name-base>org.openide.awt</code-name-base>
202
                    <build-prerequisite/>
208
                    <build-prerequisite/>
203
                    <compile-dependency/>
209
                    <compile-dependency/>
(-)a/junit/src/org/netbeans/modules/junit/resources/layer.xml (+9 lines)
Lines 171-176 Link Here
171
            <file name="org-netbeans-modules-junit-CreateTestAction.instance"/>
171
            <file name="org-netbeans-modules-junit-CreateTestAction.instance"/>
172
        </folder>
172
        </folder>
173
    </folder>
173
    </folder>
174
    <folder name="UI">
175
        <folder name="ToolActions">
176
            <folder name="Java">
177
                <file name="org-netbeans-modules-junit-CreateTestAction.shadow">
178
                    <attr name="originalFile" stringvalue="Actions/JUnitTests/org-netbeans-modules-junit-CreateTestAction.instance"/>
179
                </file>
180
            </folder>
181
        </folder>
182
    </folder>
174
    
183
    
175
    <!-- shortcuts -->
184
    <!-- shortcuts -->
176
    <folder name="Shortcuts">
185
    <folder name="Shortcuts">
(-)a/openide.actions/apichanges.xml (+14 lines)
Lines 49-54 Link Here
49
<changes>
49
<changes>
50
<change>
50
<change>
51
      <api name="actions"/>
51
      <api name="actions"/>
52
      <summary><code>ToolsAction via layers</code></summary>
53
      <version major="6" minor="15"/>
54
      <date day="26" month="2" year="2010"/>
55
      <author login="jtulach"/>
56
      <compatibility addition="yes" binary="compatible" source="compatible" semantic="compatible" deprecation="yes" deletion="no" modification="no"/>
57
      <description>
58
          Register your actions for <code>ToolsAction</code> via
59
          layer, don't use the deprecated manifest style.
60
      </description>
61
      <class package="org.openide.actions" name="ToolsAction"/>
62
      <issue number="180979 "/>
63
</change>
64
<change>
65
      <api name="actions"/>
52
      <summary><code>HeapView</code> preserves its settings between sessions</summary>
66
      <summary><code>HeapView</code> preserves its settings between sessions</summary>
53
      <version major="6" minor="5"/>
67
      <version major="6" minor="5"/>
54
      <date day="24" month="6" year="2008"/>
68
      <date day="24" month="6" year="2008"/>
(-)a/openide.actions/arch.xml (-2 / +5 lines)
Lines 825-832 Link Here
825
        </question>
825
        </question>
826
-->
826
-->
827
<answer id="resources-layer">
827
<answer id="resources-layer">
828
No in fact. Just concrete action implementation provided by this module
828
    <api name="UI-ToolActions" group="layer" type="export" category="stable">
829
are typically used in xml layers.
829
        Register your <a href="@JDK@/javax/swing/Action.html">javax.swing.Action</a>
830
        instances in <code>UI/ToolActions</code> folder to make them known
831
        to <a href="@TOP@/org/openide/actions/ToolsAction.html">ToolsAction</a>.
832
    </api>
830
</answer>
833
</answer>
831
834
832
835
(-)a/openide.actions/manifest.mf (-1 / +1 lines)
Lines 2-6 Link Here
2
OpenIDE-Module: org.openide.actions
2
OpenIDE-Module: org.openide.actions
3
OpenIDE-Module-Localizing-Bundle: org/openide/actions/Bundle.properties
3
OpenIDE-Module-Localizing-Bundle: org/openide/actions/Bundle.properties
4
AutoUpdate-Essential-Module: true
4
AutoUpdate-Essential-Module: true
5
OpenIDE-Module-Specification-Version: 6.14
5
OpenIDE-Module-Specification-Version: 6.15
6
6
(-)a/openide.actions/src/org/openide/actions/ToolsAction.java (-14 / +62 lines)
Lines 54-59 Link Here
54
import javax.swing.*;
54
import javax.swing.*;
55
import javax.swing.event.*;
55
import javax.swing.event.*;
56
import org.openide.awt.DynamicMenuContent;
56
import org.openide.awt.DynamicMenuContent;
57
import org.openide.util.lookup.Lookups;
57
58
58
59
59
/** A "meta-action" that displays (in a submenu) a list of enabled actions provided by modules.
60
/** A "meta-action" that displays (in a submenu) a list of enabled actions provided by modules.
Lines 64-73 Link Here
64
* It is desirable for most nodes to include this action somewhere in their popup menu.
65
* It is desirable for most nodes to include this action somewhere in their popup menu.
65
*
66
*
66
* <p><em>Note:</em> you do not need to touch this class to add a service action!
67
* <p><em>Note:</em> you do not need to touch this class to add a service action!
67
* Just add the action to a module manifest in an <code>Action</code> section.
68
* Just register your action into <code>UI/ToolActions</code> layer folder
68
*
69
* (read <a href="@org-openide-modules@/org/openide/modules/doc-files/api.html#how-layer">more about layers</a>)
69
* <p>The list of registered service actions is provided to this action from the implementation
70
 * since version 6.15.
70
* by means of {@link ActionManager}.
71
*
71
*
72
* @author Jaroslav Tulach
72
* @author Jaroslav Tulach
73
*/
73
*/
Lines 90-123 Link Here
90
90
91
    /* @return name
91
    /* @return name
92
    */
92
    */
93
    @Override
93
    public String getName() {
94
    public String getName() {
94
        return getActionName();
95
        return getActionName();
95
    }
96
    }
96
97
97
    /* @return help for this action
98
    /* @return help for this action
98
    */
99
    */
100
    @Override
99
    public HelpCtx getHelpCtx() {
101
    public HelpCtx getHelpCtx() {
100
        return new HelpCtx(ToolsAction.class);
102
        return new HelpCtx(ToolsAction.class);
101
    }
103
    }
102
104
103
    /* @return menu presenter for the action
105
    /* @return menu presenter for the action
104
    */
106
    */
107
    @Override
105
    public JMenuItem getMenuPresenter() {
108
    public JMenuItem getMenuPresenter() {
106
        return new Inline(this);
109
        return new Inline(this);
107
    }
110
    }
108
111
109
    /* @return menu presenter for the action
112
    /* @return menu presenter for the action
110
    */
113
    */
114
    @Override
111
    public JMenuItem getPopupPresenter() {
115
    public JMenuItem getPopupPresenter() {
112
        return new Popup(this);
116
        return new Popup(this);
113
    }
117
    }
114
118
115
    /* Does nothing.
119
    /* Does nothing.
116
    */
120
    */
121
    @Override
117
    public void actionPerformed(java.awt.event.ActionEvent ev) {
122
    public void actionPerformed(java.awt.event.ActionEvent ev) {
118
        assert false;
123
        assert false;
119
    }
124
    }
120
125
126
    @Override
121
    public Action createContextAwareInstance(Lookup actionContext) {
127
    public Action createContextAwareInstance(Lookup actionContext) {
122
        return new DelegateAction(this, actionContext);
128
        return new DelegateAction(this, actionContext);
123
    }
129
    }
Lines 128-133 Link Here
128
        return NbBundle.getMessage(ToolsAction.class, "CTL_Tools");
134
        return NbBundle.getMessage(ToolsAction.class, "CTL_Tools");
129
    }
135
    }
130
136
137
    static List<Action> getToolActions() {
138
        ActionManager am = ActionManager.getDefault();
139
        List<Action> arr = new ArrayList<Action>();
140
        arr.addAll(Arrays.<Action>asList(am.getContextActions()));
141
142
        String pref = arr.isEmpty() ? null : "";
143
        Lookup.Result<Action> result = Lookups.forPath("UI/ToolActions").lookupResult(Action.class); // NOI18N
144
        for (Lookup.Item<Action> item : result.allItems()) {
145
            final Action action = item.getInstance();
146
            if (action == null) {
147
                continue;
148
            }
149
            String where = item.getId().replaceFirst("[^/]*$", ""); // NOI18N
150
            if (pref != null && !pref.equals(where)) {
151
                arr.add(null);
152
            }
153
            pref = where;
154
            arr.add(action);
155
        }
156
        return arr;
157
    }
158
159
131
    /** Implementation method that regenerates the items in the menu or
160
    /** Implementation method that regenerates the items in the menu or
132
    * in the array.
161
    * in the array.
133
    *
162
    *
Lines 135-143 Link Here
135
    * @param list (can be null)
164
    * @param list (can be null)
136
    */
165
    */
137
    private static List<JMenuItem> generate(Action toolsAction, boolean forMenu) {
166
    private static List<JMenuItem> generate(Action toolsAction, boolean forMenu) {
138
        ActionManager am = ActionManager.getDefault();
167
        List<Action> actions = getToolActions();
139
        SystemAction[] actions = am.getContextActions();
168
        List<JMenuItem> list = new ArrayList<JMenuItem>(actions.size());
140
        List<JMenuItem> list = new ArrayList<JMenuItem>(actions.length);
141
169
142
        boolean separator = false;
170
        boolean separator = false;
143
        boolean firstItemAdded = false; // flag to prevent adding separator before actual menu items
171
        boolean firstItemAdded = false; // flag to prevent adding separator before actual menu items
Lines 211-217 Link Here
211
    /** @deprecated Useless, see {@link ActionManager}. */
239
    /** @deprecated Useless, see {@link ActionManager}. */
212
    @Deprecated
240
    @Deprecated
213
    public static interface Model {
241
    public static interface Model {
214
        public SystemAction[] getActions();
242
        public Action[] getActions();
215
243
216
        public void addChangeListener(javax.swing.event.ChangeListener l);
244
        public void addChangeListener(javax.swing.event.ChangeListener l);
217
245
Lines 235-240 Link Here
235
263
236
264
237
        
265
        
266
        @Override
238
        public JComponent[] synchMenuPresenters(JComponent[] items) {
267
        public JComponent[] synchMenuPresenters(JComponent[] items) {
239
            if (timestamp == gl().getTimestamp()) {
268
            if (timestamp == gl().getTimestamp()) {
240
                return items;
269
                return items;
Lines 246-251 Link Here
246
        }
275
        }
247
        
276
        
248
        
277
        
278
        @Override
249
        public JComponent[] getMenuPresenters() {
279
        public JComponent[] getMenuPresenters() {
250
            return synchMenuPresenters(new JComponent[0]);
280
            return synchMenuPresenters(new JComponent[0]);
251
        }        
281
        }        
Lines 271-281 Link Here
271
        }
301
        }
272
302
273
        
303
        
304
        @Override
274
        public JComponent[] synchMenuPresenters(JComponent[] items) {
305
        public JComponent[] synchMenuPresenters(JComponent[] items) {
275
            return gl().isPopupEnabled(toolsAction) ? new JMenuItem[] { menu } : new JMenuItem[0];
306
            return gl().isPopupEnabled(toolsAction) ? new JMenuItem[] { menu } : new JMenuItem[0];
276
        }
307
        }
277
        
308
        
278
        
309
        
310
        @Override
279
        public JComponent[] getMenuPresenters() {
311
        public JComponent[] getMenuPresenters() {
280
            return synchMenuPresenters(new JComponent[0]);
312
            return synchMenuPresenters(new JComponent[0]);
281
        }                
313
        }                
Lines 291-296 Link Here
291
                super(getActionName());
323
                super(getActionName());
292
            }
324
            }
293
325
326
            @Override
294
            public JPopupMenu getPopupMenu() {
327
            public JPopupMenu getPopupMenu() {
295
                JPopupMenu popup = super.getPopupMenu();
328
                JPopupMenu popup = super.getPopupMenu();
296
                fillSubmenu(popup);
329
                fillSubmenu(popup);
Lines 326-337 Link Here
326
                }
359
                }
327
            }
360
            }
328
361
362
            @Override
329
            public void popupMenuCanceled(PopupMenuEvent e) {
363
            public void popupMenuCanceled(PopupMenuEvent e) {
330
            }
364
            }
331
365
366
            @Override
332
            public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
367
            public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
333
            }
368
            }
334
369
370
            @Override
335
            public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
371
            public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
336
                lastPopup.removePopupMenuListener(this);
372
                lastPopup.removePopupMenuListener(this);
337
                lastPopup = null; // clear the status and stop listening
373
                lastPopup = null; // clear the status and stop listening
Lines 344-350 Link Here
344
    private static class G implements PropertyChangeListener {
380
    private static class G implements PropertyChangeListener {
345
        public static final String PROP_STATE = "actionsState"; // NOI18N
381
        public static final String PROP_STATE = "actionsState"; // NOI18N
346
        private int timestamp = 1;
382
        private int timestamp = 1;
347
        private SystemAction[] actions = null;
383
        private Action[] actions = null;
348
        private PropertyChangeSupport supp = new PropertyChangeSupport(this);
384
        private PropertyChangeSupport supp = new PropertyChangeSupport(this);
349
385
350
        public G() {
386
        public G() {
Lines 369-379 Link Here
369
            timestamp++;
405
            timestamp++;
370
406
371
            // deregister all actions listeners
407
            // deregister all actions listeners
372
            SystemAction[] copy = actions;
408
            Action[] copy = actions;
373
409
374
            if (copy != null) {
410
            if (copy != null) {
375
                for (int i = 0; i < copy.length; i++) {
411
                for (int i = 0; i < copy.length; i++) {
376
                    SystemAction act = copy[i];
412
                    Action act = copy[i];
377
413
378
                    if (act != null) {
414
                    if (act != null) {
379
                        act.removePropertyChangeListener(this);
415
                        act.removePropertyChangeListener(this);
Lines 385-391 Link Here
385
            copy = am.getContextActions();
421
            copy = am.getContextActions();
386
422
387
            for (int i = 0; i < copy.length; i++) {
423
            for (int i = 0; i < copy.length; i++) {
388
                SystemAction act = copy[i];
424
                Action act = copy[i];
389
425
390
                if (act != null) {
426
                if (act != null) {
391
                    act.addPropertyChangeListener(this);
427
                    act.addPropertyChangeListener(this);
Lines 402-413 Link Here
402
            firePropertyChange(PROP_STATE, null, null); // tell the world
438
            firePropertyChange(PROP_STATE, null, null); // tell the world
403
        }
439
        }
404
440
441
        @Override
405
        public void propertyChange(PropertyChangeEvent ev) {
442
        public void propertyChange(PropertyChangeEvent ev) {
406
            String prop = ev.getPropertyName();
443
            String prop = ev.getPropertyName();
407
444
408
            if ((prop == null) || prop.equals(ActionManager.PROP_CONTEXT_ACTIONS)) {
445
            if ((prop == null) || prop.equals(ActionManager.PROP_CONTEXT_ACTIONS)) {
409
                actionsListChanged();
446
                actionsListChanged();
410
            } else if (prop.equals(SystemAction.PROP_ENABLED)) {
447
            } else if (prop.equals("enabled")) {
411
                actionStateChanged();
448
                actionStateChanged();
412
            }
449
            }
413
        }
450
        }
Lines 417-423 Link Here
417
         */
454
         */
418
        private boolean isPopupEnabled(Action toolsAction) {
455
        private boolean isPopupEnabled(Action toolsAction) {
419
            boolean en = false;
456
            boolean en = false;
420
            SystemAction[] copy = actions;
457
            Action[] copy = actions;
421
458
422
            // Get action conext.
459
            // Get action conext.
423
            Lookup lookup;
460
            Lookup lookup;
Lines 470-517 Link Here
470
        }
507
        }
471
508
472
        /** Overrides superclass method, adds delegate description. */
509
        /** Overrides superclass method, adds delegate description. */
510
        @Override
473
        public String toString() {
511
        public String toString() {
474
            return super.toString() + "[delegate=" + delegate + "]"; // NOI18N
512
            return super.toString() + "[delegate=" + delegate + "]"; // NOI18N
475
        }
513
        }
476
514
477
        /** Implements <code>Lookup.Provider</code>. */
515
        /** Implements <code>Lookup.Provider</code>. */
516
        @Override
478
        public Lookup getLookup() {
517
        public Lookup getLookup() {
479
            return lookup;
518
            return lookup;
480
        }
519
        }
481
520
521
        @Override
482
        public void actionPerformed(java.awt.event.ActionEvent e) {
522
        public void actionPerformed(java.awt.event.ActionEvent e) {
483
        }
523
        }
484
524
525
        @Override
485
        public void putValue(String key, Object o) {
526
        public void putValue(String key, Object o) {
486
        }
527
        }
487
528
529
        @Override
488
        public Object getValue(String key) {
530
        public Object getValue(String key) {
489
            return delegate.getValue(key);
531
            return delegate.getValue(key);
490
        }
532
        }
491
533
534
        @Override
492
        public boolean isEnabled() {
535
        public boolean isEnabled() {
493
            // Irrelevant see G#isPopupEnabled(..).
536
            // Irrelevant see G#isPopupEnabled(..).
494
            return delegate.isEnabled();
537
            return delegate.isEnabled();
495
        }
538
        }
496
539
540
        @Override
497
        public void setEnabled(boolean b) {
541
        public void setEnabled(boolean b) {
498
            // Irrelevant see G#isPopupEnabled(..).
542
            // Irrelevant see G#isPopupEnabled(..).
499
        }
543
        }
500
544
545
        @Override
501
        public void addPropertyChangeListener(PropertyChangeListener listener) {
546
        public void addPropertyChangeListener(PropertyChangeListener listener) {
502
            support.addPropertyChangeListener(listener);
547
            support.addPropertyChangeListener(listener);
503
        }
548
        }
504
549
550
        @Override
505
        public void removePropertyChangeListener(PropertyChangeListener listener) {
551
        public void removePropertyChangeListener(PropertyChangeListener listener) {
506
            support.removePropertyChangeListener(listener);
552
            support.removePropertyChangeListener(listener);
507
        }
553
        }
508
554
509
        /** Implements <code>Presenter.Menu</code>. */
555
        /** Implements <code>Presenter.Menu</code>. */
556
        @Override
510
        public javax.swing.JMenuItem getMenuPresenter() {
557
        public javax.swing.JMenuItem getMenuPresenter() {
511
            return new Inline(this);
558
            return new Inline(this);
512
        }
559
        }
513
560
514
        /** Implements <code>Presenter.Popup</code>. */
561
        /** Implements <code>Presenter.Popup</code>. */
562
        @Override
515
        public javax.swing.JMenuItem getPopupPresenter() {
563
        public javax.swing.JMenuItem getPopupPresenter() {
516
            return new ToolsAction.Popup(this);
564
            return new ToolsAction.Popup(this);
517
        }
565
        }
(-)946c91cb4e6c (+80 lines)
Added 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.actions;
41
42
import javax.swing.Action;
43
import java.util.List;
44
import org.openide.filesystems.FileUtil;
45
import org.openide.filesystems.FileObject;
46
import org.netbeans.junit.NbTestCase;
47
import static org.junit.Assert.*;
48
49
/**
50
 *
51
 * @author Jaroslav Tulach <jtulach@netbeans.org>
52
 */
53
public class ToolsActionTest extends NbTestCase {
54
55
    public ToolsActionTest(String n) {
56
        super(n);
57
    }
58
59
    public void testActionReadFromLayer () throws Exception {
60
        CopyAction copy = CopyAction.get(CopyAction.class);
61
        CutAction cut = CutAction.get(CutAction.class);
62
        PasteAction paste = PasteAction.get(PasteAction.class);
63
64
        FileObject fo = FileUtil.createFolder(FileUtil.getConfigRoot(), "UI/ToolActions");
65
        assertNotNull("ToolActions folder found", fo);
66
67
        fo.createFolder("Cat1").createData("org-openide-actions-CutAction.instance").setAttribute("position", 100);
68
        fo.getFileObject("Cat1").createData("org-openide-actions-PasteAction.instance").setAttribute("position", 200);
69
        fo.createFolder("Cat2").createData("org-openide-actions-CopyAction.instance");
70
71
        List<Action> ToolActions = ToolsAction.getToolActions();
72
        assertEquals("Four actions: " + ToolActions, 4, ToolActions.size());
73
        assertEquals("Cut first", cut, ToolActions.get(0));
74
        assertEquals("Paste snd", paste, ToolActions.get(1));
75
        assertEquals("Separator in middle", null, ToolActions.get(2));
76
        assertEquals("Copy last", copy, ToolActions.get(3));
77
78
    }
79
80
}
(-)a/openide.modules/src/org/openide/modules/doc-files/api.html (-9 / +4 lines)
Lines 1135-1149 Link Here
1135
1135
1136
<h3><a name="sec-action">Action</a></h3>
1136
<h3><a name="sec-action">Action</a></h3>
1137
1137
1138
The class <code>Action</code> installs a system action into NetBeans. Refer to the
1138
Old and deprecated class <code>Action</code>
1139
1139
installs a system action into NetBeans. Since NetBeans 6.9 prefer
1140
<a href="@org-openide-actions@/org/openide/actions/doc-files/api.html">Actions API</a>
1140
registration via layers (folder UI/ToolsAction) to make
1141
1141
your action available as
1142
for details on how to create an action. The class must implement
1143
1144
<a href="@org-openide-util@/org/openide/util/actions/SystemAction.html"><code>SystemAction</code></a>.
1145
1146
<p>By using this manifest section, your action will be available as
1147
a "tool", i.e. it will appear (when enabled) in a list of all
1142
a "tool", i.e. it will appear (when enabled) in a list of all
1148
extension tools in any popup menu (etc.) using
1143
extension tools in any popup menu (etc.) using
1149
1144
(-)a/php.project/manifest.mf (-3 lines)
Lines 4-9 Link Here
4
OpenIDE-Module: org.netbeans.modules.php.project
4
OpenIDE-Module: org.netbeans.modules.php.project
5
OpenIDE-Module-Layer: org/netbeans/modules/php/project/resources/layer.xml
5
OpenIDE-Module-Layer: org/netbeans/modules/php/project/resources/layer.xml
6
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/php/project/resources/Bundle.properties
6
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/php/project/resources/Bundle.properties
7
8
Name: org/netbeans/modules/php/project/ui/actions/tests/CreateTestsAction.class
9
OpenIDE-Module-Class: Action
(-)a/php.project/nbproject/project.xml (-1 / +1 lines)
Lines 243-249 Link Here
243
                    <build-prerequisite/>
243
                    <build-prerequisite/>
244
                    <compile-dependency/>
244
                    <compile-dependency/>
245
                    <run-dependency>
245
                    <run-dependency>
246
                        <specification-version>6.6</specification-version>
246
                        <specification-version>6.15</specification-version>
247
                    </run-dependency>
247
                    </run-dependency>
248
                </dependency>
248
                </dependency>
249
                <dependency>
249
                <dependency>
(-)a/php.project/src/org/netbeans/modules/php/project/resources/layer.xml (+9 lines)
Lines 55-60 Link Here
55
            <file name="org-netbeans-modules-php-project-ui-actions-tests-CreateTestsAction.instance"/>
55
            <file name="org-netbeans-modules-php-project-ui-actions-tests-CreateTestsAction.instance"/>
56
        </folder>
56
        </folder>
57
    </folder>
57
    </folder>
58
    <folder name="UI">
59
        <folder name="ToolActions">
60
            <folder name="PHP">
61
                <file name="org-netbeans-modules-php-project-ui-actions-tests-CreateTestsAction.shadow">
62
                    <attr name="originalFile" stringvalue="Actions/JUnitTests/org-netbeans-modules-php-project-ui-actions-tests-CreateTestsAction.instance"/>
63
                </file>
64
            </folder>
65
        </folder>
66
    </folder>
58
67
59
    <!-- uncomment/change default values for actions Download, Upload
68
    <!-- uncomment/change default values for actions Download, Upload
60
    <folder name="Shortcuts">
69
    <folder name="Shortcuts">

Return to bug 180979