Package org.eclipse.jface.viewers
Class DecoratingLabelProvider
java.lang.Object
org.eclipse.core.commands.common.EventManager
org.eclipse.jface.viewers.BaseLabelProvider
org.eclipse.jface.viewers.LabelProvider
org.eclipse.jface.viewers.DecoratingLabelProvider
- All Implemented Interfaces:
IBaseLabelProvider
,IColorProvider
,IFontProvider
,ILabelProvider
,ITreePathLabelProvider
,IViewerLabelProvider
public class DecoratingLabelProvider
extends LabelProvider
implements IViewerLabelProvider, IColorProvider, IFontProvider, ITreePathLabelProvider
A decorating label provider is a label provider which combines
a nested label provider and an optional decorator.
The decorator decorates the label text, image, font and colors provided by
the nested label provider.
-
Constructor Summary
ConstructorDescriptionDecoratingLabelProvider
(ILabelProvider provider, ILabelDecorator decorator) Creates a decorating label provider which uses the given label decorator to decorate labels provided by the given label provider. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addListener
(ILabelProviderListener listener) TheDecoratingLabelProvider
implementation of thisIBaseLabelProvider
method adds the listener to both the nested label provider and the label decorator.void
dispose()
TheDecoratingLabelProvider
implementation of thisIBaseLabelProvider
method disposes both the nested label provider and the label decorator.getBackground
(Object element) Provides a background color for the given element.Return the decoration context associated with this label provider.Provides a font for the given element.getForeground
(Object element) Provides a foreground color for the given element.TheDecoratingLabelProvider
implementation of thisILabelProvider
method returns the image provided by the nested label provider'sgetImage
method, decorated with the decoration provided by the label decorator'sdecorateImage
method.Returns the label decorator, ornull
if none has been set.Returns the nested label provider.TheDecoratingLabelProvider
implementation of thisILabelProvider
method returns the text label provided by the nested label provider'sgetText
method, decorated with the decoration provided by the label decorator'sdecorateText
method.boolean
isLabelProperty
(Object element, String property) TheDecoratingLabelProvider
implementation of thisIBaseLabelProvider
method returnstrue
if the corresponding method on the nested label provider returnstrue
or if the corresponding method on the decorator returnstrue
.void
removeListener
(ILabelProviderListener listener) TheDecoratingLabelProvider
implementation of thisIBaseLabelProvider
method removes the listener from both the nested label provider and the label decorator.void
setDecorationContext
(IDecorationContext decorationContext) Set the decoration context that will be based to the decorator for this label provider if that decorator implementsLabelDecorator
.void
setLabelDecorator
(ILabelDecorator decorator) Sets the label decorator.protected void
updateForDecorationReady
(ViewerLabel settings, Object element) Decoration is ready.void
updateLabel
(ViewerLabel settings, Object element) Updates the label for the given element.void
updateLabel
(ViewerLabel settings, TreePath elementPath) Updates the label for the given element.Methods inherited from class org.eclipse.jface.viewers.LabelProvider
createImageProvider, createTextImageProvider, createTextProvider
Methods inherited from class org.eclipse.jface.viewers.BaseLabelProvider
fireLabelProviderChanged
Methods inherited from class org.eclipse.core.commands.common.EventManager
addListenerObject, clearListeners, getListeners, isListenerAttached, removeListenerObject
-
Constructor Details
-
DecoratingLabelProvider
Creates a decorating label provider which uses the given label decorator to decorate labels provided by the given label provider.- Parameters:
provider
- the nested label providerdecorator
- the label decorator, ornull
if no decorator is to be used initially
-
-
Method Details
-
addListener
TheDecoratingLabelProvider
implementation of thisIBaseLabelProvider
method adds the listener to both the nested label provider and the label decorator.- Specified by:
addListener
in interfaceIBaseLabelProvider
- Overrides:
addListener
in classBaseLabelProvider
- Parameters:
listener
- a label provider listener
-
dispose
public void dispose()TheDecoratingLabelProvider
implementation of thisIBaseLabelProvider
method disposes both the nested label provider and the label decorator.- Specified by:
dispose
in interfaceIBaseLabelProvider
- Overrides:
dispose
in classBaseLabelProvider
-
getImage
TheDecoratingLabelProvider
implementation of thisILabelProvider
method returns the image provided by the nested label provider'sgetImage
method, decorated with the decoration provided by the label decorator'sdecorateImage
method.- Specified by:
getImage
in interfaceILabelProvider
- Overrides:
getImage
in classLabelProvider
- Parameters:
element
- the element for which to provide the label image- Returns:
- the image used to label the element, or
null
if there is no image for the given object
-
getLabelDecorator
Returns the label decorator, ornull
if none has been set.- Returns:
- the label decorator, or
null
if none has been set.
-
getLabelProvider
Returns the nested label provider.- Returns:
- the nested label provider
-
getText
TheDecoratingLabelProvider
implementation of thisILabelProvider
method returns the text label provided by the nested label provider'sgetText
method, decorated with the decoration provided by the label decorator'sdecorateText
method.- Specified by:
getText
in interfaceILabelProvider
- Overrides:
getText
in classLabelProvider
- Parameters:
element
- the element for which to provide the label text- Returns:
- the text string used to label the element, or
null
if there is no text label for the given object
-
isLabelProperty
TheDecoratingLabelProvider
implementation of thisIBaseLabelProvider
method returnstrue
if the corresponding method on the nested label provider returnstrue
or if the corresponding method on the decorator returnstrue
.- Specified by:
isLabelProperty
in interfaceIBaseLabelProvider
- Overrides:
isLabelProperty
in classBaseLabelProvider
- Parameters:
element
- the elementproperty
- the property- Returns:
true
if the label would be affected, andfalse
if it would be unaffected
-
removeListener
TheDecoratingLabelProvider
implementation of thisIBaseLabelProvider
method removes the listener from both the nested label provider and the label decorator.- Specified by:
removeListener
in interfaceIBaseLabelProvider
- Overrides:
removeListener
in classBaseLabelProvider
- Parameters:
listener
- a label provider listener
-
setLabelDecorator
Sets the label decorator. Removes all known listeners from the old decorator, and adds all known listeners to the new decorator. The old decorator is not disposed. Fires a label provider changed event indicating that all labels should be updated. Has no effect if the given decorator is identical to the current one.- Parameters:
decorator
- the label decorator, ornull
if no decorations are to be applied
-
updateLabel
Description copied from interface:IViewerLabelProvider
Updates the label for the given element.- Specified by:
updateLabel
in interfaceIViewerLabelProvider
- Parameters:
settings
- the label to updateelement
- the element
-
updateForDecorationReady
Decoration is ready. Update anything else for the settings.- Parameters:
settings
- The object collecting the settings.element
- The Object being decorated.- Since:
- 3.1
-
getBackground
Description copied from interface:IColorProvider
Provides a background color for the given element.- Specified by:
getBackground
in interfaceIColorProvider
- Parameters:
element
- the element- Returns:
- the background color for the element, or
null
to use the default background color
-
getFont
Description copied from interface:IFontProvider
Provides a font for the given element.- Specified by:
getFont
in interfaceIFontProvider
- Parameters:
element
- the element- Returns:
- the font for the element, or
null
to use the default font
-
getForeground
Description copied from interface:IColorProvider
Provides a foreground color for the given element.- Specified by:
getForeground
in interfaceIColorProvider
- Parameters:
element
- the element- Returns:
- the foreground color for the element, or
null
to use the default foreground color
-
getDecorationContext
Return the decoration context associated with this label provider. It will be passed to the decorator if the decorator is an instance ofLabelDecorator
.- Returns:
- the decoration context associated with this label provider
- Since:
- 3.2
-
setDecorationContext
Set the decoration context that will be based to the decorator for this label provider if that decorator implementsLabelDecorator
.- Parameters:
decorationContext
- the decoration context.- Since:
- 3.2
-
updateLabel
Description copied from interface:ITreePathLabelProvider
Updates the label for the given element.- Specified by:
updateLabel
in interfaceITreePathLabelProvider
- Parameters:
settings
- the label to updateelementPath
- the path of the element being decorated
-