Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 


Eclipse Platform
Release 3.5

org.eclipse.jface.viewers
Class DecoratingLabelProvider


java.lang.Object
  extended by 

org.eclipse.core.commands.common.EventManager
      extended by 

org.eclipse.jface.viewers.BaseLabelProvider
          extended by 

org.eclipse.jface.viewers.LabelProvider
              extended by 
org.eclipse.jface.viewers.DecoratingLabelProvider
All Implemented Interfaces:
IBaseLabelProvider, IColorProvider, IFontProvider, ILabelProvider, ITreePathLabelProvider, IViewerLabelProvider

public class DecoratingLabelProvider
extends LabelProvider
implements ILabelProvider, 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
DecoratingLabelProvider ( 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
 void addListener ( ILabelProviderListener listener)
          The DecoratingLabelProvider implementation of this IBaseLabelProvider method adds the listener to both the nested label provider and the label decorator.
 void dispose ()
          The DecoratingLabelProvider implementation of this IBaseLabelProvider method disposes both the nested label provider and the label decorator.
  Color getBackground ( Object element)
          Provides a background color for the given element.
  IDecorationContext getDecorationContext ()
          Return the decoration context associated with this label provider.
  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 DecoratingLabelProvider implementation of this ILabelProvider method returns the image provided by the nested label provider's getImage method, decorated with the decoration provided by the label decorator's decorateImage method.
  ILabelDecorator getLabelDecorator ()
          Returns the label decorator, or null if none has been set.
  ILabelProvider getLabelProvider ()
          Returns the nested label provider.
  String getText ( Object element)
          The DecoratingLabelProvider implementation of this ILabelProvider method returns the text label provided by the nested label provider's getText method, decorated with the decoration provided by the label decorator's decorateText method.
 boolean isLabelProperty ( Object element, String property)
          The DecoratingLabelProvider implementation of this IBaseLabelProvider method returns true if the corresponding method on the nested label provider returns true or if the corresponding method on the decorator returns true.
 void removeListener ( ILabelProviderListener listener)
          The DecoratingLabelProvider implementation of this IBaseLabelProvider 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 implements LabelDecorator.
 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. 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

DecoratingLabelProvider

public DecoratingLabelProvider(
ILabelProvider provider,
                               
ILabelDecorator decorator)
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 provider
decorator - the label decorator, or null if no decorator is to be used initially
Method Detail

addListener

public void addListener(
ILabelProviderListener listener)
The DecoratingLabelProvider implementation of this IBaseLabelProvider method adds the listener to both the nested label provider and the label decorator.

Specified by:
addListener in interface IBaseLabelProvider
Overrides:
addListener in class BaseLabelProvider
Parameters:
listener - a label provider listener

dispose

public void dispose()
The DecoratingLabelProvider implementation of this IBaseLabelProvider method disposes both the nested label provider and the label decorator.

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

getImage

public 
Image getImage(
Object element)
The DecoratingLabelProvider implementation of this ILabelProvider method returns the image provided by the nested label provider's getImage method, decorated with the decoration provided by the label decorator's decorateImage method.

Specified by:
getImage in interface ILabelProvider
Overrides:
getImage in class LabelProvider
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

public 
ILabelDecorator getLabelDecorator()
Returns the label decorator, or null if none has been set.

Returns:
the label decorator, or null if none has been set.

getLabelProvider

public 
ILabelProvider getLabelProvider()
Returns the nested label provider.

Returns:
the nested label provider

getText

public 
String getText(
Object element)
The DecoratingLabelProvider implementation of this ILabelProvider method returns the text label provided by the nested label provider's getText method, decorated with the decoration provided by the label decorator's decorateText method.

Specified by:
getText in interface ILabelProvider
Overrides:
getText in class LabelProvider
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

public boolean isLabelProperty(
Object element,
                               
String property)
The DecoratingLabelProvider implementation of this IBaseLabelProvider method returns true if the corresponding method on the nested label provider returns true or if the corresponding method on the decorator returns true.

Specified by:
isLabelProperty in interface IBaseLabelProvider
Overrides:
isLabelProperty in class BaseLabelProvider
Parameters:
element - the element
property - the property
Returns:
true if the label would be affected, and false if it would be unaffected

removeListener

public void removeListener(
ILabelProviderListener listener)
The DecoratingLabelProvider implementation of this IBaseLabelProvider method removes the listener from both the nested label provider and the label decorator.

Specified by:
removeListener in interface IBaseLabelProvider
Overrides:
removeListener in class BaseLabelProvider
Parameters:
listener - a label provider listener

setLabelDecorator

public void setLabelDecorator(
ILabelDecorator decorator)
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, or null if no decorations are to be applied

updateLabel

public void updateLabel(
ViewerLabel settings,
                        
Object element)
Description copied from interface: IViewerLabelProvider
Updates the label for the given element.

Specified by:
updateLabel in interface IViewerLabelProvider
Parameters:
settings - the label to update
element - the element

updateForDecorationReady

protected void updateForDecorationReady(
ViewerLabel settings,
                                        
Object element)
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

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

Specified by:
getBackground in interface IColorProvider
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 interface: IFontProvider
Provides a font for the given element.

Specified by:
getFont in interface IFontProvider
Parameters:
element - the element
Returns:
the font for the element, or null to use the default font

getForeground

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

Specified by:
getForeground in interface IColorProvider
Parameters:
element - the element
Returns:
the foreground color for the element, or null to use the default foreground color

getDecorationContext

public 
IDecorationContext getDecorationContext()
Return 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
Since:
3.2

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.
Since:
3.2

updateLabel

public void updateLabel(
ViewerLabel settings,
                        
TreePath elementPath)
Description copied from interface: ITreePathLabelProvider
Updates the label for the given element.

Specified by:
updateLabel in interface ITreePathLabelProvider
Parameters:
settings - the label to update
elementPath - the path of the element being decorated

Eclipse Platform
Release 3.5

Guidelines for using Eclipse APIs.

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


 
 
  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire