|
Eclipse Platform Release 3.6 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.eclipse.jface.viewers.Viewer
org.eclipse.jface.viewers.ContentViewer
org.eclipse.jface.viewers.StructuredViewer
org.eclipse.jface.viewers.ColumnViewer
org.eclipse.jface.viewers.AbstractTreeViewer
org.eclipse.jface.viewers.TreeViewer
org.eclipse.jface.viewers.CheckboxTreeViewer
public class CheckboxTreeViewer
A concrete tree-structured viewer based on an SWT Tree
control with checkboxes on each node.
This class supports setting an ICheckStateProvider to
set the checkbox states. To see standard SWT behavior, view
SWT Snippet274.
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).
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class org.eclipse.jface.viewers.StructuredViewer |
|---|
StructuredViewer.ColorAndFontCollector, StructuredViewer.ColorAndFontCollectorWithProviders |
| Field Summary |
|---|
| Fields inherited from class org.eclipse.jface.viewers.AbstractTreeViewer |
|---|
ALL_LEVELS |
| Fields inherited from class org.eclipse.jface.viewers.Viewer |
|---|
WIDGET_DATA_KEY |
| Constructor Summary | |
|---|---|
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. |
|
| Method Summary | |
|---|---|
void |
addCheckStateListener(ICheckStateListener listener)
Adds a listener for changes to the checked state of elements in this viewer. |
protected void |
doUpdateItem(Item item,
java.lang.Object element)
Copies the attributes of the given element into the given SWT item. |
protected void |
fireCheckStateChanged(CheckStateChangedEvent event)
Notifies any check state listeners that the check state of an element has changed. |
boolean |
getChecked(java.lang.Object element)
Returns the checked state of the given element. |
java.lang.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(java.lang.Object element)
Returns the grayed state of the given element. |
java.lang.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(java.lang.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)
Deprecated. as this method only checks or unchecks visible items is is recommended that setSubtreeChecked(Object, boolean)
is used instead. |
boolean |
setChecked(java.lang.Object element,
boolean state)
Sets the checked state for the given element in this viewer. |
void |
setCheckedElements(java.lang.Object[] elements)
Sets which elements are checked in this viewer's tree. |
void |
setCheckStateProvider(ICheckStateProvider checkStateProvider)
Sets the ICheckStateProvider for this CheckboxTreeViewer. |
boolean |
setGrayChecked(java.lang.Object element,
boolean state)
Check and gray the selection rather than calling both setGrayed and setChecked as an optimization. |
boolean |
setGrayed(java.lang.Object element,
boolean state)
Sets the grayed state for the given element in this viewer. |
void |
setGrayedElements(java.lang.Object[] elements)
Sets which elements are grayed in this viewer's tree. |
boolean |
setParentsGrayed(java.lang.Object element,
boolean state)
Sets the grayed state for the given element and its parents in this viewer. |
boolean |
setSubtreeChecked(java.lang.Object element,
boolean state)
Sets the checked state for the given element and its visible children in this viewer. |
| Methods inherited from class org.eclipse.jface.viewers.ColumnViewer |
|---|
applyEditorValue, cancelEditing, checkBusy, getCell, getCellEditors, getCellModifier, getColumnProperties, getColumnViewerEditor, getItem, getLabelProvider, getViewerRow, hookEditingSupport, isBusy, isCellEditorActive, refresh, refresh, setBusy, setCellEditors, setCellModifier, setColumnProperties, setColumnViewerEditor, setLabelProvider, triggerEditorActivationEvent, update |
| Methods inherited from class org.eclipse.jface.viewers.ContentViewer |
|---|
getContentProvider, getInput |
| Methods inherited from class org.eclipse.jface.viewers.Viewer |
|---|
addHelpListener, addSelectionChangedListener, fireHelpRequested, fireSelectionChanged, getData, handleHelpRequest, removeHelpListener, removeSelectionChangedListener, setData, setSelection |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface org.eclipse.jface.viewers.ISelectionProvider |
|---|
addSelectionChangedListener, removeSelectionChangedListener, setSelection |
| Constructor Detail |
|---|
public 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 control
public 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 control| Method Detail |
|---|
public void addCheckStateListener(ICheckStateListener listener)
ICheckable
addCheckStateListener in interface ICheckablelistener - a check state listenerpublic void setCheckStateProvider(ICheckStateProvider checkStateProvider)
ICheckStateProvider for this CheckboxTreeViewer.
The check state provider will supply the logic for deciding whether the
check box associated with each item should be checked, grayed or
unchecked.
checkStateProvider - The provider.
protected void doUpdateItem(Item item,
java.lang.Object element)
AbstractTreeViewer
doUpdateItem in class AbstractTreeVieweritem - the SWT itemelement - the elementprotected void fireCheckStateChanged(CheckStateChangedEvent event)
event - a check state changed eventICheckStateListener.checkStateChanged(org.eclipse.jface.viewers.CheckStateChangedEvent)public boolean getChecked(java.lang.Object element)
ICheckable
getChecked in interface ICheckableelement - the element
true if the element is checked,
and false if not checkedpublic java.lang.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(java.lang.Object element)
element - the element
true if the element is grayed,
and false if not grayedpublic java.lang.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(java.lang.Runnable updateCode)
StructuredViewerThe default implementation of this method:
getSelection)setSelectionToWidgetgetSelection)handleInvalidSelection if the resulting selection
is different from the old selection
preservingSelection in class StructuredViewerupdateCode - the code to run
see #getPreserveSelection()public void removeCheckStateListener(ICheckStateListener listener)
ICheckable
removeCheckStateListener in interface ICheckablelistener - a check state listener
public boolean setChecked(java.lang.Object element,
boolean state)
ICheckable
setChecked in interface ICheckableelement - the elementstate - true if the item should be checked,
and false if it should be unchecked
true if the checked state could be set,
and false otherwisepublic void setCheckedElements(java.lang.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(java.lang.Object element,
boolean state)
element - the elementstate - true if the item should be grayed,
and false if it should be ungrayed
true if the gray state could be set,
and false otherwise
public boolean setGrayChecked(java.lang.Object element,
boolean state)
element - the item being checkedstate - a boolean indicating selection or deselection
public void setGrayedElements(java.lang.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(java.lang.Object element,
boolean state)
element - the elementstate - true if the item should be grayed,
and false if it should be ungrayed
true if the element is visible and the gray
state could be set, and false otherwisesetGrayed(java.lang.Object, boolean)
public boolean setSubtreeChecked(java.lang.Object element,
boolean state)
expandToLevel
for the element.
Does not fire events to check state listeners.
element - the elementstate - true if the item should be checked,
and false if it should be unchecked
true if the checked state could be set,
and false otherwisepublic void setAllChecked(boolean state)
setSubtreeChecked(Object, boolean)
is used instead.
expandToLevel
for the element.
state - true if the element should be checked,
and false if it should be uncheckedsetSubtreeChecked(Object, boolean)
|
Eclipse Platform Release 3.6 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
Guidelines for using Eclipse APIs.
Copyright (c) Eclipse contributors and others 2000, 2010. All rights reserved.