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 SummaryNested ClassesNested classes/interfaces inherited from interface eu.essilab.lablib.checkboxtree.TreeCheckingModelTreeCheckingModel.CheckingMode
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected TreeCheckingModeprotected EventListenerListEvent listener list.protected TreeModel
- 
Constructor SummaryConstructorsConstructorDescriptionCreates a DefaultTreeCheckingModel with PropagateTreeCheckingMode.
- 
Method SummaryModifier 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
- 
listenerListEvent listener list.
- 
model
 
- 
- 
Constructor Details- 
DefaultTreeCheckingModelCreates a DefaultTreeCheckingModel with PropagateTreeCheckingMode.
 
- 
- 
Method Details- 
addCheckingPathAdds a path to the checked paths set.- Specified by:
- addCheckingPathin interface- TreeCheckingModel
- Parameters:
- path- the path to be added.
 
- 
addCheckingPathsAdds the paths to the checked paths set.- Specified by:
- addCheckingPathsin interface- TreeCheckingModel
- Parameters:
- paths- the paths to be added.
 
- 
addTreeCheckingListenerAdds x to the list of listeners that are notified each time the set of checking TreePaths changes.- Specified by:
- addTreeCheckingListenerin interface- TreeCheckingModel
- Parameters:
- x- the new listener to be added
 
- 
checkSubTreeChecks the subtree with root path.- Parameters:
- path- root of the tree to be checked
 
- 
clearCheckingpublic void clearChecking()Clears the checking.- Specified by:
- clearCheckingin interface- TreeCheckingModel
 
- 
fireValueChangedNotifies all listeners that are registered for tree selection events on this object.
- 
getCheckingMode- Specified by:
- getCheckingModein interface- TreeCheckingModel
- Returns:
- The CheckingMode.
 
- 
getCheckingPaths- Specified by:
- getCheckingPathsin interface- TreeCheckingModel
- Returns:
- Returns the paths that are in the checking.
 
- 
getCheckingRoots- Specified by:
- getCheckingRootsin interface- TreeCheckingModel
- Returns:
- Returns the path of any root of a subtree in the checking.
 
- 
getChildrenChecking
- 
getChildrenPathReturn 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 interface- TreeCheckingModel
- 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.
 
- 
isPathCheckedDescription copied from interface:TreeCheckingModelReturns true if the item identified by the path is currently checked.- Specified by:
- isPathCheckedin interface- TreeCheckingModel
- Parameters:
- path- a- TreePathidentifying a node
- Returns:
- true if the node is checked
 
- 
isPathEnabledDescription copied from interface:TreeCheckingModelReturns whether the specified path checking state can be toggled.- Specified by:
- isPathEnabledin interface- TreeCheckingModel
 
- 
isPathGreyedDescription copied from interface:TreeCheckingModelReturns whether the specified path is greyed.- Specified by:
- isPathGreyedin interface- TreeCheckingModel
 
- 
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.
 
- 
pathHasUncheckedChildrenNote: 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.
 
- 
removeCheckingPathRemoves a path from the checked paths set- Specified by:
- removeCheckingPathin interface- TreeCheckingModel
- Parameters:
- path- the path to be removed
 
- 
removeCheckingPathsRemoves the paths from the checked paths set- Specified by:
- removeCheckingPathsin interface- TreeCheckingModel
- Parameters:
- paths- the paths to be removed
 
- 
removeTreeCheckingListenerRemoves x from the list of listeners that are notified each time the set of checking TreePaths changes.- Specified by:
- removeTreeCheckingListenerin interface- TreeCheckingModel
- Parameters:
- x- the listener to remove
 
- 
setCheckingModeSets the specified checking mode. The consistence of the existing checking is not enforced nor controlled.- Specified by:
- setCheckingModein interface- TreeCheckingModel
- Parameters:
- mode- the checking mode to set.
 
- 
setCheckingModeSets the specified checking mode. The consistence of the existing checking is not enforced nor controlled.
- 
setCheckingPathSets the checking to path.- Specified by:
- setCheckingPathin interface- TreeCheckingModel
 
- 
setCheckingPathsSets the checking to the specified paths.- Specified by:
- setCheckingPathsin interface- TreeCheckingModel
 
- 
setPathEnabledSets whether or not the path is enabled.- Specified by:
- setPathEnabledin interface- TreeCheckingModel
- Parameters:
- path- the path to enable/disable
 
- 
setPathsEnabledSets whether or not the paths are enabled.- Specified by:
- setPathsEnabledin interface- TreeCheckingModel
- Parameters:
- paths- the paths to enable/disable
 
- 
setTreeModelSets the specified tree model. The current checking set is cleared.
- 
toggleCheckingPathDelegates to the current checkingMode the toggling style, using the Strategy Pattern.- Specified by:
- toggleCheckingPathin interface- TreeCheckingModel
 
- 
toStringReturn a string that describes the tree model including the values of checking, enabling, greying.
- 
uncheckSubTreeUnchecks the subtree rooted at path.- Parameters:
- path- root of the tree to be unchecked
 
- 
ungreySubTreeUngreys the subtree rooted at path.- Parameters:
- path- the root of the tree to be checked
 
- 
updateAncestorsGreynessUpdates 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
 
- 
updateCheckingConsistencypublic void updateCheckingConsistency()Updates consistency of the checking, by invoking updateSubTreeCheckingConsistency on the root node.
- 
updatePathGreynessUpdates 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.
 
- 
updateSubTreeCheckingConsistencyUpdates 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
 
- 
updateSubTreeGreynessUpdates the greyness of sub-tree starting at path.- Parameters:
- path- the root of the sub-tree to be grey-updated
 
- 
updateTreeGreynesspublic void updateTreeGreyness()Updates the greyness state of the entire tree.
 
-