org.openide.loaders
Class DataObjectFilter

java.lang.Object
  |
  +--org.openide.nodes.Children
        |
        +--org.openide.nodes.Children.Array
              |
              +--org.openide.nodes.Children.Keys
                    |
                    +--org.openide.loaders.DataObjectFilter
All Implemented Interfaces:
Cloneable

public class DataObjectFilter
extends Children.Keys

Supports working with a set of filters defined by data objects. Provides a keyed list of children taken from a DataFolder.

An instance of this filter in its default settings accepts all DataObjects.

Additional specific filters can be added to this filter with putFilter(java.lang.Class, java.lang.Object) to filter particular kinds of data objects.

Also it is possible to registering filter editor classes and to obtain them, so as to allow modifications to the filter by the user.

The effect of this filter is that:


Inner classes inherited from class org.openide.nodes.Children
Children.Array, Children.Keys, Children.Map, Children.SortedArray, Children.SortedMap
 
Fields inherited from class org.openide.nodes.Children.Array
nodes
 
Fields inherited from class org.openide.nodes.Children
LEAF, MUTEX
 
Constructor Summary
DataObjectFilter()
          Create a new filter which will accept all data objects.
DataObjectFilter(Class[] representationClasses)
          Create a new filter which will accept given set of data objects.
DataObjectFilter(DataFolder dataFolder)
          Create a new filter which will accept all data objects in a given folder.
 
Method Summary
 void addLoader(Class representationClass)
          Permit a representation class of data object to be shown (after appropriate filtering).
protected  void addNotify()
          Called when children are first asked for nodes.
protected  Node[] createNodes(Object key)
          Create children for a data-object key.
 DataFolder getDataFolder()
          Get the folder this support is attached to.
static Class getFilterClass(Class representationClass)
          Get the filter class currently registered for a data object representation class.
 void putFilter(Class filterClass, Object filter)
          Add a filter for a certain type of data object.
static void registerFilterClass(Class representationClass, Class filterClass)
          Register a new filter type for a given type of data object.
 void removeLoader(Class representationClass)
          Prevent a representation class of data object from being show at all.
protected  void removeNotify()
          Called when the list of nodes for this children object is no longer needed by the IDE.
 void setDataFolder(DataFolder f)
          Attach the support to a different folder.
 
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
findChild, getNode, getNodes, getNodesCount, isInitialized, nodes
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataObjectFilter

public DataObjectFilter(Class[] representationClasses)
Create a new filter which will accept given set of data objects. Initially unattached to any data folder.
Parameters:
representationClasses - representation classes of data objects to be shown

DataObjectFilter

public DataObjectFilter()
Create a new filter which will accept all data objects. Initially unattached to any data folder.

DataObjectFilter

public DataObjectFilter(DataFolder dataFolder)
Create a new filter which will accept all data objects in a given folder.
Parameters:
dataFolder - the folder to filter
Method Detail

registerFilterClass

public static void registerFilterClass(Class representationClass,
                                       Class filterClass)
Register a new filter type for a given type of data object.
Parameters:
representationClass - the designated super class of all data objects that can use this filter
filterClass - the class of a filter to use for such data objects
See Also:
FilterCookie.getFilterClass()

getFilterClass

public static Class getFilterClass(Class representationClass)
Get the filter class currently registered for a data object representation class.
Returns:
the proper filter class, or null

putFilter

public void putFilter(Class filterClass,
                      Object filter)
Add a filter for a certain type of data object. The previous filter, if any, will be removed.
Parameters:
filterClass - the representation class this filter belongs to
filter - the filter to use for all data objects requesting this type of filter, via FilterCookie.getFilterClass(). May be null to remove.

addLoader

public void addLoader(Class representationClass)
Permit a representation class of data object to be shown (after appropriate filtering). By default all are shown, so this need be used only to counteract removeLoader(java.lang.Class).
Parameters:
representationClass - the data object representation class

removeLoader

public void removeLoader(Class representationClass)
Prevent a representation class of data object from being show at all.
Parameters:
representationClass - the data object representation class
See Also:
DataLoader.getRepresentationClass()

setDataFolder

public void setDataFolder(DataFolder f)
Attach the support to a different folder.
Parameters:
f - the new folder

getDataFolder

public DataFolder getDataFolder()
Get the folder this support is attached to.
Returns:
the folder

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)
Create children for a data-object key. If ElementCookie is provided, then the proxy node's children are used for this node's children (for this key), after possible filtering based on the current filters. If ElementCookie is not provided, then (a copy of) this data's object's delegate node is used as the sole child for this key.
Overrides:
createNodes in class Children.Keys
Parameters:
key - a DataObject to create representative children for
Returns:
a list of child nodes for this key


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