Package com.iizigo.navigator
Class LabelProvider
- 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
- com.iizigo.navigator.LabelProvider
- All Implemented Interfaces:
IProviderFlagsChangeListener
,org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider
,org.eclipse.jface.viewers.IBaseLabelProvider
,org.eclipse.jface.viewers.ILabelProvider
,org.eclipse.jface.viewers.ITableColorProvider
,org.eclipse.jface.viewers.ITableLabelProvider
,org.eclipse.jface.viewers.IToolTipProvider
,org.eclipse.ui.navigator.ICommonLabelProvider
,org.eclipse.ui.navigator.IDescriptionProvider
,org.eclipse.ui.navigator.IMementoAware
public class LabelProvider extends org.eclipse.jface.viewers.StyledCellLabelProvider implements IProviderFlagsChangeListener, org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider, org.eclipse.ui.navigator.ICommonLabelProvider, org.eclipse.jface.viewers.ITableLabelProvider, org.eclipse.jface.viewers.ITableColorProvider
The IIZI general purpose label provider.The label provider implementation is straight-forward. Its task is to produce a textual and graphical representation of every element. In addition, it implements the IDescriptionProvider interface to provide description in the status bar when an element is selected. Please note, that this class is not CNF-specific but is related to JFace ContentProvider and JFace LabelProvider, as usual for any Viewer.
- Author:
- Christopher Mindus
Constructor Summary
Constructors Constructor Description LabelProvider()
Eclipse constructor.LabelProvider(int flags)
Constructor.
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
dispose()
Disposes of the label provider.org.eclipse.swt.graphics.Color
getBackground(java.lang.Object element, int columnIndex)
Provides a background color for the given element at the specified indexorg.eclipse.swt.graphics.Image
getColumnImage(java.lang.Object element, int columnIndex)
Returns the label image for the given column of the given element.java.lang.String
getColumnText(java.lang.Object element, int columnIndex)
Returns the label text for the given column of the given element.java.lang.String
getDescription(java.lang.Object element)
Provide a description for the status bar view, if available.int
getFlags()
Gets the flags.org.eclipse.swt.graphics.Color
getForeground(java.lang.Object element, int columnIndex)
Provides a foreground color for the given element.org.eclipse.swt.graphics.Image
getImage(java.lang.Object element)
Returns the image for the label of the given element.static org.eclipse.jdt.ui.JavaElementLabelProvider
getJavaElementLabelProvider()
Gets the Java element label provider, allocates it if required.static org.eclipse.jdt.ui.JavaElementLabelProvider
getJavaElementLabelProvider_LargeImages()
Gets the Java element label provider for large images, allocates it if required.org.eclipse.jface.viewers.StyledString
getStyledText(java.lang.Object element)
Returns the styled text label for the given elementjava.lang.String
getText(java.lang.Object element)
Returns the text for the label of the given element.void
init(org.eclipse.ui.navigator.ICommonContentExtensionSite aConfig)
Initialize the label provider with the given configuration.boolean
isLabelProperty(java.lang.Object element, java.lang.String property)
Returns whether the label would be affected by a change to the given property of the given element.void
onNewFlags(int flags)
Called when the flags changed.void
restoreState(org.eclipse.ui.IMemento aMemento)
void
saveState(org.eclipse.ui.IMemento aMemento)
void
setFlags(int flags)
Sets the flags.Methods inherited from class org.eclipse.jface.viewers.StyledCellLabelProvider
erase, getColumn, getViewer, initialize, isOwnerDrawEnabled, measure, paint, prepareStyleRange, setOwnerDrawEnabled, styleDecoratedString, update
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
addListener, fireLabelProviderChanged, removeListener
Methods inherited from class org.eclipse.core.commands.common.EventManager
addListenerObject, clearListeners, getListeners, isListenerAttached, removeListenerObject
Method Detail
getJavaElementLabelProvider
public static org.eclipse.jdt.ui.JavaElementLabelProvider getJavaElementLabelProvider()
Gets the Java element label provider, allocates it if required.
getJavaElementLabelProvider_LargeImages
public static org.eclipse.jdt.ui.JavaElementLabelProvider getJavaElementLabelProvider_LargeImages()
Gets the Java element label provider for large images, allocates it if required.
onNewFlags
public void onNewFlags(int flags)
Called when the flags changed.- Specified by:
onNewFlags
in interfaceIProviderFlagsChangeListener
- Parameters:
flags
- The flags from INavigatorPresentation.
setFlags
public void setFlags(int flags)
Sets the flags.
getFlags
public int getFlags()
Gets the flags.
init
public void init(org.eclipse.ui.navigator.ICommonContentExtensionSite aConfig)
Initialize the label provider with the given configuration.- Specified by:
init
in interfaceorg.eclipse.ui.navigator.ICommonLabelProvider
- Parameters:
aConfig
- The extension site provides information that some extensions will find useful to configure themselves properly in a particular viewer.
restoreState
public void restoreState(org.eclipse.ui.IMemento aMemento)
- Specified by:
restoreState
in interfaceorg.eclipse.ui.navigator.IMementoAware
saveState
public void saveState(org.eclipse.ui.IMemento aMemento)
- Specified by:
saveState
in interfaceorg.eclipse.ui.navigator.IMementoAware
dispose
public void dispose()
Disposes of the label provider.- Specified by:
dispose
in interfaceorg.eclipse.jface.viewers.IBaseLabelProvider
- Overrides:
dispose
in classorg.eclipse.jface.viewers.StyledCellLabelProvider
isLabelProperty
public boolean isLabelProperty(java.lang.Object element, java.lang.String property)
Returns whether the label would be affected by a change to the given property of the given element. This can be used to optimize a non-structural viewer update. If the property mentioned in the update does not affect the label, then the viewer need not update the label.- Specified by:
isLabelProperty
in interfaceorg.eclipse.jface.viewers.IBaseLabelProvider
- Overrides:
isLabelProperty
in classorg.eclipse.jface.viewers.BaseLabelProvider
- Parameters:
element
- The element.property
- The property.- Returns:
true
if the label would be affected, andfalse
if it would be unaffected.
getImage
public org.eclipse.swt.graphics.Image getImage(java.lang.Object element)
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.- Specified by:
getImage
in interfaceorg.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider
- Specified by:
getImage
in interfaceorg.eclipse.jface.viewers.ILabelProvider
- 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.
getText
public java.lang.String getText(java.lang.Object element)
Returns the text for the label of the given element.- Specified by:
getText
in interfaceorg.eclipse.jface.viewers.ILabelProvider
- 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.
getStyledText
public org.eclipse.jface.viewers.StyledString getStyledText(java.lang.Object element)
Returns the styled text label for the given element- Specified by:
getStyledText
in interfaceorg.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider
- Parameters:
element
- The element to evaluate the styled string for.- Returns:
- The styled string.
getDescription
public java.lang.String getDescription(java.lang.Object element)
Provide a description for the status bar view, if available. A default string of the form "(x) items selected" will be used if this method choose to return null.The empty string ("") will be respected as a valid value if returned. Return null if the extension defers to the default method of supplying status bar descriptions.
- Specified by:
getDescription
in interfaceorg.eclipse.ui.navigator.IDescriptionProvider
- Parameters:
element
- The element selected in the Navigator.- Returns:
- A description for the status bar view, or null if not available.
getColumnImage
public org.eclipse.swt.graphics.Image getColumnImage(java.lang.Object element, int columnIndex)
Returns the label image for the given column of the given element.- Specified by:
getColumnImage
in interfaceorg.eclipse.jface.viewers.ITableLabelProvider
- Parameters:
element
- The object representing the entire row, ornull
indicating that no input object is set in the viewer.columnIndex
- The zero-based index of the column in which the label appears.- Returns:
- Image or
null
if there is no image for the given object at columnIndex.
getColumnText
public java.lang.String getColumnText(java.lang.Object element, int columnIndex)
Returns the label text for the given column of the given element.- Specified by:
getColumnText
in interfaceorg.eclipse.jface.viewers.ITableLabelProvider
- Parameters:
element
- The object representing the entire row, ornull
indicating that no input object is set in the viewer.columnIndex
- The zero-based index of the column in which the label appears.- Returns:
- String or or
null
if there is no text for the given object at columnIndex.
getForeground
public org.eclipse.swt.graphics.Color getForeground(java.lang.Object element, int columnIndex)
Provides a foreground color for the given element.- Specified by:
getForeground
in interfaceorg.eclipse.jface.viewers.ITableColorProvider
- Parameters:
element
- The element.columnIndex
- The zero-based index of the column in which the color appears.- Returns:
- The foreground color for the element, or
null
to use the default foreground color.
getBackground
public org.eclipse.swt.graphics.Color getBackground(java.lang.Object element, int columnIndex)
Provides a background color for the given element at the specified index- Specified by:
getBackground
in interfaceorg.eclipse.jface.viewers.ITableColorProvider
- Parameters:
element
- The element.columnIndex
- The zero-based index of the column in which the color appears- Returns:
- The background color for the element, or
null
to use the default background color.