diff -r ea8bd99e63e9 bugtracking/nbproject/project.xml --- a/bugtracking/nbproject/project.xml Thu Mar 26 15:42:33 2009 +0300 +++ b/bugtracking/nbproject/project.xml Thu Mar 26 20:29:11 2009 +0100 @@ -146,7 +146,7 @@ - 7.7 + 7.9 diff -r ea8bd99e63e9 bugtracking/src/org/netbeans/modules/bugtracking/layer.xml --- a/bugtracking/src/org/netbeans/modules/bugtracking/layer.xml Thu Mar 26 15:42:33 2009 +0300 +++ b/bugtracking/src/org/netbeans/modules/bugtracking/layer.xml Thu Mar 26 20:29:11 2009 +0100 @@ -52,8 +52,11 @@ - - + + + + + diff -r ea8bd99e63e9 db/nbproject/project.xml --- a/db/nbproject/project.xml Thu Mar 26 15:42:33 2009 +0300 +++ b/db/nbproject/project.xml Thu Mar 26 20:29:11 2009 +0100 @@ -151,7 +151,7 @@ - 6.2 + 7.9 diff -r ea8bd99e63e9 db/src/org/netbeans/modules/db/resources/mf-layer.xml --- a/db/src/org/netbeans/modules/db/resources/mf-layer.xml Thu Mar 26 15:42:33 2009 +0300 +++ b/db/src/org/netbeans/modules/db/resources/mf-layer.xml Thu Mar 26 20:29:11 2009 +0100 @@ -562,9 +562,12 @@ --> - - - + + + + + + diff -r ea8bd99e63e9 hudson/nbproject/project.xml --- a/hudson/nbproject/project.xml Thu Mar 26 15:42:33 2009 +0300 +++ b/hudson/nbproject/project.xml Thu Mar 26 20:29:11 2009 +0100 @@ -120,7 +120,7 @@ - 7.1 + 7.9 diff -r ea8bd99e63e9 hudson/src/org/netbeans/modules/hudson/layer.xml --- a/hudson/src/org/netbeans/modules/hudson/layer.xml Thu Mar 26 15:42:33 2009 +0300 +++ b/hudson/src/org/netbeans/modules/hudson/layer.xml Thu Mar 26 20:29:11 2009 +0100 @@ -22,8 +22,11 @@ - - + + + + + diff -r ea8bd99e63e9 openide.nodes/apichanges.xml --- a/openide.nodes/apichanges.xml Thu Mar 26 15:42:33 2009 +0300 +++ b/openide.nodes/apichanges.xml Thu Mar 26 20:29:11 2009 +0100 @@ -46,6 +46,24 @@ Nodes API + + + Support for declarative Node registrations + + + + + +

+ NodeOp.factory + is new method, particularly useful from + layers + that allows declarative definition of a root node. +

+
+ + +
Adding ChildFactory.Detachable to allow ChildFactory implementations to diff -r ea8bd99e63e9 openide.nodes/nbproject/project.properties --- a/openide.nodes/nbproject/project.properties Thu Mar 26 15:42:33 2009 +0300 +++ b/openide.nodes/nbproject/project.properties Thu Mar 26 20:29:11 2009 +0100 @@ -44,4 +44,4 @@ javadoc.arch=${basedir}/arch.xml javadoc.apichanges=${basedir}/apichanges.xml -spec.version.base=7.8.0 +spec.version.base=7.9.0 diff -r ea8bd99e63e9 openide.nodes/src/org/openide/nodes/LazyNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/openide.nodes/src/org/openide/nodes/LazyNode.java Thu Mar 26 20:29:11 2009 +0100 @@ -0,0 +1,103 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2009 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 2009 Sun Microsystems, Inc. + */ + +package org.openide.nodes; + +import java.util.List; +import java.util.Map; +import javax.swing.Action; + +/** Lazy delegating node. + * + * @author Jaroslav Tulach + */ +final class LazyNode extends FilterNode { + private Map map; + + LazyNode(Map map) { + this(new ChFactory(), map); + } + private LazyNode(ChFactory factory, Map map) { + super(new AbstractNode(Children.create(factory, true))); + factory.node = this; + this.map = map; + + AbstractNode an = (AbstractNode)getOriginal(); + + an.setName((String) map.get("name")); // NOI18N + an.setDisplayName((String) map.get("displayName")); // NOI18N + an.setShortDescription((String) map.get("shortDescription")); // NOI18N + an.setIconBaseWithExtension((String)map.get("iconResource")); // NOI18N + } + + @Override + public Action[] getActions(boolean context) { + switchToOriginal(); + return super.getActions(context); + } + + + final void switchToOriginal() { + Node n; + synchronized (this) { + if (map == null) { + return; + } + n = (Node)map.get("original"); // NOI18N + map = null; + } + changeOriginal(n, true); + } + + private static final class ChFactory extends ChildFactory { + LazyNode node; + + @Override + protected boolean createKeys(List toPopulate) { + LazyNode n = node; + node = null; + if (n != null) { + n.switchToOriginal(); + return true; + } else { + return false; + } + } + } +} diff -r ea8bd99e63e9 openide.nodes/src/org/openide/nodes/NodeOp.java --- a/openide.nodes/src/org/openide/nodes/NodeOp.java Thu Mar 26 15:42:33 2009 +0300 +++ b/openide.nodes/src/org/openide/nodes/NodeOp.java Thu Mar 26 20:29:11 2009 +0100 @@ -442,6 +442,58 @@ return WeakListeners.create(NodeListener.class, l, source); } + /** Creates a lazy node - a node that displays basic information + * about the original node behind it, without touching it. As soon as + * the node is expanded, or a pop up menu is invoked on it, it switches + * to the real delegates and since then everything is being bridged to + * the real node. + *

+ * This method is especially useful when used from + * layers. + * Use following + * XML snippet to register your node into Services tab: + *

+     * <folder name="UI">
+     *   <folder name="Runtime">
+     *     <file name="org-yourorg-yourpgk-YourNode.instance">
+     *       <attr name="instanceCreate" methodvalue="org.openide.nodes.NodeOp.factory"/>
+     *       <attr name="name" stringvalue="YourNode"/>
+     *       <attr name="displayName" bundlevalue="org.yourorg.yourpkg.Bundle#NAME-KEY"/>
+     *       <attr name="shortDescription" bundlevalue="org.yourorg.yourpkg.Bundle#SHORT-KEY"/>
+     *       <attr name="iconResource" stringvalue="org/yourorg/yourpkg/image.png"/>
+     *       <attr name="original" newvalue="org.yourorg.yourpkg.YourNode"/>
+     *     <file/>
+     *   <folder/>
+     * <folder/>
+     * 
+ * + * @param original the real node behind the one created + * @param name programatic name of the node + * @param displayName human readable name of the node + * @param shortDescription short description for the node + * @param iconResource path to icon to use as in {@link AbstractNode#setIconBaseWithExtension(java.lang.String)} + * @return new node with preset defaults that can delegate to original + * + * @since 7.9 + */ + public static Node factory( + Node original, + String name, String displayName, String shortDescription, + String iconResource + ) { + Map map = new HashMap(); + map.put("original", original); // NOI18N + map.put("name", name); // NOI18N + map.put("displayName", displayName); // NOI18N + map.put("shortDescription", shortDescription); // NOI18N + map.put("iconResource", iconResource); // NOI18N + return new LazyNode(map); + } + + static Node factory(Map map) { + return new LazyNode(map); + } + /** Utility method to remove dependency of this package on * org.openide.actions. This method takes names of classes from * that package and creates their instances. diff -r ea8bd99e63e9 openide.nodes/test/unit/src/org/openide/nodes/LazyNodeTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/openide.nodes/test/unit/src/org/openide/nodes/LazyNodeTest.java Thu Mar 26 20:29:11 2009 +0100 @@ -0,0 +1,186 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2009 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 2009 Sun Microsystems, Inc. + */ + +package org.openide.nodes; + +import java.util.HashMap; +import javax.swing.Action; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.openide.util.HelpCtx; +import org.openide.util.actions.CallbackSystemAction; +import org.openide.util.actions.SystemAction; +import static org.junit.Assert.*; + +/** + * + * @author Jaroslav Tulach + */ +public class LazyNodeTest { + + public LazyNodeTest() { + } + + @BeforeClass + public static void setUpClass() throws Exception { + } + + @AfterClass + public static void tearDownClass() throws Exception { + } + + @Before + public void setUp() { + } + + @After + public void tearDown() { + } + + @Test + public void testCreateOriginalAfterNodeExpansion() { + doCreateOriginal(true); + } + + @Test + public void testCreateOriginalAfterGetActions() { + doCreateOriginal(false); + } + + private void doCreateOriginal(boolean askForChildren) { + AbstractNode realNode = new AbstractNode(new Children.Array()) { + @Override + public Action[] getActions(boolean context) { + return getActions(); + } + + @SuppressWarnings("deprecation") + @Override + public SystemAction[] getActions() { + return new SystemAction[] { + A1.get(A1.class), + A2.get(A2.class), + A3.get(A3.class) + }; + } + }; + realNode.setName("RealNode"); + realNode.setDisplayName("Real Node"); + realNode.setShortDescription("Real Node for Test"); + realNode.getChildren().add(new Node[] { + new AbstractNode(Children.LEAF), + new AbstractNode(Children.LEAF), + new AbstractNode(Children.LEAF), + }); + + CntHashMap chm = new CntHashMap("original"); + chm.put("name", "ANode"); + chm.put("displayName", "A Node"); + chm.put("shortDescription", "A Node for Test"); + chm.put("iconResource", "org/openide/nodes/beans.gif"); + chm.put("original", realNode); + + Node instance = NodeOp.factory(chm); + assertEquals("ANode", instance.getName()); + assertEquals("A Node", instance.getDisplayName()); + assertEquals("A Node for Test", instance.getShortDescription()); + assertEquals("No real node queried yet", 0, chm.cnt); + + if (askForChildren) { + Node[] arr = instance.getChildren().getNodes(true); + assertEquals("Three children", 3, arr.length); + } else { + Action[] arr = instance.getActions(true); + assertEquals("Three actions", 3, arr.length); + } + + assertEquals("Real node queried now", 1, chm.cnt); + + assertEquals("RealNode", instance.getName()); + assertEquals("Real Node", instance.getDisplayName()); + assertEquals("Real Node for Test", instance.getShortDescription()); + } + + private static class CntHashMap extends HashMap { + private final Object keyToWatch; + int cnt; + + public CntHashMap(Object keyToWatch) { + this.keyToWatch = keyToWatch; + } + + @Override + public Object get(Object key) { + if (keyToWatch.equals(key)) { + cnt++; + } + return super.get(key); + } + + + } + + public static class A1 extends CallbackSystemAction { + @Override + public String getName() { + return "A1"; + } + + @Override + public HelpCtx getHelpCtx() { + throw new UnsupportedOperationException("Not supported yet."); + } + + } + public static final class A2 extends A1 { + @Override + public String getName() { + return "A2"; + } + } + public static final class A3 extends A1 { + @Override + public String getName() { + return "A3"; + } + } +} \ No newline at end of file diff -r ea8bd99e63e9 server/nbproject/project.xml --- a/server/nbproject/project.xml Thu Mar 26 15:42:33 2009 +0300 +++ b/server/nbproject/project.xml Thu Mar 26 20:29:11 2009 +0100 @@ -100,7 +100,7 @@ - 7.3 + 7.9 diff -r ea8bd99e63e9 server/src/org/netbeans/modules/server/resources/layer.xml --- a/server/src/org/netbeans/modules/server/resources/layer.xml Thu Mar 26 15:42:33 2009 +0300 +++ b/server/src/org/netbeans/modules/server/resources/layer.xml Thu Mar 26 20:29:11 2009 +0100 @@ -46,8 +46,12 @@ - - + + + + + + diff -r ea8bd99e63e9 websvc.saas.ui/nbproject/project.xml --- a/websvc.saas.ui/nbproject/project.xml Thu Mar 26 15:42:33 2009 +0300 +++ b/websvc.saas.ui/nbproject/project.xml Thu Mar 26 20:29:11 2009 +0100 @@ -30,6 +30,15 @@ 1 1.6 + + + + org.netbeans.modules.websvc.jaxwsmodelapi + + + + 1 + 1.0 @@ -103,7 +112,7 @@ - 7.3 + 7.9 diff -r ea8bd99e63e9 websvc.saas.ui/src/org/netbeans/modules/websvc/saas/ui/layer.xml --- a/websvc.saas.ui/src/org/netbeans/modules/websvc/saas/ui/layer.xml Thu Mar 26 15:42:33 2009 +0300 +++ b/websvc.saas.ui/src/org/netbeans/modules/websvc/saas/ui/layer.xml Thu Mar 26 20:29:11 2009 +0100 @@ -46,6 +46,12 @@ + + + + + +