Package eu.essilab.lablib.checkboxtree
Class DefaultTreeCheckingModel
java.lang.Object
eu.essilab.lablib.checkboxtree.DefaultTreeCheckingModel
- All Implemented Interfaces:
TreeCheckingModel
The default checking model, providing methods for storing and retrieving the
checked TreePaths. Adding/removing paths is delegated to a CheckingMode
instance. This implementation is based on TreePath only and does not take
advantage of TreeNode convenience methods (this is left to future/alternative
implementations).
- Author:
- Lorenzo Bigagli, Enrico Boldrini
-
Nested Class Summary
Nested classes/interfaces inherited from interface eu.essilab.lablib.checkboxtree.TreeCheckingModel
TreeCheckingModel.CheckingMode
-
Field Summary
Modifier and TypeFieldDescriptionprotected TreeCheckingMode
protected EventListenerList
Event listener list.protected TreeModel
-
Constructor Summary
ConstructorDescriptionCreates a DefaultTreeCheckingModel with PropagateTreeCheckingMode. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addCheckingPath
(TreePath path) Adds a path to the checked paths set.void
addCheckingPaths
(TreePath[] paths) Adds the paths to the checked paths set.void
Adds x to the list of listeners that are notified each time the set of checking TreePaths changes.void
checkSubTree
(TreePath path) Checks the subtree with root path.void
Clears the checking.protected void
Notifies all listeners that are registered for tree selection events on this object.TreePath[]
TreePath[]
getChildrenChecking
(TreePath path) protected TreePath[]
getChildrenPath
(TreePath path) Return the paths that are children of path, using methods of TreeModel.TreePath[]
boolean
hasDifferentChildren
(TreePath path) boolean
isPathChecked
(TreePath path) Returns true if the item identified by the path is currently checked.boolean
isPathEnabled
(TreePath path) Returns whether the specified path checking state can be toggled.boolean
isPathGreyed
(TreePath path) Returns whether the specified path is greyed.boolean
protected boolean
pathHasChildrenWithValue
(TreePath path, boolean value) boolean
Note: The checking and the greyness of children MUST be consistent to work properly.void
removeCheckingPath
(TreePath path) Removes a path from the checked paths setvoid
removeCheckingPaths
(TreePath[] paths) Removes the paths from the checked paths setvoid
Removes x from the list of listeners that are notified each time the set of checking TreePaths changes.void
Sets the specified checking mode.void
Sets the specified checking mode.void
setCheckingPath
(TreePath path) Sets the checking to path.void
setCheckingPaths
(TreePath[] paths) Sets the checking to the specified paths.void
setPathEnabled
(TreePath path, boolean enable) Sets whether or not the path is enabled.void
setPathsEnabled
(TreePath[] paths, boolean enable) Sets whether or not the paths are enabled.void
setTreeModel
(TreeModel newModel) Sets the specified tree model.void
toggleCheckingPath
(TreePath path) Delegates to the current checkingMode the toggling style, using the Strategy Pattern.toString()
Return a string that describes the tree model including the values of checking, enabling, greying.void
uncheckSubTree
(TreePath path) Unchecks the subtree rooted at path.void
ungreySubTree
(TreePath path) Ungreys the subtree rooted at path.void
Updates the grayness value of the parents of path.void
Updates consistency of the checking, by invoking updateSubTreeCheckingConsistency on the root node.protected void
updatePathGreyness
(TreePath ancestor) Updates the greyness value value for the given path if there are children with different values.void
Updates consistency of the checking of sub-tree starting at path.void
Updates the greyness of sub-tree starting at path.void
Updates the greyness state of the entire tree.
-
Field Details
-
checkingMode
-
listenerList
Event listener list. -
model
-
-
Constructor Details
-
DefaultTreeCheckingModel
Creates a DefaultTreeCheckingModel with PropagateTreeCheckingMode.
-
-
Method Details
-
addCheckingPath
Adds a path to the checked paths set.- Specified by:
addCheckingPath
in interfaceTreeCheckingModel
- Parameters:
path
- the path to be added.
-
addCheckingPaths
Adds the paths to the checked paths set.- Specified by:
addCheckingPaths
in interfaceTreeCheckingModel
- Parameters:
paths
- the paths to be added.
-
addTreeCheckingListener
Adds x to the list of listeners that are notified each time the set of checking TreePaths changes.- Specified by:
addTreeCheckingListener
in interfaceTreeCheckingModel
- Parameters:
x
- the new listener to be added
-
checkSubTree
Checks the subtree with root path.- Parameters:
path
- root of the tree to be checked
-
clearChecking
public void clearChecking()Clears the checking.- Specified by:
clearChecking
in interfaceTreeCheckingModel
-
fireValueChanged
Notifies all listeners that are registered for tree selection events on this object. -
getCheckingMode
- Specified by:
getCheckingMode
in interfaceTreeCheckingModel
- Returns:
- The CheckingMode.
-
getCheckingPaths
- Specified by:
getCheckingPaths
in interfaceTreeCheckingModel
- Returns:
- Returns the paths that are in the checking.
-
getCheckingRoots
- Specified by:
getCheckingRoots
in interfaceTreeCheckingModel
- Returns:
- Returns the path of any root of a subtree in the checking.
-
getChildrenChecking
-
getChildrenPath
Return the paths that are children of path, using methods of TreeModel. Nodes don't have to be of type TreeNode.- Parameters:
path
- the parent path- Returns:
- the array of children path
-
getGreyingPaths
- Specified by:
getGreyingPaths
in interfaceTreeCheckingModel
- Returns:
- The paths that are in the greying.
-
hasDifferentChildren
- Parameters:
path
- the root path of the tree to be checked.- Returns:
- true if exists a child of node with a value different from itself.
-
isPathChecked
Description copied from interface:TreeCheckingModel
Returns true if the item identified by the path is currently checked.- Specified by:
isPathChecked
in interfaceTreeCheckingModel
- Parameters:
path
- aTreePath
identifying a node- Returns:
- true if the node is checked
-
isPathEnabled
Description copied from interface:TreeCheckingModel
Returns whether the specified path checking state can be toggled.- Specified by:
isPathEnabled
in interfaceTreeCheckingModel
-
isPathGreyed
Description copied from interface:TreeCheckingModel
Returns whether the specified path is greyed.- Specified by:
isPathGreyed
in interfaceTreeCheckingModel
-
pathHasCheckedChildren
- Parameters:
path
- the root of the subtree to be checked.- Returns:
- true if exists a checked node in the subtree of path.
-
pathHasChildrenWithValue
- Parameters:
path
- the root of the subtree to be searched.value
- the value to be found.- Returns:
- true if exists a node with checked status value in the subtree of path.
-
pathHasUncheckedChildren
Note: The checking and the greyness of children MUST be consistent to work properly.- Parameters:
path
- the root of the subtree to be checked.- Returns:
- true if exists an unchecked node in the subtree of path.
-
removeCheckingPath
Removes a path from the checked paths set- Specified by:
removeCheckingPath
in interfaceTreeCheckingModel
- Parameters:
path
- the path to be removed
-
removeCheckingPaths
Removes the paths from the checked paths set- Specified by:
removeCheckingPaths
in interfaceTreeCheckingModel
- Parameters:
paths
- the paths to be removed
-
removeTreeCheckingListener
Removes x from the list of listeners that are notified each time the set of checking TreePaths changes.- Specified by:
removeTreeCheckingListener
in interfaceTreeCheckingModel
- Parameters:
x
- the listener to remove
-
setCheckingMode
Sets the specified checking mode. The consistence of the existing checking is not enforced nor controlled.- Specified by:
setCheckingMode
in interfaceTreeCheckingModel
- Parameters:
mode
- the checking mode to set.
-
setCheckingMode
Sets the specified checking mode. The consistence of the existing checking is not enforced nor controlled. -
setCheckingPath
Sets the checking to path.- Specified by:
setCheckingPath
in interfaceTreeCheckingModel
-
setCheckingPaths
Sets the checking to the specified paths.- Specified by:
setCheckingPaths
in interfaceTreeCheckingModel
-
setPathEnabled
Sets whether or not the path is enabled.- Specified by:
setPathEnabled
in interfaceTreeCheckingModel
- Parameters:
path
- the path to enable/disable
-
setPathsEnabled
Sets whether or not the paths are enabled.- Specified by:
setPathsEnabled
in interfaceTreeCheckingModel
- Parameters:
paths
- the paths to enable/disable
-
setTreeModel
Sets the specified tree model. The current checking set is cleared. -
toggleCheckingPath
Delegates to the current checkingMode the toggling style, using the Strategy Pattern.- Specified by:
toggleCheckingPath
in interfaceTreeCheckingModel
-
toString
Return a string that describes the tree model including the values of checking, enabling, greying. -
uncheckSubTree
Unchecks the subtree rooted at path.- Parameters:
path
- root of the tree to be unchecked
-
ungreySubTree
Ungreys the subtree rooted at path.- Parameters:
path
- the root of the tree to be checked
-
updateAncestorsGreyness
Updates the grayness value of the parents of path. Note: the greyness and checking of the other nodes (not ancestors) MUST BE consistent.- Parameters:
path
- the treepath containing the ancestors to be grey-updated
-
updateCheckingConsistency
public void updateCheckingConsistency()Updates consistency of the checking, by invoking updateSubTreeCheckingConsistency on the root node. -
updatePathGreyness
Updates the greyness value value for the given path if there are children with different values. Note: the greyness and cheking of children MUST BE consistent.- Parameters:
ancestor
- the path to be grey-updated.
-
updateSubTreeCheckingConsistency
Updates consistency of the checking of sub-tree starting at path. It's based on paths greyness.- Parameters:
path
- the root of the sub-tree to be grey-updated
-
updateSubTreeGreyness
Updates the greyness of sub-tree starting at path.- Parameters:
path
- the root of the sub-tree to be grey-updated
-
updateTreeGreyness
public void updateTreeGreyness()Updates the greyness state of the entire tree.
-