org.eclipse.emf.edit.provider
Class WrapperItemProvider

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

public class WrapperItemProvider
extends java.lang.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 interfaces:

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
protected  class WrapperItemProvider.ReplacementAffectedObjectCommand
          A ReplacementAffectedObjectCommand wraps another command to return as its affected objects the single wrapper that replaces this wrapper.
protected  class WrapperItemProvider.SimpleCopyCommand
          A command base class for copying a simple value and the wrapper.
protected  class WrapperItemProvider.WrapperItemPropertyDescriptor
          An item property descriptor for the single property of a wrapper for a simple value.
protected  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 java.lang.String COPY_COMMAND_DESCRIPTION
          A description for copy command inner classes, the same as in CopyCommand.
protected static java.lang.String COPY_COMMAND_LABEL
          A label for copy command inner classes, the same one used by CopyCommand.
protected  EStructuralFeature feature
          The structural feature, if applicable, through which the value can be set and retrieved.
protected  int index
          The index at which the value is located.
protected  java.lang.Object owner
          The object that owns the value.
protected  java.lang.Object value
          The wrapped value.
 
Constructor Summary
WrapperItemProvider(java.lang.Object value, java.lang.Object owner, EStructuralFeature feature, int index, AdapterFactory adapterFactory)
          Creates an instance.
 
Method Summary
 Command baseCreateCommand(java.lang.Object object, EditingDomain domain, java.lang.Class<? extends Command> commandClass, CommandParameter commandParameter)
          Implements creation of a set, copy, or drag-and-drop command by calling out to createSetCommand, createCopyCommand, or createDragAndDropCommand.
 Command createCommand(java.lang.Object object, EditingDomain domain, java.lang.Class<? extends Command> commandClass, CommandParameter commandParameter)
          {IEditingDomainItemProvider#createCommand IEditingDomainItemProvider.createCommand} is implemented via baseCreateCommand to create set, copy, and drag-and-drop commands, only.
protected  Command createCopyCommand(EditingDomain domain, java.lang.Object owner, CopyCommand.Helper helper)
          Returns an UnexecutableCommand.
protected  Command createDragAndDropCommand(EditingDomain domain, java.lang.Object owner, float location, int operations, int operation, java.util.Collection<?> collection)
          Creates a DragAndDropCommand.
protected  Command createSetCommand(EditingDomain domain, java.lang.Object owner, java.lang.Object feature, java.lang.Object value, int index)
          Return an UnexecutableCommand.
 void dispose()
          Disposes the wrapper by deactivating any notification that this wrapper may provide.
 java.lang.Object getBackground(java.lang.Object object)
          IItemColorProvider.getBackground is implemented by returning null.
 java.util.Collection<?> getChildren(java.lang.Object object)
          ITreeItemContentProvider.getChildren is implemented to return an empty list.
 java.lang.Object getEditableValue(java.lang.Object object)
          IItemPropertySource.getEditableValue is implemented to return the value, itself.
 java.util.Collection<?> getElements(java.lang.Object object)
          IStructuredItemContentProvider.getElements is implemented by forwarding the call to getChildren.
 EStructuralFeature getFeature()
          Returns the structural feature through which the value can be set and retrieved, or null if the feature is unknown or not applicable.
 java.lang.Object getFont(java.lang.Object object)
          IItemFontProvider.getFont is implemented by returning null.
 java.lang.Object getForeground(java.lang.Object object)
          IItemColorProvider.getForeground is implemented by returning null.
 java.lang.Object getImage(java.lang.Object object)
          IItemLabelProvider.getImage is implemented by returning the default icon for an EMF.Edit item.
 int getIndex()
          The index at which the value is located, or CommandParameter.NO_INDEX if the index isn't known to the wrapper.
 java.util.Collection<?> getNewChildDescriptors(java.lang.Object object, EditingDomain editingDomain, java.lang.Object sibling)
          IEditingDomainItemProvider.getNewChildDescriptors is implemented to return an empty list.
 java.lang.Object getOwner()
          Returns the object that owns the value.
 java.lang.Object getParent(java.lang.Object object)
          ITreeItemContentProvider.getParent is implemented by returning the owner.
protected  java.lang.String getPropertyCategory()
          Returns a category for a value's single property.
protected  java.lang.String getPropertyDescription()
          Returns a description for a value's single property.
 IItemPropertyDescriptor getPropertyDescriptor(java.lang.Object object, java.lang.Object propertyId)
          IItemPropertySource.getPropertyDescriptor is implemented by iterating over the descriptors returned by getPropertyDescriptors, and returning the first descriptor whose ID or feature matches the specified ID, or null if none match.
 java.util.List<IItemPropertyDescriptor> getPropertyDescriptors(java.lang.Object object)
          IItemPropertySource.getPropertyDescriptors is implemented to return an empty list.
protected  java.lang.String[] getPropertyFilterFlags()
          Returns filter flags for a value's single property.
protected  java.lang.Object getPropertyImage()
          Returns an image for a value's single property.
protected  java.lang.Object getPropertyImage(java.lang.Class<?> typeClass)
          Returns the property image for the specified type.
protected  java.lang.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.
 java.lang.String getText(java.lang.Object object)
          IItemLabelProvider.getText is implemented by returning a non-null value, as a string, or "null".
 java.lang.String getUpdateableText(java.lang.Object object)
          IUpdateableItemText.getUpdateableText is implemented by forwarding the call to getText.
 java.lang.Object getValue()
          Returns the wrapped value.
 boolean hasChildren(java.lang.Object object)
          ITreeItemContentProvider.hasChildren is implemented by testing whether the collection returned by getChildren is non-empty.
protected  boolean isPropertyMultiLine()
          Returns whether value's single property consists of multi-line text.
protected  boolean isPropertySettable()
          Returns whether a value's single property is settable.
protected  boolean isPropertySortChoices()
          Returns whether value's single property should sort its choices for selection.
 void setIndex(int index)
          Sets the index.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

value

protected java.lang.Object value
The wrapped value.


owner

protected java.lang.Object owner
The object that owns the value.


feature

protected EStructuralFeature feature
The structural feature, if applicable, through which the value can be set and retrieved.


index

protected int index
The index at which the value is located. If feature is non-null, this index is within that feature.


adapterFactory

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


COPY_COMMAND_LABEL

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


COPY_COMMAND_DESCRIPTION

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

Constructor Detail

WrapperItemProvider

public WrapperItemProvider(java.lang.Object value,
                           java.lang.Object owner,
                           EStructuralFeature feature,
                           int index,
                           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 java.lang.Object getValue()
Returns the wrapped value.

Specified by:
getValue in interface IWrapperItemProvider

getOwner

public java.lang.Object getOwner()
Returns the object that owns the value.

Specified by:
getOwner in interface IWrapperItemProvider

getFeature

public EStructuralFeature getFeature()
Returns the structural feature through which the value can be set and retrieved, or null if the feature is unknown or not applicable.

Specified by:
getFeature in interface IWrapperItemProvider

getIndex

public int getIndex()
The index at which the value is located, or CommandParameter.NO_INDEX if the index isn't known to the wrapper. If feature is non-null, this index is within that feature.

Specified by:
getIndex in interface IWrapperItemProvider

setIndex

public void setIndex(int index)
Sets the index. Has no effect if the index isn't known to the wrapper.

Specified by:
setIndex in interface IWrapperItemProvider

getElements

public java.util.Collection<?> getElements(java.lang.Object object)
IStructuredItemContentProvider.getElements is implemented by forwarding the call to getChildren.


getChildren

public java.util.Collection<?> getChildren(java.lang.Object object)
ITreeItemContentProvider.getChildren is implemented to return an empty list. Subclasses may override it to return something else.


hasChildren

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


getParent

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


getText

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


getImage

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


getFont

public java.lang.Object getFont(java.lang.Object object)
IItemFontProvider.getFont is implemented by returning null.


getForeground

public java.lang.Object getForeground(java.lang.Object object)
IItemColorProvider.getForeground is implemented by returning null.


getBackground

public java.lang.Object getBackground(java.lang.Object object)
IItemColorProvider.getBackground is implemented by returning null.


getUpdateableText

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


getPropertyDescriptors

public java.util.List<IItemPropertyDescriptor> getPropertyDescriptors(java.lang.Object object)
IItemPropertySource.getPropertyDescriptors is implemented to return an empty list. Subclasses may override it to return something else.


getPropertyDescriptor

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


getEditableValue

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


getPropertyName

protected java.lang.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 java.lang.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. By default, this returns whether the structural feature is changeable. Subclasses may use this in creating a property descriptor, and user subclasses may override it to restrict or allow setting of the property.


isPropertyMultiLine

protected boolean isPropertyMultiLine()
Returns whether value's single property consists of multi-line text. By default, false is returned. Subclasses may use this in creating a property descriptor, and user subclasses may override it to enable multi-line text editing.

Since:
2.2.0

isPropertySortChoices

protected boolean isPropertySortChoices()
Returns whether value's single property should sort its choices for selection. By default, false is returned. Subclasses may use this in creating a property descriptor, and user subclasses may override it to enable sorting.

Since:
2.2.0

getPropertyImage

protected java.lang.Object getPropertyImage()
Returns an image for a value's single property. By default, a standard property icon is selected based on the type of the structural feature. Subclasses may use this in creating a property descriptor, and user subclasses may override it to select a different icon.


getPropertyImage

protected java.lang.Object getPropertyImage(java.lang.Class<?> typeClass)
Returns the property image for the specified type. Implementations of getPropertyImage typically call this method.


getPropertyCategory

protected java.lang.String getPropertyCategory()
Returns a category for a value's single property. By default, null is returned. Subclasses may use this in creating a property descriptor, and user subclasses may override it to actually provide a category.


getPropertyFilterFlags

protected java.lang.String[] getPropertyFilterFlags()
Returns filter flags for a value's single property. By default, null is returned. Subclasses may use this in creating a property descriptor, and user subclasses may override it to actually provide filter flags.


getNewChildDescriptors

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


createCommand

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


baseCreateCommand

public Command baseCreateCommand(java.lang.Object object,
                                 EditingDomain domain,
                                 java.lang.Class<? extends Command> commandClass,
                                 CommandParameter commandParameter)
Implements creation of a set, copy, or drag-and-drop command by calling out to createSetCommand, createCopyCommand, or createDragAndDropCommand.


createSetCommand

protected Command createSetCommand(EditingDomain domain,
                                   java.lang.Object owner,
                                   java.lang.Object feature,
                                   java.lang.Object value,
                                   int index)
Return an UnexecutableCommand. Subclasses should override this to map this into a real set on a model object.


createCopyCommand

protected Command createCopyCommand(EditingDomain domain,
                                    java.lang.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,
                                           java.lang.Object owner,
                                           float location,
                                           int operations,
                                           int operation,
                                           java.util.Collection<?> collection)
Creates a DragAndDropCommand.


getRootAdapterFactory

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


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