org.eclipse.emf.edit.provider
Class WrapperItemProvider

java.lang.Object
  extended byorg.eclipse.emf.edit.provider.WrapperItemProvider
All Implemented Interfaces:
IDisposable, IWrapperItemProvider
Direct Known Subclasses:
AttributeValueWrapperItemProvider, DelegatingWrapperItemProvider

public class WrapperItemProvider
extends Object
implements IWrapperItemProvider

A basic implementation of IWrapperProvider from which others can extend. This class provides all the methods required to implement the following item provider iterfaces:

Subclasses should declare which of these interfaces they are meant to implement, and override methods as needed. In addition, a partial implementation for IUpdateableItemText is provided, along with additional methods and classes that are useful in implementing multiple subclasses.


Nested Class Summary
 class WrapperItemProvider.SimpleCopyCommand
          A command base class for copying a simple value and the wrapper.
 class WrapperItemProvider.WrappingCopyCommand
          A command base class for copying the wrapper for a value that is partly copied by another command.
 
Field Summary
protected  AdapterFactory adapterFactory
          The adapter factory for the owner's item provider.
protected static String COPY_COMMAND_DESCRIPTION
          A description for copy command inner classes, the same as in CopyCommand.
protected static String COPY_COMMAND_LABEL
          A label for copy command inner classes, the same one used by CopyCommand.
protected  Object owner
          The object that owns the value.
protected  Object value
          The wrapped value.
 
Constructor Summary
WrapperItemProvider(Object value, Object owner, AdapterFactory adapterFactory)
          Creates an instance.
 
