Package org.eclipse.jface.viewers
Class DecoratingStyledCellLabelProvider
- java.lang.Object
-
- org.eclipse.core.commands.common.EventManager
-
- org.eclipse.jface.viewers.BaseLabelProvider
-
- org.eclipse.jface.viewers.CellLabelProvider
-
- org.eclipse.jface.viewers.OwnerDrawLabelProvider
-
- org.eclipse.jface.viewers.StyledCellLabelProvider
-
- org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider
-
- org.eclipse.jface.viewers.DecoratingStyledCellLabelProvider
-
- All Implemented Interfaces:
IBaseLabelProvider,IToolTipProvider
public class DecoratingStyledCellLabelProvider extends DelegatingStyledCellLabelProvider
ADecoratingStyledCellLabelProvideris aDelegatingStyledCellLabelProviderthat uses a nestedDelegatingStyledCellLabelProvider.IStyledLabelProviderto compute styled text label and image and takes aILabelDecoratorto decorate the label.Use this label provider as a replacement for the
DecoratingLabelProviderwhen decorating styled text labels.The
DecoratingStyledCellLabelProviderwill try to evaluate the text decoration added by theILabelDecoratorand will apply the style returned bygetDecorationStyle(Object)The
ILabelDecoratorcan optionally implementIColorDecoratorandIFontDecoratorto provide foreground and background color and font decoration.- Since:
- 3.4
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider
DelegatingStyledCellLabelProvider.IStyledLabelProvider
-
-
Field Summary
-
Fields inherited from class org.eclipse.jface.viewers.StyledCellLabelProvider
COLORS_ON_SELECTION, NO_FOCUS
-
-
Constructor Summary
Constructors Constructor Description DecoratingStyledCellLabelProvider(DelegatingStyledCellLabelProvider.IStyledLabelProvider labelProvider, ILabelDecorator decorator, IDecorationContext decorationContext)Creates aDecoratingStyledCellLabelProviderthat delegates the requests for styled labels and for images to aDelegatingStyledCellLabelProvider.IStyledLabelProvider.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddListener(ILabelProviderListener listener)Adds a listener to this label provider.voiddispose()TheBaseLabelProviderimplementation of thisIBaseLabelProvidermethod clears its internal listener list.ColorgetBackground(Object element)Provides a background color for the given element.IDecorationContextgetDecorationContext()Returns the decoration context associated with this label provider.protected StyledString.StylergetDecorationStyle(Object element)Sets theStyledString.Stylerto be used for string decorations.FontgetFont(Object element)Provides a font for the given element.ColorgetForeground(Object element)Provides a foreground color for the given element.ImagegetImage(Object element)Returns the image for the label of the given element.ILabelDecoratorgetLabelDecorator()Returns the decorator ornullif no decorator is installedprotected StyledStringgetStyledText(Object element)Returns the styled text for the label of the given element.booleanisLabelProperty(Object element, String property)TheBaseLabelProviderimplementation of thisIBaseLabelProvidermethod returnstrue.voidremoveListener(ILabelProviderListener listener)Removes a listener to this label provider.voidsetDecorationContext(IDecorationContext decorationContext)Set the decoration context that will be based to the decorator for this label provider if that decorator implementsLabelDecorator.voidsetLabelDecorator(ILabelDecorator newDecorator)Sets the label decorator.voidupdate(ViewerCell cell)Update the label for cell.-
Methods inherited from class org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider
getStyledStringProvider, getToolTipText
-
Methods inherited from class org.eclipse.jface.viewers.StyledCellLabelProvider
erase, getColumn, getViewer, initialize, isOwnerDrawEnabled, measure, paint, prepareStyleRange, setOwnerDrawEnabled, styleDecoratedString
-
Methods inherited from class org.eclipse.jface.viewers.OwnerDrawLabelProvider
dispose, initialize, setOwnerDrawEnabled, setUpOwnerDraw
-
Methods inherited from class org.eclipse.jface.viewers.CellLabelProvider
getToolTipBackgroundColor, getToolTipDisplayDelayTime, getToolTipFont, getToolTipForegroundColor, getToolTipImage, getToolTipShift, getToolTipStyle, getToolTipTimeDisplayed, useNativeToolTip
-
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 Detail
-
DecoratingStyledCellLabelProvider
public DecoratingStyledCellLabelProvider(DelegatingStyledCellLabelProvider.IStyledLabelProvider labelProvider, ILabelDecorator decorator, IDecorationContext decorationContext)
Creates aDecoratingStyledCellLabelProviderthat delegates the requests for styled labels and for images to aDelegatingStyledCellLabelProvider.IStyledLabelProvider.- Parameters:
labelProvider- the styled label providerdecorator- a label decorator ornullto not decorate the labeldecorationContext- a decoration context ornullif the no decorator is configured or the default decorator should be used
-
-
Method Detail
-
getDecorationContext
public IDecorationContext getDecorationContext()
Returns 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
-
setDecorationContext
public void setDecorationContext(IDecorationContext decorationContext)
Set the decoration context that will be based to the decorator for this label provider if that decorator implementsLabelDecorator.- Parameters:
decorationContext- the decoration context.
-
update
public void update(ViewerCell cell)
Description copied from class:CellLabelProviderUpdate the label for cell.- Overrides:
updatein classDelegatingStyledCellLabelProvider- Parameters:
cell-ViewerCell
-
getForeground
public Color getForeground(Object element)
Description copied from class:DelegatingStyledCellLabelProviderProvides a foreground color for the given element.- Overrides:
getForegroundin classDelegatingStyledCellLabelProvider- Parameters:
element- the element- Returns:
- the foreground color for the element, or
nullto use the default foreground color
-
getBackground
public Color getBackground(Object element)
Description copied from class:DelegatingStyledCellLabelProviderProvides a background color for the given element.- Overrides:
getBackgroundin classDelegatingStyledCellLabelProvider- Parameters:
element- the element- Returns:
- the background color for the element, or
nullto use the default background color
-
getFont
public Font getFont(Object element)
Description copied from class:DelegatingStyledCellLabelProviderProvides a font for the given element.- Overrides:
getFontin classDelegatingStyledCellLabelProvider- Parameters:
element- the element- Returns:
- the font for the element, or
nullto use the default font
-
getImage
public Image getImage(Object element)
Description copied from class:DelegatingStyledCellLabelProviderReturns the image for the label of the given element. The image is owned by the label provider and must not be disposed directly. Instead, dispose the label provider when no longer needed.- Overrides:
getImagein classDelegatingStyledCellLabelProvider- 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
-
getStyledText
protected StyledString getStyledText(Object element)
Returns the styled text for the label of the given element.- Overrides:
getStyledTextin classDelegatingStyledCellLabelProvider- Parameters:
element- the element for which to provide the styled label text- Returns:
- the styled text string used to label the element
-
getDecorationStyle
protected StyledString.Styler getDecorationStyle(Object element)
Sets theStyledString.Stylerto be used for string decorations. By default thedecoration style. Clients can override. Note that it is the client's responsibility to react on color changes of the decoration color by refreshing the view- Parameters:
element- the element that has been decorated- Returns:
- return the decoration style
-
getLabelDecorator
public ILabelDecorator getLabelDecorator()
Returns the decorator ornullif no decorator is installed- Returns:
- the decorator or
nullif no decorator is installed
-
setLabelDecorator
public void setLabelDecorator(ILabelDecorator newDecorator)
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:
newDecorator- the label decorator, ornullif no decorations are to be applied
-
addListener
public void addListener(ILabelProviderListener listener)
Description copied from interface:IBaseLabelProviderAdds a listener to this label provider. Has no effect if an identical listener is already registered.Label provider listeners are informed about state changes that affect the rendering of the viewer that uses this label provider.
- Specified by:
addListenerin interfaceIBaseLabelProvider- Overrides:
addListenerin classDelegatingStyledCellLabelProvider- Parameters:
listener- a label provider listener
-
removeListener
public void removeListener(ILabelProviderListener listener)
Description copied from interface:IBaseLabelProviderRemoves a listener to this label provider. Has no effect if an identical listener is not registered.- Specified by:
removeListenerin interfaceIBaseLabelProvider- Overrides:
removeListenerin classDelegatingStyledCellLabelProvider- Parameters:
listener- a label provider listener
-
isLabelProperty
public boolean isLabelProperty(Object element, String property)
Description copied from class:BaseLabelProviderTheBaseLabelProviderimplementation of thisIBaseLabelProvidermethod returnstrue. Subclasses may override.- Specified by:
isLabelPropertyin interfaceIBaseLabelProvider- Overrides:
isLabelPropertyin classDelegatingStyledCellLabelProvider- Parameters:
element- the elementproperty- the property- Returns:
trueif the label would be affected, andfalseif it would be unaffected
-
dispose
public void dispose()
Description copied from class:BaseLabelProviderTheBaseLabelProviderimplementation of thisIBaseLabelProvidermethod clears its internal listener list. Subclasses may extend but should call the super implementation.- Specified by:
disposein interfaceIBaseLabelProvider- Overrides:
disposein classDelegatingStyledCellLabelProvider
-
-