|
Copyright © 2011 Citra Technologies. All Rights Reserved. | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.citra.treetable.AbstractTreeTableModel
com.citra.treetable.TreeModelMap
com.citra.treetable.TreeTableModelMap
com.citra.treetable.DefaultFilterTreeTableModel
public class DefaultFilterTreeTableModel
DefaultFilterTreeTableModel provides filtering capabilities to a TreeTableModel. This class wraps around a TreeTableModel and uses an internal FilterTableModel instance to filter each group row of the model. You can use the filter tablemodel to control the filtering.
Field Summary | |
---|---|
static int |
AND_FILTER
the mode which defines an AND combination of a node and level filter |
protected TableFilter |
defaultFilter
the current default filter |
protected EventListenerList |
filterListenerList
the list of filter treemodel listeners. |
protected int |
filterMode
the current filter mode |
static int |
LEVEL_FILTER
the mode which defines a single filter assigned per level |
static int |
NODE_FILTER
the mode which defines a single filter assigned per node |
static int |
OR_FILTER
the mode which defines an OR combination of a node and level filter |
Fields inherited from class com.citra.treetable.TreeTableModelMap |
---|
treeTableModel |
Fields inherited from class com.citra.treetable.TreeModelMap |
---|
treeModel |
Fields inherited from class com.citra.treetable.AbstractTreeTableModel |
---|
listenerList, root |
Fields inherited from interface com.citra.treetable.TreeTableModel |
---|
CHANGE_COLUMN_SOURCE |
Constructor Summary | |
---|---|
DefaultFilterTreeTableModel(TreeTableModel treeTableModel)
Constructs a DefaultFilterTreeTableModel. |
Method Summary | |
---|---|
void |
addFilterTreeTableModelListener(FilterTreeTableModelListener l)
Adds a FilterTreeTableModelListener that is notified each time filters are added or removed. |
void |
clear()
Clears the model of any filtering performed. |
void |
clearFilters()
Removes all assigned filters. |
static InputStream |
convertFilterState(InputStream input,
String library)
Converts a filter inputstream, created by another library version, to a stream of the current version. |
static InputStream |
convertFilterState(InputStream input,
String library,
FilterConverter converter)
Converts a filter inputstream, created by another library version, to a stream of the current version. |
protected void |
fireApplyLevelFilter(FilterTreeTableModelEvent e)
Notifies listeners that a filter has been assigned at a node level. |
protected void |
fireApplyNodeFilter(FilterTreeTableModelEvent e)
Notifies listeners that a filter has been assigned at a node. |
protected void |
fireClearFilters()
Notifies listeners that all filters have been removed. |
Object |
getChild(Object parent,
int index)
Returns the child of parent at index index
in the parent's
child array. parent must be a node previously obtained
from this data source. This should not return null
if index
is a valid index for parent (that is index >= 0 &&
index < getChildCount(parent )). |
int |
getChildCount(Object parent)
Returns the number of children of parent .
Returns 0 if the node
is a leaf or if it has no children. parent must be a node
previously obtained from this data source. |
TableFilter |
getDefaultFilter()
Determines the default filter. |
TableFilter |
getFilterAtLevel(int level)
Retrieves the TableFilter that is assigned at the node level identified by level . |
TableFilter |
getFilterAtNode(Object node)
Retrieves the TableFilter that is assigned for the node identified by node . |
int |
getFilterMode()
Determines the filtering mode. |
FilterTableModel |
getFilterTableModel()
Returns the internal filter tablemodel instance. |
int |
getIndexOfChild(Object parent,
Object child)
Returns the index of child in parent. If parent
is null or child is null ,
returns -1. |
int |
getLevelForNode(Object node)
Determines the level of the supplied node. |
int[] |
getMappedIndexes(Object node)
Returns an array representing how the nodes' children have been transformed. |
Map |
getNodeFilters()
Retrieves a map of the filters assigned to the nodes of the model. |
TreeTableModel |
getUnfilteredTreeTableModel()
Retrieves the TreeTableModel that holds the unfiltered data. |
boolean |
isLeaf(Object node)
Returns true if node is a leaf.
It is possible for this method to return false
even if node has no children.
A directory in a filesystem, for example,
may contain no files; the node representing
the directory is not a leaf, but it also has no children. |
void |
loadFilterState(ObjectInputStream in)
Restores the filters and assigns them on the model. |
void |
removeFilterTreeTableModelListener(FilterTreeTableModelListener l)
Removes a FilterTreeTableModelListener that is notified each time filters are added or removed. |
TableFilter |
retrieveFilter(Object node)
Determines the table filter to use for the node identified by node . |
void |
saveFilterState(ObjectOutputStream out)
Saves the filters that are currently installed on the model. |
void |
setDefaultFilter(TableFilter newDefaultFilter)
Assigns a new default filter. |
void |
setFilterAtLevel(TableFilter filter,
int level)
Assigns a TableFilter at the node level identified by level . |
void |
setFilterAtNode(TableFilter filter,
Object node)
Assigns a TableFilter for the node identified by node . |
void |
setFilterMode(int filterMode)
Assigns the filtering mode. |
boolean |
shouldFilter(Object node)
Determines on which occasions the filter treetable model should apply the filter. |
void |
treeNodesChanged(TreeModelEvent e)
Invoked after a node (or a set of siblings) has changed in some way. The node(s) have not changed locations in the tree or altered their children arrays, but other attributes have changed and may affect presentation. Example: the name of a file has changed, but it is in the same location in the file system. To indicate the root has changed, childIndices and children will be null. Use |
void |
treeNodesInserted(TreeModelEvent e)
Invoked after nodes have been inserted into the tree. Use |
void |
treeNodesRemoved(TreeModelEvent e)
Invoked after nodes have been removed from the tree. Note that if a subtree is removed from the tree, this method may only be invoked once for the root of the removed subtree, not once for each individual set of siblings removed. Use |
void |
treeStructureChanged(TreeModelEvent e)
Invoked after the tree has drastically changed structure from a given node down. If the path returned by e.getPath() is of length one and the first element does not identify the current root node the first element should become the new root of the tree.
Use |
Methods inherited from class com.citra.treetable.TreeTableModelMap |
---|
addReorderListener, fireRowsMapped, fireRowsReordered, getColumnClass, getColumnCount, getColumnName, getInnerTreeTableModel, getTreeTableModel, getUncachedChildren, getUncachedGroupCount, getUncachedGroups, getValueAt, isAggregate, isCellEditable, isCountCached, isFooter, isHeader, isRangedModel, isValueCached, removeReorderListener, rowsReordered, setTreeModel, setTreeTableModel, setValueAt |
Methods inherited from class com.citra.treetable.TreeModelMap |
---|
getPathToRoot, getPathToRoot, getRoot, getTreeModel, nodeChanged, nodesChanged, nodeStructureChanged, valueForPathChanged |
Methods inherited from class com.citra.treetable.AbstractTreeTableModel |
---|
addTreeModelListener, fireTreeNodesChanged, fireTreeNodesInserted, fireTreeNodesRemoved, fireTreeStructureChanged, fireTreeTableStructureChanged, fireTreeTableStructureChanged, removeTreeModelListener, setRoot |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface com.citra.treetable.TreeTableModel |
---|
getColumnClass, getColumnCount, getColumnName, getValueAt, isAggregate, isCellEditable, isFooter, isHeader, setValueAt |
Methods inherited from interface javax.swing.tree.TreeModel |
---|
addTreeModelListener, getRoot, removeTreeModelListener, valueForPathChanged |
Field Detail |
---|
protected TableFilter defaultFilter
protected int filterMode
public static final int NODE_FILTER
public static final int LEVEL_FILTER
public static final int AND_FILTER
public static final int OR_FILTER
protected EventListenerList filterListenerList
Constructor Detail |
---|
public DefaultFilterTreeTableModel(TreeTableModel treeTableModel)
Method Detail |
---|
public void addFilterTreeTableModelListener(FilterTreeTableModelListener l)
addFilterTreeTableModelListener
in interface FilterTreeTableModel
l
- the listener to addpublic void clearFilters()
clearFilters
in interface FilterTreeTableModel
protected void fireApplyLevelFilter(FilterTreeTableModelEvent e)
e
- the eventprotected void fireApplyNodeFilter(FilterTreeTableModelEvent e)
e
- the eventprotected void fireClearFilters()
public Object getChild(Object parent, int index)
parent
at index index
in the parent's
child array. parent
must be a node previously obtained
from this data source. This should not return null
if index
is a valid index for parent
(that is index >= 0 &&
index < getChildCount(parent
)).
getChild
in interface TreeModel
getChild
in class TreeModelMap
parent
- a node in the tree, obtained from this data source
parent
at index index
public int getChildCount(Object parent)
parent
.
Returns 0 if the node
is a leaf or if it has no children. parent
must be a node
previously obtained from this data source.
getChildCount
in interface TreeModel
getChildCount
in class TreeModelMap
parent
- a node in the tree, obtained from this data source
parent
public TableFilter getDefaultFilter()
DefaultFilterTreeTableModel.setFilterAtLevel(com.citra.filter.TableFilter, int)
and DefaultFilterTreeTableModel.setFilterAtNode(com.citra.filter.TableFilter, java.lang.Object)
methods.
public TableFilter getFilterAtLevel(int level)
level
.
getFilterAtLevel
in interface FilterTreeTableModel
level
public TableFilter getFilterAtNode(Object node)
node
.
getFilterAtNode
in interface FilterTreeTableModel
node
public int getFilterMode()
retrieveFilter
method.
The mode can be:
NODE_FILTER: single filter assigned per node
LEVEL_FILTER: single filter assigned per level
AND_FILTER: AND combination of node and level filters
OR_FILTER: OR combination of node and level filters
public FilterTableModel getFilterTableModel()
public int getIndexOfChild(Object parent, Object child)
parent
is null
or child
is null
,
returns -1.
getIndexOfChild
in interface TreeModel
getIndexOfChild
in class TreeModelMap
parent
- a note in the tree, obtained from this data sourcechild
- the node we are interested in
child
or parent
are null
public int getLevelForNode(Object node)
node
- the node we want to retrieve the level for
public int[] getMappedIndexes(Object node)
getMappedIndexes
in class TreeTableModelMap
node
- the tree node
public TreeTableModel getUnfilteredTreeTableModel()
getUnfilteredTreeTableModel
in interface FilterTreeTableModel
public void removeFilterTreeTableModelListener(FilterTreeTableModelListener l)
removeFilterTreeTableModelListener
in interface FilterTreeTableModel
l
- the listener to removepublic TableFilter retrieveFilter(Object node)
node
.
retrieveFilter
in interface FilterTreeTableModel
node
- the node for which the filter is evaluated
public void setDefaultFilter(TableFilter newDefaultFilter)
DefaultFilterTreeTableModel.setFilterAtLevel(com.citra.filter.TableFilter, int)
and DefaultFilterTreeTableModel.setFilterAtNode(com.citra.filter.TableFilter, java.lang.Object)
methods.
newDefaultFilter
- the default filter to assignpublic void setFilterAtLevel(TableFilter filter, int level)
level
.
setFilterAtLevel
in interface FilterTreeTableModel
filter
- the table filter to assignlevel
- the level to assign the filter atpublic void setFilterAtNode(TableFilter filter, Object node)
node
.
setFilterAtNode
in interface FilterTreeTableModel
filter
- the table filter to assignnode
- the node for which the filter is assignedpublic void setFilterMode(int filterMode)
retrieveFilter
method.
The mode can be:
NODE_FILTER: single filter assigned per node
LEVEL_FILTER: single filter assigned per level
AND_FILTER: AND combination of node and level filters
OR_FILTER: OR combination of node and level filters
filterMode
- the filter modepublic boolean shouldFilter(Object node)
For example, for not filtering the root node:
return node != getRoot();
For not filtering the root node and its direct children nodes:
return node != getRoot() && super.getIndexOfChild(getRoot(), node) == -1;
To allow filtering only at a specific node level, and supposing node
is a DefaultMutableTreeNode:
DefaultMutableTreeNode n = (DefaultMutableTreeNode) node;
int level = n.getLevel();
return level == 3;
You can also take the filters currently installed in the filter tablemodel instance into consideration in your evaluation of this method:
TableFilter filter = getFilterTableModel().getTableFilter();
if (filter != null) {
int column = filter.getColumn();
if (column == 3 && node != getRoot()) return false;
}
return true;
node
- the affected node
public void treeNodesChanged(TreeModelEvent e)
Invoked after a node (or a set of siblings) has changed in some way. The node(s) have not changed locations in the tree or altered their children arrays, but other attributes have changed and may affect presentation. Example: the name of a file has changed, but it is in the same location in the file system.
To indicate the root has changed, childIndices and children will be null.
Use e.getPath()
to get the parent of the changed node(s).
e.getChildIndices()
returns the index(es) of the changed node(s).
treeNodesChanged
in interface TreeModelListener
treeNodesChanged
in class TreeModelMap
public void treeNodesInserted(TreeModelEvent e)
Invoked after nodes have been inserted into the tree.
Use e.getPath()
to get the parent of the new node(s).
e.getChildIndices()
returns the index(es) of the new node(s)
in ascending order.
treeNodesInserted
in interface TreeModelListener
treeNodesInserted
in class TreeModelMap
public void treeNodesRemoved(TreeModelEvent e)
Invoked after nodes have been removed from the tree. Note that if a subtree is removed from the tree, this method may only be invoked once for the root of the removed subtree, not once for each individual set of siblings removed.
Use e.getPath()
to get the former parent of the deleted node(s).
e.getChildIndices()
returns, in ascending order, the index(es)
the node(s) had before being deleted.
treeNodesRemoved
in interface TreeModelListener
treeNodesRemoved
in class TreeModelMap
public void treeStructureChanged(TreeModelEvent e)
Invoked after the tree has drastically changed structure from a given node down. If the path returned by e.getPath() is of length one and the first element does not identify the current root node the first element should become the new root of the tree.
Use e.getPath()
to get the path to the node.
e.getChildIndices()
returns null.
treeStructureChanged
in interface TreeModelListener
treeStructureChanged
in class TreeModelMap
public void clear()
public boolean isLeaf(Object node)
true
if node
is a leaf.
It is possible for this method to return false
even if node
has no children.
A directory in a filesystem, for example,
may contain no files; the node representing
the directory is not a leaf, but it also has no children.
isLeaf
in interface TreeModel
isLeaf
in class TreeModelMap
node
- a node in the tree, obtained from this data source
node
is a leafpublic void saveFilterState(ObjectOutputStream out) throws Exception
loadFilterState
method.
out
- the object output stream to write to when saving the filter state
Exception
public void loadFilterState(ObjectInputStream in) throws Exception
saveFilterState
method.
in
- the object input stream to read from in order to construct the filters
Exception
public Map getNodeFilters()
getNodeFilters
in interface FilterTreeTableModel
public static InputStream convertFilterState(InputStream input, String library) throws Exception
input
- the filter inputstream from the older versionlibrary
- the pathname to the jar file that created the stream
Exception
public static InputStream convertFilterState(InputStream input, String library, FilterConverter converter) throws Exception
input
- the filter inputstream from the older versionlibrary
- the pathname to the jar file that created the streamconverter
- supplies support for custom filters and tablefilters
Exception
|
Copyright © 2011 Citra Technologies. All Rights Reserved. | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |