Class ColumnViewer
- All Implemented Interfaces:
- IInputProvider,- IInputSelectionProvider,- IPostSelectionProvider,- ISelectionProvider
- Direct Known Subclasses:
- AbstractTableViewer,- AbstractTreeViewer
ColumnViewer should implement a matching concrete subclass of ViewerColumn.
 This class is not intended to be subclassed outside of the JFace viewers framework.
- Since:
- 3.3
- 
Nested Class SummaryNested classes/interfaces inherited from class org.eclipse.jface.viewers.StructuredViewerStructuredViewer.ColorAndFontCollector, StructuredViewer.ColorAndFontCollectorWithProviders
- 
Field SummaryFields inherited from class org.eclipse.jface.viewers.ViewerWIDGET_DATA_KEY
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidApply the value of the active cell editor if one is active.voidCancels a currently active cell editor if one is active.protected booleanChecks if this viewer is currently busy, logging a warning and returningtrueif it is busy.protected abstract ColumnViewerEditorCreates the viewer editor used for editing cell contents.protected voiddisassociate(Item item) Disassociates the given SWT item from its corresponding element.protected abstract intReturns the number of columns contained in the receiver.voideditElement(Object element, int column) Starts editing the given element at the given column index.protected voidNotifies any post selection listeners that a post selection event has been received.Returns the viewer cell at the given widget-relative coordinates, ornullif there is no cell at that locationReturn the CellEditors for the receiver, ornullif no cell editors are set.Returns the cell modifier of this viewer, ornullif none has been set.Object[]Returns the column properties of this table viewer.protected abstract WidgetgetColumnViewerOwner(int columnIndex) Returns the column widget at the given column index.protected ItemgetItem(int x, int y) Returns the item at the given display-relative coordinates, ornullif there is no item at that location or the underlying SWT-Control is not made up ofItem(e.gListViewer)protected abstract ItemReturns theItemat the given widget-relative coordinates, ornullif there is no item at the given coordinates.getLabelProvider(int columnIndex) Returns the label provider associated with the column at the given index ornullif no column with this index is known.protected Object[]getRawChildren(Object parent) Returns the children of the given parent without sorting and filtering them.protected Object[]getSortedChildren(Object parent) Returns the sorted and filtered set of children of the given element.protected ViewerRowgetViewerRow(Point point) Returns the viewer row at the given widget-relative coordinates.protected abstract ViewerRowgetViewerRowFromItem(Widget item) Returns aViewerRowassociated with the given row widget.protected voidhandleDispose(DisposeEvent event) Handles a dispose event on this viewer's control.protected voidhandleDoubleSelect(SelectionEvent event) Handles a double-click select event from the widget.protected voidhookControl(Control control) Adds event listener hooks to the given control.protected voidhookEditingSupport(Control control) Hook up the editing support.booleanisBusy()Returnstrueif this viewer is currently busy processing a refresh, add, remove, insert, replace, setItemCount, expandToLevel, update, setExpandedElements, or similar method that may make calls to client code.booleanReturns whether there is an active cell editor.final booleanisExpandableNode(Object element) Return if it is an instance of ExpandableNodevoidRefreshes this viewer starting with the given element.voidRefreshes this viewer starting with the given element.protected voidsetBusy(boolean busy) Sets the busy state of this viewer.voidsetCellEditors(CellEditor[] editors) Sets the cell editors of this column viewer.voidsetCellModifier(ICellModifier modifier) Sets the cell modifier for this column viewer.voidsetColumnProperties(String[] columnProperties) Sets the column properties of this column viewer.voidsetColumnViewerEditor(ColumnViewerEditor columnViewerEditor) voidsetDisplayIncrementally(int incrementSize) Sets the viewers items limit on direct children at one level.voidsetLabelProvider(IBaseLabelProvider labelProvider) The column viewer implementation of thisViewerframework method ensures that the given label provider is an instance ofITableLabelProvider,ILabelProvider, orCellLabelProvider.protected voidInvoking this method fires an editor activation event which tries to enable the editor but before this event is passed toColumnViewerEditorActivationStrategyto see if this event should really trigger editor activationprotected voidRemoves all elements from the map.voidUpdates the given element's presentation when one or more of its properties changes.protected voidupdateSelection(ISelection selection) Updates the selection of this viewer.Methods inherited from class org.eclipse.jface.viewers.StructuredVieweraddDoubleClickListener, addDragSupport, addDropSupport, addFilter, addOpenListener, addPostSelectionChangedListener, assertContentProviderType, assertElementsNotNull, associate, buildLabel, doFindInputItem, doFindItem, doUpdateItem, equals, filter, findItem, findItems, fireDoubleClick, fireOpen, getColorAndFontCollector, getComparator, getComparer, getFilteredChildren, getFilters, getRoot, getSelection, getSelectionFromWidget, getSorter, getStructuredSelection, handleInvalidSelection, handleLabelProviderChanged, handleOpen, handlePostSelect, handleSelect, hasFilters, internalRefresh, internalRefresh, internalUpdate, mapElement, needsRefilter, preservingSelection, refresh, refresh, refreshItem, removeDoubleClickListener, removeFilter, removeOpenListener, removePostSelectionChangedListener, resetFilters, reveal, setComparator, setComparer, setContentProvider, setFilters, setInput, setSelection, setSelectionToWidget, setSelectionToWidget, setSorter, setUseHashlookup, testFindItem, testFindItems, unmapElement, unmapElement, update, updateItem, usingElementMapMethods inherited from class org.eclipse.jface.viewers.ContentViewergetContentProvider, getInput, getLabelProvider, labelProviderChangedMethods inherited from class org.eclipse.jface.viewers.VieweraddHelpListener, addSelectionChangedListener, fireHelpRequested, fireSelectionChanged, getControl, getData, handleHelpRequest, inputChanged, removeHelpListener, removeSelectionChangedListener, scrollDown, scrollUp, setData, setSelectionMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.eclipse.jface.viewers.ISelectionProvideraddSelectionChangedListener, removeSelectionChangedListener, setSelection
- 
Constructor Details- 
ColumnViewerpublic ColumnViewer()Create a new instance of the receiver.
 
- 
- 
Method Details- 
hookControlDescription copied from class:ContentViewerAdds event listener hooks to the given control.All subclasses must call this method when their control is first established. The ContentViewerimplementation of this method hooks dispose events for the given control. Subclasses may override if they need to add other control hooks; however,super.hookControlmust be invoked.- Overrides:
- hookControlin class- StructuredViewer
- Parameters:
- control- the control
 
- 
hookEditingSupportHook up the editing support. Subclasses may override.- Parameters:
- control- the control you want to hook on
 
- 
createViewerEditorCreates the viewer editor used for editing cell contents. To be implemented by subclasses.- Returns:
- the editor, or nullif this viewer does not support editing cell contents.
 
- 
getCellReturns the viewer cell at the given widget-relative coordinates, ornullif there is no cell at that location- Parameters:
- point- the widget-relative coordinates
- Returns:
- the cell or nullif no cell is found at the given point
- Since:
- 3.4
 
- 
getViewerRowReturns the viewer row at the given widget-relative coordinates.- Parameters:
- point- the widget-relative coordinates of the viewer row
- Returns:
- ViewerRow the row or nullif no row is found at the given coordinates
 
- 
getViewerRowFromItemReturns aViewerRowassociated with the given row widget. Implementations may re-use the same instance for different row widgets; callers can only use the viewer row locally and until the next call to this method.- Parameters:
- item- the row widget
- Returns:
- ViewerRow a viewer row object
 
- 
getColumnViewerOwnerReturns the column widget at the given column index.- Parameters:
- columnIndex- the column index
- Returns:
- Widget the column widget
 
- 
getItemAtReturns theItemat the given widget-relative coordinates, ornullif there is no item at the given coordinates.- Parameters:
- point- the widget-relative coordinates
- Returns:
- the Itemat the coordinates ornullif there is no item at the given coordinates
 
- 
getItemDescription copied from class:StructuredViewerReturns the item at the given display-relative coordinates, ornullif there is no item at that location or the underlying SWT-Control is not made up ofItem(e.gListViewer)The default implementation of this method returns null.- Overrides:
- getItemin class- StructuredViewer
- Parameters:
- x- horizontal coordinate
- y- vertical coordinate
- Returns:
- the item, or nullif there is no item at the given coordinates
 
- 
setLabelProviderThe column viewer implementation of thisViewerframework method ensures that the given label provider is an instance ofITableLabelProvider,ILabelProvider, orCellLabelProvider.If the label provider is an ITableLabelProvider, then it provides a separate label text and image for each column. Implementers ofITableLabelProvidermay also implementITableColorProviderand/orITableFontProviderto provide colors and/or fonts.If the label provider is an ILabelProvider, then it provides only the label text and image for the first column, and any remaining columns are blank. Implementers ofILabelProvidermay also implementIColorProviderand/orIFontProviderto provide colors and/or fonts.- Overrides:
- setLabelProviderin class- StructuredViewer
- Parameters:
- labelProvider- the label provider, or- nullif none
 
- 
cancelEditingpublic void cancelEditing()Cancels a currently active cell editor if one is active. All changes already done in the cell editor are lost.- Since:
- 3.1 (in subclasses, added in 3.3 to abstract class)
 
- 
applyEditorValuepublic void applyEditorValue()Apply the value of the active cell editor if one is active.- Since:
- 3.11 (public - protected since 3.3)
 
- 
editElementStarts editing the given element at the given column index.- Parameters:
- element- the model element
- column- the column index
- Since:
- 3.1 (in subclasses, added in 3.3 to abstract class)
 
- 
getCellEditorsReturn the CellEditors for the receiver, ornullif no cell editors are set.Since 3.3, an alternative API is available, see ViewerColumn.setEditingSupport(EditingSupport)for a more flexible way of editing values in a column viewer.- Returns:
- CellEditor[]
- Since:
- 3.1 (in subclasses, added in 3.3 to abstract class)
- See Also:
 
- 
getCellModifierReturns the cell modifier of this viewer, ornullif none has been set.Since 3.3, an alternative API is available, see ViewerColumn.setEditingSupport(EditingSupport)for a more flexible way of editing values in a column viewer.- Returns:
- the cell modifier, or null
- Since:
- 3.1 (in subclasses, added in 3.3 to abstract class)
- See Also:
 
- 
getColumnPropertiesReturns the column properties of this table viewer. The properties must correspond with the columns of the table control. They are used to identify the column in a cell modifier.Since 3.3, an alternative API is available, see ViewerColumn.setEditingSupport(EditingSupport)for a more flexible way of editing values in a column viewer.- Returns:
- the list of column properties
- Since:
- 3.1 (in subclasses, added in 3.3 to abstract class)
- See Also:
 
- 
isCellEditorActivepublic boolean isCellEditorActive()Returns whether there is an active cell editor.Since 3.3, an alternative API is available, see ViewerColumn.setEditingSupport(EditingSupport)for a more flexible way of editing values in a column viewer.- Returns:
- trueif there is an active cell editor, and- falseotherwise
- Since:
- 3.1 (in subclasses, added in 3.3 to abstract class)
- See Also:
 
- 
refreshDescription copied from class:StructuredViewerRefreshes this viewer starting with the given element.Unlike the updatemethods, this handles structural changes to the given element (e.g. addition or removal of children). If only the given element needs updating, it is more efficient to use theupdatemethods.- Overrides:
- refreshin class- StructuredViewer
- Parameters:
- element- the element
 
- 
refreshDescription copied from class:StructuredViewerRefreshes this viewer starting with the given element. Labels are updated as described inrefresh(boolean updateLabels).Unlike the updatemethods, this handles structural changes to the given element (e.g. addition or removal of children). If only the given element needs updating, it is more efficient to use theupdatemethods.- Overrides:
- refreshin class- StructuredViewer
- Parameters:
- element- the element
- updateLabels-- trueto update labels for existing elements,- falseto only update labels as needed, assuming that labels for existing elements are unchanged.
 
- 
updateDescription copied from class:StructuredViewerUpdates the given element's presentation when one or more of its properties changes. Only the given element is updated.This does not handle structural changes (e.g. addition or removal of elements), and does not update any other related elements (e.g. child elements). To handle structural changes, use the refreshmethods instead.This should be called when an element has changed in the model, in order to have the viewer accurately reflect the model. This method only affects the viewer, not the model. Specifying which properties are affected may allow the viewer to optimize the update. For example, if the label provider is not affected by changes to any of these properties, an update may not actually be required. Specifying propertiesasnullforces a full update of the element.If the viewer has a sorter which is affected by a change to one of the properties, the element's position is updated to maintain the sort order. Note that resorting may not happen if propertiesisnull.If the viewer has a filter which is affected by a change to one of the properties, the element may appear or disappear if the change affects whether or not the element is filtered out. Note that filtering may not happen if propertiesisnull.- Overrides:
- updatein class- StructuredViewer
- Parameters:
- element- the element
- properties- the properties that have changed, or- nullto indicate unknown
 
- 
setCellEditorsSets the cell editors of this column viewer. If editing is not supported by this viewer the call simply has no effect.Since 3.3, an alternative API is available, see ViewerColumn.setEditingSupport(EditingSupport)for a more flexible way of editing values in a column viewer.Users setting up an editable TreeViewerorTableViewerwith more than 1 column have to pass the SWT.FULL_SELECTION style bit- Parameters:
- editors- the list of cell editors
- Since:
- 3.1 (in subclasses, added in 3.3 to abstract class)
- See Also:
 
- 
setCellModifierSets the cell modifier for this column viewer. This method does nothing if editing is not supported by this viewer.Since 3.3, an alternative API is available, see ViewerColumn.setEditingSupport(EditingSupport)for a more flexible way of editing values in a column viewer.Users setting up an editable TreeViewerorTableViewerwith more than 1 column have to pass the SWT.FULL_SELECTION style bit- Parameters:
- modifier- the cell modifier
- Since:
- 3.1 (in subclasses, added in 3.3 to abstract class)
- See Also:
 
- 
setColumnPropertiesSets the column properties of this column viewer. The properties must correspond with the columns of the control. They are used to identify the column in a cell modifier. If editing is not supported by this viewer the call simply has no effect.Since 3.3, an alternative API is available, see ViewerColumn.setEditingSupport(EditingSupport)for a more flexible way of editing values in a column viewer.Users setting up an editable TreeViewerorTableViewerwith more than 1 column have to pass the SWT.FULL_SELECTION style bit- Parameters:
- columnProperties- the list of column properties
- Since:
- 3.1 (in subclasses, added in 3.3 to abstract class)
- See Also:
 
- 
doGetColumnCountprotected abstract int doGetColumnCount()Returns the number of columns contained in the receiver. If no columns were created by the programmer, this value is zero, despite the fact that visually, one column of items may be visible. This occurs when the programmer uses the column viewer like a list, adding elements but never creating a column.- Returns:
- the number of columns
- Since:
- 3.3
 
- 
getLabelProviderReturns the label provider associated with the column at the given index ornullif no column with this index is known.- Parameters:
- columnIndex- the column index
- Returns:
- the label provider associated with the column or
        nullif no column with this index is known
- Since:
- 3.3
 
- 
handleDisposeDescription copied from class:ContentViewerHandles a dispose event on this viewer's control.The ContentViewerimplementation of this method disposes of this viewer's label provider and content provider (if it has one). Subclasses should override this method to perform any additional cleanup of resources; however, overriding methods must invokesuper.handleDispose.- Overrides:
- handleDisposein class- StructuredViewer
- Parameters:
- event- a dispose event
 
- 
triggerEditorActivationEventInvoking this method fires an editor activation event which tries to enable the editor but before this event is passed toColumnViewerEditorActivationStrategyto see if this event should really trigger editor activation- Parameters:
- event- the activation event
 
- 
setColumnViewerEditor- Parameters:
- columnViewerEditor- the new column viewer editor
 
- 
getColumnViewerEditor- Returns:
- the currently attached viewer editor
 
- 
getRawChildrenDescription copied from class:StructuredViewerReturns the children of the given parent without sorting and filtering them. The resulting array must not be modified, as it may come directly from the model's internal state.Returns an empty array if the given parent is null.- Overrides:
- getRawChildrenin class- StructuredViewer
- Parameters:
- parent- the parent element
- Returns:
- the child elements
 
- 
checkBusyprotected boolean checkBusy()Checks if this viewer is currently busy, logging a warning and returningtrueif it is busy. A column viewer is busy when it is processing a refresh, add, remove, insert, replace, setItemCount, expandToLevel, update, setExpandedElements, or similar method that may make calls to client code. Column viewers are not designed to handle reentrant calls while they are busy. The method returnstrueif the viewer is busy. It is recommended that this method be used by subclasses to determine whether the viewer is busy to return early from state-changing methods.This method is not intended to be overridden by subclasses. - Returns:
- trueif the viewer is busy.
- Since:
- 3.4
 
- 
setBusyprotected void setBusy(boolean busy) Sets the busy state of this viewer. Subclasses MUST usetry...finallyas follows to ensure that the busy flag is reset to its original value:boolean oldBusy = isBusy(); setBusy(true); try { // do work } finally { setBusy(oldBusy); }This method is not intended to be overridden by subclasses. - Parameters:
- busy- the new value of the busy flag
- Since:
- 3.4
 
- 
isBusypublic boolean isBusy()Returnstrueif this viewer is currently busy processing a refresh, add, remove, insert, replace, setItemCount, expandToLevel, update, setExpandedElements, or similar method that may make calls to client code. Column viewers are not designed to handle reentrant calls while they are busy. It is recommended that clients avoid using this method if they can ensure by other means that they will not make reentrant calls to methods like the ones listed above. See bug 184991 for background discussion.This method is not intended to be overridden by subclasses. - Returns:
- Returns whether this viewer is busy.
- Since:
- 3.4
 
- 
getSortedChildrenDescription copied from class:StructuredViewerReturns the sorted and filtered set of children of the given element. The resulting array must not be modified, as it may come directly from the model's internal state.- Overrides:
- getSortedChildrenin class- StructuredViewer
- Parameters:
- parent- the parent element
- Returns:
- a sorted and filtered array of child elements
 
- 
setDisplayIncrementallypublic void setDisplayIncrementally(int incrementSize) Sets the viewers items limit on direct children at one level.If the number of direct children will exceed this limit, the viewer will only show a subset of children up to the limit and add an ExpandableNodeelement after last shown item.This method must be called before StructuredViewer.setInput(Object). A parameter less than or equal to zero has no effect on the viewer.This API does not guaranteed to work with SWT.VIRTUALviewers.- Parameters:
- incrementSize- A non-negative integer greater than 0 to enable items limit
- Since:
- 3.31
 
- 
disassociateDescription copied from class:StructuredViewerDisassociates the given SWT item from its corresponding element. Sets the item's data tonulland removes the element from the element map (if enabled).- Overrides:
- disassociatein class- StructuredViewer
- Parameters:
- item- the widget
 
- 
handleDoubleSelectDescription copied from class:StructuredViewerHandles a double-click select event from the widget.This method is internal to the framework; subclassers should not call this method. - Overrides:
- handleDoubleSelectin class- StructuredViewer
- Parameters:
- event- the SWT selection event
 
- 
isExpandableNodeReturn if it is an instance of ExpandableNode- Parameters:
- element- model object representing a special "expandable" node
- Returns:
- return if it is an instance of ExpandableNode
- Since:
- 3.31
 
- 
updateSelectionDescription copied from class:StructuredViewerUpdates the selection of this viewer.This framework method should be called when the selection in the viewer widget changes. The default implementation of this method notifies all selection change listeners recorded in an internal state variable. Overriding this method is generally not required; however, if overriding in a subclass, super.updateSelectionmust be invoked.- Overrides:
- updateSelectionin class- StructuredViewer
- Parameters:
- selection- the selection, or- nullif none
 
- 
firePostSelectionChangedDescription copied from class:StructuredViewerNotifies any post selection listeners that a post selection event has been received. Only listeners registered at the time this method is called are notified.- Overrides:
- firePostSelectionChangedin class- StructuredViewer
- Parameters:
- event- a selection changed event
- See Also:
 
- 
unmapAllElementsprotected void unmapAllElements()Description copied from class:StructuredViewerRemoves all elements from the map.This method is internal to the framework; subclassers should not call this method. - Overrides:
- unmapAllElementsin class- StructuredViewer
 
 
-