站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > NetBeans API Javadoc 5.0.0

FilterNode.Children (NetBeans Nodes API) - NetBeans API Javadoc 5.0.0

 

org.openide.nodes
Class FilterNode.Children

java.lang.Object
  extended byorg.openide.nodes.Children
      extended byorg.openide.nodes.Children.Array
          extended byorg.openide.nodes.Children.Keys
              extended byorg.openide.nodes.FilterNode.Children
All Implemented Interfaces:
Cloneable
Enclosing class:
FilterNode

public static class FilterNode.Children
extends Children.Keys
implements Cloneable

Children for a filter node. Listens on changes in subnodes of the original node and asks this filter node to creates representants for these subnodes.

This class is used as the default for subnodes of filter node, but subclasses may modify it or provide a totally different implementation.

FilterNode.Children is not well suited to cases where you need to insert additional nodes at the beginning or end of the list, or where you may need to merge together multiple original children lists, or reorder them, etc. That is because the keys are of type Node, one for each original child, and the keys are reset during addNotify(), filterChildrenAdded(org.openide.nodes.NodeMemberEvent), filterChildrenRemoved(org.openide.nodes.NodeMemberEvent), and filterChildrenReordered(org.openide.nodes.NodeReorderEvent), so it is not trivial to use different keys: you would need to override addNotify (calling super first!) and the other three update methods. For such complex cases you will do better by creating your own Children.Keys subclass, setting keys that are useful to you, and keeping a NodeListener on the original node to handle changes.


Nested Class Summary
 
Nested classes inherited from class org.openide.nodes.Children
Children.Array, Children.Keys, Children.Map, Children.SortedArray, Children.SortedMap
 
Field Summary
protected  Node original
          Original node.
 
Fields inherited from class org.openide.nodes.Children.Array
nodes
 
Fields inherited from class org.openide.nodes.Children
LEAF, MUTEX
 
Constructor Summary
FilterNode.Children(Node or)
          Create children.
 
Method Summary
 boolean add(Node[] arr)
          Add nodes this container.
protected  void addNotify()
          Initializes listening to changes in original node.
protected  void changeOriginal(Node original)
          Sets the original children for this children.
 Object clone()
          Special handling for clonning.
protected  Node copyNode(Node node)
          Allows subclasses to override creation of node representants for nodes in the mirrored children list.
protected  Node[] createNodes(Object key)
          Create nodes representing copies of the original node's children.
protected  void filterChildrenAdded(NodeMemberEvent ev)
          Called when the filter node adds a new child.
protected  void filterChildrenRemoved(NodeMemberEvent ev)
          Called when the filter node removes a child.
protected  void filterChildrenReordered(NodeReorderEvent ev)
          Called when the filter node reorders its children.
protected  void finalize()
          Closes the listener, if any, on the original node.
 Node findChild(String name)
          Find a child node by name.
 Node[] getNodes(boolean optimalResult)
          Implementation that ensures the original node is fully initialized if optimal result is requested.
 boolean remove(Node[] arr)
          Remove nodes from the list.
protected  void removeNotify()
          Clears current keys, because all mirrored nodes disappeared.
 
Methods inherited from class org.openide.nodes.Children.Keys
destroyNodes, refreshKey, setBefore, setKeys, setKeys
 
Methods inherited from class org.openide.nodes.Children.Array
initCollection, refresh
 
Methods inherited from class org.openide.nodes.Children
getNode, getNodes, getNodesCount, isInitialized, nodes
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

original

protected Node original
Original node. Should not be modified.

Constructor Detail

FilterNode.Children

public FilterNode.Children(Node or)
Create children.

Parameters:
or - original node to take children from
Method Detail

changeOriginal

protected final void changeOriginal(Node original)
Sets the original children for this children. Be aware that this method aquires write lock on the nodes hierarchy (Children.MUTEX). Take care not to call this method under read lock.

Parameters:
original - The new original node.
Since:
1.39

finalize

protected void finalize()
Closes the listener, if any, on the original node.


clone

public Object clone()
Description copied from class: Children.Keys
Special handling for clonning.

Overrides:
clone in class Children.Keys

addNotify

protected void addNotify()
Initializes listening to changes in original node.

Overrides:
addNotify in class Children
See Also:
Children.isInitialized()

removeNotify

protected void removeNotify()
Clears current keys, because all mirrored nodes disappeared.

Overrides:
removeNotify in class Children

copyNode

protected Node copyNode(Node node)
Allows subclasses to override creation of node representants for nodes in the mirrored children list. The default implementation simply uses Node.cloneNode().

Note that this method is only suitable for a 1-to-1 mirroring.

Parameters:
node - node to create copy of
Returns:
copy of the original node

findChild

public Node findChild(String name)
Description copied from class: Children
Find a child node by name. This may be overridden in subclasses to provide a more advanced way of finding the child, but the default implementation simply scans through the list of nodes to find the first one with the requested name.

Normally the list of nodes should have been computed by the time this returns, but see Children.getNodes() for an important caveat as to why this may not be doing what you want and what to do instead.

Overrides:
findChild in class Children
Parameters:
name - (code) name of child node to find or null if any arbitrary child may be returned
Returns:
the node or null if it could not be found

createNodes

protected Node[] createNodes(Object key)
Create nodes representing copies of the original node's children. The default implementation returns exactly one representative for each original node, as returned by copyNode(org.openide.nodes.Node). Subclasses may override this to avoid displaying a copy of an original child at all, or even to display multiple nodes representing the original.

Specified by:
createNodes in class Children.Keys
Parameters:
key - the original child node
Returns:
zero or more nodes representing the original child node

add

public boolean add(Node[] arr)
Description copied from class: Children
Add nodes this container. The parent node of these nodes is changed to the parent node of this list. Each node can be added only once. If there is some reason a node cannot be added, for example if the node expects only a special type of subnodes, the method should do nothing and return false to signal that the addition has not been successful.

This method should be implemented by subclasses to filter some nodes, etc.

Overrides:
add in class Children.Keys

remove

public boolean remove(Node[] arr)
Description copied from class: Children
Remove nodes from the list. Only nodes that are present are removed.

Overrides:
remove in class Children.Keys

filterChildrenAdded

protected void filterChildrenAdded(NodeMemberEvent ev)
Called when the filter node adds a new child. The default implementation makes a corresponding change.

Parameters:
ev - info about the change

filterChildrenRemoved

protected void filterChildrenRemoved(NodeMemberEvent ev)
Called when the filter node removes a child. The default implementation makes a corresponding change.

Parameters:
ev - info about the change

filterChildrenReordered

protected void filterChildrenReordered(NodeReorderEvent ev)
Called when the filter node reorders its children. The default implementation makes a corresponding change.

Parameters:
ev - info about the change

getNodes

public Node[] getNodes(boolean optimalResult)
Implementation that ensures the original node is fully initialized if optimal result is requested.

Overrides:
getNodes in class Children
Parameters:
optimalResult - if true, the method will block until the original node is fully initialized.
Returns:
array of nodes
Since:
3.9

 

Built on May 3 2007.  |  Portions Copyright 1997-2005 Sun Microsystems, Inc. All rights reserved.