org.eclipse.emf.edit.ui.provider
Class AdapterFactoryLabelProvider

java.lang.Object
  extended by org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider
All Implemented Interfaces:
org.eclipse.emf.edit.provider.INotifyChangedListener, org.eclipse.jface.viewers.IBaseLabelProvider, org.eclipse.jface.viewers.ILabelProvider, org.eclipse.jface.viewers.ITableLabelProvider
Direct Known Subclasses:
AdapterFactoryLabelProvider.ColorProvider, AdapterFactoryLabelProvider.FontAndColorProvider, AdapterFactoryLabelProvider.FontProvider, MEClassLabelProvider, ShortLabelProvider

public class AdapterFactoryLabelProvider
extends Object
implements org.eclipse.jface.viewers.ILabelProvider, org.eclipse.jface.viewers.ITableLabelProvider, org.eclipse.emf.edit.provider.INotifyChangedListener

This label provider wraps an AdapterFactory and it delegates its JFace provider interfaces to corresponding adapter-implemented item provider interfaces. All method calls to the various label provider interfaces are delegated to interfaces implemented by the adapters generated by the AdapterFactory. ILabelProvider is delegated to IItemLabelProvider; IFontProvider is delegated to IItemFontProvider; IColorProvider is delegated to IItemColorProvider; ITableLabelProvider is delegated to ITableItemLabelProvider; and ITableFontProvider is delegated to ITableItemFontProvider. and ITableColorProvider is delegated to ITableItemColorProvider.

The label provider has no mechanism for notifying the viewer of changes. As long as the AdapterFactory is also used in an AdapterFactoryContentProvider, this won't be a problem, because notifications will be forward as a result of that.


Nested Class Summary
static class AdapterFactoryLabelProvider.ColorProvider
          An extended version of the adapter factory label provider that also provides for colors.
static class AdapterFactoryLabelProvider.FontAndColorProvider
          An extended version of the adapter factory label provider that also provides for fonts and colors.
static class AdapterFactoryLabelProvider.FontProvider
          An extended version of the adapter factory label provider that also provides for fonts.
 
Constructor Summary
AdapterFactoryLabelProvider(org.eclipse.emf.common.notify.AdapterFactory adapterFactory)
          Construct an instance that wraps the given factory.
 
