Converting apisupport to layers. apisupport_release_2_0
authorjglick@netbeans.org
Mon, 04 Dec 2000 11:18:43 +0000
changeset 4112f3ecabfa269
parent 410 3e474f616d0c
child 412 01992f426323
Converting apisupport to layers.
apisupport/src/org/netbeans/modules/apisupport/resources/templates/Nodes_API/Bundle.properties
apisupport/src/org/netbeans/modules/apisupport/resources/templates/Nodes_API/Container_node.group
apisupport/src/org/netbeans/modules/apisupport/resources/templates/Nodes_API/Container_node.html
apisupport/src/org/netbeans/modules/apisupport/resources/templates/Nodes_API/Filter_node.group
apisupport/src/org/netbeans/modules/apisupport/resources/templates/Nodes_API/Filter_node.html
apisupport/src/org/netbeans/modules/apisupport/resources/templates/Nodes_API/Leaf_node.group
apisupport/src/org/netbeans/modules/apisupport/resources/templates/Nodes_API/Leaf_node.html
apisupport/src/org/netbeans/modules/apisupport/resources/templates/Nodes_API/__Sample_container__Children_java
apisupport/src/org/netbeans/modules/apisupport/resources/templates/Nodes_API/__Sample_container__Node_java
apisupport/src/org/netbeans/modules/apisupport/resources/templates/Nodes_API/__Sample_filter__Children_java
apisupport/src/org/netbeans/modules/apisupport/resources/templates/Nodes_API/__Sample_filter__Node_java
apisupport/src/org/netbeans/modules/apisupport/resources/templates/Nodes_API/__Sample_leaf__Node_java
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/apisupport/src/org/netbeans/modules/apisupport/resources/templates/Nodes_API/Bundle.properties	Mon Dec 04 11:18:43 2000 +0000
     1.3 @@ -0,0 +1,9 @@
     1.4 +# Nodes API
     1.5 +LBL_node=<display name of node>
     1.6 +HINT_node=<description of node>
     1.7 +#LBL_NewType=<display name of type of new object>
     1.8 +#LBL_PasteType=<display name of type of pasting>
     1.9 +# {0} - original display name
    1.10 +#LBL_FilterNode_display_name_format=<somehow filtering {0}>
    1.11 +#LBL_AddedSheet=<display name of tab>
    1.12 +#HINT_AddedSheet=<description of tab>
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/apisupport/src/org/netbeans/modules/apisupport/resources/templates/Nodes_API/Container_node.group	Mon Dec 04 11:18:43 2000 +0000
     2.3 @@ -0,0 +1,7 @@
     2.4 +Templates/API_Support/Nodes_API/__Sample_container__Node.java
     2.5 +Templates/API_Support/Nodes_API/__Sample_container__Children.java
     2.6 +Templates/API_Support/Nodes_API/__Sample__NodeIcon.gif
     2.7 +Templates/API_Support/Nodes_API/__Sample__NodeIcon32.gif
     2.8 +Templates/API_Support/Nodes_API/__Sample__NodeIconOpen.gif
     2.9 +Templates/API_Support/Nodes_API/__Sample__NodeIconOpen32.gif
    2.10 +Templates/API_Support/Nodes_API/Bundle.properties
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/apisupport/src/org/netbeans/modules/apisupport/resources/templates/Nodes_API/Container_node.html	Mon Dec 04 11:18:43 2000 +0000
     3.3 @@ -0,0 +1,25 @@
     3.4 +<!--
     3.5 +  --                 Sun Public License Notice
     3.6 +  -- 
     3.7 +  -- The contents of this file are subject to the Sun Public License
     3.8 +  -- Version 1.0 (the "License"). You may not use this file except in
     3.9 +  -- compliance with the License. A copy of the License is available at
    3.10 +  -- http://www.sun.com/
    3.11 +  -- 
    3.12 +  -- The Original Code is NetBeans. The Initial Developer of the Original
    3.13 +  -- Code is Sun Microsystems, Inc. Portions Copyright 1997-2000 Sun
    3.14 +  -- Microsystems, Inc. All Rights Reserved.
    3.15 +  -->
    3.16 +
    3.17 +<HTML><BODY>
    3.18 +Adds to the functionality in <code>Leaf_node</code> by providing
    3.19 +a list of child nodes, in this case using the common and versatile <code>Children.Keys</code>.
    3.20 +It adds support for adding new subnodes, handling pastes of various types of data and converting
    3.21 +them, and reordering child nodes. The children class (separate) shows how you can lazily determine
    3.22 +what the children should be (only when the parent is expanded), including garbage collecting them
    3.23 +after a period of disuse; create nodes corresponding to various abstract keys which represent them;
    3.24 +and manipulate the key set in various ways, usually in cooperation with the parent node. The icon
    3.25 +set for the parent may provide a different appearance when the node is expanded.
    3.26 +
    3.27 +<p>The default executor lets you see a test sample of the node inside the IDE.
    3.28 +</BODY></HTML>
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/apisupport/src/org/netbeans/modules/apisupport/resources/templates/Nodes_API/Filter_node.group	Mon Dec 04 11:18:43 2000 +0000
     4.3 @@ -0,0 +1,3 @@
     4.4 +Templates/API_Support/Nodes_API/__Sample_filter__Node.java
     4.5 +Templates/API_Support/Nodes_API/__Sample_filter__Children.java
     4.6 +Templates/API_Support/Nodes_API/Bundle.properties
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/apisupport/src/org/netbeans/modules/apisupport/resources/templates/Nodes_API/Filter_node.html	Mon Dec 04 11:18:43 2000 +0000
     5.3 @@ -0,0 +1,23 @@
     5.4 +<!--
     5.5 +  --                 Sun Public License Notice
     5.6 +  -- 
     5.7 +  -- The contents of this file are subject to the Sun Public License
     5.8 +  -- Version 1.0 (the "License"). You may not use this file except in
     5.9 +  -- compliance with the License. A copy of the License is available at
    5.10 +  -- http://www.sun.com/
    5.11 +  -- 
    5.12 +  -- The Original Code is NetBeans. The Initial Developer of the Original
    5.13 +  -- Code is Sun Microsystems, Inc. Portions Copyright 1997-2000 Sun
    5.14 +  -- Microsystems, Inc. All Rights Reserved.
    5.15 +  -->
    5.16 +
    5.17 +<HTML><BODY>
    5.18 +A node which just acts as a mirror of another node, usually
    5.19 +partially overriding the original's behavior. The template shows how to control which operations
    5.20 +and delegated to the original node, and which are performed on the filter node. It also includes
    5.21 +examples of adding cookies and properties (on the Property Sheet) to the original (the additions
    5.22 +being visible only in the filter). The template also includes a <code>FilterNode.Children</code>
    5.23 +implementation which permits you to also customize the appearance and behavior of the displayed
    5.24 +children of the filter node, such as specially mirroring the original node's children. There
    5.25 +are no icons in this template because usually the icon is delegated to the original node.
    5.26 +</BODY></HTML>
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/apisupport/src/org/netbeans/modules/apisupport/resources/templates/Nodes_API/Leaf_node.group	Mon Dec 04 11:18:43 2000 +0000
     6.3 @@ -0,0 +1,4 @@
     6.4 +Templates/API_Support/Nodes_API/__Sample_leaf__Node.java
     6.5 +Templates/API_Support/Nodes_API/__Sample__NodeIcon.gif
     6.6 +Templates/API_Support/Nodes_API/__Sample__NodeIcon32.gif
     6.7 +Templates/API_Support/Nodes_API/Bundle.properties
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/apisupport/src/org/netbeans/modules/apisupport/resources/templates/Nodes_API/Leaf_node.html	Mon Dec 04 11:18:43 2000 +0000
     7.3 @@ -0,0 +1,22 @@
     7.4 +<!--
     7.5 +  --                 Sun Public License Notice
     7.6 +  -- 
     7.7 +  -- The contents of this file are subject to the Sun Public License
     7.8 +  -- Version 1.0 (the "License"). You may not use this file except in
     7.9 +  -- compliance with the License. A copy of the License is available at
    7.10 +  -- http://www.sun.com/
    7.11 +  -- 
    7.12 +  -- The Original Code is NetBeans. The Initial Developer of the Original
    7.13 +  -- Code is Sun Microsystems, Inc. Portions Copyright 1997-2000 Sun
    7.14 +  -- Microsystems, Inc. All Rights Reserved.
    7.15 +  -->
    7.16 +
    7.17 +<HTML><BODY>
    7.18 +A subclass of <code>AbstractNode</code> representing a leaf
    7.19 +(i.e. it has no children). There is commented-out code for many different things which can
    7.20 +be done with the node, such as adding a property sheet, customizing the context menu,
    7.21 +customizing cut/copy/delete/rename, the display name/icon/context help associations,
    7.22 +adding cookies, and providing a customizer component. The template includes icons.
    7.23 +
    7.24 +<p>The default executor lets you see a test sample of the node inside the IDE.
    7.25 +</BODY></HTML>
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/apisupport/src/org/netbeans/modules/apisupport/resources/templates/Nodes_API/__Sample_container__Children_java	Mon Dec 04 11:18:43 2000 +0000
     8.3 @@ -0,0 +1,62 @@
     8.4 +package Templates.API_Support.Nodes_API;
     8.5 +
     8.6 +import java.util.*;
     8.7 +
     8.8 +import org.openide.nodes.*;
     8.9 +
    8.10 +/** List of children of a containing node.
    8.11 + * Remember to document what your permitted keys are!
    8.12 + *
    8.13 + * @author __USER__
    8.14 + */
    8.15 +public class __Sample_container__Children extends Children.Keys {
    8.16 +
    8.17 +    /** Optional holder for the keys, to be used when changing them dynamically. */
    8.18 +    protected List myKeys;
    8.19 +
    8.20 +    public __NAME__ () {
    8.21 +        myKeys = null;
    8.22 +    }
    8.23 +
    8.24 +    protected void addNotify () {
    8.25 +        if (myKeys != null) return;
    8.26 +        myKeys = new LinkedList ();
    8.27 +        // add whatever keys you need
    8.28 +        setKeys (myKeys);
    8.29 +    }
    8.30 +
    8.31 +    protected void removeNotify () {
    8.32 +        myKeys = null;
    8.33 +        setKeys (Collections.EMPTY_SET);
    8.34 +    }
    8.35 +
    8.36 +    protected Node[] createNodes (Object key) {
    8.37 +        // interpret your key here...usually one node generated, but could be zero or more
    8.38 +        return new Node[] { new MyNode ((MyParameter) key) };
    8.39 +    }
    8.40 +
    8.41 +    /** Optional accessor method for the keys, for use by the container node or maybe subclasses. */
    8.42 +    /*
    8.43 +    protected addKey (Object newKey) {
    8.44 +	// Make sure some keys already exist:
    8.45 +	addNotify ();
    8.46 +	myKeys.add (newKey);
    8.47 +	// Ensure that the node(s) is displayed:
    8.48 +	refreshKey (newKey);
    8.49 +    }
    8.50 +    */
    8.51 +
    8.52 +    /** Optional accessor method for keys, for use by the container node or maybe subclasses. */
    8.53 +    /*
    8.54 +    protected void setKeys (Collection keys) {
    8.55 +	myKeys = new LinkedList ();
    8.56 +	myKeys.addAll (keys);
    8.57 +	super.setKeys (keys);
    8.58 +    }
    8.59 +    */
    8.60 +
    8.61 +    // Could also write e.g. removeKey to be used by the nodes in this children.
    8.62 +    // Or, could listen to changes in their status (NodeAdapter.nodeDestroyed)
    8.63 +    // and automatically remove them from the keys list here. Etc.
    8.64 +
    8.65 +}
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/apisupport/src/org/netbeans/modules/apisupport/resources/templates/Nodes_API/__Sample_container__Node_java	Mon Dec 04 11:18:43 2000 +0000
     9.3 @@ -0,0 +1,253 @@
     9.4 +package Templates.API_Support.Nodes_API;
     9.5 +
     9.6 +import org.openide.actions.*;
     9.7 +import org.openide.nodes.*;
     9.8 +import org.openide.util.HelpCtx;
     9.9 +import org.openide.util.NbBundle;
    9.10 +import org.openide.util.actions.SystemAction;
    9.11 +
    9.12 +/** A node with some children.
    9.13 + *
    9.14 + * @author __USER__
    9.15 + */
    9.16 +public class __Sample_container__Node extends AbstractNode {
    9.17 +
    9.18 +    public __NAME__ () {
    9.19 +        super (new __NAME$Node$Children$MyChildren__ ());
    9.20 +        setIconBase ("/__PACKAGE_AND_NAME_SLASHES$Node$NodeIcon$MyIcon__");
    9.21 +        // Whatever is most relevant to a user:
    9.22 +        setDefaultAction (Properties.class);
    9.23 +        // Set FeatureDescriptor stuff:
    9.24 +        setName ("preferablyUniqueNameForThisNodeAmongSiblings"); // or, super.setName if needed
    9.25 +        setDisplayName (NbBundle.getMessage (__NAME__.class, "LBL_node"));
    9.26 +        setShortDescription (NbBundle.getMessage (__NAME__.class, "HINT_node"));
    9.27 +        // Add cookies, e.g.:
    9.28 +        /*
    9.29 +        getCookieSet ().add (new OpenCookie () {
    9.30 +		public void open () {
    9.31 +		    // Open something useful...
    9.32 +		}
    9.33 +	    });
    9.34 +        */
    9.35 +        // Make reorderable:
    9.36 +        // getCookieSet ().add (new ReorderMe ());
    9.37 +    }
    9.38 +
    9.39 +    // Create the popup menu:
    9.40 +    protected SystemAction[] createActions () {
    9.41 +        return new SystemAction[] {
    9.42 +                   SystemAction.get (OpenLocalExplorerAction.class),
    9.43 +                   null,
    9.44 +                   // SystemAction.get (MyFavoriteAction.class),
    9.45 +                   // null,                     // separator
    9.46 +                   /* according to what it can do:
    9.47 +                   SystemAction.get (ReorderAction.class),
    9.48 +                   null,
    9.49 +                   SystemAction.get (CutAction.class),
    9.50 +                   SystemAction.get (CopyAction.class),
    9.51 +                   SystemAction.get (PasteAction.class),
    9.52 +                   null,
    9.53 +                   SystemAction.get (DeleteAction.class),
    9.54 +                   SystemAction.get (RenameAction.class),
    9.55 +                   null,
    9.56 +                   SystemAction.get (NewAction.class),
    9.57 +                   null,
    9.58 +                   */
    9.59 +                   SystemAction.get (ToolsAction.class),
    9.60 +                   null,
    9.61 +                   SystemAction.get (PropertiesAction.class),
    9.62 +               };
    9.63 +    }
    9.64 +
    9.65 +    public HelpCtx getHelpCtx () {
    9.66 +        return HelpCtx.DEFAULT_HELP;
    9.67 +        // When you have help, change to:
    9.68 +        // return new HelpCtx (__NAME__.class);
    9.69 +    }
    9.70 +
    9.71 +    protected __NAME$Node$Children$MyChildren__ get__NAME$Node$Children$MyChildren__ () {
    9.72 +        return (__NAME$Node$Children$MyChildren__) getChildren ();
    9.73 +    }
    9.74 +
    9.75 +    // RECOMMENDED - handle cloning specially (so as not to invoke the overhead of FilterNode):
    9.76 +    /*
    9.77 +    public Node cloneNode () {
    9.78 +	// Try to pass in similar constructor params to what you originally got:
    9.79 +	return new __NAME__ ();
    9.80 +    }
    9.81 +    */
    9.82 +
    9.83 +    // Create a property sheet:
    9.84 +    /*
    9.85 +    protected Sheet createSheet () {
    9.86 +	Sheet sheet = super.createSheet ();
    9.87 +	// Make sure there is a "Properties" set:
    9.88 +	Sheet.Set props = sheet.get (Sheet.PROPERTIES); // get by name, not display name
    9.89 +	if (props == null) {
    9.90 +	    props = Sheet.createPropertiesSet ();
    9.91 +	    sheet.put (props);
    9.92 +	}
    9.93 +	props.put (new MyProp (someParams));
    9.94 +    }
    9.95 +    */
    9.96 +
    9.97 +    // Permit new subnodes to be created:
    9.98 +    /*
    9.99 +    public NewType[] getNewTypes () {
   9.100 +	return new NewType[] { new NewType () {
   9.101 +		public String getName () {
   9.102 +		    return NbBundle.getMessage (__NAME__.class, "LBL_NewType");
   9.103 +		}
   9.104 +		// If you have help:
   9.105 +		// public HelpCtx getHelpCtx () {
   9.106 +		//     return __NAME__.class.getName () + ".newType";
   9.107 +		// }
   9.108 +		public void create () throws IOException {
   9.109 +		    // do whatever you need, e.g.:
   9.110 +		    get__NAME$Node$Children$MyChildren__ ().addKey (someNewKey);
   9.111 +		    // Throw an IOException if you are creating an underlying
   9.112 +		    // object and this fails.
   9.113 +		}
   9.114 +	    }
   9.115 +	};
   9.116 +    }
   9.117 +    */
   9.118 +
   9.119 +    // Permit things to be pasted into this node:
   9.120 +    /*
   9.121 +    protected void createPasteTypes (final Transferable t, List l) {
   9.122 +	// Make sure to pick up super impl, which adds intelligent node paste type:
   9.123 +	super.createPasteTypes (t, l);
   9.124 +	if (t.isDataFlavorSupported (DataFlavor.stringFlavor)) {
   9.125 +	    l.add (new PasteType () {
   9.126 +		    public String getName () {
   9.127 +			return NbBundle.getMessage (__NAME__.class, "LBL_PasteType");
   9.128 +		    }
   9.129 +		    // If you have help:
   9.130 +		    // public HelpCtx getHelpCtx () {
   9.131 +		    //     return __NAME__.class.getName () + ".pasteType";
   9.132 +		    // }
   9.133 +		    public Transferable paste () throws IOException {
   9.134 +			try {
   9.135 +			    String data = (String) t.getTransferData (DataFlavor.stringFlavor);
   9.136 +			    // Or, you can look for nodes and related things in the transferable, using e.g.:
   9.137 +			    // Node n = NodeTransfer.node (t, NodeTransfer.COPY);
   9.138 +			    // Node[] ns = NodeTransfer.nodes (t, NodeTransfer.MOVE);
   9.139 +			    // MyCookie cookie = (MyCookie) NodeTransfer.cookie (t, NodeTransfer.COPY, MyCookie.class);
   9.140 +			    // do something, e.g.:
   9.141 +			    get__NAME$Node$Children$MyChildren__ ().addKey (data);
   9.142 +			    // Throw an IOException if you are creating an underlying
   9.143 +			    // object and this fails.
   9.144 +			    // To leave the clipboard as is:
   9.145 +			    return null;
   9.146 +			    // To clear the clipboard:
   9.147 +			    // return ExTransferable.EMPTY;
   9.148 +			} catch (UnsupportedFlavorException ufe) {
   9.149 +			    // Should not happen, since t said it supported this flavor, but:
   9.150 +			    throw new IOException (ufe.getMessage ());
   9.151 +			}
   9.152 +		    }
   9.153 +		});
   9.154 +	}
   9.155 +    }
   9.156 +    */
   9.157 +
   9.158 +    // Handle renaming:
   9.159 +    /*
   9.160 +    public boolean canRename () {
   9.161 +	return true;
   9.162 +    }
   9.163 +    public void setName (String nue) {
   9.164 +	// Update visible name, fire property changes:
   9.165 +	super.setName (nue);
   9.166 +	// perform additional actions, i.e. rename underlying object
   9.167 +    }
   9.168 +    */
   9.169 +
   9.170 +    // Handle deleting:
   9.171 +    /*
   9.172 +    public boolean canDestroy () {
   9.173 +	return true;
   9.174 +    }
   9.175 +    public void destroy () throws IOException {
   9.176 +	// Actually remove the node itself and fire property changes:
   9.177 +	super.destroy ();
   9.178 +	// perform additional actions, i.e. delete underlying object
   9.179 +	// (and don't forget about objects represented by your children!)
   9.180 +    }
   9.181 +    */
   9.182 +
   9.183 +    // Handle copying and cutting specially:
   9.184 +    /*
   9.185 +    public boolean canCopy () {
   9.186 +	return true;
   9.187 +    }
   9.188 +    public boolean canCut () {
   9.189 +	return true;
   9.190 +    }
   9.191 +    public Transferable clipboardCopy () {
   9.192 +	// Add to, do not replace, the default node copy flavor:
   9.193 +	ExTransferable et = ExTransferable.create (super.clipboardCopy ());
   9.194 +	et.put (new ExTransferable.Single (DataFlavor.stringFlavor) {
   9.195 +		protected Object getData () {
   9.196 +		    return __NAME__.this.getDisplayName ();
   9.197 +		}
   9.198 +	    });
   9.199 +	return et;
   9.200 +    }
   9.201 +    public Transferable clipboardCut () {
   9.202 +	// Add to, do not replace, the default node cut flavor:
   9.203 +	ExTransferable et = ExTransferable.create (super.clipboardCut ());
   9.204 +	// This is not so useful because this node will not be destroyed afterwards
   9.205 +	// (it is up to the paste type to decide whether to remove the "original",
   9.206 +	// and it is not safe to assume that getData will only be called once):
   9.207 +	et.put (new ExTransferable.Single (DataFlavor.stringFlavor) {
   9.208 +		protected Object getData () {
   9.209 +		    return __NAME__.this.getDisplayName ();
   9.210 +		}
   9.211 +	    });
   9.212 +	return et;
   9.213 +    }
   9.214 +    */
   9.215 +
   9.216 +    // Permit user to customize whole node at once (instead of per-property):
   9.217 +    /*
   9.218 +    public boolean hasCustomizer () {
   9.219 +	return true;
   9.220 +    }
   9.221 +    public Component getCustomizer () {
   9.222 +	return new MyCustomizingPanel (this);
   9.223 +    }
   9.224 +    */
   9.225 +
   9.226 +    // Permit node to be reordered (you may also want to put
   9.227 +    // MoveUpAction and MoveDownAction on the subnodes, if you can,
   9.228 +    // but ReorderAction on the parent is enough):
   9.229 +    /*
   9.230 +    private class ReorderMe extends Index.Support {
   9.231 +      
   9.232 +	public Node[] getNodes () {
   9.233 +	    return __NAME__.this.getChildren ().getNodes ();
   9.234 +	}
   9.235 +      
   9.236 +	public int getNodesCount () {
   9.237 +	    return getNodes ().length;
   9.238 +	}
   9.239 +      
   9.240 +	// This assumes that there is exactly one child node per key.
   9.241 +	// If you are using e.g. Children.Array, you can use shortcut implementations
   9.242 +	// of the Index cookie.
   9.243 +	public void reorder (int[] perm) {
   9.244 +	    // Remember: {2, 0, 1} cycles three items forwards.
   9.245 +	    List old = __NAME__.this.get__NAME$Node$Children$MyChildren__ ().myKeys;
   9.246 +	    if (list.size () != perm.length) throw new IllegalArgumentException ();
   9.247 +	    List nue = new ArrayList (perm.length);
   9.248 +	    for (int i = 0; i < perm.length; i++)
   9.249 +		nue.set (i, old.get (perm[i]));
   9.250 +	    __NAME__.this.get__NAME$Node$Children$MyChildren__ ().setKeys (nue);
   9.251 +	}
   9.252 +      
   9.253 +    }
   9.254 +    */
   9.255 +
   9.256 +}
    10.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.2 +++ b/apisupport/src/org/netbeans/modules/apisupport/resources/templates/Nodes_API/__Sample_filter__Children_java	Mon Dec 04 11:18:43 2000 +0000
    10.3 @@ -0,0 +1,41 @@
    10.4 +package Templates.API_Support.Nodes_API;
    10.5 +
    10.6 +import org.openide.nodes.*;
    10.7 +
    10.8 +/** Customizes display of filtered children.
    10.9 + *
   10.10 + * @author __USER__
   10.11 + */
   10.12 +public class __Sample_filter__Children extends FilterNode.Children {
   10.13 +
   10.14 +    public __NAME__ (Node orig) {
   10.15 +        // This is the original parent node:
   10.16 +        super (orig);
   10.17 +    }
   10.18 +
   10.19 +    public Object clone () {
   10.20 +        return new __NAME__ (original);
   10.21 +    }
   10.22 +
   10.23 +    protected Node copyNode (Node child) {
   10.24 +        // Perhaps create a customized child somehow, e.g. recurse:
   10.25 +        return new __NAME$Children$Node$MyFilterNode__ (child);
   10.26 +    }
   10.27 +
   10.28 +    // If you need to display 0 or >1 nodes for one original child, you must
   10.29 +    // directly override this:
   10.30 +    /*
   10.31 +    protected Node[] createNodes (Object key) {
   10.32 +	Node child = (Node) key;
   10.33 +	SomeCookie cookie = (SomeCookie) child.getCookie (SomeCookie.class);
   10.34 +	if (cookie != null) {
   10.35 +	    // Represent and also show something else besides, for example.
   10.36 +	    return new Node[] { child.cloneNode (), new ExtraInfoNode (cookie) };
   10.37 +	} else {
   10.38 +	    // Do not represent.
   10.39 +	    return new Node[] { };
   10.40 +	}
   10.41 +    }
   10.42 +    */
   10.43 +
   10.44 +}
    11.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.2 +++ b/apisupport/src/org/netbeans/modules/apisupport/resources/templates/Nodes_API/__Sample_filter__Node_java	Mon Dec 04 11:18:43 2000 +0000
    11.3 @@ -0,0 +1,131 @@
    11.4 +package Templates.API_Support.Nodes_API;
    11.5 +
    11.6 +import org.openide.nodes.*;
    11.7 +
    11.8 +/** A customized filter node.
    11.9 + *
   11.10 + * @author __USER__
   11.11 + */
   11.12 +public class __Sample_filter__Node extends FilterNode {
   11.13 +
   11.14 +    public __NAME__ (Node original) {
   11.15 +        super (original, new __NAME$Node$Children$MyChildren__ (original));
   11.16 +        // Or if you just want to copy all the children as plain FilterNode's
   11.17 +        // (or acc. to Node.cloneNode) you can use:
   11.18 +        // super (original);
   11.19 +        // If you wish to operate on the filter node, instead of / in addition to the original,
   11.20 +        // for basic node operations, you should use e.g.:
   11.21 +        // disableDelegation (DELEGATE_DESTROY | DELEGATE_SET_DISPLAY_NAME);
   11.22 +        // Then you can customize some parts, e.g.:
   11.23 +        // super.setDisplayName (NbBundle.getMessage (__NAME__.class, "LBL_FilterNode_display_name_format", getDisplayName ());
   11.24 +        // To change the icon, you must use getIcon -- there is no icon resource, you
   11.25 +        // must load it yourself.
   11.26 +    }
   11.27 +
   11.28 +    public Node cloneNode () {
   11.29 +        // Usually you will want to override this if you are subclassing.
   11.30 +        // Otherwise a filter of a filter is created, which works but is not ideal.
   11.31 +        return new __NAME__ (getOriginal ());
   11.32 +    }
   11.33 +
   11.34 +    /*
   11.35 +    // Often you will want to override this if you are subclassing.
   11.36 +    // Otherwise the filter node cannot be persisted, so for example
   11.37 +    // Explorer windows rooted at it will not be correctly restored.
   11.38 +    public Node.Handle getHandle () {
   11.39 +	Node.Handle origHandle = getOriginal ().getHandle ();
   11.40 +	// Simplest behavior: just store the original node and try to recreate
   11.41 +	// a filter based on that.
   11.42 +	if (origHandle != null)
   11.43 +	    return new __NAME$Node$Handle$NodeHandle__ (origHandle);
   11.44 +	else
   11.45 +	    return null; // cannot persist original, do not persist filter
   11.46 +    }
   11.47 +    // Note that this class should be static and is serializable:
   11.48 +    private static class __NAME$Node$Handle$NodeHandle__ extends Node.Handle {
   11.49 +	private Node.Handle origHandle; // the only serializable state
   11.50 +	public __NAME$Node$Handle$NodeHandle__ (Node.Handle origHandle) {
   11.51 +	    this.origHandle = origHandle;
   11.52 +	}
   11.53 +	public Node getNode () throws IOException {
   11.54 +	    // Simplest behavior. If you have more configuration present in the filter,
   11.55 +	    // for example additional options to the constructor, you will probably need
   11.56 +	    // to manually store them or otherwise know how to recreate them.
   11.57 +	    return new __NAME__ (origHandle);
   11.58 +	}
   11.59 +    }
   11.60 +    */
   11.61 +
   11.62 +    // To override handling of e.g. node destruction, you may:
   11.63 +    /*
   11.64 +    public boolean canDestroy () {
   11.65 +	return true;
   11.66 +    }
   11.67 +    public void destroy () throws IOException {
   11.68 +	super.destroy (); // if you have disabled DELEGATE_DESTROY, this destroys this node
   11.69 +	// getOriginal ().destroy (); // you might wish to destroy both
   11.70 +	// Can perform other actions here to your liking.
   11.71 +    }
   11.72 +    */
   11.73 +
   11.74 +    // To add cookies:
   11.75 +    /*
   11.76 +    public Node.Cookie getCookie (Class clazz) {
   11.77 +	if (clazz.isAssignableFrom (MySupportedCookie.class))
   11.78 +	    return new MyCookieSupport (getOriginal ());
   11.79 +	else
   11.80 +	    return getOriginal ().getCookie (clazz);
   11.81 +    }
   11.82 +    */
   11.83 +
   11.84 +    // To add properties, cumbersome but straightforward:
   11.85 +    /*
   11.86 +    public Node.PropertySet[] getPropertySets () {
   11.87 +	Node.PropertySet[] pss = getOriginal ().getPropertySets ();
   11.88 +	final Node.Property myProp = new SomethingProp (getOriginal ());
   11.89 +	int found = -1;
   11.90 +	for (int i = 0; i < pss.length; i++) {
   11.91 +	    if (pss[i].getName ().equals (Sheet.PROPERTIES)) {
   11.92 +		found = i;
   11.93 +		break;
   11.94 +	    }
   11.95 +	}
   11.96 +	Node.PropertySet[] nue;
   11.97 +	if (found != -1) {
   11.98 +	    nue = new Node.PropertySet[pss.length];
   11.99 +	    for (int i = 0; i < pss.length; i++) {
  11.100 +		if (i == found) {
  11.101 +		    final Node.PropertySet oldps = pss[i];
  11.102 +		    nue[i] = new Node.PropertySet () {
  11.103 +			    public void Node.Property[] getProperties () {
  11.104 +				Node.PropertySet[] result = new Node.PropertySet[oldps.length + 1];
  11.105 +				System.arraycopy (oldps, 0, result, 0, oldps.length);
  11.106 +				result[oldps.length] = myProp;
  11.107 +				return result;
  11.108 +			    }
  11.109 +			};
  11.110 +		    nue[i].setName (oldps.getName ());
  11.111 +		    nue[i].setDisplayName (oldps.getDisplayName ());
  11.112 +		    nue[i].setShortDescription (oldps.getShortDescription ());
  11.113 +		} else {
  11.114 +		    nue[i] = pss[i];
  11.115 +		}
  11.116 +	    }
  11.117 +	} else {
  11.118 +	    nue = new Node.PropertySet[pss.length + 1];
  11.119 +	    Node.PropertySet added = new Node.PropertySet () {
  11.120 +		    public void Node.Property[] getProperties () {
  11.121 +			return myProp;
  11.122 +		    }
  11.123 +		};
  11.124 +	    added.setName (Sheet.PROPERTIES);
  11.125 +	    added.setDisplayName (NbBundle.getMessage (__NAME__.class, "LBL_AddedSheet"));
  11.126 +	    added.setShortDescription (NbBundle.getMessage (__NAME__.class, "HINT_AddedSheet"));
  11.127 +	    System.arraycopy (pss, 0, nue, 0, pss.length);
  11.128 +	    nue[pss.length] = added;
  11.129 +	}
  11.130 +	return nue;
  11.131 +    }
  11.132 +    */
  11.133 +
  11.134 +}
    12.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.2 +++ b/apisupport/src/org/netbeans/modules/apisupport/resources/templates/Nodes_API/__Sample_leaf__Node_java	Mon Dec 04 11:18:43 2000 +0000
    12.3 @@ -0,0 +1,148 @@
    12.4 +package Templates.API_Support.Nodes_API;
    12.5 +
    12.6 +import org.openide.actions.*;
    12.7 +import org.openide.nodes.*;
    12.8 +import org.openide.util.HelpCtx;
    12.9 +import org.openide.util.NbBundle;
   12.10 +import org.openide.util.actions.SystemAction;
   12.11 +
   12.12 +/** A simple node with no children.
   12.13 + *
   12.14 + * @author __USER__
   12.15 + */
   12.16 +public class __Sample_leaf__Node extends AbstractNode {
   12.17 +
   12.18 +    public __Sample_leaf__Node () {
   12.19 +        super (Children.LEAF);
   12.20 +        setIconBase ("/__PACKAGE_AND_NAME_SLASHES$Node$NodeIcon$MyIcon__");
   12.21 +        // Whatever is most relevant to a user:
   12.22 +        setDefaultAction (SystemAction.get (PropertiesAction.class));
   12.23 +        // Set FeatureDescriptor stuff:
   12.24 +        setName ("preferablyUniqueNameForThisNodeAmongSiblings"); // or, super.setName if needed
   12.25 +        setDisplayName (NbBundle.getMessage (__NAME__.class, "LBL_node"));
   12.26 +        setShortDescription (NbBundle.getMessage (__NAME__.class, "HINT_node"));
   12.27 +        // Add cookies, e.g.:
   12.28 +        /*
   12.29 +        getCookieSet ().add (new OpenCookie () {
   12.30 +		public void open () {
   12.31 +		    // Open something useful...
   12.32 +		}
   12.33 +	    });
   12.34 +        */
   12.35 +    }
   12.36 +
   12.37 +    // Create the popup menu:
   12.38 +    protected SystemAction[] createActions () {
   12.39 +        return new SystemAction[] {
   12.40 +                   // SystemAction.get (MyFavoriteAction.class),
   12.41 +                   // null,                     // separator
   12.42 +                   /* according to what it can do:
   12.43 +                   SystemAction.get (CutAction.class),
   12.44 +                   SystemAction.get (CopyAction.class),
   12.45 +                   null,
   12.46 +                   SystemAction.get (DeleteAction.class),
   12.47 +                   SystemAction.get (RenameAction.class),
   12.48 +                   null,
   12.49 +                   */
   12.50 +                   SystemAction.get (ToolsAction.class),
   12.51 +                   null,
   12.52 +                   SystemAction.get (PropertiesAction.class),
   12.53 +               };
   12.54 +    }
   12.55 +
   12.56 +    public HelpCtx getHelpCtx () {
   12.57 +        return HelpCtx.DEFAULT_HELP;
   12.58 +        // When you have help, change to:
   12.59 +        // return new HelpCtx (__NAME__.class);
   12.60 +    }
   12.61 +
   12.62 +    // RECOMMENDED - handle cloning specially (so as not to invoke the overhead of FilterNode):
   12.63 +    /*
   12.64 +    public Node cloneNode () {
   12.65 +	// Try to pass in similar constructor params to what you originally got:
   12.66 +	return new __NAME__ ();
   12.67 +    }
   12.68 +    */
   12.69 +
   12.70 +    // Create a property sheet:
   12.71 +    /*
   12.72 +    protected Sheet createSheet () {
   12.73 +	Sheet sheet = super.createSheet ();
   12.74 +	// Make sure there is a "Properties" set:
   12.75 +	Sheet.Set props = sheet.get (Sheet.PROPERTIES); // get by name, not display name
   12.76 +	if (props == null) {
   12.77 +	    props = Sheet.createPropertiesSet ();
   12.78 +	    sheet.put (props);
   12.79 +	}
   12.80 +	props.put (new MyProp (someParams));
   12.81 +    }
   12.82 +    */
   12.83 +
   12.84 +    // Handle renaming:
   12.85 +    /*
   12.86 +    public boolean canRename () {
   12.87 +	return true;
   12.88 +    }
   12.89 +    public void setName (String nue) {
   12.90 +	// Update visible name, fire property changes:
   12.91 +	super.setName (nue);
   12.92 +	// perform additional actions, i.e. rename underlying object
   12.93 +    }
   12.94 +    */
   12.95 +
   12.96 +    // Handle deleting:
   12.97 +    /*
   12.98 +    public boolean canDestroy () {
   12.99 +	return true;
  12.100 +    }
  12.101 +    public void destroy () throws IOException {
  12.102 +	// Actually remove the node itself and fire property changes:
  12.103 +	super.destroy ();
  12.104 +	// perform additional actions, i.e. delete underlying object
  12.105 +    }
  12.106 +    */
  12.107 +
  12.108 +    // Handle copying and cutting specially:
  12.109 +    /*
  12.110 +    public boolean canCopy () {
  12.111 +	return true;
  12.112 +    }
  12.113 +    public boolean canCut () {
  12.114 +	return true;
  12.115 +    }
  12.116 +    public Transferable clipboardCopy () {
  12.117 +	// Add to, do not replace, the default node copy flavor:
  12.118 +	ExTransferable et = ExTransferable.create (super.clipboardCopy ());
  12.119 +	et.put (new ExTransferable.Single (DataFlavor.stringFlavor) {
  12.120 +		protected Object getData () {
  12.121 +		    return __NAME__.this.getDisplayName ();
  12.122 +		}
  12.123 +	    });
  12.124 +	return et;
  12.125 +    }
  12.126 +    public Transferable clipboardCut () {
  12.127 +	// Add to, do not replace, the default node cut flavor:
  12.128 +	ExTransferable et = ExTransferable.create (super.clipboardCut ());
  12.129 +	// This is not so useful because this node will not be destroyed afterwards
  12.130 +	// (it is up to the paste type to decide whether to remove the "original",
  12.131 +	// and it is not safe to assume that getData will only be called once):
  12.132 +	et.put (new ExTransferable.Single (DataFlavor.stringFlavor) {
  12.133 +		protected Object getData () {
  12.134 +		    return __NAME__.this.getDisplayName ();
  12.135 +		}
  12.136 +	    });
  12.137 +	return et;
  12.138 +    }
  12.139 +    */
  12.140 +
  12.141 +    // Permit user to customize whole node at once (instead of per-property):
  12.142 +    /*
  12.143 +    public boolean hasCustomizer () {
  12.144 +	return true;
  12.145 +    }
  12.146 +    public Component getCustomizer () {
  12.147 +	return new MyCustomizingPanel (this);
  12.148 +    }
  12.149 +    */
  12.150 +
  12.151 +}