--- a/core.startup/src/org/netbeans/core/startup/ManifestSection.java Fri Feb 19 19:07:27 2010 +0100 +++ a/core.startup/src/org/netbeans/core/startup/ManifestSection.java Fri Feb 19 19:33:11 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); --- a/diff/manifest.mf Fri Feb 19 19:07:27 2010 +0100 +++ a/diff/manifest.mf Fri Feb 19 19:33:11 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 - --- a/diff/nbproject/project.xml Fri Feb 19 19:07:27 2010 +0100 +++ a/diff/nbproject/project.xml Fri Feb 19 19:33:11 2010 +0100 @@ -173,7 +173,7 @@ - 6.2 + 6.15 --- a/diff/src/org/netbeans/modules/diff/mf-layer.xml Fri Feb 19 19:07:27 2010 +0100 +++ a/diff/src/org/netbeans/modules/diff/mf-layer.xml Fri Feb 19 19:33:11 2010 +0100 @@ -49,6 +49,20 @@ + + + + + + + + + + + + + + --- a/favorites/manifest.mf Fri Feb 19 19:07:27 2010 +0100 +++ a/favorites/manifest.mf Fri Feb 19 19:33:11 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 - --- a/favorites/nbproject/project.xml Fri Feb 19 19:07:27 2010 +0100 +++ a/favorites/nbproject/project.xml Fri Feb 19 19:33:11 2010 +0100 @@ -60,7 +60,7 @@ - 6.2 + 6.15 --- a/favorites/src/org/netbeans/modules/favorites/resources/layer.xml Fri Feb 19 19:07:27 2010 +0100 +++ a/favorites/src/org/netbeans/modules/favorites/resources/layer.xml Fri Feb 19 19:33:11 2010 +0100 @@ -92,6 +92,17 @@ + + + + + + + + + + + --- a/form/manifest.mf Fri Feb 19 19:07:27 2010 +0100 +++ a/form/manifest.mf Fri Feb 19 19:33:11 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 --- a/form/nbproject/project.xml Fri Feb 19 19:07:27 2010 +0100 +++ a/form/nbproject/project.xml Fri Feb 19 19:33:11 2010 +0100 @@ -247,7 +247,7 @@ - 6.2 + 6.15 --- a/form/src/org/netbeans/modules/form/resources/layer.xml Fri Feb 19 19:07:27 2010 +0100 +++ a/form/src/org/netbeans/modules/form/resources/layer.xml Fri Feb 19 19:33:11 2010 +0100 @@ -117,6 +117,16 @@ + + + + + + + + + + --- a/j2ee.sun.appsrv81/nbproject/project.xml Fri Feb 19 19:07:27 2010 +0100 +++ a/j2ee.sun.appsrv81/nbproject/project.xml Fri Feb 19 19:33:11 2010 +0100 @@ -264,7 +264,7 @@ - 6.2 + 6.15 --- a/j2ee.sun.appsrv81/src/org/netbeans/modules/j2ee/sun/ide/j2ee/layer.xml Fri Feb 19 19:07:27 2010 +0100 +++ a/j2ee.sun.appsrv81/src/org/netbeans/modules/j2ee/sun/ide/j2ee/layer.xml Fri Feb 19 19:33:11 2010 +0100 @@ -309,6 +309,7 @@ + @@ -323,6 +324,15 @@ + + + + + + + + + --- a/o.n.core/nbproject/project.xml Fri Feb 19 19:07:27 2010 +0100 +++ a/o.n.core/nbproject/project.xml Fri Feb 19 19:33:11 2010 +0100 @@ -83,7 +83,7 @@ - 6.2 + 6.15 --- a/o.n.core/src/org/netbeans/core/ModuleActions.java Fri Feb 19 19:07:27 2010 +0100 +++ a/o.n.core/src/org/netbeans/core/ModuleActions.java Fri Feb 19 19:33:11 2010 +0100 @@ -49,10 +49,12 @@ import javax.swing.Action; import org.openide.actions.ActionManager; -import org.openide.util.actions.SystemAction; import org.openide.util.Lookup; import org.netbeans.core.startup.ManifestSection; +import org.openide.util.LookupEvent; +import org.openide.util.LookupListener; +import org.openide.util.lookup.Lookups; /** @@ -60,17 +62,23 @@ * @author Jaroslav Tulach, Jesse Glick */ @org.openide.util.lookup.ServiceProvider(service=org.openide.actions.ActionManager.class) -public class ModuleActions extends ActionManager -/*implements PropertyChangeListener*/ { - +public class ModuleActions extends ActionManager implements LookupListener { /** array of all actions added by modules */ - private static SystemAction[] array; + private List array; /** of (ModuleItem, List (ManifestSection.ActionSection)) */ private static Map> map = new HashMap> (8); /** current module */ private static Object module = null; /** Map of currently running actions */ - private Map runningActions = new HashMap(); + private final Map runningActions = new HashMap(); + /** result of changes */ + private final Lookup.Result result; + + @SuppressWarnings("LeakingThisInConstructor") + public ModuleActions() { + result = Lookups.forPath("UI/ToolsActions").lookupResult(Action.class); + result.addLookupListener(this); + } public static ModuleActions getDefaultInstance() { ActionManager mgr = ActionManager.getDefault(); @@ -81,12 +89,13 @@ /** Array with all activated actions. * Can contain null that will be replaced by separators. */ - public SystemAction[] getContextActions () { - SystemAction[] a = array; + @Override + protected List getToolsActions() { + List a = array; if (a != null) { return a; } - array = a = createActions (); + array = a = Collections.unmodifiableList(createActions()); return a; } @@ -94,9 +103,11 @@ * actions. */ @SuppressWarnings("deprecation") + @Override public void invokeAction(final Action a, final ActionEvent e) { try { org.openide.util.Mutex.EVENT.readAccess (new Runnable() { + @Override public void run() { showWaitCursor(e); } @@ -107,6 +118,7 @@ } finally { removeRunningAction(e); org.openide.util.Mutex.EVENT.readAccess (new Runnable() { + @Override public void run() { hideWaitCursor(e); } @@ -176,7 +188,7 @@ list.add (a); //a.addPropertyChangeListener (INSTANCE); - array = null; + getDefaultInstance().array = null; getDefaultInstance().fireChange (); // PENDING this is too often } @@ -194,16 +206,16 @@ map.remove (module); } - array = null; + getDefaultInstance().array = null; getDefaultInstance().fireChange (); // PENDING this is too often } /** Creates the actions. */ - private synchronized static SystemAction[] createActions () { + private synchronized List createActions () { Iterator> it = map.values ().iterator (); - ArrayList arr = new ArrayList (map.size () * 5); + ArrayList arr = new ArrayList (map.size () * 5); while (it.hasNext ()) { List l = it.next (); @@ -213,21 +225,32 @@ ManifestSection.ActionSection s = actions.next(); try { - arr.add (s.getInstance ()); + arr.add ((Action)s.getInstance ()); } catch (Exception ex) { Logger.getLogger(ModuleActions.class.getName()).log(Level.WARNING, null, ex); } } - - if (it.hasNext ()) { // add separator between modules arr.add (null); } - } - return (SystemAction[])arr.toArray (new SystemAction[arr.size ()]); + String pref = arr.isEmpty() ? null : ""; + for (Lookup.Item item : result.allItems()) { + final Action action = item.getInstance(); + if (action == null) { + continue; + } + String where = item.getId().replaceFirst("[^/]*$", ""); + if (pref != null && !pref.equals(where)) { + arr.add(null); + } + pref = where; + arr.add(action); + } + + return arr; } @@ -263,13 +286,13 @@ assert !glassPaneUses.containsKey(key); java.awt.Component c = activeGlassPane(); if (c == null) { - err.warning("showWaitCursor could not find a suitable glass pane; key=" + key); + err.log(Level.WARNING, "showWaitCursor could not find a suitable glass pane; key={0}", key); return; } if (glassPaneUses.values().contains(c)) { - err.fine("wait cursor already displayed on " + c); + err.log(Level.FINE, "wait cursor already displayed on {0}", c); } else { - err.fine("wait cursor will be displayed on " + c); + err.log(Level.FINE, "wait cursor will be displayed on {0}", c); c.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); c.setVisible(true); } @@ -288,14 +311,17 @@ } glassPaneUses.remove(key); if (glassPaneUses.values().contains(c)) { - err.fine("wait cursor still displayed on " + c); + err.log(Level.FINE, "wait cursor still displayed on {0}", c); } else { - err.fine("wait cursor will be hidden on " + c); + err.log(Level.FINE, "wait cursor will be hidden on {0}", c); c.setVisible(false); c.setCursor(null); } } - - + + @Override + public void resultChanged(LookupEvent ev) { + array = null; + } } --- a/o.n.core/src/org/netbeans/core/resources/mf-layer.xml Fri Feb 19 19:07:27 2010 +0100 +++ a/o.n.core/src/org/netbeans/core/resources/mf-layer.xml Fri Feb 19 19:33:11 2010 +0100 @@ -98,4 +98,9 @@ + + + + + --- a/o.n.core/test/unit/src/org/netbeans/core/ModuleActionsTest.java Fri Feb 19 19:07:27 2010 +0100 +++ a/o.n.core/test/unit/src/org/netbeans/core/ModuleActionsTest.java Fri Feb 19 19:33:11 2010 +0100 @@ -41,8 +41,14 @@ package org.netbeans.core; +import java.util.List; +import javax.swing.Action; import org.netbeans.junit.*; -import junit.textui.TestRunner; +import org.openide.actions.CopyAction; +import org.openide.actions.CutAction; +import org.openide.actions.PasteAction; +import org.openide.filesystems.FileObject; +import org.openide.filesystems.FileUtil; /** Tests behaviour of asynchronous actions and exit dialog. */ @@ -52,10 +58,7 @@ super(name); } - public static void main(String[] args) { - TestRunner.run(new NbTestSuite(ModuleActionsTest.class)); - } - + @Override protected boolean runInEQ () { return true; } @@ -79,16 +82,40 @@ fail ("Act should be running: " + col); } + 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.getConfigFile("UI/ToolsActions"); + assertNotNull("ToolsActions 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 toolsActions = ModuleActions.getDefaultInstance().getToolsActions(); + assertEquals("Four actions: " + toolsActions, 4, toolsActions.size()); + assertEquals("Cut first", cut, toolsActions.get(0)); + assertEquals("Paste snd", paste, toolsActions.get(1)); + assertEquals("Separator in middle", null, toolsActions.get(2)); + assertEquals("Copy last", copy, toolsActions.get(3)); + + } + public static class Act extends org.openide.util.actions.CallableSystemAction { + @Override public org.openide.util.HelpCtx getHelpCtx () { return org.openide.util.HelpCtx.DEFAULT_HELP; } + @Override public String getName () { return getClass().getName (); } + @Override public synchronized void performAction () { notifyAll (); try { @@ -98,6 +125,7 @@ } } + @Override protected boolean asynchronous () { return true; } --- a/openide.actions/apichanges.xml Fri Feb 19 19:07:27 2010 +0100 +++ a/openide.actions/apichanges.xml Fri Feb 19 19:33:11 2010 +0100 @@ -49,6 +49,20 @@ + ActionManager.getToolsActions + + + + + + New method ActionManager.getToolsActions allows + plain swing Actions to appear inside of tools action. + + + + + + HeapView preserves its settings between sessions --- a/openide.actions/manifest.mf Fri Feb 19 19:07:27 2010 +0100 +++ a/openide.actions/manifest.mf Fri Feb 19 19:33:11 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 --- a/openide.actions/src/org/openide/actions/ActionManager.java Fri Feb 19 19:07:27 2010 +0100 +++ a/openide.actions/src/org/openide/actions/ActionManager.java Fri Feb 19 19:33:11 2010 +0100 @@ -46,6 +46,8 @@ import java.awt.event.ActionEvent; import java.beans.*; +import java.util.Arrays; +import java.util.List; import javax.swing.Action; @@ -73,7 +75,7 @@ ActionManager am = Lookup.getDefault().lookup(ActionManager.class); if (am == null) { - am = new Trivial(); + am = new ActionManager(){}; } return am; @@ -84,8 +86,23 @@ * Can contain nulls that will be replaced by separators. * * @return array of actions + * @deprecated override {@link #getToolsActions()} */ - public abstract SystemAction[] getContextActions(); + @Deprecated + public SystemAction[] getContextActions() { + return new SystemAction[0]; + } + + /** Get all registered actions that should be displayed + * by the tools action. + * Can contain nulls that will be replaced by separators. + * + * @return an immutable list of actions + * @since 6.15 + */ + protected List getToolsActions() { + return Arrays.asList(getContextActions()); + } /** Invokes action in a RequestPrecessor dedicated to performing * actions. @@ -127,14 +144,4 @@ supp.firePropertyChange(name, o, n); } } - - /** - * Trivial impl. - * @see "#32092" - */ - private static final class Trivial extends ActionManager { - public SystemAction[] getContextActions() { - return new SystemAction[0]; - } - } } --- a/openide.actions/src/org/openide/actions/ToolsAction.java Fri Feb 19 19:07:27 2010 +0100 +++ a/openide.actions/src/org/openide/actions/ToolsAction.java Fri Feb 19 19:33:11 2010 +0100 @@ -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); } @@ -136,8 +142,8 @@ */ private static List generate(Action toolsAction, boolean forMenu) { ActionManager am = ActionManager.getDefault(); - SystemAction[] actions = am.getContextActions(); - List list = new ArrayList(actions.length); + List actions = am.getToolsActions(); + List list = new ArrayList(actions.size()); boolean separator = false; boolean firstItemAdded = false; // flag to prevent adding separator before actual menu items @@ -211,7 +217,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 +241,7 @@ + @Override public JComponent[] synchMenuPresenters(JComponent[] items) { if (timestamp == gl().getTimestamp()) { return items; @@ -246,6 +253,7 @@ } + @Override public JComponent[] getMenuPresenters() { return synchMenuPresenters(new JComponent[0]); } @@ -271,11 +279,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 +301,7 @@ super(getActionName()); } + @Override public JPopupMenu getPopupMenu() { JPopupMenu popup = super.getPopupMenu(); fillSubmenu(popup); @@ -326,12 +337,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 +358,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 +383,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 +399,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 +416,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 +432,7 @@ */ private boolean isPopupEnabled(Action toolsAction) { boolean en = false; - SystemAction[] copy = actions; + Action[] copy = actions; // Get action conext. Lookup lookup; @@ -470,48 +485,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); } --- a/php.project/manifest.mf Fri Feb 19 19:07:27 2010 +0100 +++ a/php.project/manifest.mf Fri Feb 19 19:33:11 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 --- a/php.project/nbproject/project.xml Fri Feb 19 19:07:27 2010 +0100 +++ a/php.project/nbproject/project.xml Fri Feb 19 19:33:11 2010 +0100 @@ -243,7 +243,7 @@ - 6.6 + 6.15 --- a/php.project/src/org/netbeans/modules/php/project/resources/layer.xml Fri Feb 19 19:07:27 2010 +0100 +++ a/php.project/src/org/netbeans/modules/php/project/resources/layer.xml Fri Feb 19 19:33:11 2010 +0100 @@ -55,6 +55,15 @@ + + + + + + + + +