Package org.eclipse.jface.viewers
Class OwnerDrawLabelProvider
java.lang.Object
org.eclipse.core.commands.common.EventManager
org.eclipse.jface.viewers.BaseLabelProvider
org.eclipse.jface.viewers.CellLabelProvider
org.eclipse.jface.viewers.OwnerDrawLabelProvider
- All Implemented Interfaces:
IBaseLabelProvider
,IToolTipProvider
- Direct Known Subclasses:
StyledCellLabelProvider
OwnerDrawLabelProvider is an abstract implementation of a label provider that
handles custom draw.
This class is intended to be subclassed by implementors.
- Since:
- 3.3
-
Constructor Summary
ConstructorDescriptionCreate a new instance of the receiver based on a column viewer. -
Method Summary
Modifier and TypeMethodDescriptionvoid
dispose
(ColumnViewer viewer, ViewerColumn column) Dispose of this label provider which was used with the given column viewer and column.protected void
Handle the erase event.protected void
initialize
(ColumnViewer viewer, ViewerColumn column) This implementation ofCellLabelProvider.initialize(ColumnViewer, ViewerColumn)
delegates toinitialize(ColumnViewer, ViewerColumn, boolean)
with a value oftrue
forenableOwnerDraw
.protected final void
initialize
(ColumnViewer viewer, ViewerColumn column, boolean enableOwnerDraw) May be called from subclasses that overrideinitialize(ColumnViewer, ViewerColumn)
but want to customize whether owner draw will be enabled.protected abstract void
Handle the measure event.protected abstract void
Handle the paint event.protected void
setOwnerDrawEnabled
(ColumnViewer viewer, ViewerColumn column, boolean enabled) Enables or disables owner draw for the given viewer and column.static void
setUpOwnerDraw
(ColumnViewer viewer) Deprecated.void
update
(ViewerCell cell) Update the label for cell.Methods inherited from class org.eclipse.jface.viewers.CellLabelProvider
getToolTipBackgroundColor, getToolTipDisplayDelayTime, getToolTipFont, getToolTipForegroundColor, getToolTipImage, getToolTipShift, getToolTipStyle, getToolTipText, getToolTipTimeDisplayed, useNativeToolTip
Methods inherited from class org.eclipse.jface.viewers.BaseLabelProvider
addListener, dispose, fireLabelProviderChanged, isLabelProperty, removeListener
Methods inherited from class org.eclipse.core.commands.common.EventManager
addListenerObject, clearListeners, getListeners, isListenerAttached, removeListenerObject
-
Constructor Details
-
OwnerDrawLabelProvider
public OwnerDrawLabelProvider()Create a new instance of the receiver based on a column viewer.
-
-
Method Details
-
setUpOwnerDraw
Deprecated.Since 3.4, the default implementation ofCellLabelProvider.initialize(ColumnViewer, ViewerColumn)
in this class will set up the necessary owner draw callbacks automatically. Calls to this method can be removed.Set up the owner draw callbacks for the viewer.- Parameters:
viewer
- the viewer the owner draw is set up
-
dispose
Description copied from class:CellLabelProvider
Dispose of this label provider which was used with the given column viewer and column. Subclasses may extend but should call the super implementation (which callsBaseLabelProvider.dispose()
).- Overrides:
dispose
in classCellLabelProvider
- Parameters:
viewer
- the viewercolumn
- the column, ornull
if a column is not available.
-
initialize
This implementation ofCellLabelProvider.initialize(ColumnViewer, ViewerColumn)
delegates toinitialize(ColumnViewer, ViewerColumn, boolean)
with a value oftrue
forenableOwnerDraw
. Subclasses may override this method but should either call the super implementation or, alternatively,initialize(ColumnViewer, ViewerColumn, boolean)
.- Overrides:
initialize
in classCellLabelProvider
- Parameters:
viewer
- the viewercolumn
- the column, ornull
if a column is not available.
-
initialize
May be called from subclasses that overrideinitialize(ColumnViewer, ViewerColumn)
but want to customize whether owner draw will be enabled. This method callssuper.initialize(ColumnViewer, ViewerColumn)
, and then enables or disables owner draw by callingsetOwnerDrawEnabled(ColumnViewer, ViewerColumn, boolean)
.- Parameters:
viewer
- the viewercolumn
- the column, ornull
if a column is not available.enableOwnerDraw
-true
if owner draw should be enabled for the given viewer and column,false
otherwise.- Since:
- 3.4
-
update
Description copied from class:CellLabelProvider
Update the label for cell.- Specified by:
update
in classCellLabelProvider
- Parameters:
cell
-ViewerCell
-
erase
Handle the erase event. The default implementation colors the background of selected areas withSWT.COLOR_LIST_SELECTION
and foregrounds withSWT.COLOR_LIST_SELECTION_TEXT
. Note that this implementation causes non-native behavior on some platforms. Subclasses should override this method and not call the super implementation.- Parameters:
event
- the erase eventelement
- the model object- See Also:
-
measure
Handle the measure event.- Parameters:
event
- the measure eventelement
- the model element- See Also:
-
paint
Handle the paint event.- Parameters:
event
- the paint eventelement
- the model element- See Also:
-
setOwnerDrawEnabled
Enables or disables owner draw for the given viewer and column. This method will attach or remove a listener to the underlying control as necessary. This method is called frominitialize(ColumnViewer, ViewerColumn)
anddispose(ColumnViewer, ViewerColumn)
but may be called from subclasses to enable or disable owner draw dynamically.- Parameters:
viewer
- the viewercolumn
- the column, ornull
if a column is not availableenabled
-true
if owner draw should be enabled,false
otherwise- Since:
- 3.4
-
CellLabelProvider.initialize(ColumnViewer, ViewerColumn)
in this class will set up the necessary owner draw callbacks automatically.