Method Summary
 void addListener(org.eclipse.jface.viewers.ILabelProviderListener listener)
          Since we won't ever generate these notifications, we can just ignore this.
 void dispose()
          This discards the content provider and removes this as a listener to the adapterFactory.
 void fireLabelProviderChanged()
           
 org.eclipse.emf.common.notify.AdapterFactory getAdapterFactory()
          Return the wrapped AdapterFactory.
 org.eclipse.swt.graphics.Color getBackground(Object object)
          This implements IColorProvider.getBackground by forwarding it to an object that implements IItemColorProvider.getBackground
 org.eclipse.swt.graphics.Color getBackground(Object object, int columnIndex)
          This implements ITableColorProvider.getBackground by forwarding it to an object that implements ITableItemColorProvider.getBackground or failing that, an object that implements IItemColorProvider.getBackground where the columnIndex is ignored.
 org.eclipse.swt.graphics.Image getColumnImage(Object object, int columnIndex)
          This implements ITableLabelProvider.getColumnImage by forwarding it to an object that implements ITableItemLabelProvider.getColumnImage or failing that, an object that implements IItemLabelProvider.getImage where the columnIndex is ignored.
 String getColumnText(Object object, int columnIndex)
          This implements ITableLabelProvider.getColumnText by forwarding it to an object that implements ITableItemLabelProvider.getColumnText or failing that, an object that implements IItemLabelProvider.getText where the columnIndex are is ignored.
 org.eclipse.swt.graphics.Color getDefaultBackground()
          Return the default background color.
 org.eclipse.swt.graphics.Font getDefaultFont()
          Return the default font.
 org.eclipse.swt.graphics.Color getDefaultForeground()
          Return the default foreground color.
 org.eclipse.swt.graphics.Font getFont(Object object)
          This implements IFontProvider.getFont by forwarding it to an object that implements IItemFontProvider.getFont
 org.eclipse.swt.graphics.Font getFont(Object object, int columnIndex)
          This implements ITableFontProvider.getFont by forwarding it to an object that implements ITableItemFontProvider.getFont or failing that, an object that implements IItemFontProvider.getFont where the columnIndex is ignored.
 org.eclipse.swt.graphics.Color getForeground(Object object)
          This implements IColorProvider.getForeground by forwarding it to an object that implements IItemColorProvider.getForeground
 org.eclipse.swt.graphics.Color getForeground(Object object, int columnIndex)
          This implements ITableColorProvider.getForeground by forwarding it to an object that implements ITableItemColorProvider.getForeground or failing that, an object that implements IItemColorProvider.getForeground where the columnIndex is ignored.
 org.eclipse.swt.graphics.Image getImage(Object object)
          This implements ILabelProvider.getImage by forwarding it to an object that implements IItemLabelProvider.getImage
 String getText(Object object)
          This implements ILabelProvider.getText by forwarding it to an object that implements IItemLabelProvider.getText
 boolean isFireLabelUpdateNotifications()
          Returns whether this label provider fires update notifications.
 boolean isLabelProperty(Object object, String id)
          This always returns true right now.
 void notifyChanged(org.eclipse.emf.common.notify.Notification notification)
           
 void removeListener(org.eclipse.jface.viewers.ILabelProviderListener listener)
          Since we won't ever add listeners, we can just ignore this.
 void setAdapterFactory(org.eclipse.emf.common.notify.AdapterFactory adapterFactory)
          Set the wrapped AdapterFactory.
 void setDefaultBackground(org.eclipse.swt.graphics.Color color)
          Set the default background color.
 void setDefaultFont(org.eclipse.swt.graphics.Font font)
          Set the default font.
 void setDefaultForeground(org.eclipse.swt.graphics.Color color)
          Set the default foreground color.
 void setFireLabelUpdateNotifications(boolean isFireLabelUpdateNotifications)
          Sets whether this label provider fires update notifications.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AdapterFactoryLabelProvider

public AdapterFactoryLabelProvider(org.eclipse.emf.common.notify.AdapterFactory adapterFactory)
Construct an instance that wraps the given factory. If the adapter factory is an IChangeNotifier, a listener is added to it, so it's important to call dispose().

Parameters:
adapterFactory - an adapter factory that yield adapters that implement the various item label provider interfaces.
Method Detail

getAdapterFactory

public org.eclipse.emf.common.notify.AdapterFactory getAdapterFactory()
Return the wrapped AdapterFactory.


setAdapterFactory

public void setAdapterFactory(org.eclipse.emf.common.notify.AdapterFactory adapterFactory)
Set the wrapped AdapterFactory. If the adapter factory is an IChangeNotifier, a listener is added to it, so it's important to call dispose().


getDefaultFont

public org.eclipse.swt.graphics.Font getDefaultFont()
Return the default font.


setDefaultFont

public void setDefaultFont(org.eclipse.swt.graphics.Font font)
Set the default font.


getDefaultForeground

public org.eclipse.swt.graphics.Color getDefaultForeground()
Return the default foreground color.


setDefaultForeground

public void setDefaultForeground(org.eclipse.swt.graphics.Color color)
Set the default foreground color.


getDefaultBackground

public org.eclipse.swt.graphics.Color getDefaultBackground()
Return the default background color.


setDefaultBackground

public void setDefaultBackground(org.eclipse.swt.graphics.Color color)
Set the default background color.


addListener

public void addListener(org.eclipse.jface.viewers.ILabelProviderListener listener)
Since we won't ever generate these notifications, we can just ignore this.

Specified by:
addListener in interface org.eclipse.jface.viewers.IBaseLabelProvider

removeListener

