|
Eclipse Platform 2.0 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.eclipse.jface.viewers.Viewer | +--org.eclipse.jface.viewers.ContentViewer | +--org.eclipse.jface.viewers.StructuredViewer | +--org.eclipse.jface.viewers.TableViewer | +--org.eclipse.jface.viewers.CheckboxTableViewer
A concrete viewer based on an SWT Table
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 table control and configured with a domain-specific content provider, label provider, element filter (optional), and element sorter (optional).
Field Summary |
Fields inherited from class org.eclipse.jface.viewers.Viewer |
WIDGET_DATA_KEY |
Constructor Summary | |
CheckboxTableViewer(Composite parent)
Deprecated. use newCheckList(Composite, int) or new CheckboxTableViewer(Table) instead (see below for details) |
|
CheckboxTableViewer(Composite parent,
int style)
Deprecated. use newCheckList(Composite, int) or new CheckboxTableViewer(Table) instead (see above for details) |
|
CheckboxTableViewer(Table table)
Creates a table viewer on the given table control. |
Method Summary | |
void |
addCheckStateListener(ICheckStateListener listener)
Adds a listener for changes to the checked state of elements in this viewer. |
protected static Table |
createTable(Composite parent,
int style)
Creates a new table control with one column. |
boolean |
getChecked(Object element)
Returns the checked state of the given element. |
Object[] |
getCheckedElements()
Returns a list of elements corresponding to checked table items in this viewer. |
boolean |
getGrayed(Object element)
Returns the grayed state of the given element. |
Object[] |
getGrayedElements()
Returns a list of elements corresponding to grayed nodes in this viewer. |
void |
handleSelect(SelectionEvent event)
Handles a select event from the widget. |
static CheckboxTableViewer |
newCheckList(Composite parent,
int style)
Creates a table viewer on a newly-created table control under the given parent. |
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. |
void |
setAllGrayed(boolean state)
Sets to the given value the grayed 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 nodes are checked in this viewer. |
boolean |
setGrayed(Object element,
boolean state)
Sets the grayed state for the given element in this viewer. |
void |
setGrayedElements(Object[] elements)
Sets which nodes are grayed in this viewer. |
Methods inherited from class org.eclipse.jface.viewers.TableViewer |
add, add, cancelEditing, doFindInputItem, doFindItem, doUpdateItem, editElement, getCellEditors, getCellModifier, getColumnProperties, getControl, getElementAt, getLabelProvider, getSelectionFromWidget, getTable, hookControl, indexForElement, inputChanged, insert, internalRefresh, internalRefresh, isCellEditorActive, remove, remove, reveal, setCellEditors, setCellModifier, setColumnProperties, setLabelProvider, setSelectionToWidget |
Methods inherited from class org.eclipse.jface.viewers.ContentViewer |
getContentProvider, getInput, handleDispose, labelProviderChanged |
Methods inherited from class org.eclipse.jface.viewers.Viewer |
addHelpListener, addSelectionChangedListener, fireHelpRequested, fireSelectionChanged, getData, handleHelpRequest, removeHelpListener, removeSelectionChangedListener, scrollDown, scrollUp, setData, setSelection |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public CheckboxTableViewer(Composite parent)
SWT.CHECK
and SWT.BORDER
.
The table has one column.
The viewer has no input, no content provider, a default label provider,
no sorter, and no filters.
This is equivalent to calling new CheckboxTableViewer(parent, SWT.BORDER)
.
See that constructor for more details.
parent
- the parent controlpublic CheckboxTableViewer(Composite parent, int style)
SWT.CHECK
style bit.
The table has one column.
The viewer has no input, no content provider, a default label provider,
no sorter, and no filters.
This also adds a TableColumn
for the single column,
and sets a TableLayout
on the table which sizes the column to fill
the table for its initial sizing, but does nothing on subsequent resizes.
If the caller just needs to show a single column with no header,
it is preferable to use the newCheckList
factory method instead,
since SWT properly handles the initial sizing and subsequent resizes in this case.
If the caller adds its own columns, uses Table.setHeadersVisible(true)
,
or needs to handle dynamic resizing of the table, it is recommended to
create the Table
itself, specifying the SWT.CHECK
style bit
(along with any other style bits needed), and use new CheckboxTableViewer(Table)
rather than this constructor.
parent
- the parent controlstyle
- SWT style bitspublic CheckboxTableViewer(Table table)
SWT.CHECK
style bit must be set on the given table control.
The viewer has no input, no content provider, a default label provider,
no sorter, and no filters.
table
- the table controlMethod Detail |
public static CheckboxTableViewer newCheckList(Composite parent, int style)
SWT.CHECK
style bit.
The table shows its contents in a single column, with no header.
The viewer has no input, no content provider, a default label provider,
no sorter, and no filters.
No TableColumn
is added. SWT does not require a
TableColumn
if showing only a single column with no header.
SWT correctly handles the initial sizing and subsequent resizes in this case.
parent
- the parent controlstyle
- SWT style bitspublic void addCheckStateListener(ICheckStateListener listener)
ICheckable
addCheckStateListener
in interface ICheckable
listener
- a check state listenerprotected static Table createTable(Composite parent, int style)
parent
- the parent controlstyle
- style bits
public boolean getChecked(Object element)
ICheckable
getChecked
in interface ICheckable
element
- the element
true
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 element
true
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[])
public void handleSelect(SelectionEvent event)
StructuredViewer
This method is internal to the framework; subclassers should not call this method.
handleSelect
in class StructuredViewer
event
- the SWT selection eventprotected void preservingSelection(Runnable updateCode)
StructuredViewer
The default implementation of this method:
getSelection
)setSelectionToWidget
getSelection
)handleInvalidSelection
if the selection
did not takepostUpdateHook
preservingSelection
in class StructuredViewer
updateCode
- the code to runpublic void removeCheckStateListener(ICheckStateListener listener)
ICheckable
removeCheckStateListener
in interface ICheckable
listener
- a check state listenerpublic void setAllChecked(boolean state)
state
- true
if the element should be checked,
and false
if it should be uncheckedpublic void setAllGrayed(boolean state)
state
- true
if the element should be grayed,
and false
if it should be ungrayedpublic boolean setChecked(Object element, boolean state)
ICheckable
setChecked
in interface ICheckable
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 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 list of checked elements (element type: Object
)getCheckedElements()
public boolean setGrayed(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
otherwisepublic 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()
|
Eclipse Platform 2.0 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |