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
ConstructorsConstructorDescriptionDecoratingLabelProvider(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 TypeMethodDescriptionvoidaddListener(ILabelProviderListener listener) TheDecoratingLabelProviderimplementation of thisIBaseLabelProvidermethod adds the listener to both the nested label provider and the label decorator.voiddispose()TheDecoratingLabelProviderimplementation of thisIBaseLabelProvidermethod 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.TheDecoratingLabelProviderimplementation of thisILabelProvidermethod returns the image provided by the nested label provider'sgetImagemethod, decorated with the decoration provided by the label decorator'sdecorateImagemethod.Returns the label decorator, ornullif none has been set.Returns the nested label provider.TheDecoratingLabelProviderimplementation of thisILabelProvidermethod returns the text label provided by the nested label provider'sgetTextmethod, decorated with the decoration provided by the label decorator'sdecorateTextmethod.booleanisLabelProperty(Object element, String property) TheDecoratingLabelProviderimplementation of thisIBaseLabelProvidermethod returnstrueif the corresponding method on the nested label provider returnstrueor if the corresponding method on the decorator returnstrue.voidremoveListener(ILabelProviderListener listener) TheDecoratingLabelProviderimplementation of thisIBaseLabelProvidermethod removes the listener from both the nested label provider and the label decorator.voidsetDecorationContext(IDecorationContext decorationContext) Set the decoration context that will be based to the decorator for this label provider if that decorator implementsLabelDecorator.voidsetLabelDecorator(ILabelDecorator decorator) Sets the label decorator.protected voidupdateForDecorationReady(ViewerLabel settings, Object element) Decoration is ready.voidupdateLabel(ViewerLabel settings, Object element) Updates the label for the given element.voidupdateLabel(ViewerLabel settings, TreePath elementPath) Updates the label for the given element.Methods inherited from class org.eclipse.jface.viewers.LabelProvider
createImageProvider, createTextImageProvider, createTextProviderMethods inherited from class org.eclipse.jface.viewers.BaseLabelProvider
fireLabelProviderChangedMethods 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, ornullif no decorator is to be used initially
-
-
Method Details
-
addListener
TheDecoratingLabelProviderimplementation of thisIBaseLabelProvidermethod adds the listener to both the nested label provider and the label decorator.- Specified by:
addListenerin interfaceIBaseLabelProvider- Overrides:
addListenerin classBaseLabelProvider- Parameters:
listener- a label provider listener
-
dispose
public void dispose()TheDecoratingLabelProviderimplementation of thisIBaseLabelProvidermethod disposes both the nested label provider and the label decorator.- Specified by:
disposein interfaceIBaseLabelProvider- Overrides:
disposein classBaseLabelProvider
-
getImage
TheDecoratingLabelProviderimplementation of thisILabelProvidermethod returns the image provided by the nested label provider'sgetImagemethod, decorated with the decoration provided by the label decorator'sdecorateImagemethod.- Specified by:
getImagein interfaceILabelProvider- Overrides:
getImagein classLabelProvider- Parameters:
element- the element for which to provide the label image- Returns:
- the image used to label the element, or
nullif there is no image for the given object
-
getLabelDecorator
Returns the label decorator, ornullif none has been set.- Returns:
- the label decorator, or
nullif none has been set.
-
getLabelProvider
Returns the nested label provider.- Returns:
- the nested label provider
-
getText
TheDecoratingLabelProviderimplementation of thisILabelProvidermethod returns the text label provided by the nested label provider'sgetTextmethod, decorated with the decoration provided by the label decorator'sdecorateTextmethod.- Specified by:
getTextin interfaceILabelProvider- Overrides:
getTextin classLabelProvider- Parameters:
element- the element for which to provide the label text- Returns:
- the text string used to label the element, or
nullif there is no text label for the given object
-
isLabelProperty
TheDecoratingLabelProviderimplementation of thisIBaseLabelProvidermethod returnstrueif the corresponding method on the nested label provider returnstrueor if the corresponding method on the decorator returnstrue.- Specified by:
isLabelPropertyin interfaceIBaseLabelProvider- Overrides:
isLabelPropertyin classBaseLabelProvider- Parameters:
element- the elementproperty- the property- Returns:
trueif the label would be affected, andfalseif it would be unaffected
-
removeListener
TheDecoratingLabelProviderimplementation of thisIBaseLabelProvidermethod removes the listener from both the nested label provider and the label decorator.- Specified by:
removeListenerin interfaceIBaseLabelProvider- Overrides:
removeListenerin 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, ornullif no decorations are to be applied
-
updateLabel
Description copied from interface:IViewerLabelProviderUpdates the label for the given element.- Specified by:
updateLabelin 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:IColorProviderProvides a background color for the given element.- Specified by:
getBackgroundin interfaceIColorProvider- Parameters:
element- the element- Returns:
- the background color for the element, or
nullto use the default background color
-
getFont
Description copied from interface:IFontProviderProvides a font for the given element.- Specified by:
getFontin interfaceIFontProvider- Parameters:
element- the element- Returns:
- the font for the element, or
nullto use the default font
-
getForeground
Description copied from interface:IColorProviderProvides a foreground color for the given element.- Specified by:
getForegroundin interfaceIColorProvider- Parameters:
element- the element- Returns:
- the foreground color for the element, or
nullto 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:ITreePathLabelProviderUpdates the label for the given element.- Specified by:
updateLabelin interfaceITreePathLabelProvider- Parameters:
settings- the label to updateelementPath- the path of the element being decorated
-