public void removeListener(org.eclipse.jface.viewers.ILabelProviderListener listener)
Since we won't ever add listeners, we can just ignore this.

Specified by:
removeListener in interface org.eclipse.jface.viewers.IBaseLabelProvider

dispose

public void dispose()
This discards the content provider and removes this as a listener to the adapterFactory.

Specified by:
dispose in interface org.eclipse.jface.viewers.IBaseLabelProvider

isLabelProperty

public boolean isLabelProperty(Object object,
                               String id)
This always returns true right now.

Specified by:
isLabelProperty in interface org.eclipse.jface.viewers.IBaseLabelProvider

getImage

public org.eclipse.swt.graphics.Image getImage(Object object)
This implements ILabelProvider.getImage by forwarding it to an object that implements IItemLabelProvider.getImage

Specified by:
getImage in interface org.eclipse.jface.viewers.ILabelProvider

getText

public String getText(Object object)
This implements ILabelProvider.getText by forwarding it to an object that implements IItemLabelProvider.getText

Specified by:
getText in interface org.eclipse.jface.viewers.ILabelProvider

getFont

public org.eclipse.swt.graphics.Font getFont(Object object)
This implements IFontProvider.getFont by forwarding it to an object that implements IItemFontProvider.getFont


getForeground

public org.eclipse.swt.graphics.Color getForeground(Object object)
This implements IColorProvider.getForeground by forwarding it to an object that implements IItemColorProvider.getForeground


getBackground

public org.eclipse.swt.graphics.Color getBackground(Object object)
This implements IColorProvider.getBackground by forwarding it to an object that implements IItemColorProvider.getBackground


getColumnImage

public org.eclipse.swt.graphics.Image getColumnImage(Object object,
                                                     int columnIndex)
This implements ITableLabelProvider.getColumnImage by forwarding it to an object that implements ITableItemLabelProvider.getColumnImage or failing that, an object that implements IItemLabelProvider.getImage where the columnIndex is ignored.

Specified by:
getColumnImage in interface org.eclipse.jface.viewers.ITableLabelProvider

getColumnText

public String getColumnText(Object object,
                            int columnIndex)
This implements ITableLabelProvider.getColumnText by forwarding it to an object that implements ITableItemLabelProvider.getColumnText or failing that, an object that implements IItemLabelProvider.getText where the columnIndex are is ignored.

Specified by:
getColumnText in interface org.eclipse.jface.viewers.ITableLabelProvider

getFont

public org.eclipse.swt.graphics.Font getFont(Object object,
                                             int columnIndex)
This implements ITableFontProvider.getFont by forwarding it to an object that implements ITableItemFontProvider.getFont or failing that, an object that implements IItemFontProvider.getFont where the columnIndex is ignored.


getForeground

public org.eclipse.swt.graphics.Color getForeground(Object object,
                                                    int columnIndex)
This implements ITableColorProvider.getForeground by forwarding it to an object that implements ITableItemColorProvider.getForeground or failing that, an object that implements IItemColorProvider.getForeground where the columnIndex is ignored.


getBackground

public org.eclipse.swt.graphics.Color getBackground(Object object,
                                                    int columnIndex)
This implements ITableColorProvider.getBackground by forwarding it to an object that implements ITableItemColorProvider.getBackground or failing that, an object that implements IItemColorProvider.getBackground where the columnIndex is ignored.


isFireLabelUpdateNotifications

public boolean isFireLabelUpdateNotifications()
Returns whether this label provider fires update notifications.


setFireLabelUpdateNotifications

public void setFireLabelUpdateNotifications(boolean isFireLabelUpdateNotifications)
Sets whether this label provider fires update notifications.


fireLabelProviderChanged

public void fireLabelProviderChanged()

notifyChanged

public void notifyChanged(org.eclipse.emf.common.notify.Notification notification)
Specified by:
notifyChanged in interface org.eclipse.emf.edit.provider.INotifyChangedListener


Copyright © 2014. All Rights Reserved.