JIDE 3.5.15

com.jidesoft.tree
Class FilterableCheckBoxTreeSelectionModel

java.lang.Object
  extended by javax.swing.tree.DefaultTreeSelectionModel
      extended by com.jidesoft.swing.CheckBoxTreeSelectionModel
          extended by com.jidesoft.tree.FilterableCheckBoxTreeSelectionModel
All Implemented Interfaces:
Serializable, Cloneable, EventListener, TreeModelListener, TreeSelectionModel

public class FilterableCheckBoxTreeSelectionModel
extends CheckBoxTreeSelectionModel

FilterableCheckBoxTreeSelectionModel is a subclass of CheckBoxTreeSelectionModel and use in CheckBoxTree to keep track of the checked tree paths.

With this class, you can solve the selection issue while implementing FilterableTreeModel in CheckBoxTree.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class com.jidesoft.swing.CheckBoxTreeSelectionModel
_pathHasAdded
 
Fields inherited from class javax.swing.tree.DefaultTreeSelectionModel
changeSupport, leadIndex, leadPath, leadRow, listenerList, listSelectionModel, rowMapper, selection, SELECTION_MODE_PROPERTY, selectionMode
 
Fields inherited from interface javax.swing.tree.TreeSelectionModel
CONTIGUOUS_TREE_SELECTION, DISCONTIGUOUS_TREE_SELECTION, SINGLE_TREE_SELECTION
 
Constructor Summary
FilterableCheckBoxTreeSelectionModel(TreeModel model)
           
FilterableCheckBoxTreeSelectionModel(TreeModel model, boolean digIn)
           
 
Method Summary
protected  void addSelectionPaths(TreePath[] paths, boolean needCheckPathSelection)
          Add the selection paths.
protected  boolean areSiblingsSelected(TreePath path)
          tells whether all siblings of given path are selected.
protected  Object getChild(Object node, int i)
          Get the child of node in the designated index.
protected  int getChildrenCount(Object node)
          Get the children count
protected  boolean isParentActuallySelected(TreePath path, TreePath parent)
          Check if the parent path is really selected.
 boolean isPartiallySelected(TreePath path)
          Tests whether there is any unselected node in the subtree of given path.
 void removeSelectionPaths(TreePath[] paths)
           
 void treeStructureChanged(TreeModelEvent e)
           
 
Methods inherited from class com.jidesoft.swing.CheckBoxTreeSelectionModel
addSelectionPaths, getModel, isDigIn, isPathSelected, isPathSelected, isRowSelected, isSingleEventMode, notifyPathChange, notifyPathChange, removeSelectionPaths, setBatchMode, setDigIn, setModel, setSelectionPaths, setSingleEventMode, treeNodesChanged, treeNodesInserted, treeNodesRemoved
 
Methods inherited from class javax.swing.tree.DefaultTreeSelectionModel
addPropertyChangeListener, addSelectionPath, addTreeSelectionListener, arePathsContiguous, canPathsBeAdded, canPathsBeRemoved, clearSelection, clone, fireValueChanged, getLeadSelectionPath, getLeadSelectionRow, getListeners, getMaxSelectionRow, getMinSelectionRow, getPropertyChangeListeners, getRowMapper, getSelectionCount, getSelectionMode, getSelectionPath, getSelectionPaths, getSelectionRows, getTreeSelectionListeners, insureRowContinuity, insureUniqueness, isSelectionEmpty, removePropertyChangeListener, removeSelectionPath, removeTreeSelectionListener, resetRowSelection, setRowMapper, setSelectionMode, setSelectionPath, toString, updateLeadIndex
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FilterableCheckBoxTreeSelectionModel

public FilterableCheckBoxTreeSelectionModel(TreeModel model)

FilterableCheckBoxTreeSelectionModel

public FilterableCheckBoxTreeSelectionModel(TreeModel model,
                                            boolean digIn)
Method Detail

addSelectionPaths

protected void addSelectionPaths(TreePath[] paths,
                                 boolean needCheckPathSelection)
Description copied from class: CheckBoxTreeSelectionModel
Add the selection paths.

Overrides:
addSelectionPaths in class CheckBoxTreeSelectionModel
Parameters:
paths - the paths to be added
needCheckPathSelection - the flag to indicating if the path selection should be checked to improve performance

removeSelectionPaths

public void removeSelectionPaths(TreePath[] paths)
Specified by:
removeSelectionPaths in interface TreeSelectionModel
Overrides:
removeSelectionPaths in class CheckBoxTreeSelectionModel

isPartiallySelected

public boolean isPartiallySelected(TreePath path)
Description copied from class: CheckBoxTreeSelectionModel
Tests whether there is any unselected node in the subtree of given path.

Inherited from JTree, the TreePath must be a path instance inside the tree model. If you populate a new TreePath instance on the fly, it would not work.

Overrides:
isPartiallySelected in class CheckBoxTreeSelectionModel
Parameters:
path - check if the path is partially selected.
Returns:
true if partially. Otherwise false.

isParentActuallySelected

protected boolean isParentActuallySelected(TreePath path,
                                           TreePath parent)
Description copied from class: CheckBoxTreeSelectionModel
Check if the parent path is really selected.

The default implementation is just return true. In filterable scenario, you could override this method to check more.

Inherited from JTree, the TreePath must be a path instance inside the tree model. If you populate a new TreePath instance on the fly, it would not work.

Overrides:
isParentActuallySelected in class CheckBoxTreeSelectionModel
Parameters:
path - the original path to be checked
parent - the parent part which is closest to the original path and is selected
Returns:
true if the path is actually selected without any doubt. Otherwise false.

areSiblingsSelected

protected boolean areSiblingsSelected(TreePath path)
Description copied from class: CheckBoxTreeSelectionModel
tells whether all siblings of given path are selected.

Inherited from JTree, the TreePath must be a path instance inside the tree model. If you populate a new TreePath instance on the fly, it would not work.

Overrides:
areSiblingsSelected in class CheckBoxTreeSelectionModel
Parameters:
path - the tree path
Returns:
true if the siblings are all selected.

getChildrenCount

protected int getChildrenCount(Object node)
Description copied from class: CheckBoxTreeSelectionModel
Get the children count

Overrides:
getChildrenCount in class CheckBoxTreeSelectionModel
Parameters:
node - the parent node
Returns:
the children count of the parent node.

getChild

protected Object getChild(Object node,
                          int i)
Description copied from class: CheckBoxTreeSelectionModel
Get the child of node in the designated index.

Overrides:
getChild in class CheckBoxTreeSelectionModel
Parameters:
node - the parent node
i - the child index
Returns:
the child node

treeStructureChanged

public void treeStructureChanged(TreeModelEvent e)
Specified by:
treeStructureChanged in interface TreeModelListener
Overrides:
treeStructureChanged in class CheckBoxTreeSelectionModel

JIDE 3.5.15