org.openide.src.nodes
Class SourceChildren

java.lang.Object
  |
  +--org.openide.nodes.Children
        |
        +--org.openide.nodes.Children.Array
              |
              +--org.openide.nodes.Children.Keys
                    |
                    +--org.openide.src.nodes.SourceChildren
All Implemented Interfaces:
Cloneable, FilterCookie, Node.Cookie

public class SourceChildren
extends Children.Keys
implements FilterCookie

Normal implementation of children for source element nodes.

Ordering and filtering of the children can be customized using SourceElementFilter. FilterCookie is implemented to provide a means for user customization of the filter.

The child list listens to changes in the source element, as well as the filter, and automatically updates itself as appropriate.

A child factory can be used to cause the children list to create non-default child nodes, if desired, both at the time of the creation of the children list, and when new children are added.

The children list may be unattached to any source element temporarily, in which case it will have no children (except possibly an error indicator).


Inner classes inherited from class org.openide.nodes.Children
Children.Array, Children.Keys, Children.Map, Children.SortedArray, Children.SortedMap
 
Field Summary
protected  SourceElement element
          The element whose subelements are represented.
protected  ElementNodeFactory factory
          Factory for obtaining class nodes.
protected  SourceElementFilter filter
          Filter for elements.
 
Fields inherited from class org.openide.nodes.Children.Array
nodes
 
Fields inherited from class org.openide.nodes.Children
LEAF, MUTEX
 
Constructor Summary
SourceChildren()
          Create a children list with the default factory and no attached source element.
SourceChildren(ElementNodeFactory factory)
          Create a children list with no attached source element.
SourceChildren(ElementNodeFactory factory, SourceElement element)
          Create a children list.
SourceChildren(SourceElement element)
          Create a children list with the default factory.
 
Method Summary
protected  void addNotify()
          Called when children are first asked for nodes.
protected  Node[] createNodes(Object key)
          Create nodes for a given key.
 Node findChild(String name)
          Find a child node by name.
 SourceElement getElement()
          Get the currently attached source element.
 Object getFilter()
          Get the current filter.
 Class getFilterClass()
          Get the declared filter (super-)class.
protected  void removeNotify()
          Called when the list of nodes for this children object is no longer needed by the IDE.
 void setElement(SourceElement element)
          Set a new source element to get information about children from.
 void setFilter(Object filter)
          Set the current filter.
 
Methods inherited from class org.openide.nodes.Children.Keys
add, clone, destroyNodes, refreshKey, remove, 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, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

element

protected SourceElement element
The element whose subelements are represented.

filter

protected SourceElementFilter filter
Filter for elements. Can be null, in which case modifier filtering is disabled, and ordering may be reset to the default order.

factory

protected ElementNodeFactory factory
Factory for obtaining class nodes.
Constructor Detail

SourceChildren

public SourceChildren()
Create a children list with the default factory and no attached source element.

SourceChildren

public SourceChildren(SourceElement element)
Create a children list with the default factory.
Parameters:
element - source element to attach to, or null

SourceChildren

public SourceChildren(ElementNodeFactory factory)
Create a children list with no attached source element.
Parameters:
factory - a factory for creating children

SourceChildren

public SourceChildren(ElementNodeFactory factory,
                      SourceElement element)
Create a children list.
Parameters:
factory - a factory for creating children
element - source element to attach to, or null
Method Detail

getFilterClass

public Class getFilterClass()
Description copied from interface: FilterCookie
Get the declared filter (super-)class.
Specified by:
getFilterClass in interface FilterCookie
Following copied from interface: org.openide.cookies.FilterCookie
Returns:
the class, or may be null if no filter is currently in use

getFilter

public Object getFilter()
Description copied from interface: FilterCookie
Get the current filter.
Specified by:
getFilter in interface FilterCookie
Following copied from interface: org.openide.cookies.FilterCookie
Returns:
the filter, or null if none is currently in use

setFilter

public void setFilter(Object filter)
Description copied from interface: FilterCookie
Set the current filter.
Specified by:
setFilter in interface FilterCookie
Following copied from interface: org.openide.cookies.FilterCookie
Parameters:
filter - the filter, or null if none should be used

addNotify

protected void addNotify()
Description copied from class: Children
Called when children are first asked for nodes. Typical implementations at this time calculate their node list (or keys for Children.Keys etc.).
Overrides:
addNotify in class Children
Following copied from class: org.openide.nodes.Children
See Also:
Children.isInitialized()

removeNotify

protected void removeNotify()
Description copied from class: Children
Called when the list of nodes for this children object is no longer needed by the IDE. Typical implementations at this time remove all children to save memory (or clear the keys for Children.Keys etc.).
Overrides:
removeNotify in class Children

createNodes

protected Node[] createNodes(Object key)
Description copied from class: Children.Keys
Create nodes for a given key.
Overrides:
createNodes in class Children.Keys
Following copied from class: org.openide.nodes.Children.Keys
Parameters:
key - the key
Returns:
child nodes for this key or null if there should be no nodes for this key

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
Following copied from class: org.openide.nodes.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

getElement

public SourceElement getElement()
Get the currently attached source element.
Returns:
the element, or null if unattached

setElement

public void setElement(SourceElement element)
Set a new source element to get information about children from.
Parameters:
element - the new element, or null to detach


Built on December 12 2001.  |  Portions Copyright 1997-2001 Sun Microsystems, Inc. All rights reserved.