public class CheckboxTreeViewer extends TreeViewer implements ICheckable
Tree
control with checkboxes on each node.
This class is not intended to be subclassed outside the viewer framework. It is designed to be instantiated with a pre-existing SWT tree control and configured with a domain-specific content provider, label provider, element filter (optional), and element sorter (optional).
StructuredViewer.ColorAndFontCollector, StructuredViewer.ColorAndFontCollectorWithProvidersALL_LEVELSWIDGET_DATA_KEY| Constructor and Description |
|---|
CheckboxTreeViewer(Composite parent)
Creates a tree viewer on a newly-created tree control under the given parent.
|
CheckboxTreeViewer(Composite parent,
int style)
Creates a tree viewer on a newly-created tree control under the given parent.
|
CheckboxTreeViewer(Tree tree)
Creates a tree viewer on the given tree control.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addCheckStateListener(ICheckStateListener listener)
Adds a listener for changes to the checked state of elements
in this viewer.
|
protected void |
fireCheckStateChanged(CheckStateChangedEvent event)
Notifies any check state listeners that the check state of an element has changed.
|
boolean |
getChecked(Object element)
Returns the checked state of the given element.
|
Object[] |
getCheckedElements()
Returns a list of checked elements in this viewer's tree,
including currently hidden ones that are marked as
checked but are under a collapsed ancestor.
|
boolean |
getGrayed(Object element)
Returns the grayed state of the given element.
|
Object[] |
getGrayedElements()
Returns a list of grayed elements in this viewer's tree,
including currently hidden ones that are marked as
grayed but are under a collapsed ancestor.
|
protected void |
handleDoubleSelect(SelectionEvent event)
Handles a double-click select event from the widget.
|
protected void |
handleSelect(SelectionEvent event)
Handles a select event from the widget.
|
protected void |
preservingSelection(Runnable updateCode)
Attempts to preserves the current selection across a run of the given
code.
|
void |
removeCheckStateListener(ICheckStateListener listener)
Removes the given check state listener from this viewer.
|
void |
setAllChecked(boolean state)
Sets to the given value the checked state for all elements in this viewer.
|
boolean |
setChecked(Object element,
boolean state)
Sets the checked state for the given element in this viewer.
|
void |
setCheckedElements(Object[] elements)
Sets which elements are checked in this viewer's tree.
|
boolean |
setGrayChecked(Object element,
boolean state)
Check and gray the selection rather than calling both
setGrayed and setChecked as an optimization.
|
boolean |
setGrayed(Object element,
boolean state)
Sets the grayed state for the given element in this viewer.
|
void |
setGrayedElements(Object[] elements)
Sets which elements are grayed in this viewer's tree.
|
boolean |
setParentsGrayed(Object element,
boolean state)
Sets the grayed state for the given element and its parents
in this viewer.
|
boolean |
setSubtreeChecked(Object element,
boolean state)
Sets the checked state for the given element and its visible
children in this viewer.
|
addTreeListener, assertContentProviderType, buildLabel, cancelEditing, createChildren, doUpdateItem, editElement, getCellEditors, getCellModifier, getChild, getChildren, getColumnProperties, getControl, getExpanded, getItem, getItemCount, getItemCount, getItems, getLabelProvider, getParentElement, getParentItem, getRawChildren, getSelection, getTree, hookControl, internalAdd, internalRefreshStruct, isCellEditorActive, isExpandable, isSameSelection, mapElement, newItem, removeAll, replace, setCellEditors, setCellModifier, setChildCount, setColumnProperties, setExpanded, setLabelProvider, setSelection, showItemadd, add, addSelectionListener, addTreeListener, associate, collapseAll, collapseToLevel, createTreeItem, disassociate, doFindInputItem, doFindItem, doUpdateItem, expandAll, expandToLevel, expandToLevel, fireTreeCollapsed, fireTreeExpanded, getAutoExpandLevel, getExpandedElements, getExpandedState, getExpandedTreePaths, getFilteredChildren, getNextItem, getPreviousItem, getSelection, getSelectionFromWidget, getSortedChildren, getTreePathFromItem, getVisibleExpandedElements, handleTreeCollapse, handleTreeExpand, indexForElement, inputChanged, insert, internalCollapseToLevel, internalExpand, internalExpandToLevel, internalGetWidgetToSelect, internalRefresh, internalRefresh, internalRefresh, internalRemove, internalRemove, labelProviderChanged, remove, remove, remove, removeTreeListener, reveal, scrollDown, scrollUp, setAutoExpandLevel, setContentProvider, setExpandedElements, setExpandedState, setExpandedTreePaths, setSelectionToWidget, setSelectionToWidget, updateChildren, updatePlusaddDoubleClickListener, addDragSupport, addDropSupport, addFilter, addOpenListener, addPostSelectionChangedListener, assertElementsNotNull, equals, filter, findItem, findItems, fireDoubleClick, fireOpen, firePostSelectionChanged, getColorAndFontCollector, getComparator, getComparer, getFilters, getRoot, getSorter, handleInvalidSelection, handleLabelProviderChanged, handleOpen, handlePostSelect, hasFilters, internalUpdate, needsRefilter, refresh, refresh, refresh, refresh, refreshItem, removeDoubleClickListener, removeFilter, removeOpenListener, removePostSelectionChangedListener, resetFilters, setComparator, setComparer, setInput, setSelection, setSorter, setUseHashlookup, testFindItem, testFindItems, unmapAllElements, unmapElement, unmapElement, update, update, updateItem, updateSelection, usingElementMapgetContentProvider, getInput, handleDisposeaddHelpListener, addSelectionChangedListener, fireHelpRequested, fireSelectionChanged, getData, handleHelpRequest, removeHelpListener, removeSelectionChangedListener, setData, setSelectionclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddSelectionChangedListener, removeSelectionChangedListener, setSelectionpublic CheckboxTreeViewer(Composite parent)
CHECK and BORDER.
The viewer has no input, no content provider, a default label provider,
no sorter, and no filters.parent - the parent controlpublic CheckboxTreeViewer(Composite parent, int style)
CHECK style bit.
The viewer has no input, no content provider, a default label provider,
no sorter, and no filters.parent - the parent controlstyle - the SWT style bitspublic CheckboxTreeViewer(Tree tree)
SWT.CHECK style bit must be set on the given tree control.
The viewer has no input, no content provider, a default label provider,
no sorter, and no filters.tree - the tree controlpublic void addCheckStateListener(ICheckStateListener listener)
ICheckableaddCheckStateListener in interface ICheckablelistener - a check state listenerprotected void fireCheckStateChanged(CheckStateChangedEvent event)
event - a check state changed eventICheckStateListener.checkStateChanged(org.eclipse.jface.viewers.CheckStateChangedEvent)public boolean getChecked(Object element)
ICheckablegetChecked in interface ICheckableelement - the elementtrue if the element is checked,
and false if not checkedpublic Object[] getCheckedElements()
This method is typically used when preserving the interesting
state of a viewer; setCheckedElements is used during the restore.
setCheckedElements(java.lang.Object[])public boolean getGrayed(Object element)
element - the elementtrue if the element is grayed,
and false if not grayedpublic Object[] getGrayedElements()
This method is typically used when preserving the interesting
state of a viewer; setGrayedElements is used during the restore.
setGrayedElements(java.lang.Object[])protected void handleDoubleSelect(SelectionEvent event)
StructuredViewerThis method is internal to the framework; subclassers should not call this method.
handleDoubleSelect in class AbstractTreeViewerevent - the SWT selection eventprotected void handleSelect(SelectionEvent event)
StructuredViewerThis method is internal to the framework; subclassers should not call this method.
handleSelect in class StructuredViewerevent - the SWT selection eventprotected void preservingSelection(Runnable updateCode)
StructuredViewerThe default implementation of this method:
getSelection)setSelectionToWidgetgetSelection)
handleInvalidSelection if the selection did not
takepostUpdateHookpreservingSelection in class StructuredViewerupdateCode - the code to runpublic void removeCheckStateListener(ICheckStateListener listener)
ICheckableremoveCheckStateListener in interface ICheckablelistener - a check state listenerpublic boolean setChecked(Object element, boolean state)
ICheckablesetChecked in interface ICheckableelement - the elementstate - true if the item should be checked,
and false if it should be uncheckedtrue if the checked state could be set,
and false otherwisepublic void setCheckedElements(Object[] elements)
This method is typically used when restoring the interesting
state of a viewer captured by an earlier call to getCheckedElements.
elements - the array of checked elementsgetCheckedElements()public boolean setGrayed(Object element, boolean state)
element - the elementstate - true if the item should be grayed,
and false if it should be ungrayedtrue if the gray state could be set,
and false otherwisepublic boolean setGrayChecked(Object element, boolean state)
element - the item being checkedstate - a boolean indicating selection or deselectionpublic void setGrayedElements(Object[] elements)
This method is typically used when restoring the interesting
state of a viewer captured by an earlier call to getGrayedElements.
elements - the array of grayed elementsgetGrayedElements()public boolean setParentsGrayed(Object element, boolean state)
element - the elementstate - true if the item should be grayed,
and false if it should be ungrayedtrue if the element is visible and the gray
state could be set, and false otherwisesetGrayed(java.lang.Object, boolean)public boolean setSubtreeChecked(Object element, boolean state)
expandToLevel
for the element.element - the elementstate - true if the item should be checked,
and false if it should be uncheckedtrue if the checked state could be set,
and false otherwisepublic void setAllChecked(boolean state)
state - true if the element should be checked,
and false if it should be uncheckedGuidelines for using Eclipse APIs. Copyright (c) IBM Corp. and others 2000, 2006. All rights reserved.