Overview

 
Package  Use  Tree  Deprecated  Index  Help 
 PREV CLASS   NEXT CLASS FRAMES    NO FRAMES  
SUMMARY: NESTED | FIELD | CONSTR | METHOD DETAIL: FIELD | CONSTR | METHOD


 

org.eclipse.emf.edit.provider
Class DelegatingWrapperItemProvider

java.lang.Object
  extended byorg.eclipse.emf.edit.provider.WrapperItemProvider
      extended byorg.eclipse.emf.edit.provider.DelegatingWrapperItemProvider

All Implemented Interfaces:
IChangeNotifier, IDisposable, IEditingDomainItemProvider, IItemLabelProvider, IItemPropertySource, INotifyChangedListener, IStructuredItemContentProvider, ITreeItemContentProvider, IWrapperItemProvider

Direct Known Subclasses:
FeatureMapEntryWrapperItemProvider


public class DelegatingWrapperItemProvider
extends WrapperItemProvider
implements IStructuredItemContentProvider, ITreeItemContentProvider, IItemLabelProvider, IItemPropertySource, IEditingDomainItemProvider, IChangeNotifier, INotifyChangedListener

A wrapper for model objects and other wrappers. This handles most of the item provider methods by delegating to the item provider returned by adapting on the value, but it returns the owner as the parent, and it has to decorate the children, property descriptors, and commands that it returns.


Nested Class Summary
 class DelegatingWrapperItemProvider.AffectedObjectsWrappingCommand
          An AffectedObjectsWrappingCommand wraps another command to substitue this wrapper for its value and child wrappers for their corresonding child values, whenever they appear in the affected objects.
 class DelegatingWrapperItemProvider.AffectedObjectsWrappingCommandActionDelegate
          An AffectedObjectsWrappingCommandActionDelegate wraps another command that also implements CommandActionDelegate, to substitue this wrapper for its value and child wrappers for their corresonding child values, whenever they appear in the affected objects.
 
Nested classes inherited from class org.eclipse.emf.edit.provider.WrapperItemProvider
WrapperItemProvider.SimpleCopyCommand, WrapperItemProvider.WrappingCopyCommand
 
Field Summary
protected  IChangeNotifier changeNotifier
          Records any listeners for this wrapper and fires notifications to them.
protected  Map childrenMap
          The wrapped children are cached here, keyed by the children returned by the delegate item provider.
protected  Collection delegateChildren
          The collection of children last returned by the delegate item provider is cached here.
protected  Object delegateItemProvider
          The wrapped value's item provider, to which most methods are delegated.
protected  List propertyDescriptors
          The decorated property descriptors are cached here.
 
Fields inherited from class org.eclipse.emf.edit.provider.WrapperItemProvider
adapterFactory, COPY_COMMAND_DESCRIPTION, COPY_COMMAND_LABEL, owner, value
 
Constructor Summary
DelegatingWrapperItemProvider(Object value, Object owner, AdapterFactory adapterFactory)
          Creates an instance for the given value.
 
Method Summary
 void addListener(INotifyChangedListener listener)
          Adds a listener to receive this wrapper's repeated notifications.
 Command createCommand(Object object, EditingDomain domain, Class commandClass, CommandParameter commandParameter)
          Uses the delegate item provider to create a command for the delegate value, and then calls wrapCommand to return an appropriate wrapper-substituting command wrapper for it.
protected  IWrapperItemProvider createWrapper(Object value, Object owner, AdapterFactory adapterFactory)
          Creates a new instance of this wrapper for the given value, owner, and adapter factory.
 void dispose()
          Deactivates notification repeating and disposes any wrappers it is maintaining for its children.
 void fireNotifyChanged(Notification notification)
          Fires a notification to the adapter factory and any registered listeners.
 Collection getChildren(Object object)
          Uses the delgate item provider to return the delegate value's children, with appropriate wrappers to ensure that this wrapper is considered their parent.
protected  Object getDelegateValue()
          Returns the value from which to obtain and which to pass to a delegate item provider.
 Object getEditableValue(Object object)
          Uses the delegate item provider to return an editable value.
 Collection getElements(Object object)
          Uses the delegate item provider to return the delegate value's elements.
 Object getImage(Object object)
          Uses the delegate item provider to return the delegate value's image.
 Collection getNewChildDescriptors(Object object, EditingDomain editingDomain, Object sibling)
          Uses the delegate item provider to return the delegate value's new child descriptors.
 List getPropertyDescriptors(Object object)
          Wraps the property descriptors returned by the delegate item provider, caching and returning them.
