|
JIDE 3.5.15 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.jidesoft.tree.AbstractTreeModel com.jidesoft.tree.DefaultTreeModelWrapper com.jidesoft.tree.FilterableTreeModel
public class FilterableTreeModel
FilterableTreeModel
is a TreeModelWrapper that can handle filters.
setAndMode(boolean)
to set to
false. If so, as long as one filter return false for a value, the value will be kept.
By default, filters won't take effect immediately. You need to call setFiltersApplied(true)
to apply
those filters. If filtersApplied
flag is true already, you just need to call refresh(). We don't refresh
automatically because you might have several filters to add. You can add all of them, then only call refresh once.
Field Summary | |
---|---|
protected List<Filter> |
_filters
The data structure contains all the filters. |
protected boolean |
_filtersApplied
A flag to turn on/off filters. |
Fields inherited from class com.jidesoft.tree.DefaultTreeModelWrapper |
---|
EVENT_TYPE_NODES_CHANGED, EVENT_TYPE_NODES_INSERTED, EVENT_TYPE_NODES_REMOVED, EVENT_TYPE_STRUCTURE_CHANGED |
Fields inherited from class com.jidesoft.tree.AbstractTreeModel |
---|
listenerList |
Constructor Summary | |
---|---|
FilterableTreeModel()
|
|
FilterableTreeModel(TreeModel model)
Creates a FilterableTreeModel from any tree model. |
Method Summary | |
---|---|
void |
addFilter(Filter filter)
Adds a filter. |
void |
addFilters(List<Filter> filters)
Adds a list of filters. |
void |
clearFilters()
Removes all filters. |
void |
clearFiltersOnTreePath(TreePath path)
Clears the filters related to the tree path. |
protected void |
configureListModelWrapper(ListModelWrapper wrapper,
Object node)
This is the method that will be called to configure the empty list model wrapper you created in DefaultTreeModelWrapper.createListModelWrapper(Object) . |
protected ListModelWrapper |
createListModelWrapper(Object node)
Creates an empty list model wrapper. |
Filter[] |
getFilters()
Gets the filters. |
protected Object |
getParent(Object node)
Get parent object of the specific node. |
boolean |
isAndMode()
Sets the logic of filters. |
protected boolean |
isFiltered(Object node)
Check if the node should be filtered away. |
protected boolean |
isFilterEndNode(Object node)
Checks if the node is filter end node. |
boolean |
isFilterEntireTreeImmediately()
|
boolean |
isFiltersApplied()
Checks if the filters are in effect. |
boolean |
isHideEmptyParentNode()
Returns the value of hideEmptyParentNode property. |
boolean |
isKeepAllChildren()
If a parent node matches, all its children will be kept if this flag is true. |
boolean |
isMatchesLeafNodeOnly()
If the filters matches the leaf node only. |
void |
refresh()
Reapply all filters after they are changed. |
void |
removeFilter(Filter filter)
Removes the filters. |
void |
setAndMode(boolean andMode)
Sets the logic of the filters. |
void |
setFilterEntireTreeImmediately(boolean filterEntireTreeImmediately)
|
void |
setFiltersApplied(boolean apply)
Applies or unapplies the filters. |
void |
setHideEmptyParentNode(boolean hideEmptyParentNode)
Sets the value of hideEmptyParentNode property. |
void |
setKeepAllChildren(boolean keepAllChildren)
Sets the value of keepAllChildren property. |
void |
setMatchesLeafNodeOnly(boolean matchesLeafNodeOnly)
Sets the value of matchesLeafNodeOnly property. |
void |
treeNodesChanged(TreeModelEvent e)
Method for TreeModelListener. |
void |
treeNodesInserted(TreeModelEvent e)
Method for TreeModelListener. |
void |
treeNodesRemoved(TreeModelEvent e)
Method for TreeModelListener. |
void |
treeStructureChanged(TreeModelEvent e)
Method for TreeModelListener. |
protected void |
updateTree(TreeModelEvent e)
Updates the tree based on the TreeModelEvent. |
protected void |
updateTreeOnNodeChanged(TreeModelEvent e)
Updates the tree based on the node changed event. |
protected void |
updateTreeOnNodeInserted(TreeModelEvent e)
Updates the tree based on the node inserted event. |
protected void |
updateTreeOnNodeRemoved(TreeModelEvent e)
Updates the tree based on the node removed event. |
protected void |
updateTreeOnStructureChanged(TreeModelEvent e)
Updates the tree based on the tree structure changed event. |
Methods inherited from class com.jidesoft.tree.DefaultTreeModelWrapper |
---|
clearAllListModelWrappers, clearListModelWrapper, convertTreeModelEvent, convertTreeModelEvent, getActualModel, getChild, getChildCount, getIndexOfChild, getListModelWrapper, getRoot, initWrapper, isLeaf, setActualModel, setListModelWrapper, valueForPathChanged |
Methods inherited from class com.jidesoft.tree.AbstractTreeModel |
---|
addTreeModelListener, fireTreeNodesChanged, fireTreeNodesInserted, fireTreeNodesRemoved, fireTreeStructureChanged, fireTreeStructureChanged, getPathToRoot, getPathToRoot, getTreeModelListeners, nodeChanged, nodesChanged, removeTreeModelListener |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected List<Filter> _filters
protected boolean _filtersApplied
setFiltersApplied(boolean)
with true will turn it on and setFiltersApplied(boolean)
with false will turn it off.
Constructor Detail |
---|
public FilterableTreeModel()
public FilterableTreeModel(TreeModel model)
model
- the tree modelMethod Detail |
---|
protected ListModelWrapper createListModelWrapper(Object node)
DefaultTreeModelWrapper
FilterableTreeModel
overrides it to create an instance of FilterableListModel
. SortableTreeModel
overrides it to create an instance of SortableListModel
.
Default implementation of this method in this class simply returns a new instance of
DefaultListModelWrapper
.
createListModelWrapper
in class DefaultTreeModelWrapper
node
- the tree node
protected void configureListModelWrapper(ListModelWrapper wrapper, Object node)
DefaultTreeModelWrapper
DefaultTreeModelWrapper.createListModelWrapper(Object)
. Subclass can override it to configure the list model. For example, FilterableTreeModel
uses this method to add filters that defined on FilterableTreeModel
to
FilterableListModel
and turn those filters on.
In default implementation on DefaultTreeModelWrapper
, this method is empty.
configureListModelWrapper
in class DefaultTreeModelWrapper
wrapper
- the wrapper to be configured.node
- the tree nodeprotected boolean isFilterEndNode(Object node)
node
- the tree node to check
public void addFilters(List<Filter> filters)
filters
- the filters to be addedpublic void addFilter(Filter filter)
filter
- the filter to be addedpublic void removeFilter(Filter filter)
addFilter(Filter)
.
filter
- the filter to be removedpublic void clearFilters()
public Filter[] getFilters()
addFilters(java.util.List)
public void setFiltersApplied(boolean apply)
apply
- true to apply the filters.public void refresh()
public boolean isFiltersApplied()
public boolean isAndMode()
public void setAndMode(boolean andMode)
andMode
- the filter modepublic void treeNodesInserted(TreeModelEvent e)
DefaultTreeModelWrapper
treeNodesInserted
in interface TreeModelListener
treeNodesInserted
in class DefaultTreeModelWrapper
e
- the TreeModelEventpublic void treeNodesRemoved(TreeModelEvent e)
DefaultTreeModelWrapper
treeNodesRemoved
in interface TreeModelListener
treeNodesRemoved
in class DefaultTreeModelWrapper
e
- the TreeModelEventpublic void treeStructureChanged(TreeModelEvent e)
DefaultTreeModelWrapper
treeStructureChanged
in interface TreeModelListener
treeStructureChanged
in class DefaultTreeModelWrapper
e
- the TreeModelEventpublic void treeNodesChanged(TreeModelEvent e)
DefaultTreeModelWrapper
treeNodesChanged
in interface TreeModelListener
treeNodesChanged
in class DefaultTreeModelWrapper
e
- the TreeModelEventpublic void clearFiltersOnTreePath(TreePath path)
path
- the tree path.protected void updateTreeOnNodeInserted(TreeModelEvent e)
e
- TreeModelEventprotected void updateTreeOnNodeRemoved(TreeModelEvent e)
e
- TreeModelEventprotected void updateTreeOnNodeChanged(TreeModelEvent e)
e
- TreeModelEventprotected void updateTreeOnStructureChanged(TreeModelEvent e)
e
- TreeModelEventprotected boolean isFiltered(Object node)
node
- the node
protected void updateTree(TreeModelEvent e)
e
- TreeModelEventpublic boolean isFilterEntireTreeImmediately()
public void setFilterEntireTreeImmediately(boolean filterEntireTreeImmediately)
public boolean isHideEmptyParentNode()
isMatchesLeafNodeOnly()
returns true.
public void setHideEmptyParentNode(boolean hideEmptyParentNode)
hideEmptyParentNode
- true or falsepublic boolean isMatchesLeafNodeOnly()
public void setMatchesLeafNodeOnly(boolean matchesLeafNodeOnly)
matchesLeafNodeOnly
- true or falsepublic boolean isKeepAllChildren()
public void setKeepAllChildren(boolean keepAllChildren)
keepAllChildren
- the flagprotected Object getParent(Object node)
node
- the node
|
JIDE 3.5.15 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |