Eclipse Platform
Release 3.4

org.eclipse.jface.viewers
Class DecoratingStyledCellLabelProvider

java.lang.Object
  extended byorg.eclipse.core.commands.common.EventManager
      extended byorg.eclipse.jface.viewers.BaseLabelProvider
          extended byorg.eclipse.jface.viewers.CellLabelProvider
              extended byorg.eclipse.jface.viewers.OwnerDrawLabelProvider
                  extended byorg.eclipse.jface.viewers.StyledCellLabelProvider
                      extended byorg.eclipse.jface.viewers.DelegatingStyledCellLabelProvider
                          extended byorg.eclipse.jface.viewers.DecoratingStyledCellLabelProvider
All Implemented Interfaces:
IBaseLabelProvider

public class DecoratingStyledCellLabelProvider
extends DelegatingStyledCellLabelProvider

A DecoratingStyledCellLabelProvider is a DelegatingStyledCellLabelProvider that uses a nested DelegatingStyledCellLabelProvider.IStyledLabelProvider to compute styled text label and image and takes a ILabelDecorator to decorate the label.

Use this label provider as a replacement for the DecoratingLabelProvider when decorating styled text labels.

The DecoratingStyledCellLabelProvider will try to evaluate the text decoration added by the ILabelDecorator and will apply the style returned by getDecorationStyle(Object)

The ILabelDecorator can optionally implement IColorDecorator and IFontDecorator to provide foreground and background color and font decoration.

Since:
3.4

Nested Class Summary
 
Nested classes 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
DecoratingStyledCellLabelProvider(DelegatingStyledCellLabelProvider.IStyledLabelProvider labelProvider, ILabelDecorator decorator, IDecorationContext decorationContext)
          Creates a DecoratingStyledCellLabelProvider that delegates the requests for styled labels and for images to a DelegatingStyledCellLabelProvider.IStyledLabelProvider.
 
Method Summary
 void addListener(ILabelProviderListener listener)
          Adds a listener to this label provider.
 void dispose()
          The BaseLabelProvider implementation of this IBaseLabelProvider method clears its internal listener list.
 Color getBackground(Object element)
          Provides a background color for the given element.
 IDecorationContext getDecorationContext()
          Returns the decoration context associated with this label provider.
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)
          Returns the image for the label of the given element.
 ILabelDecorator getLabelDecorator()
          Returns the decorator or null if no decorator is installed
protected  StyledString getStyledText(Object element)
          Returns the styled text for the label of the given element.
 boolean isLabelProperty(Object element, String property)
          The BaseLabelProvider implementation of this IBaseLabelProvider method returns true.
 void removeListener(ILabelProviderListener listener)
          Removes a listener to this label provider.
 void setDecorationContext(IDecorationContext decorationContext)
          Set the decoration context that will be based to the decorator for this label provider if that decorator implements LabelDecorator.
 void setLabelDecorator(ILabelDecorator newDecorator)
          Sets the label decorator.
 void update(ViewerCell cell)
          Update the label for cell.
 
Methods inherited from class org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider
getStyledStringProvider
 
Methods inherited from class org.eclipse.jface.viewers.StyledCellLabelProvider
erase, getColumn, getViewer, initialize, isOwnerDrawEnabled, measure, paint, prepareStyleRange, setOwnerDrawEnabled
 
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, getToolTipText, 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DecoratingStyledCellLabelProvider

public DecoratingStyledCellLabelProvider(DelegatingStyledCellLabelProvider.IStyledLabelProvider labelProvider,
                                         ILabelDecorator decorator,
                                         IDecorationContext decorationContext)
Creates a DecoratingStyledCellLabelProvider that delegates the requests for styled labels and for images to a DelegatingStyledCellLabelProvider.IStyledLabelProvider.

Parameters:
labelProvider - the styled label provider
decorator - a label decorator or null to not decorate the label
decorationContext - a decoration context or null if 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 of LabelDecorator.

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 implements LabelDecorator.

Parameters:
decorationContext - the decoration context.

update

public void update(ViewerCell cell)
Description copied from class: CellLabelProvider
Update the label for cell.

Overrides:
update in class DelegatingStyledCellLabelProvider

getForeground

public Color getForeground(Object element)
Description copied from class: DelegatingStyledCellLabelProvider
Provides a foreground color for the given element.

Overrides:
getForeground in class DelegatingStyledCellLabelProvider
Parameters:
element - the element
Returns:
the foreground color for the element, or null to use the default foreground color

getBackground

public Color getBackground(Object element)
Description copied from class: DelegatingStyledCellLabelProvider
Provides a background color for the given element.

Overrides:
getBackground in class DelegatingStyledCellLabelProvider
Parameters:
element - the element
Returns:
the background color for the element, or null to use the default background color

getFont

public Font getFont(Object element)
Description copied from class: DelegatingStyledCellLabelProvider
Provides a font for the given element.

Overrides:
getFont in class DelegatingStyledCellLabelProvider
Parameters:
element - the element
Returns:
the font for the element, or null to use the default font

getImage

public Image getImage(Object element)
Description copied from class: DelegatingStyledCellLabelProvider
Returns 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:
getImage in class DelegatingStyledCellLabelProvider
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

getStyledText

protected StyledString getStyledText(Object element)
Returns the styled text for the label of the given element.

Overrides:
getStyledText in class DelegatingStyledCellLabelProvider
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 the StyledString.Styler to be used for string decorations. By default the decoration 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 or null if no decorator is installed

Returns:
the decorator or null if 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, or null if no decorations are to be applied

addListener

public void addListener(ILabelProviderListener listener)
Description copied from interface: IBaseLabelProvider
Adds 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:
addListener in interface IBaseLabelProvider
Overrides:
addListener in class DelegatingStyledCellLabelProvider

removeListener

public void removeListener(ILabelProviderListener listener)
Description copied from interface: IBaseLabelProvider
Removes a listener to this label provider. Has no affect if an identical listener is not registered.

Specified by:
removeListener in interface IBaseLabelProvider
Overrides:
removeListener in class DelegatingStyledCellLabelProvider

isLabelProperty

public boolean isLabelProperty(Object element,
                               String property)
Description copied from class: BaseLabelProvider
The BaseLabelProvider implementation of this IBaseLabelProvider method returns true. Subclasses may override.

Specified by:
isLabelProperty in interface IBaseLabelProvider
Overrides:
isLabelProperty in class DelegatingStyledCellLabelProvider

dispose

public void dispose()
Description copied from class: BaseLabelProvider
The BaseLabelProvider implementation of this IBaseLabelProvider method clears its internal listener list. Subclasses may extend but should call the super implementation.

Specified by:
dispose in interface IBaseLabelProvider
Overrides:
dispose in class DelegatingStyledCellLabelProvider

Eclipse Platform
Release 3.4

Guidelines for using Eclipse APIs.

Copyright (c) Eclipse contributors and others 2000, 2008. All rights reserved.