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

java.lang.Object
  extended by org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider
All Implemented Interfaces:
INotifyChangedListener, IContentProvider, IStructuredContentProvider, ITreeContentProvider, IPropertySourceProvider
Direct Known Subclasses:
Ecore2XMLEditor.ReverseAdapterFactoryContentProvider, EcoreEditor.ReverseAdapterFactoryContentProvider, EXTLibraryEditor.ReverseAdapterFactoryContentProvider, GenModelEditor.ReverseAdapterFactoryContentProvider, JavaEditor.ReverseAdapterFactoryContentProvider

public class AdapterFactoryContentProvider
extends java.lang.Object
implements ITreeContentProvider, IPropertySourceProvider, INotifyChangedListener

This content provider wraps an AdapterFactory and it delegates its JFace provider interfaces to corresponding adapter-implemented item provider interfaces. All method calls to the various structured content provider interfaces are delegated to interfaces implemented by the adapters generated by the AdapterFactory. IStructuredContentProvider is delegated to IStructuredItemContentProvider; ITreeContentProvider is delegated to ITreeItemContentProvider; and IPropertySourceProvider to IItemPropertySource.


Nested Class Summary
static class AdapterFactoryContentProvider.ViewerRefresh
          A runnable class that efficiently updates a Viewer via standard APIs, based on queued IViewerNotifications from the model's item providers.
 
Field Summary
protected  AdapterFactory adapterFactory
          This keeps track of the one factory we are using.
protected  Viewer viewer
          This keeps track of the one viewer using this content provider.
protected  AdapterFactoryContentProvider.ViewerRefresh viewerRefresh
          This is used to queue viewer notifications and refresh viewers based on them.
 
Constructor Summary
AdapterFactoryContentProvider(AdapterFactory adapterFactory)
          This constructs an instance that wraps this factory.
 
Method Summary
protected  IPropertySource createPropertySource(java.lang.Object object, IItemPropertySource itemPropertySource)
           
 void dispose()
          This discards the content provider and removes this as a listener to the adapterFactory.
 AdapterFactory getAdapterFactory()
          This returns the wrapped factory.
 java.lang.Object[] getChildren(java.lang.Object object)
          This implements ITreeContentProvider.getChildren to forward the call to an object that implements ITreeItemContentProvider.getChildren.
 java.lang.Object[] getElements(java.lang.Object object)
          This implements IStructuredContentProvider.getElements to forward the call to an object that implements IStructuredItemContentProvider.getElements.
 java.lang.Object getParent(java.lang.Object object)
          This implements ITreeContentProvider.getParent to forward the call to an object that implements ITreeItemContentProvider.getParent.
 IPropertySource getPropertySource(java.lang.Object object)
          This implements IPropertySourceProvider.getPropertySource to forward the call to an object that implements IItemPropertySource.
 boolean hasChildren(java.lang.Object object)
          This implements ITreeContentProvider.hasChildren to forward the call to an object that implements ITreeItemContentProvider.hasChildren.
 void inputChanged(Viewer viewer, java.lang.Object oldInput, java.lang.Object newInput)
          The given Viewer will start (oldInput == null) or stop (newInput == null) listening for domain events.
 void notifyChanged(Notification notification)
           
 void setAdapterFactory(AdapterFactory adapterFactory)
          This sets the wrapped factory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

adapterFactory

protected AdapterFactory adapterFactory
This keeps track of the one factory we are using. Use a ComposedAdapterFactory if adapters from more the one factory are involved in the model.


viewer

protected Viewer viewer
This keeps track of the one viewer using this content provider.


viewerRefresh

protected AdapterFactoryContentProvider.ViewerRefresh viewerRefresh
This is used to queue viewer notifications and refresh viewers based on them.

Since:
2.2.0
Constructor Detail

AdapterFactoryContentProvider

public AdapterFactoryContentProvider(AdapterFactory adapterFactory)
This constructs an instance that wraps this factory. The factory should yield adapters that implement the various IItemContentProvider interfaces. If the adapter factory is an IChangeNotifier, a listener is added to it, so it's important to call dispose().

Method Detail

setAdapterFactory

public void setAdapterFactory(AdapterFactory adapterFactory)
This sets the wrapped factory. If the adapter factory is an IChangeNotifier, a listener is added to it, so it's important to call dispose().


getAdapterFactory

public AdapterFactory getAdapterFactory()
This returns the wrapped factory.


inputChanged

public void inputChanged(Viewer viewer,
                         java.lang.Object oldInput,
                         java.lang.Object newInput)
The given Viewer will start (oldInput == null) or stop (newInput == null) listening for domain events.

Specified by:
inputChanged in interface IContentProvider

getElements

public java.lang.Object[] getElements(java.lang.Object object)
This implements IStructuredContentProvider.getElements to forward the call to an object that implements IStructuredItemContentProvider.getElements.

Specified by:
getElements in interface IStructuredContentProvider
Specified by:
getElements in interface ITreeContentProvider

getChildren

public java.lang.Object[] getChildren(java.lang.Object object)
This implements ITreeContentProvider.getChildren to forward the call to an object that implements ITreeItemContentProvider.getChildren.

Specified by:
getChildren in interface ITreeContentProvider

hasChildren

public boolean hasChildren(java.lang.Object object)
This implements ITreeContentProvider.hasChildren to forward the call to an object that implements ITreeItemContentProvider.hasChildren.

Specified by:
hasChildren in interface ITreeContentProvider

getParent

public java.lang.Object getParent(java.lang.Object object)
This implements ITreeContentProvider.getParent to forward the call to an object that implements ITreeItemContentProvider.getParent.

Specified by:
getParent in interface ITreeContentProvider

dispose

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

Specified by:
dispose in interface IContentProvider

getPropertySource

public IPropertySource getPropertySource(java.lang.Object object)
This implements IPropertySourceProvider.getPropertySource to forward the call to an object that implements IItemPropertySource.

Specified by:
getPropertySource in interface IPropertySourceProvider

createPropertySource

protected IPropertySource createPropertySource(java.lang.Object object,
                                               IItemPropertySource itemPropertySource)

notifyChanged

public void notifyChanged(Notification notification)
Specified by:
notifyChanged in interface INotifyChangedListener

Copyright 2001-2006 IBM Corporation and others.
All Rights Reserved.