org.eclipse.net4j.util.ui.views
Class ItemProvider<INPUT>

java.lang.Object
  extended by org.eclipse.net4j.util.ui.StructuredContentProvider<INPUT>
      extended by org.eclipse.net4j.util.ui.views.ItemProvider<INPUT>
All Implemented Interfaces:
EventListener, IBaseLabelProvider, IColorProvider, IContentProvider, IFontProvider, ILabelProvider, IStructuredContentProvider, ITreeContentProvider, IListener
Direct Known Subclasses:
ContainerItemProvider

public abstract class ItemProvider<INPUT>
extends StructuredContentProvider<INPUT>
implements ITreeContentProvider, ILabelProvider, IColorProvider, IFontProvider


Field Summary
static Object[] NO_ELEMENTS
           
 
Constructor Summary
ItemProvider()
           
 
Method Summary
 void addListener(ILabelProviderListener listener)
          Adds a listener to this label provider.
protected  void fillContextMenu(IMenuManager manager, ITreeSelection selection)
           
protected  void fireLabelProviderChanged()
           
protected  void fireLabelProviderChanged(Object element)
           
protected  void fireLabelProviderChanged(Object[] elements)
           
 Color getBackground(Object element)
          Provides a background color for the given element.
 Object[] getElements(Object parent)
          Returns the elements to display in the viewer when its input is set to the given element.
 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 obj)
          Returns the image for the label of the given element.
 ILabelProviderListener[] getListeners()
           
 String getText(Object obj)
          Returns the text for the label of the given element.
 boolean hasChildren(Object parent)
          Returns whether the given element has children.
 boolean isLabelProperty(Object element, String property)
          Returns whether the label would be affected by a change to the given property of the given element.
 void removeListener(ILabelProviderListener listener)
          Removes a listener to this label provider.
 
Methods inherited from class org.eclipse.net4j.util.ui.StructuredContentProvider
connectInput, disconnectInput, dispose, getDisplay, getInput, getItalicFont, getViewer, inputChanged, notifyEvent, refreshElement, refreshSynced, refreshViewer, revealElement, selectElement, updateLabels
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.eclipse.jface.viewers.ITreeContentProvider
getChildren, getParent
 
Methods inherited from interface org.eclipse.jface.viewers.IContentProvider
dispose, inputChanged
 
Methods inherited from interface org.eclipse.jface.viewers.IBaseLabelProvider
dispose
 

Field Detail

NO_ELEMENTS

public static final Object[] NO_ELEMENTS
Constructor Detail

ItemProvider

public ItemProvider()
Method Detail

getElements

public final Object[] getElements(Object parent)
Description copied from interface: org.eclipse.jface.viewers.ITreeContentProvider
Returns the elements to display in the viewer when its input is set to the given element. These elements can be presented as rows in a table, items in a list, etc. The result is not modified by the viewer.

NOTE: The returned array must not contain the given inputElement, since this leads to recursion issues in AbstractTreeViewer (see bug 9262).

Specified by:
getElements in interface IStructuredContentProvider
Specified by:
getElements in interface ITreeContentProvider
Parameters:
parent - the input element
Returns:
the array of elements to display in the viewer

hasChildren

public boolean hasChildren(Object parent)
Description copied from interface: org.eclipse.jface.viewers.ITreeContentProvider
Returns whether the given element has children.

Intended as an optimization for when the viewer does not need the actual children. Clients may be able to implement this more efficiently than getChildren.

Specified by:
hasChildren in interface ITreeContentProvider
Parameters:
parent - the element
Returns:
true if the given element has children, and false if it has no children

getText

public String getText(Object obj)
Description copied from interface: org.eclipse.jface.viewers.ILabelProvider
Returns the text for the label of the given element.

Specified by:
getText in interface ILabelProvider
Parameters:
obj - 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

getImage

public Image getImage(Object obj)
Description copied from interface: org.eclipse.jface.viewers.ILabelProvider
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 interface ILabelProvider
Parameters:
obj - 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

getBackground

public Color getBackground(Object element)
Description copied from interface: org.eclipse.jface.viewers.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

getForeground

public Color getForeground(Object element)
Description copied from interface: org.eclipse.jface.viewers.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

getFont

public Font getFont(Object element)
Description copied from interface: org.eclipse.jface.viewers.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

isLabelProperty

public boolean isLabelProperty(Object element,
                               String property)
Description copied from interface: org.eclipse.jface.viewers.IBaseLabelProvider
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 interface IBaseLabelProvider
Parameters:
element - the element
property - the property
Returns:
true if the label would be affected, and false if it would be unaffected

getListeners

public ILabelProviderListener[] getListeners()

addListener

public void addListener(ILabelProviderListener listener)
Description copied from interface: org.eclipse.jface.viewers.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
Parameters:
listener - a label provider listener

removeListener

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

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

fillContextMenu

protected void fillContextMenu(IMenuManager manager,
                               ITreeSelection selection)

fireLabelProviderChanged

protected void fireLabelProviderChanged()

fireLabelProviderChanged

protected void fireLabelProviderChanged(Object element)

fireLabelProviderChanged

protected void fireLabelProviderChanged(Object[] elements)


Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.