public abstract class StyledCellLabelProvider extends OwnerDrawLabelProvider
StyledCellLabelProvider
supports styled labels by using owner
draw.
Besides the styles in labels, the label provider preserves native viewer behavior:
For providing the label's styles, create a subclass and overwrite
update(ViewerCell)
to
return set all information needed to render a element. Use
ViewerCell.setStyleRanges(StyleRange[])
to set style ranges
on the label.
Modifier and Type | Field and Description |
---|---|
static int |
COLORS_ON_SELECTION
Style constant for indicating that the styled colors are to be applied
even it the viewer's item is selected.
|
static int |
NO_FOCUS
Style constant for indicating to draw the focus if requested by the owner
draw event.
|
Constructor and Description |
---|
StyledCellLabelProvider()
Creates a new StyledCellLabelProvider.
|
StyledCellLabelProvider(int style)
Creates a new StyledCellLabelProvider.
|
Modifier and Type | Method and Description |
---|---|
void |
dispose()
The
BaseLabelProvider implementation of this
IBaseLabelProvider method clears its internal listener list. |
protected void |
erase(Event event,
Object element)
Handle the erase event.
|
protected ViewerColumn |
getColumn()
Returns the column on which this label provider is installed on or
null if the
label provider is not installed. |
protected ColumnViewer |
getViewer()
Returns the viewer on which this label provider is installed on or
null if the
label provider is not installed. |
void |
initialize(ColumnViewer viewer,
ViewerColumn column)
This implementation of
CellLabelProvider.initialize(ColumnViewer, ViewerColumn)
delegates to OwnerDrawLabelProvider.initialize(ColumnViewer, ViewerColumn, boolean)
with a value of true for enableOwnerDraw . |
boolean |
isOwnerDrawEnabled()
Returns
true is the owner draw rendering is enabled for this label provider. |
protected void |
measure(Event event,
Object element)
Handle the measure event.
|
protected void |
paint(Event event,
Object element)
Handle the paint event.
|
protected StyleRange |
prepareStyleRange(StyleRange styleRange,
boolean applyColors)
Prepares the given style range before it is applied to the label.
|
void |
setOwnerDrawEnabled(boolean enabled)
Specifies whether owner draw rendering is enabled for this label
provider.
|
static StyledString |
styleDecoratedString(String decoratedString,
StyledString.Styler decorationStyler,
StyledString styledString)
Applies decoration styles to the decorated string and adds the styles of the previously
undecorated string.
|
void |
update(ViewerCell cell)
Update the label for cell.
|
dispose, initialize, setOwnerDrawEnabled, setUpOwnerDraw
getToolTipBackgroundColor, getToolTipDisplayDelayTime, getToolTipFont, getToolTipForegroundColor, getToolTipImage, getToolTipShift, getToolTipStyle, getToolTipText, getToolTipTimeDisplayed, useNativeToolTip
addListener, fireLabelProviderChanged, isLabelProperty, removeListener
addListenerObject, clearListeners, getListeners, isListenerAttached, removeListenerObject
public static final int COLORS_ON_SELECTION
public static final int NO_FOCUS
public StyledCellLabelProvider()
public StyledCellLabelProvider(int style)
style
- the style bitsCOLORS_ON_SELECTION
,
NO_FOCUS
public boolean isOwnerDrawEnabled()
true
is the owner draw rendering is enabled for this label provider.
By default owner draw rendering is enabled. If owner draw rendering is disabled, rending is
done by the viewer and no styled ranges (see ViewerCell.getStyleRanges()
)
are drawn.true
is the rendering of styles is enabled.public void setOwnerDrawEnabled(boolean enabled)
ViewerCell.getStyleRanges()
) are drawn.
It is the caller's responsibility to also call
StructuredViewer.refresh()
or similar methods to update the
underlying widget.enabled
- specifies if owner draw rendering is enabledprotected final ColumnViewer getViewer()
null
if the
label provider is not installed.null
if the
label provider is not installed.protected final ViewerColumn getColumn()
null
if the
label provider is not installed.null
if the
label provider is not installed.public void initialize(ColumnViewer viewer, ViewerColumn column)
OwnerDrawLabelProvider
CellLabelProvider.initialize(ColumnViewer, ViewerColumn)
delegates to OwnerDrawLabelProvider.initialize(ColumnViewer, ViewerColumn, boolean)
with a value of true
for enableOwnerDraw
.
Subclasses may override this method but should either call the super
implementation or, alternatively,
OwnerDrawLabelProvider.initialize(ColumnViewer, ViewerColumn, boolean)
.initialize
in class OwnerDrawLabelProvider
viewer
- the viewercolumn
- the column, or null
if a column is not
available.public void dispose()
BaseLabelProvider
BaseLabelProvider
implementation of this
IBaseLabelProvider
method clears its internal listener list.
Subclasses may extend but should call the super implementation.dispose
in interface IBaseLabelProvider
dispose
in class BaseLabelProvider
public void update(ViewerCell cell)
CellLabelProvider
update
in class OwnerDrawLabelProvider
cell
- ViewerCell
protected StyleRange prepareStyleRange(StyleRange styleRange, boolean applyColors)
StyledCellLabelProvider
will also ignore all font settings on the
style range. Clients can override.styleRange
- the style range to prepare. the style range element must not be modifiedapplyColors
- specifies if colors should be applied.protected void erase(Event event, Object element)
erase
in class OwnerDrawLabelProvider
event
- the erase eventelement
- the model objectSWT.EraseItem
protected void measure(Event event, Object element)
OwnerDrawLabelProvider
measure
in class OwnerDrawLabelProvider
event
- the measure eventelement
- the model elementSWT.MeasureItem
protected void paint(Event event, Object element)
OwnerDrawLabelProvider
paint
in class OwnerDrawLabelProvider
event
- the paint eventelement
- the model elementSWT.PaintItem
public static StyledString styleDecoratedString(String decoratedString, StyledString.Styler decorationStyler, StyledString styledString)
If the decoratedString
contains the styledString
, then the result
keeps the styles of the styledString
and styles the decorations with the
decorationStyler
. Otherwise, the decorated string is returned without any
styles.
decoratedString
- the decorated stringdecorationStyler
- the styler to use for the decoration or null
for no
stylesstyledString
- the original styled stringstyledString
)
Copyright (c) 2000, 2014 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.