public class WorkbenchLabelProvider extends LabelProvider implements IColorProvider, IFontProvider, DelegatingStyledCellLabelProvider.IStyledLabelProvider
IWorkbenchAdapter
adapter associated with them. All dispensed
images are cached until the label provider is explicitly disposed.
This class provides a facility for subclasses to define annotations
on the labels and icons of adaptable objects.Constructor and Description |
---|
WorkbenchLabelProvider()
Creates a new workbench label provider.
|
Modifier and Type | Method and Description |
---|---|
protected ImageDescriptor |
decorateImage(ImageDescriptor input,
Object element)
Returns an image descriptor that is based on the given descriptor,
but decorated with additional information relating to the state
of the provided object.
|
protected String |
decorateText(String input,
Object element)
Returns a label that is based on the given label,
but decorated with additional information relating to the state
of the provided object.
|
void |
dispose()
The
BaseLabelProvider implementation of this
IBaseLabelProvider method clears its internal listener list. |
protected IWorkbenchAdapter |
getAdapter(Object o)
Returns the implementation of IWorkbenchAdapter for the given
object.
|
protected IWorkbenchAdapter2 |
getAdapter2(Object o)
Returns the implementation of IWorkbenchAdapter2 for the given
object.
|
protected IWorkbenchAdapter3 |
getAdapter3(Object o)
Returns the implementation of IWorkbenchAdapter3 for the given object.
|
Color |
getBackground(Object element)
Provides a background color for the given element.
|
static ILabelProvider |
getDecoratingWorkbenchLabelProvider()
Returns a workbench label provider that is hooked up to the decorator
mechanism.
|
protected StyledString.Styler |
getDecorationStyle(Object element)
Sets the
StyledString.Styler to be used for string decorations. |
Font |
getFont(Object element)
Provides a font for the given element.
|
Color |
getForeground(Object element)
Provides a foreground color for the given element.
|
Image |
getImage(Object element)
The
LabelProvider implementation of this
ILabelProvider method returns null . |
StyledString |
getStyledText(Object element)
The default implementation of this returns the styled text label for the
given element.
|
String |
getText(Object element)
The
LabelProvider implementation of this
ILabelProvider method returns the element's
toString string. |
addListener, fireLabelProviderChanged, isLabelProperty, removeListener
addListenerObject, clearListeners, getListeners, isListenerAttached, removeListenerObject
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addListener, isLabelProperty, removeListener
public WorkbenchLabelProvider()
public static ILabelProvider getDecoratingWorkbenchLabelProvider()
DecoratingLabelProvider
which wraps a
new WorkbenchLabelProvider
protected ImageDescriptor decorateImage(ImageDescriptor input, Object element)
input
- The base image to decorate.element
- The element used to look up decorations.CompositeImageDescriptor
protected String decorateText(String input, Object element)
input
- The base text to decorate.element
- The element used to look up decorations.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
protected final IWorkbenchAdapter getAdapter(Object o)
o
- the object to look up.null
if the adapter is not defined or the
object is not adaptable.protected final IWorkbenchAdapter2 getAdapter2(Object o)
o
- the object to look up.null
if the adapter is not defined or the
object is not adaptable.protected final IWorkbenchAdapter3 getAdapter3(Object o)
o
- the object to look up.null
if the adapter is not
defined or the object is not adaptable.public final Image getImage(Object element)
LabelProvider
LabelProvider
implementation of this
ILabelProvider
method returns null
.
Subclasses may override.getImage
in interface DelegatingStyledCellLabelProvider.IStyledLabelProvider
getImage
in interface ILabelProvider
getImage
in class LabelProvider
element
- the element for which to provide the label imagenull
if there is no image for the given objectpublic StyledString getStyledText(Object element)
getStyledText
in interface DelegatingStyledCellLabelProvider.IStyledLabelProvider
element
- the element to evaluate the styled string forprotected StyledString.Styler getDecorationStyle(Object element)
StyledString.Styler
to be used for string decorations. By default the
decoration style
. Clients can
override.element
- the element that has been decoratedpublic final String getText(Object element)
LabelProvider
LabelProvider
implementation of this
ILabelProvider
method returns the element's
toString
string. Subclasses may override.getText
in interface ILabelProvider
getText
in class LabelProvider
element
- the element for which to provide the label textnull
if there is no text label for the given objectpublic Color getForeground(Object element)
IColorProvider
getForeground
in interface IColorProvider
element
- the elementnull
to use the default foreground colorpublic Color getBackground(Object element)
IColorProvider
getBackground
in interface IColorProvider
element
- the elementnull
to use the default background colorpublic Font getFont(Object element)
IFontProvider
getFont
in interface IFontProvider
element
- the elementnull
to use the default font
Copyright (c) 2000, 2015 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.