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 ClassesNested classes/interfaces inherited from interface eu.essilab.lablib.checkboxtree.TreeCheckingModel
TreeCheckingModel.CheckingMode -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected TreeCheckingModeprotected EventListenerListEvent listener list.protected TreeModel -
Constructor Summary
ConstructorsConstructorDescriptionCreates a DefaultTreeCheckingModel with PropagateTreeCheckingMode. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCheckingPath(TreePath path) Adds a path to the checked paths set.voidaddCheckingPaths(TreePath[] paths) Adds the paths to the checked paths set.voidAdds x to the list of listeners that are notified each time the set of checking TreePaths changes.voidcheckSubTree(TreePath path) Checks the subtree with root path.voidClears the checking.protected voidNotifies 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[]booleanhasDifferentChildren(TreePath path) booleanisPathChecked(TreePath path) Returns true if the item identified by the path is currently checked.booleanisPathEnabled(TreePath path) Returns whether the specified path checking state can be toggled.booleanisPathGreyed(TreePath path) Returns whether the specified path is greyed.booleanprotected booleanpathHasChildrenWithValue(TreePath path, boolean value) booleanNote: The checking and the greyness of children MUST be consistent to work properly.voidremoveCheckingPath(TreePath path) Removes a path from the checked paths setvoidremoveCheckingPaths(TreePath[] paths) Removes the paths from the checked paths setvoidRemoves x from the list of listeners that are notified each time the set of checking TreePaths changes.voidSets the specified checking mode.voidSets the specified checking mode.voidsetCheckingPath(TreePath path) Sets the checking to path.voidsetCheckingPaths(TreePath[] paths) Sets the checking to the specified paths.voidsetPathEnabled(TreePath path, boolean enable) Sets whether or not the path is enabled.voidsetPathsEnabled(TreePath[] paths, boolean enable) Sets whether or not the paths are enabled.voidsetTreeModel(TreeModel newModel) Sets the specified tree model.voidtoggleCheckingPath(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.voiduncheckSubTree(TreePath path) Unchecks the subtree rooted at path.voidungreySubTree(TreePath path) Ungreys the subtree rooted at path.voidUpdates the grayness value of the parents of path.voidUpdates consistency of the checking, by invoking updateSubTreeCheckingConsistency on the root node.protected voidupdatePathGreyness(TreePath ancestor) Updates the greyness value value for the given path if there are children with different values.voidUpdates consistency of the checking of sub-tree starting at path.voidUpdates the greyness of sub-tree starting at path.voidUpdates 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:
addCheckingPathin interfaceTreeCheckingModel- Parameters:
path- the path to be added.
-
addCheckingPaths
Adds the paths to the checked paths set.- Specified by:
addCheckingPathsin 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:
addTreeCheckingListenerin 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:
clearCheckingin interfaceTreeCheckingModel
-
fireValueChanged
Notifies all listeners that are registered for tree selection events on this object. -
getCheckingMode
- Specified by:
getCheckingModein interfaceTreeCheckingModel- Returns:
- The CheckingMode.
-
getCheckingPaths
- Specified by:
getCheckingPathsin interfaceTreeCheckingModel- Returns:
- Returns the paths that are in the checking.
-
getCheckingRoots
- Specified by:
getCheckingRootsin 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:
getGreyingPathsin 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:TreeCheckingModelReturns true if the item identified by the path is currently checked.- Specified by:
isPathCheckedin interfaceTreeCheckingModel- Parameters:
path- aTreePathidentifying a node- Returns:
- true if the node is checked
-
isPathEnabled
Description copied from interface:TreeCheckingModelReturns whether the specified path checking state can be toggled.- Specified by:
isPathEnabledin interfaceTreeCheckingModel
-
isPathGreyed
Description copied from interface:TreeCheckingModelReturns whether the specified path is greyed.- Specified by:
isPathGreyedin 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:
removeCheckingPathin interfaceTreeCheckingModel- Parameters:
path- the path to be removed
-
removeCheckingPaths
Removes the paths from the checked paths set- Specified by:
removeCheckingPathsin 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:
removeTreeCheckingListenerin 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:
setCheckingModein 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:
setCheckingPathin interfaceTreeCheckingModel
-
setCheckingPaths
Sets the checking to the specified paths.- Specified by:
setCheckingPathsin interfaceTreeCheckingModel
-
setPathEnabled
Sets whether or not the path is enabled.- Specified by:
setPathEnabledin interfaceTreeCheckingModel- Parameters:
path- the path to enable/disable
-
setPathsEnabled
Sets whether or not the paths are enabled.- Specified by:
setPathsEnabledin 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:
toggleCheckingPathin 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.
-