|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.openide.nodes.Children org.openide.nodes.Children.Array org.openide.nodes.Children.Keys org.openide.nodes.FilterNode.Children
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 |
protected Node original
Constructor Detail |
public FilterNode.Children(Node or)
or
- original node to take children fromMethod Detail |
protected final void changeOriginal(Node original)
Children.MUTEX
).
Take care not to call this method under read lock.
original
- The new original node.protected void finalize()
public Object clone()
Children.Keys
clone
in class Children.Keys
protected void addNotify()
Children.isInitialized()
protected void removeNotify()
removeNotify
in class Children
protected Node copyNode(Node node)
Node.cloneNode()
.
Note that this method is only suitable for a 1-to-1 mirroring.
node
- node to create copy of
public Node findChild(String name)
Children
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.
name
- (code) name of child node to find or null
if any arbitrary child may
be returned
null
if it could not be foundprotected Node[] createNodes(Object key)
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.
createNodes
in class Children.Keys
key
- the original child node
public boolean add(Node[] arr)
Children
false
to signal that the addition has not been successful.
This method should be implemented by subclasses to filter some nodes, etc.
add
in class Children.Keys
public boolean remove(Node[] arr)
Children
remove
in class Children.Keys
protected void filterChildrenAdded(NodeMemberEvent ev)
ev
- info about the changeprotected void filterChildrenRemoved(NodeMemberEvent ev)
ev
- info about the changeprotected void filterChildrenReordered(NodeReorderEvent ev)
ev
- info about the changepublic Node[] getNodes(boolean optimalResult)
optimalResult
- if true
, the method will block
until the original node is fully initialized.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |