public class CheckBoxTreeSelectionModel
extends javax.swing.tree.DefaultTreeSelectionModel
CheckBoxTreeSelectionModel
is a selection _model based on DefaultTreeSelectionModel
and use
in CheckBoxTree
to keep track of the checked tree paths.构造器和说明 |
---|
CheckBoxTreeSelectionModel(javax.swing.tree.TreeModel model) |
CheckBoxTreeSelectionModel(javax.swing.tree.TreeModel model,
boolean digIn) |
限定符和类型 | 方法和说明 |
---|---|
void |
addSelectionPaths(javax.swing.tree.TreePath[] paths)
Overrides the method in DefaultTreeSelectionModel to consider digIn mode.
|
javax.swing.tree.TreeModel |
getModel() |
boolean |
isDigIn()
Gets the dig-in mode.
|
boolean |
isPartiallySelected(javax.swing.tree.TreePath path)
Tests whether there is any unselected node in the subtree of given path.
|
boolean |
isPathSelected(javax.swing.tree.TreePath path,
boolean digIn)
Tells whether given path is selected. if dig is true,
then a path is assumed to be selected, if one of its ancestor is selected.
|
boolean |
isSingleEventMode() |
protected void |
notifyPathChange(javax.swing.tree.TreePath[] changedPaths,
boolean isNew,
javax.swing.tree.TreePath oldLeadSelection)
Notifies listeners of a change in path. changePaths should contain
instances of PathPlaceHolder.
|
protected void |
notifyPathChange(java.util.Vector changedPaths,
javax.swing.tree.TreePath oldLeadSelection) |
void |
removeSelectionPaths(javax.swing.tree.TreePath[] paths) |
void |
setBatchMode(boolean batchMode) |
void |
setDigIn(boolean digIn)
Sets the dig-in mode.
|
void |
setModel(javax.swing.tree.TreeModel model) |
void |
setSelectionPaths(javax.swing.tree.TreePath[] pPaths)
Overrides the method in DefaultTreeSelectionModel to consider digIn mode.
|
void |
setSingleEventMode(boolean singleEventMode)
Single event mode is a mode that always fires only one event when you select or unselect a tree node.
|
addPropertyChangeListener, addSelectionPath, addTreeSelectionListener, arePathsContiguous, canPathsBeAdded, canPathsBeRemoved, clearSelection, clone, fireValueChanged, getLeadSelectionPath, getLeadSelectionRow, getListeners, getMaxSelectionRow, getMinSelectionRow, getPropertyChangeListeners, getRowMapper, getSelectionCount, getSelectionMode, getSelectionPath, getSelectionPaths, getSelectionRows, getTreeSelectionListeners, insureRowContinuity, insureUniqueness, isPathSelected, isRowSelected, isSelectionEmpty, removePropertyChangeListener, removeSelectionPath, removeTreeSelectionListener, resetRowSelection, setRowMapper, setSelectionMode, setSelectionPath, toString, updateLeadIndex
public CheckBoxTreeSelectionModel(javax.swing.tree.TreeModel model)
public CheckBoxTreeSelectionModel(javax.swing.tree.TreeModel model, boolean digIn)
public javax.swing.tree.TreeModel getModel()
public void setModel(javax.swing.tree.TreeModel model)
public boolean isDigIn()
public void setDigIn(boolean digIn)
digIn
- true to enable dig-in mode. False to disable it.public boolean isPartiallySelected(javax.swing.tree.TreePath path)
path
- check if the path is partially selected.public boolean isPathSelected(javax.swing.tree.TreePath path, boolean digIn)
path
- check if the path is selected.digIn
- whether we will check its descendants.protected void notifyPathChange(java.util.Vector changedPaths, javax.swing.tree.TreePath oldLeadSelection)
notifyPathChange
在类中 javax.swing.tree.DefaultTreeSelectionModel
public void setSelectionPaths(javax.swing.tree.TreePath[] pPaths)
setSelectionPaths
在接口中 javax.swing.tree.TreeSelectionModel
setSelectionPaths
在类中 javax.swing.tree.DefaultTreeSelectionModel
pPaths
- the tree paths to be selected.public void addSelectionPaths(javax.swing.tree.TreePath[] paths)
addSelectionPaths
在接口中 javax.swing.tree.TreeSelectionModel
addSelectionPaths
在类中 javax.swing.tree.DefaultTreeSelectionModel
paths
- the tree paths to be added to selection paths.public void removeSelectionPaths(javax.swing.tree.TreePath[] paths)
removeSelectionPaths
在接口中 javax.swing.tree.TreeSelectionModel
removeSelectionPaths
在类中 javax.swing.tree.DefaultTreeSelectionModel
public boolean isSingleEventMode()
public void setSingleEventMode(boolean singleEventMode)
A -- a
|- b
|- c
Case 1: Assuming b and c are selected at this point, you click on a.
DefaultTreeSelectionModel.getSelectionPaths()
to find out.
In non-single event mode, the events reflect what happened inside the selection model. So you can get a complete picture
of the exact state without asking the selection model. The downside is it will generate too many events. With this option, you
can decide which mode you want to use that is the best for your case.
By default, singleEventMode is set to false to be compatible with the older versions that don't have this option.singleEventMode
- true or false.protected void notifyPathChange(javax.swing.tree.TreePath[] changedPaths, boolean isNew, javax.swing.tree.TreePath oldLeadSelection)
changedPaths
- the paths that are changed.isNew
- is it a new path.oldLeadSelection
- the old selection.public void setBatchMode(boolean batchMode)