diff -r 946c91cb4e6c core.startup/src/org/netbeans/core/startup/ManifestSection.java --- a/core.startup/src/org/netbeans/core/startup/ManifestSection.java Sun Feb 21 17:41:27 2010 +0100 +++ b/core.startup/src/org/netbeans/core/startup/ManifestSection.java Mon Feb 22 15:17:50 2010 +0100 @@ -268,6 +268,7 @@ // no section tag return null; } else if (sectionName.equalsIgnoreCase("Action")) { // NOI18N + warnObsolete(sectionName, module); return new ActionSection(name, module); } else if (sectionName.equalsIgnoreCase("Option")) { // NOI18N warnObsolete(sectionName, module); diff -r 946c91cb4e6c diff/manifest.mf --- a/diff/manifest.mf Sun Feb 21 17:41:27 2010 +0100 +++ b/diff/manifest.mf Mon Feb 22 15:17:50 2010 +0100 @@ -4,10 +4,3 @@ OpenIDE-Module-Implementation-Version: 42 OpenIDE-Module-Layer: org/netbeans/modules/diff/mf-layer.xml AutoUpdate-Show-In-Client: false - -Name: org/netbeans/modules/diff/DiffAction.class -OpenIDE-Module-Class: Action - -Name: org/netbeans/modules/diff/PatchAction.class -OpenIDE-Module-Class: Action - diff -r 946c91cb4e6c diff/nbproject/project.xml --- a/diff/nbproject/project.xml Sun Feb 21 17:41:27 2010 +0100 +++ b/diff/nbproject/project.xml Mon Feb 22 15:17:50 2010 +0100 @@ -173,7 +173,7 @@ - 6.2 + 6.15 diff -r 946c91cb4e6c diff/src/org/netbeans/modules/diff/mf-layer.xml --- a/diff/src/org/netbeans/modules/diff/mf-layer.xml Sun Feb 21 17:41:27 2010 +0100 +++ b/diff/src/org/netbeans/modules/diff/mf-layer.xml Mon Feb 22 15:17:50 2010 +0100 @@ -49,6 +49,20 @@ + + + + + + + + + + + + + + diff -r 946c91cb4e6c favorites/manifest.mf --- a/favorites/manifest.mf Sun Feb 21 17:41:27 2010 +0100 +++ b/favorites/manifest.mf Mon Feb 22 15:17:50 2010 +0100 @@ -5,7 +5,3 @@ OpenIDE-Module-Layer: org/netbeans/modules/favorites/resources/layer.xml AutoUpdate-Show-In-Client: false AutoUpdate-Essential-Module: true - -Name: org/netbeans/modules/favorites/Actions$Add.class -OpenIDE-Module-Class: Action - diff -r 946c91cb4e6c favorites/nbproject/project.xml --- a/favorites/nbproject/project.xml Sun Feb 21 17:41:27 2010 +0100 +++ b/favorites/nbproject/project.xml Mon Feb 22 15:17:50 2010 +0100 @@ -60,7 +60,7 @@ - 6.2 + 6.15 diff -r 946c91cb4e6c favorites/src/org/netbeans/modules/favorites/resources/layer.xml --- a/favorites/src/org/netbeans/modules/favorites/resources/layer.xml Sun Feb 21 17:41:27 2010 +0100 +++ b/favorites/src/org/netbeans/modules/favorites/resources/layer.xml Mon Feb 22 15:17:50 2010 +0100 @@ -92,6 +92,17 @@ + + + + + + + + + + + diff -r 946c91cb4e6c form/manifest.mf --- a/form/manifest.mf Sun Feb 21 17:41:27 2010 +0100 +++ b/form/manifest.mf Mon Feb 22 15:17:50 2010 +0100 @@ -10,6 +10,3 @@ org.openide.modules.InstalledFileLocator OpenIDE-Module-Layer: org/netbeans/modules/form/resources/layer.xml AutoUpdate-Show-In-Client: false - -Name: org/netbeans/modules/form/actions/InstallToPaletteAction.class -OpenIDE-Module-Class: Action diff -r 946c91cb4e6c form/nbproject/project.xml --- a/form/nbproject/project.xml Sun Feb 21 17:41:27 2010 +0100 +++ b/form/nbproject/project.xml Mon Feb 22 15:17:50 2010 +0100 @@ -247,7 +247,7 @@ - 6.2 + 6.15 diff -r 946c91cb4e6c form/src/org/netbeans/modules/form/resources/layer.xml --- a/form/src/org/netbeans/modules/form/resources/layer.xml Sun Feb 21 17:41:27 2010 +0100 +++ b/form/src/org/netbeans/modules/form/resources/layer.xml Mon Feb 22 15:17:50 2010 +0100 @@ -117,6 +117,16 @@ + + + + + + + + + + diff -r 946c91cb4e6c j2ee.sun.appsrv81/manifest.mf --- a/j2ee.sun.appsrv81/manifest.mf Sun Feb 21 17:41:27 2010 +0100 +++ b/j2ee.sun.appsrv81/manifest.mf Mon Feb 22 15:17:50 2010 +0100 @@ -7,6 +7,3 @@ OpenIDE-Module: org.netbeans.modules.j2ee.sun.appsrv81/1 OpenIDE-Module-Provides: org.netbeans.modules.serverplugins.javaee OpenIDE-Module-Recommends: org.netbeans.modules.identity.kit - -Name: org/netbeans/modules/j2ee/sun/ide/j2ee/runtime/actions/RunASVerifierAction.class -OpenIDE-Module-Class: Action diff -r 946c91cb4e6c j2ee.sun.appsrv81/nbproject/project.xml --- a/j2ee.sun.appsrv81/nbproject/project.xml Sun Feb 21 17:41:27 2010 +0100 +++ b/j2ee.sun.appsrv81/nbproject/project.xml Mon Feb 22 15:17:50 2010 +0100 @@ -264,7 +264,7 @@ - 6.2 + 6.15 diff -r 946c91cb4e6c j2ee.sun.appsrv81/src/org/netbeans/modules/j2ee/sun/ide/j2ee/layer.xml --- a/j2ee.sun.appsrv81/src/org/netbeans/modules/j2ee/sun/ide/j2ee/layer.xml Sun Feb 21 17:41:27 2010 +0100 +++ b/j2ee.sun.appsrv81/src/org/netbeans/modules/j2ee/sun/ide/j2ee/layer.xml Mon Feb 22 15:17:50 2010 +0100 @@ -309,6 +309,7 @@ + @@ -323,6 +324,15 @@ + + + + + + + + + diff -r 946c91cb4e6c openide.actions/apichanges.xml --- a/openide.actions/apichanges.xml Sun Feb 21 17:41:27 2010 +0100 +++ b/openide.actions/apichanges.xml Mon Feb 22 15:17:50 2010 +0100 @@ -49,6 +49,20 @@ + ToolsAction via layers + + + + + + Register your actions for ToolsAction via + layer, don't use the deprecated manifest style. + + + + + + HeapView preserves its settings between sessions diff -r 946c91cb4e6c openide.actions/arch.xml --- a/openide.actions/arch.xml Sun Feb 21 17:41:27 2010 +0100 +++ b/openide.actions/arch.xml Mon Feb 22 15:17:50 2010 +0100 @@ -825,8 +825,11 @@ --> -No in fact. Just concrete action implementation provided by this module -are typically used in xml layers. + + Register your javax.swing.Action + instances in UI/ToolActions folder to make them known + to ToolsAction. + diff -r 946c91cb4e6c openide.actions/manifest.mf --- a/openide.actions/manifest.mf Sun Feb 21 17:41:27 2010 +0100 +++ b/openide.actions/manifest.mf Mon Feb 22 15:17:50 2010 +0100 @@ -2,5 +2,5 @@ OpenIDE-Module: org.openide.actions OpenIDE-Module-Localizing-Bundle: org/openide/actions/Bundle.properties AutoUpdate-Essential-Module: true -OpenIDE-Module-Specification-Version: 6.14 +OpenIDE-Module-Specification-Version: 6.15 diff -r 946c91cb4e6c openide.actions/src/org/openide/actions/ToolsAction.java --- a/openide.actions/src/org/openide/actions/ToolsAction.java Sun Feb 21 17:41:27 2010 +0100 +++ b/openide.actions/src/org/openide/actions/ToolsAction.java Mon Feb 22 15:17:50 2010 +0100 @@ -54,6 +54,7 @@ import javax.swing.*; import javax.swing.event.*; import org.openide.awt.DynamicMenuContent; +import org.openide.util.lookup.Lookups; /** A "meta-action" that displays (in a submenu) a list of enabled actions provided by modules. @@ -64,10 +65,9 @@ * It is desirable for most nodes to include this action somewhere in their popup menu. * *