protected  Object getRefreshElement(Notification notification)
          Returns the operative object of this notification, from which the viewer would be refreshed.
 String getText(Object object)
          Uses the delegate item provider to return the delegate value's text.
 boolean hasChildren(Object object)
          Uses the delegate item provider to test whether the delegate vlaue has children.
 void notifyChanged(Notification notification)
          Called by delegateItemProvider when it normally fires a notification to it's adapter factory; if the notification originated from the delegate value, this repeats the notification, using wrapNotification to substitute this wrapper as the operative object.
 void removeListener(INotifyChangedListener listener)
          Removes a notification listener.
protected  void updateChildren()
          Uses the delegate item provider to get the delegate value's children, assigning the collection to delegateChildren, and to update the childrenMap.
protected  Command wrapCommand(Command command, Class commandClass)
          Wraps the given command in an appropriate command that will substitute the delegating wrapper for its value and child wrappers for their corresponding values, whenever they appear in the affected objects.
protected  Notification wrapNotification(Notification notification)
          Wraps the given notification, substituting this wrapper as the operative object, by calling ViewerNotification.wrapNotification.
 
Methods inherited from class org.eclipse.emf.edit.provider.WrapperItemProvider
baseCreateCommand, createCopyCommand, createDragAndDropCommand, getIndex, getParent, getPropertyDescription, getPropertyDescriptor, getPropertyImage, getPropertyImage, getPropertyName, getRootAdapterFactory, getUpdateableText, getValue, isPropertySettable, setIndex
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.eclipse.emf.edit.provider.ITreeItemContentProvider
getParent
 
Methods inherited from interface org.eclipse.emf.edit.provider.IItemPropertySource
getPropertyDescriptor
 
Methods inherited from interface org.eclipse.emf.edit.provider.IEditingDomainItemProvider
getParent
 

 

Field Detail

 

 

delegateItemProvider

protected Object delegateItemProvider

The wrapped value's item provider, to which most methods are delegated.


 

 

childrenMap

protected Map childrenMap

The wrapped children are cached here, keyed by the children returned by the delegate item provider.


 

 

delegateChildren

protected Collection delegateChildren

The collection of children last returned by the delegate item provider is cached here.


 

 

propertyDescriptors

protected List propertyDescriptors

The decorated property descriptors are cached here.


 

 

changeNotifier

protected IChangeNotifier changeNotifier

Records any listeners for this wrapper and fires notifications to them.

Constructor Detail

 

 

DelegatingWrapperItemProvider

public DelegatingWrapperItemProvider(Object value,
                                     Object owner,
                                     AdapterFactory adapterFactory)

Creates an instance for the given value. A decorator for the object's item provider is created, and set up to repeat notifications, decorating them, so that they will update this wrapper, rather than the model object they originate from.

Throws:
IllegalArgumentException - If the specified value is null.
Method Detail

 

 

dispose

public void dispose()

Deactivates notification repeating and disposes any wrappers it is maintaining for its children.

Specified by:
dispose in interface IDisposable
Overrides:
dispose in class WrapperItemProvider


 

 

getDelegateValue

protected Object getDelegateValue()

Returns the value from which to obtain and which to pass to a delegate item provider. If this returns null, no delegate item provider should ever be obtained. This implementation simply returns the value of the wrapper, though subclasses may override it to return something else.


 

 

getElements

public Collection getElements(Object object)

Uses the delegate item provider to return the delegate value's elements.

Specified by:
getElements in interface IStructuredItemContentProvider
Overrides:
getElements in class WrapperItemProvider


 

 

getChildren

public Collection getChildren(Object object)

Uses the delgate item provider to return the delegate value's children, with appropriate wrappers to ensure that this wrapper is considered their parent. Each child is replaced by the corresponding wrapper from childrenMap, after updating it by calling updateChildren.

Specified by:
getChildren in interface ITreeItemContentProvider
Overrides:
getChildren in class WrapperItemProvider


 

 

updateChildren

protected void updateChildren()

Uses the delegate item provider to get the delegate value's children, assigning the collection to delegateChildren, and to update the childrenMap. New chidren are wrapped by calling createWrapper and added to the map; Wrappers for children that have been removed are disposed.


 

 

createWrapper

protected IWrapperItemProvider createWrapper(Object value,
                                             Object owner,
                                             AdapterFactory adapterFactory)

Creates a new instance of this wrapper for the given value, owner, and adapter factory.


 

 

hasChildren

public boolean hasChildren(Object object)

Uses the delegate item provider to test whether the delegate vlaue has children.

Specified by:
hasChildren in interface ITreeItemContentProvider
Overrides:
hasChildren in class WrapperItemProvider


 

 

getText

public String getText(Object object)

Uses the delegate item provider to return the delegate value's text.

Specified by:
getText in interface IItemLabelProvider
Overrides:
getText in class WrapperItemProvider


 

 

getImage

public Object getImage(Object object)

Uses the delegate item provider to return the delegate value's image.

Specified by:
getImage in interface IItemLabelProvider
Overrides:
getImage in class WrapperItemProvider


 

 

getPropertyDescriptors

public List getPropertyDescriptors(Object object)

Wraps the property descriptors returned by the delegate item provider, caching and returning them.

Specified by:
getPropertyDescriptors in interface IItemPropertySource
Overrides:
getPropertyDescriptors in class WrapperItemProvider


 

 

getEditableValue

public Object getEditableValue(Object object)

Uses the delegate item provider to return an editable value.

Specified by:
getEditableValue in interface IItemPropertySource
Overrides:
getEditableValue in class WrapperItemProvider


 

 

getNewChildDescriptors

public Collection getNewChildDescriptors(Object object,
                                         EditingDomain editingDomain,
                                         Object sibling)

Uses the delegate item provider to return the delegate value's new child descriptors.

Specified by:
getNewChildDescriptors in interface IEditingDomainItemProvider
Overrides:
getNewChildDescriptors in class WrapperItemProvider


 

 

createCommand

public Command createCommand(Object object,
                             EditingDomain domain,
                             Class commandClass,
                             CommandParameter commandParameter)

Uses the delegate item provider to create a command for the delegate value, and then calls wrapCommand to return an appropriate wrapper-substituting command wrapper for it. Drag and drop commands are created directly by calling createDragAndDropCommand.

Specified by:
createCommand in interface IEditingDomainItemProvider
Overrides:
createCommand in class WrapperItemProvider


 

 

wrapCommand

protected Command wrapCommand(Command command,
                              Class commandClass)

Wraps the given command in an appropriate command that will substitute the delegating wrapper for its value and child wrappers for their corresponding values, whenever they appear in the affected objects. This implementation returns an DelegatingWrapperItemProvider.AffectedObjectsWrappingCommand or an DelegatingWrapperItemProvider.AffectedObjectsWrappingCommandActionDelegate, depending on whether the given command implements CommandActionDelegate.


 

 

addListener

public void addListener(INotifyChangedListener listener)

Adds a listener to receive this wrapper's repeated notifications.

Specified by:
addListener in interface IChangeNotifier


 

 

removeListener

public void removeListener(INotifyChangedListener listener)

Removes a notification listener.

Specified by:
removeListener in interface IChangeNotifier


 

 

fireNotifyChanged

public void fireNotifyChanged(Notification notification)

Fires a notification to the adapter factory and any registered listeners.

Specified by:
fireNotifyChanged in interface IChangeNotifier


 

 

notifyChanged

public void notifyChanged(Notification notification)

Called by delegateItemProvider when it normally fires a notification to it's adapter factory; if the notification originated from the delegate value, this repeats the notification, using wrapNotification to substitute this wrapper as the operative object.

Specified by:
notifyChanged in interface INotifyChangedListener


 

 

getRefreshElement

protected Object getRefreshElement(Notification notification)

Returns the operative object of this notification, from which the viewer would be refreshed. If the notification is an IViewerNotification, the element is returned. Otherwise, the notifier is returned.


 

 

wrapNotification

protected Notification wrapNotification(Notification notification)

Wraps the given notification, substituting this wrapper as the operative object, by calling ViewerNotification.wrapNotification.


 

Overview

 
Package  Use  Tree  Deprecated  Index  Help 
Copyright 2001-2004 IBM Corporation and others.
All Rights Reserved.
 PREV CLASS   NEXT CLASS FRAMES    NO FRAMES  
SUMMARY: NESTED | FIELD | CONSTR | METHOD DETAIL: FIELD | CONSTR | METHOD