--- a/openide.actions/apichanges.xml +++ a/openide.actions/apichanges.xml @@ -52,6 +52,20 @@ + SelectionType ANY in SaveAction + + + + + + SaveAction has been modified to allow one or more SaveCookies + into it's context. The previous behavior was to allow EXACTLY_ONE. + + + + + + ToolsAction via layers @@ -91,7 +105,7 @@ topComponent.getActionMap().put("jumpPrev", new YourPrevAction()); topComponent.getActionMap().put("jumpNext", new YourNextAction()); - if your component provides items and you want the user to jump + if your component provides items and you want the user to jump among them using standard next/prev actions. @@ -107,7 +121,7 @@ This action was used only as default action on templates. It instantiates the template when it was double clicked in the Options dialog. This behaviour was changed and action is not useful anymore. It is deprecated and it usage - should be avoided. Part of the deprecatation was that + should be avoided. Part of the deprecatation was that org.openide.loadersDataNode.getDefaultAction() does not return this action on templates anymore. --- a/openide.actions/manifest.mf +++ a/openide.actions/manifest.mf @@ -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.19 +OpenIDE-Module-Specification-Version: 6.20 --- a/openide.actions/src/org/openide/actions/SaveAction.java +++ a/openide.actions/src/org/openide/actions/SaveAction.java @@ -47,6 +47,8 @@ import java.awt.event.ActionEvent; import java.beans.PropertyChangeListener; import java.io.IOException; +import java.util.Collection; +import java.util.LinkedList; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.AbstractAction; @@ -64,11 +66,12 @@ import org.openide.util.UserQuestionException; import org.openide.util.actions.CookieAction; -/** Save a single object. -* @see SaveCookie -* -* @author Jan Jancura, Petr Hamernik, Ian Formanek, Dafe Simonek -*/ +/** Save a one or more objects. Since version 6.20 this handles ANY selection + * instead of EXACTLY_ONE selection. + * @see SaveCookie + * + * @author Jan Jancura, Petr Hamernik, Ian Formanek, Dafe Simonek + */ public class SaveAction extends CookieAction { private static Class dataObject; private static java.lang.reflect.Method getNodeDelegate; @@ -87,24 +90,37 @@ } final void performAction(Lookup context) { - SaveCookie sc = context.lookup(SaveCookie.class); - if (sc == null) { - return; + Collection cookieList = context.lookupAll(SaveCookie.class); + Collection nodeList = new LinkedList(context.lookupAll(Node.class)); + + COOKIE: for (SaveCookie saveCookie : cookieList) { + + //Determine if the saveCookie belongs to a node in our context + for (Node node : nodeList) { + if (saveCookie.equals(node.getCookie(SaveCookie.class))) { + performAction(saveCookie, node); + nodeList.remove(node); + continue COOKIE; + } + } + + //The saveCookie was not found in any node in our context - save it by itself. + performAction(saveCookie, null); } - Node n = context.lookup(Node.class); - performAction(sc, n); } + protected void performAction(final Node[] activatedNodes) { + for (int i = 0; i < activatedNodes.length; i++) { + Node node = activatedNodes[i]; + SaveCookie sc = node.getCookie(SaveCookie.class); + assert sc != null : "SaveCookie must be present on " + node + ". " + + "See http://www.netbeans.org/issues/show_bug.cgi?id=68285 for details on overriding " + node.getClass().getName() + ".getCookie correctly."; - protected void performAction(final Node[] activatedNodes) { - SaveCookie sc = activatedNodes[0].getCookie(SaveCookie.class); - assert sc != null : "SaveCookie must be present on " + activatedNodes[0] + ". " + - "See http://www.netbeans.org/issues/show_bug.cgi?id=68285 for details on overriding " + activatedNodes[0].getClass().getName() + ".getCookie correctly."; - - // avoid NPE if disabled assertions - if (sc == null) return ; + // avoid NPE if disabled assertions + if (sc == null) return ; - performAction(sc, activatedNodes[0]); + performAction(sc, node); + } } private void performAction(SaveCookie sc, Node n) {