Note: you do not need to touch this class to add a service action! -* Just add the action to a module manifest in an Action section. -* -*

The list of registered service actions is provided to this action from the implementation -* by means of {@link ActionManager}. +* Just register your action into UI/ToolActions layer folder +* (read more about layers) + * since version 6.15. * * @author Jaroslav Tulach */ @@ -90,34 +90,40 @@ /* @return name */ + @Override public String getName() { return getActionName(); } /* @return help for this action */ + @Override public HelpCtx getHelpCtx() { return new HelpCtx(ToolsAction.class); } /* @return menu presenter for the action */ + @Override public JMenuItem getMenuPresenter() { return new Inline(this); } /* @return menu presenter for the action */ + @Override public JMenuItem getPopupPresenter() { return new Popup(this); } /* Does nothing. */ + @Override public void actionPerformed(java.awt.event.ActionEvent ev) { assert false; } + @Override public Action createContextAwareInstance(Lookup actionContext) { return new DelegateAction(this, actionContext); } @@ -128,6 +134,29 @@ return NbBundle.getMessage(ToolsAction.class, "CTL_Tools"); } + static List getToolActions() { + ActionManager am = ActionManager.getDefault(); + List arr = new ArrayList(); + arr.addAll(Arrays.asList(am.getContextActions())); + + String pref = arr.isEmpty() ? null : ""; + Lookup.Result result = Lookups.forPath("UI/ToolActions").lookupResult(Action.class); // NOI18N + for (Lookup.Item item : result.allItems()) { + final Action action = item.getInstance(); + if (action == null) { + continue; + } + String where = item.getId().replaceFirst("[^/]*$", ""); // NOI18N + if (pref != null && !pref.equals(where)) { + arr.add(null); + } + pref = where; + arr.add(action); + } + return arr; + } + + /** Implementation method that regenerates the items in the menu or * in the array. * @@ -135,9 +164,8 @@ * @param list (can be null) */ private static List generate(Action toolsAction, boolean forMenu) { - ActionManager am = ActionManager.getDefault(); - SystemAction[] actions = am.getContextActions(); - List list = new ArrayList(actions.length); + List actions = getToolActions(); + List list = new ArrayList(actions.size()); boolean separator = false; boolean firstItemAdded = false; // flag to prevent adding separator before actual menu items @@ -211,7 +239,7 @@ /** @deprecated Useless, see {@link ActionManager}. */ @Deprecated public static interface Model { - public SystemAction[] getActions(); + public Action[] getActions(); public void addChangeListener(javax.swing.event.ChangeListener l); @@ -235,6 +263,7 @@ + @Override public JComponent[] synchMenuPresenters(JComponent[] items) { if (timestamp == gl().getTimestamp()) { return items; @@ -246,6 +275,7 @@ } + @Override public JComponent[] getMenuPresenters() { return synchMenuPresenters(new JComponent[0]); } @@ -271,11 +301,13 @@ } + @Override public JComponent[] synchMenuPresenters(JComponent[] items) { return gl().isPopupEnabled(toolsAction) ? new JMenuItem[] { menu } : new JMenuItem[0]; } + @Override public JComponent[] getMenuPresenters() { return synchMenuPresenters(new JComponent[0]); } @@ -291,6 +323,7 @@ super(getActionName()); } + @Override public JPopupMenu getPopupMenu() { JPopupMenu popup = super.getPopupMenu(); fillSubmenu(popup); @@ -326,12 +359,15 @@ } } + @Override public void popupMenuCanceled(PopupMenuEvent e) { } + @Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) { } + @Override public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { lastPopup.removePopupMenuListener(this); lastPopup = null; // clear the status and stop listening @@ -344,7 +380,7 @@ private static class G implements PropertyChangeListener { public static final String PROP_STATE = "actionsState"; // NOI18N private int timestamp = 1; - private SystemAction[] actions = null; + private Action[] actions = null; private PropertyChangeSupport supp = new PropertyChangeSupport(this); public G() { @@ -369,11 +405,11 @@ timestamp++; // deregister all actions listeners - SystemAction[] copy = actions; + Action[] copy = actions; if (copy != null) { for (int i = 0; i < copy.length; i++) { - SystemAction act = copy[i]; + Action act = copy[i]; if (act != null) { act.removePropertyChangeListener(this); @@ -385,7 +421,7 @@ copy = am.getContextActions(); for (int i = 0; i < copy.length; i++) { - SystemAction act = copy[i]; + Action act = copy[i]; if (act != null) { act.addPropertyChangeListener(this); @@ -402,12 +438,13 @@ firePropertyChange(PROP_STATE, null, null); // tell the world } + @Override public void propertyChange(PropertyChangeEvent ev) { String prop = ev.getPropertyName(); if ((prop == null) || prop.equals(ActionManager.PROP_CONTEXT_ACTIONS)) { actionsListChanged(); - } else if (prop.equals(SystemAction.PROP_ENABLED)) { + } else if (prop.equals("enabled")) { actionStateChanged(); } } @@ -417,7 +454,7 @@ */ private boolean isPopupEnabled(Action toolsAction) { boolean en = false; - SystemAction[] copy = actions; + Action[] copy = actions; // Get action conext. Lookup lookup; @@ -470,48 +507,59 @@ } /** Overrides superclass method, adds delegate description. */ + @Override public String toString() { return super.toString() + "[delegate=" + delegate + "]"; // NOI18N } /** Implements Lookup.Provider. */ + @Override public Lookup getLookup() { return lookup; } + @Override public void actionPerformed(java.awt.event.ActionEvent e) { } + @Override public void putValue(String key, Object o) { } + @Override public Object getValue(String key) { return delegate.getValue(key); } + @Override public boolean isEnabled() { // Irrelevant see G#isPopupEnabled(..). return delegate.isEnabled(); } + @Override public void setEnabled(boolean b) { // Irrelevant see G#isPopupEnabled(..). } + @Override public void addPropertyChangeListener(PropertyChangeListener listener) { support.addPropertyChangeListener(listener); } + @Override public void removePropertyChangeListener(PropertyChangeListener listener) { support.removePropertyChangeListener(listener); } /** Implements Presenter.Menu. */ + @Override public javax.swing.JMenuItem getMenuPresenter() { return new Inline(this); } /** Implements Presenter.Popup. */ + @Override public javax.swing.JMenuItem getPopupPresenter() { return new ToolsAction.Popup(this); } diff -r 946c91cb4e6c openide.actions/test/unit/src/org/openide/actions/ToolsActionTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/openide.actions/test/unit/src/org/openide/actions/ToolsActionTest.java Mon Feb 22 15:17:50 2010 +0100 @@ -0,0 +1,80 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2010 Sun Microsystems, Inc. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): + * + * Portions Copyrighted 2010 Sun Microsystems, Inc. + */ + +package org.openide.actions; + +import javax.swing.Action; +import java.util.List; +import org.openide.filesystems.FileUtil; +import org.openide.filesystems.FileObject; +import org.netbeans.junit.NbTestCase; +import static org.junit.Assert.*; + +/** + * + * @author Jaroslav Tulach + */ +public class ToolsActionTest extends NbTestCase { + + public ToolsActionTest(String n) { + super(n); + } + + public void testActionReadFromLayer () throws Exception { + CopyAction copy = CopyAction.get(CopyAction.class); + CutAction cut = CutAction.get(CutAction.class); + PasteAction paste = PasteAction.get(PasteAction.class); + + FileObject fo = FileUtil.createFolder(FileUtil.getConfigRoot(), "UI/ToolActions"); + assertNotNull("ToolActions folder found", fo); + + fo.createFolder("Cat1").createData("org-openide-actions-CutAction.instance").setAttribute("position", 100); + fo.getFileObject("Cat1").createData("org-openide-actions-PasteAction.instance").setAttribute("position", 200); + fo.createFolder("Cat2").createData("org-openide-actions-CopyAction.instance"); + + List ToolActions = ToolsAction.getToolActions(); + assertEquals("Four actions: " + ToolActions, 4, ToolActions.size()); + assertEquals("Cut first", cut, ToolActions.get(0)); + assertEquals("Paste snd", paste, ToolActions.get(1)); + assertEquals("Separator in middle", null, ToolActions.get(2)); + assertEquals("Copy last", copy, ToolActions.get(3)); + + } + +} \ No newline at end of file diff -r 946c91cb4e6c openide.modules/src/org/openide/modules/doc-files/api.html --- a/openide.modules/src/org/openide/modules/doc-files/api.html Sun Feb 21 17:41:27 2010 +0100 +++ b/openide.modules/src/org/openide/modules/doc-files/api.html Mon Feb 22 15:17:50 2010 +0100 @@ -1135,15 +1135,10 @@

Action

-The class Action installs a system action into NetBeans. Refer to the - -Actions API - -for details on how to create an action. The class must implement - -SystemAction. - -

By using this manifest section, your action will be available as +Old and deprecated class Action +installs a system action into NetBeans. Since NetBeans 6.9 prefer +registration via layers (folder UI/ToolsAction) to make +your action available as a "tool", i.e. it will appear (when enabled) in a list of all extension tools in any popup menu (etc.) using diff -r 946c91cb4e6c php.project/manifest.mf --- a/php.project/manifest.mf Sun Feb 21 17:41:27 2010 +0100 +++ b/php.project/manifest.mf Mon Feb 22 15:17:50 2010 +0100 @@ -4,6 +4,3 @@ OpenIDE-Module: org.netbeans.modules.php.project OpenIDE-Module-Layer: org/netbeans/modules/php/project/resources/layer.xml OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/php/project/resources/Bundle.properties - -Name: org/netbeans/modules/php/project/ui/actions/tests/CreateTestsAction.class -OpenIDE-Module-Class: Action diff -r 946c91cb4e6c php.project/nbproject/project.xml --- a/php.project/nbproject/project.xml Sun Feb 21 17:41:27 2010 +0100 +++ b/php.project/nbproject/project.xml Mon Feb 22 15:17:50 2010 +0100 @@ -243,7 +243,7 @@ - 6.6 + 6.15 diff -r 946c91cb4e6c php.project/src/org/netbeans/modules/php/project/resources/layer.xml --- a/php.project/src/org/netbeans/modules/php/project/resources/layer.xml Sun Feb 21 17:41:27 2010 +0100 +++ b/php.project/src/org/netbeans/modules/php/project/resources/layer.xml Mon Feb 22 15:17:50 2010 +0100 @@ -55,6 +55,15 @@ + + + + + + + + +