Method Summary
 Command baseCreateCommand(Object object, EditingDomain domain, Class commandClass, CommandParameter commandParameter)
          Implements creation of copy and drag-and-drop commands by calling out to createCopyCommand or createDragAndDropCommand.
 Command createCommand(Object object, EditingDomain domain, Class commandClass, CommandParameter commandParameter)
          {IEditingDomainItemProvider#createCommand IEditingDomainItemProvider.createCommand} is implemented via baseCreateCommand to create copy and drag-and-drop commands, only.
protected  Command createCopyCommand(EditingDomain domain, Object owner, CopyCommand.Helper helper)
          Returns an UnexecutableCommand.
protected  Command createDragAndDropCommand(EditingDomain domain, Object owner, float location, int operations, int operation, Collection collection)
          Creates a DragAndDropCommand.
 void dispose()
          Disposes the wrapper by deactivating any notification that this wrapper may provide.
 Collection getChildren(Object object)
          ITreeItemContentProvider.getChildren is implemented to return an empty list.
 Object getEditableValue(Object object)
          IItemPropertySource.getEditableValue is implemented to return the value, itself.
 Collection getElements(Object object)
          IStructuredItemContentProvider.getElements is implemented by forwarding the call to getChildren.
 Object getImage(Object object)
          IItemLabelProvider.getImage is implemented by returning the default icon for an EMF.Edit item.
 int getIndex()
          Returns CommandParameter.NO_INDEX, indicating that the index isn't known to this base wrapper implementation.
 Collection getNewChildDescriptors(Object object, EditingDomain editingDomain, Object sibling)
          IEditingDomainItemProvider.getNewChildDescriptors is implemented to return an empty list.
 Object getParent(Object object)
          ITreeItemContentProvider.getParent is implemented by returning the owner.
protected  String getPropertyDescription()
          Returns a description for a value's single property.
 IItemPropertyDescriptor getPropertyDescriptor(Object object, Object propertyId)
          IItemPropertySource.getPropertyDescriptor is implemented by iterating over the descriptors returned by getPropertyDescriptors, and returning the first descriptor whose ID matches the specified ID, or null if none match.
 List getPropertyDescriptors(Object object)
          IItemPropertySource.getPropertyDescriptors is implemented to return an empty list.
protected  Object getPropertyImage()
          Returns an image for a value's single property.
protected  Object getPropertyImage(Class typeClass)
          Returns the property image for the specified type.
protected  String getPropertyName()
          Returns a name for a value's single property.
protected  AdapterFactory getRootAdapterFactory()
          Returns the adapterFactory, if non-composeable, otherwise, returns its root adapter factory.
 String getText(Object object)
          IItemLabelProvider.getText is implemented by returning a non-null value, as a string, or "null".
 String getUpdateableText(Object object)
          IUpdateableItemText.getUpdateableText is implemented by forwarding the call to getText.
 Object getValue()
          Returns the wrapped value.
 boolean hasChildren(Object object)
          ITreeItemContentProvider.hasChildren is implemented by testing whether the collection returned by getChildren is non-empty.
protected  boolean isPropertySettable()
          Returns whether a value's single property is settable.
 void setIndex(int index)
          Has no effect, as the index isn't known to this base wrapper implementation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

value

protected Object value
The wrapped value.


owner

protected Object owner
The object that owns the value.


adapterFactory

protected AdapterFactory adapterFactory
The adapter factory for the owner's item provider.


COPY_COMMAND_LABEL

protected static final String COPY_COMMAND_LABEL
A label for copy command inner classes, the same one used by CopyCommand.


COPY_COMMAND_DESCRIPTION

protected static final String COPY_COMMAND_DESCRIPTION
A description for copy command inner classes, the same as in CopyCommand.

Constructor Detail

WrapperItemProvider

public WrapperItemProvider(Object value,
                           Object owner,
                           AdapterFactory adapterFactory)
Creates an instance. The adapter factory of the owner's item provider may be needed for echoing notifications and providing property descriptors.

Method Detail

dispose

public void dispose()
Disposes the wrapper by deactivating any notification that this wrapper may provide. Since this implementation does not provide any notification, this method does nothing.

Specified by:
dispose in interface IDisposable

getValue

public Object getValue()
Returns the wrapped value.

Specified by:
getValue in interface IWrapperItemProvider

getIndex

public int getIndex()
Returns CommandParameter.NO_INDEX, indicating that the index isn't known to this base wrapper implementation.

Specified by:
getIndex in interface IWrapperItemProvider

setIndex

public void setIndex(int index)
Has no effect, as the index isn't known to this base wrapper implementation.

Specified by:
setIndex in interface IWrapperItemProvider

getElements

public Collection getElements(Object object)
IStructuredItemContentProvider.getElements is implemented by forwarding the call to getChildren.


getChildren

public Collection getChildren(Object object)
ITreeItemContentProvider.getChildren is implemented to return an empty list. Subclasses may override it to return something else.


hasChildren

public boolean hasChildren(Object object)
ITreeItemContentProvider.hasChildren is implemented by testing whether the collection returned by getChildren is non-empty.


getParent

public Object getParent(Object object)
ITreeItemContentProvider.getParent is implemented by returning the owner.


getText

public String getText(Object object)
IItemLabelProvider.getText is implemented by returning a non-null value, as a string, or "null".


getImage

public Object getImage(Object object)
IItemLabelProvider.getImage is implemented by returning the default icon for an EMF.Edit item.


getUpdateableText

public String getUpdateableText(Object object)
IUpdateableItemText.getUpdateableText is implemented by forwarding the call to getText.


getPropertyDescriptors

public List getPropertyDescriptors(Object object)
IItemPropertySource.getPropertyDescriptors is implemented to return an empty list. Subclasses may override it to return something else.


getPropertyDescriptor

public IItemPropertyDescriptor getPropertyDescriptor(Object object,
                                                     Object propertyId)
IItemPropertySource.getPropertyDescriptor is implemented by iterating over the descriptors returned by getPropertyDescriptors, and returning the first descriptor whose ID matches the specified ID, or null if none match.


getEditableValue

public Object getEditableValue(Object object)
IItemPropertySource.getEditableValue is implemented to return the value, itself.


getPropertyName

protected String getPropertyName()
Returns a name for a value's single property. Subclasses may use this in creating a property descriptor, and user subclasses may override it to provide a specific name.


getPropertyDescription

protected String getPropertyDescription()
Returns a description for a value's single property. Subclasses may use this in creating a property descriptor, and user subclasses may override it to provide a specific name.


isPropertySettable

protected boolean isPropertySettable()
Returns whether a value's single property is settable. Subclasses may use this in creating a property descriptor and override it to provide a specific name.


getPropertyImage

protected Object getPropertyImage()
Returns an image for a value's single property. By default, the generic property icon is returned. Subclasses may use this in creating a property descriptor and override it to provide a more specific icon.


getPropertyImage

protected Object getPropertyImage(Class typeClass)
Returns the property image for the specified type. Overrides for getPropertyImage typically call this method.


getNewChildDescriptors

public Collection getNewChildDescriptors(Object object,
                                         EditingDomain editingDomain,
                                         Object sibling)
IEditingDomainItemProvider.getNewChildDescriptors is implemented to return an empty list. Subclasses may override it to return something else.


createCommand

public Command createCommand(Object object,
                             EditingDomain domain,
                             Class commandClass,
                             CommandParameter commandParameter)
{IEditingDomainItemProvider#createCommand IEditingDomainItemProvider.createCommand} is implemented via baseCreateCommand to create copy and drag-and-drop commands, only.


baseCreateCommand

public Command baseCreateCommand(Object object,
                                 EditingDomain domain,
                                 Class commandClass,
                                 CommandParameter commandParameter)
Implements creation of copy and drag-and-drop commands by calling out to createCopyCommand or createDragAndDropCommand.


createCopyCommand

protected Command createCopyCommand(EditingDomain domain,
                                    Object owner,
                                    CopyCommand.Helper helper)
Returns an UnexecutableCommand. An ordinary CopyCommand is only useful for copying model objects, so it would be inappropriate here. Subclasses should override it to return something more useful, like a concrete subclass of a WrapperItemProvider.SimpleCopyCommand or WrapperItemProvider.WrappingCopyCommand.


createDragAndDropCommand

protected Command createDragAndDropCommand(EditingDomain domain,
                                           Object owner,
                                           float location,
                                           int operations,
                                           int operation,
                                           Collection collection)
Creates a DragAndDropCommand.


getRootAdapterFactory

protected AdapterFactory getRootAdapterFactory()
Returns the adapterFactory, if non-composeable, otherwise, returns its root adapter factory.


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