| |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.emf.common.notify.impl.AdapterImpl
org.eclipse.emf.edit.provider.ItemProviderAdapter
This adapter implementation provides a convenient reusable base for adapters that will be used as item providers. Default implementations for the following interfaces are provided: IItemLabelProvider, IItemPropertySource, IStructuredItemContentProvider, ITreeItemContentProvider, and IEditingDomainItemProvider. Also, IUpdateableItemText.getUpdateableText(java.lang.Object) is implemented to delegate to getText(java.lang.Object); often the editable text will be just the text, in which case this is a good default implementation.
Nested Class Summary | |
protected static class | ItemProviderAdapter.ChildrenStore
A ChildrenStore stores a number of objects that are to be presented as the children of an object. |
protected static class | ItemProviderAdapter.ModifiableSingletonEList
A single-element implementation of EList. |
class | ItemProviderAdapter.ResultAndAffectedObjectsWrappingCommand
A ResultAndAffectedObjectsWrappingCommand wraps another command to substitute IWrapperItemProviders for their values in the command's result and affected objects. |
class | ItemProviderAdapter.ResultAndAffectedObjectsWrappingCommandActionDelegate
A ResultAndAffectedObjectsWrappingCommandActionDelegate wraps another command that also implements CommandActionDelegate, to substitute IWrapperItemProviders for its values, which have been unwrapped for the command to operate on properly. |
Field Summary | |
protected AdapterFactory | adapterFactory
This keeps track of the adapter factory that created this adaptor. |
protected IChangeNotifier | changeNotifier
This is used to implement IChangeNotifier. |
protected List | childrenFeatures
This is used to store all the children features. |
protected List | childrenReferences
Deprecated. As of EMF 2.0, replaced by childrenFeatures. |
protected Map | childrenStoreMap
When ItemProviderAdapter.ChildrenStores are to be used to cache children (typically to hold wrappers for non-EObject children), this maps adapted objects to their corresponding stores. |
protected List | itemPropertyDescriptors
This is used to store all the property descriptors. |
protected Collection | targets
This keeps track of all the targets to which this adapter is set. |
protected Disposable | wrappers
This holds children wrappers that are created by this item provider, so that they can be disposed with it. |
protected Boolean | wrappingNeeded
This caches the result returned by isWrappingNeeded so that it need not be recomputed each time. |
Fields inherited from class org.eclipse.emf.common.notify.impl.AdapterImpl |
target |
Constructor Summary | |
ItemProviderAdapter(AdapterFactory adapterFactory)
An instance is created from an adapter factory. |
Method Summary | |
void | addListener(INotifyChangedListener listener)
This adds another listener. |
protected void | adjustWrapperIndex(Object object,
int increment)
If the given object implements IWrapperItemProvider and specifies an index, that index is adjusted by the given increment. |
protected void | adjustWrapperIndices(List objects,
int from,
int increment)
For each element of the given list, starting at from, that implements IWrapperItemProvider and specifies an index, that index is adjusted by the given increment. |
protected void | adjustWrapperIndices(List objects,
int from,
int to,
int increment)
For each element of the given list, between from and to, that implements IWrapperItemProvider and specifies an index, that index is adjusted by the given increment. |
protected void | collectNewChildDescriptors(Collection newChildDescriptors,
Object object)
This adds to newChildDescriptors, a collection of CommandParameters, parameters for possible children of the specified object, when viewed as an instance of the type for which this is an item provider. |
protected Command | createAddCommand(EditingDomain domain,
EObject owner,
EReference feature,
Collection collection,
int index)
Deprecated. As of EMF 2.0, replaced by createAddCommand. |
protected Command | createAddCommand(EditingDomain domain,
EObject owner,
EStructuralFeature feature,
Collection collection,
int index)
This creates a primitive AddCommand. |
protected CommandParameter | createChildParameter(Object feature,
Object child)
This is a convenience method that creates a CommandParameter for a given parent feature and child object. |
protected ItemProviderAdapter.ChildrenStore | createChildrenStore(Object object)
Consults isWrappingNeeded to decide whether to create a store for the children of the given object. |
Command | createCommand(Object object,
EditingDomain domain,
Class commandClass,
CommandParameter commandParameter)
This implements delegated command creation for the given object. |
protected Command | createCopyCommand(EditingDomain domain,
EObject owner,
CopyCommand.Helper helper)
This creates a primitive CopyCommand. |
protected Command | createCreateChildCommand(EditingDomain domain,
EObject owner,
EReference feature,
EObject value,
int index,
Collection collection)
Deprecated. As of EMF 2.0, replaced by createCreateChildCommand. |
protected Command | createCreateChildCommand(EditingDomain domain,
EObject owner,
EStructuralFeature feature,
Object value,
int index,
Collection collection)
This creates a primitive CreateChildCommand. |
protected Command | createCreateCopyCommand(EditingDomain domain,
EObject owner,
CopyCommand.Helper helper)
This creates a primitive CreateCopyCommand. |
protected Command | createDragAndDropCommand(EditingDomain domain,
Object owner,
float location,
int operations,
int operation,
Collection collection)
This creates a primitive DragAndDropCommand. |
protected Command | createInitializeCopyCommand(EditingDomain domain,
EObject owner,
CopyCommand.Helper helper)
This creates a primitive InitializeCopyCommand. |
protected Command | createMoveCommand(EditingDomain domain,
EObject owner,
EReference feature,
EObject value,
int index)
Deprecated. As of EMF 2.0, replaced by createMoveCommand. |
protected Command | createMoveCommand(EditingDomain domain,
EObject owner,
EStructuralFeature feature,
Object value,
int index)
This creates a primitive MoveCommand. |
protected Command | createRemoveCommand(EditingDomain domain,
EObject owner,
EReference feature,
Collection collection)
Deprecated. As of EMF 2.0, replaced by createRemoveCommand. |
protected Command | createRemoveCommand(EditingDomain domain,
EObject owner,
EStructuralFeature feature,
Collection collection)
This creates a primitive RemoveCommand. |
protected Command | createReplaceCommand(EditingDomain domain,
EObject owner,
EReference feature,
EObject value,
Collection collection)
Deprecated. As of EMF 2.0, replaced by createReplaceCommand. |
protected Command | createReplaceCommand(EditingDomain domain,
EObject owner,
EStructuralFeature feature,
EObject value,
Collection collection)
This creates a primitive ReplaceCommand. |
protected Command | createSetCommand(EditingDomain domain,
EObject owner,
EStructuralFeature feature,
Object value)
This returned a primitive SetCommand, but it has been replaced, since this command can now take an index. |
protected Command | createSetCommand(EditingDomain domain,
EObject owner,
EStructuralFeature feature,
Object value,
int index)
This creates a primitive SetCommand. |
protected Object | createWrapper(EObject object,
EStructuralFeature feature,
Object value,
int index)
Creates and returns a wrapper for the given value, at the given index in the given feature of the given object if such a wrapper is needed; otherwise, returns the original value. |
void | dispose()
This will remove this adapter from all its the targets and dispose any remainging children wrappers in the children store. |
protected void | disposeWrapper(Object object)
If the given object implements IWrapperItemProvider, it is disposed by calling dispose. |
protected void | disposeWrappers(List objects)
Each element of the given list that implements IWrapperItemProvider is disposed by calling IWrapperItemProvider#dispose dispose} and is removed from wrappers. |
protected Command | factorAddCommand(EditingDomain domain,
CommandParameter commandParameter)
This method factors an AddCommand for a collection of objects into one or more primitive add command, i.e., one per unique feature. |
protected Command | factorMoveCommand(EditingDomain domain,
CommandParameter commandParameter)
This method factors a MoveCommand to determine the feature. |
protected Command | factorRemoveCommand(EditingDomain domain,
CommandParameter commandParameter)
This method factors a RemoveCommand for a collection of objects into one or more primitive remove commands, i.e., one per unique feature. |
void | fireNotifyChanged(Notification notification)
This convenience method converts the arguments into an appropriate update call on the viewer. |
AdapterFactory | getAdapterFactory()
This provides access to the factory. |
URL | getBaseURL()
Get the base URL from the resource locator. |
protected EStructuralFeature | getChildFeature(Object object,
Object child)
This returns the most appropriate feature of the object into which the given child could be added. |
protected EReference | getChildReference(Object object,
Object child)
Deprecated. As of EMF 2.0, replaced by getChildFeature. |
Collection | getChildren(Object object)
This implements ITreeItemContentProvider.getChildren. |
protected Collection | getChildrenFeatures(Object object)
If this is defined to be something other than an empty list, it is used to implement getChildren, including in determining whether to cache children and, if so, in setting up the store. |
protected Collection | getChildrenReferences(Object object)
Deprecated. As of EMF 2.0, replaced by getChildrenFeatures. |
protected ItemProviderAdapter.ChildrenStore | getChildrenStore(Object object)
Returns the store for the children of the given object, or null if no such store is being maintained. |
String | getCreateChildDescription(Object owner,
Object feature,
Object child,
Collection selection)
This returns the description for CreateChildCommand. |
Object | getCreateChildImage(Object owner,
Object feature,
Object child,
Collection selection)
This returns the icon image for CreateChildCommand. |
Collection | getCreateChildResult(Object child)
This returns the result collection for CreateChildCommand. |
String | getCreateChildText(Object owner,
Object feature,
Object child,
Collection selection)
This returns the label for CreateChildCommand. |
String | getCreateChildToolTipText(Object owner,
Object feature,
Object child,
Collection selection)
This returns the tool tip text for CreateChildCommand. |
Object | getEditableValue(Object object)
This implements IItemPropertySource.getEditableValue by simply returning the object itself. |
Collection | getElements(Object object)
This implements IStructuredItemContentProvider.getElements by forwarding the call to getChildren. |
protected String | getFeatureText(Object feature)
This looks up the name of the specified feature. |
protected Object | getFeatureValue(EObject object,
EStructuralFeature feature)
This method is called by factorRemoveCommand to retrieve the children objects of the features returned from getChildrenFeatures. |
Object | getImage(Object object)
This implements IItemLabelProvider.getImage by returning null. |
Object | getImage(String key)
Get an image from the resource locator. |
Collection | getNewChildDescriptors(Object object,
EditingDomain editingDomain,
Object sibling)
This implements IEditingDomainItemProvider.getNewChildDescriptors, returning CommandParameters to describe all the possible children that can be added to the specified object. |
Object | getParent(Object object)
This implements ITreeItemContentProvider.getParent by returning the EMF object's container. |
IItemPropertyDescriptor | getPropertyDescriptor(Object object,
Object propertyId)
This convenience method finds a particular descriptor given its property name. |
List | getPropertyDescriptors(Object object)
This implements IItemPropertySource.getPropertyDescriptors by returning the locally stored vector of descriptors. |
Object | getPropertyValue(Object object,
String property)
This implements a PropertySource by delegating to the descriptor, which is assumed to support the IItemPropertyDescriptor interface |
protected Object | getReferenceValue(EObject object,
EReference reference)
Deprecated. As of EMF 2.0, replaced by getFeatureValue. |
protected ResourceLocator | getResourceLocator()
Get the resource locator for this adapter's resources. |
protected ResourceLocator | getResourceLocator(Object anyObject)
Get the resource locator from the adapter of the object, if possible. |
protected AdapterFactory | getRootAdapterFactory()
Gets the root factory if this local adapter factory is composed, otherwise just the local one. |
protected EStructuralFeature | getSetFeature(Object object,
Object value)
This returns the most appropriate feature of the object into which the value be set. |
protected Collection | getSetFeatures(Object object)
If this is defined to be something other than an empty list, it is used to implement getSetFeature and to deduce the EMF feature in the SetCommand createCommand. |
String | getString(String key)
Get a translated string from the resource locator. |
String | getString(String key,
Object[] substitutions)
Get a translated string from the resource locator, with substitutions. |
protected String | getString(String key,
String s0)
Get a translated string from the resource locator, substituting another such translated string. |
protected String | getString(String key,
String s0,
String s1)
Get a translated string from the resource locator, substituting two other such translated strings. |
String | getText(Object object)
This implements IItemLabelProvider.getText by simply calling toString on the argument. |
protected String | getTypeText(Object object)
This looks up the name of the type of the specified object. |
String | getUpdateableText(Object object)
This implements IUpdateableItemText.getUpdateableText by simply calling getText(java.lang.Object). |
protected Collection | getWrappedValues(CommandParameter commandParameter)
Returns a collection of any objects in the given command parameter's collection and value, that implement IWrapperItemProvider. |
boolean | hasChildren(Object object)
This implements ITreeItemContentProvider.hasChildren by simply testing whether getChildren returns any children. |
boolean | isAdapterForType(Object type)
The adapter factory is used as the type key. |
protected boolean | isEquivalentValue(Object value,
Object referenceValue)
Returns whether the given value is to be considered equivalent to the given reference value. |
boolean | isPropertySet(Object object,
String property)
This implements PropertySource by delegating to the descriptor, which is assumed to support the IItemPropertyDescriptor interface |
protected boolean | isWrappingNeeded(Object object)
Returns whether this item provider may need to use wrappers for some or all of the values it returns as children. |
void | removeListener(INotifyChangedListener listener)
This removes a listener. |
void | resetPropertyValue(Object object,
String property)
This implements PropertySource.resetPropertyValue by delegating to the descriptor, which is assumed to support the IItemPropertyDescriptor interface |
void | setPropertyValue(Object object,
String property,
Object value)
This implements PropertySource by delegating to the descriptor, which is assumed to support the IItemPropertyDescriptor interface |
void | setTarget(Notifier target)
Sets the target from which the adapter will receive notification. |
protected Object | unwrap(Object object)
If the given object implements IWrapperItemProvider, it is unwrapped by obtaining a value from getValue. |
protected CommandParameter | unwrapCommandValues(CommandParameter commandParameter,
Class commandClass)
If the given command parameter contains wrapped values that need to be unwrapped for the given command class to operate on, a new command parameter will be returned, with those values unwrapped; otherwise, the original one is returned. |
protected void | updateChildren(Notification notification)
Updates any cached children based on the given notification. |
protected Object | wrap(EObject object,
EStructuralFeature feature,
Object value,
int index)
Wraps a value, if needed, and keeps the wrapper for disposal along with the item provider. |
protected Command | wrapCommand(Command command,
Object object,
Class commandClass,
CommandParameter commandParameter,
CommandParameter oldCommandParameter)
Returns a version of the given command that automatically re-wraps values that have been unwrapped when returning them as the command's result or affected objects. |
Methods inherited from class org.eclipse.emf.common.notify.impl.AdapterImpl |
getTarget, notifyChanged |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected AdapterFactory adapterFactory
protected List itemPropertyDescriptors
protected List childrenFeatures
protected List childrenReferences
protected IChangeNotifier changeNotifier
protected Collection targets
protected Map childrenStoreMap
protected Disposable wrappers
protected Boolean wrappingNeeded
Constructor Detail |
public ItemProviderAdapter(AdapterFactory adapterFactory)
Method Detail |
public boolean isAdapterForType(Object type)
public AdapterFactory getAdapterFactory()
public void addListener(INotifyChangedListener listener)
public void removeListener(INotifyChangedListener listener)
public void fireNotifyChanged(Notification notification)
public Object getEditableValue(Object object)
public List getPropertyDescriptors(Object object)
public IItemPropertyDescriptor getPropertyDescriptor(Object object, Object propertyId)
public Object getPropertyValue(Object object, String property)
public boolean isPropertySet(Object object, String property)
public void resetPropertyValue(Object object, String property)
public void setPropertyValue(Object object, String property, Object value)
public Collection getElements(Object object)
public Collection getChildren(Object object)
public boolean hasChildren(Object object)
protected Collection getChildrenFeatures(Object object)
protected Collection getChildrenReferences(Object object)
protected Object getFeatureValue(EObject object, EStructuralFeature feature)
protected Object getReferenceValue(EObject object, EReference reference)
protected EStructuralFeature getChildFeature(Object object, Object child)
protected EReference getChildReference(Object object, Object child)
protected Collection getSetFeatures(Object object)
protected EStructuralFeature getSetFeature(Object object, Object value)
public Object getParent(Object object)
public Object getImage(Object object)
public String getText(Object object)
public String getUpdateableText(Object object)
public Collection getNewChildDescriptors(Object object, EditingDomain editingDomain, Object sibling)
This implementation invokes collectNewChildDescriptors, which should be overridden by derived classes, to build this collection.
If sibling is non-null, an index is added to each CommandParameter with a multi-valued feature, to ensure that the new child object gets added in the right position.
protected boolean isEquivalentValue(Object value, Object referenceValue)
protected void collectNewChildDescriptors(Collection newChildDescriptors, Object object)
public Command createCommand(Object object, EditingDomain domain, Class commandClass, CommandParameter commandParameter)
protected Command createSetCommand(EditingDomain domain, EObject owner, EStructuralFeature feature, Object value, int index)
protected Command createSetCommand(EditingDomain domain, EObject owner, EStructuralFeature feature, Object value)
This method will soon be deprecated. New code should use or override the new form, instead.
protected Command createCopyCommand(EditingDomain domain, EObject owner, CopyCommand.Helper helper)
protected Command createCreateCopyCommand(EditingDomain domain, EObject owner, CopyCommand.Helper helper)
protected Command createInitializeCopyCommand(EditingDomain domain, EObject owner, CopyCommand.Helper helper)
protected Command createRemoveCommand(EditingDomain domain, EObject owner, EStructuralFeature feature, Collection collection)
protected Command createRemoveCommand(EditingDomain domain, EObject owner, EReference feature, Collection collection)
protected Command createReplaceCommand(EditingDomain domain, EObject owner, EStructuralFeature feature, EObject value, Collection collection)
protected Command createReplaceCommand(EditingDomain domain, EObject owner, EReference feature, EObject value, Collection collection)
protected Command createAddCommand(EditingDomain domain, EObject owner, EStructuralFeature feature, Collection collection, int index)
protected Command createAddCommand(EditingDomain domain, EObject owner, EReference feature, Collection collection, int index)
protected Command createMoveCommand(EditingDomain domain, EObject owner, EStructuralFeature feature, Object value, int index)
protected Command createMoveCommand(EditingDomain domain, EObject owner, EReference feature, EObject value, int index)
protected Command createDragAndDropCommand(EditingDomain domain, Object owner, float location, int operations, int operation, Collection collection)
protected Command createCreateChildCommand(EditingDomain domain, EObject owner, EStructuralFeature feature, Object value, int index, Collection collection)
protected Command createCreateChildCommand(EditingDomain domain, EObject owner, EReference feature, EObject value, int index, Collection collection)
protected Command factorRemoveCommand(EditingDomain domain, CommandParameter commandParameter)
protected Command factorAddCommand(EditingDomain domain, CommandParameter commandParameter)
protected Command factorMoveCommand(EditingDomain domain, CommandParameter commandParameter)
public void setTarget(Notifier target)
public void dispose()
protected CommandParameter createChildParameter(Object feature, Object child)
public Collection getCreateChildResult(Object child)
public String getCreateChildText(Object owner, Object feature, Object child, Collection selection)
public String getCreateChildDescription(Object owner, Object feature, Object child, Collection selection)
public String getCreateChildToolTipText(Object owner, Object feature, Object child, Collection selection)
public Object getCreateChildImage(Object owner, Object feature, Object child, Collection selection)
protected String getTypeText(Object object)
protected String getFeatureText(Object feature)
protected ResourceLocator getResourceLocator()
protected ResourceLocator getResourceLocator(Object anyObject)
protected AdapterFactory getRootAdapterFactory()
public URL getBaseURL()
public Object getImage(String key)
public String getString(String key)
public String getString(String key, Object[] substitutions)
protected String getString(String key, String s0)
protected String getString(String key, String s0, String s1)
protected boolean isWrappingNeeded(Object object)
This implementation consults getChildrenFeatures, returning true if any feature map or simple attributes contribute children. This provides backwards compatibility with pre-2.0 subclasses and enables the more useful new default behaviour for attributes, which were previously not allowed. Subclasses may override this to enable wrapping of cross-referenced model objects, or to immediately return true or false, as desired. This is a convenient way to disable all of the new wrapping features in 2.0.
protected ItemProviderAdapter.ChildrenStore getChildrenStore(Object object)
protected ItemProviderAdapter.ChildrenStore createChildrenStore(Object object)
protected Object wrap(EObject object, EStructuralFeature feature, Object value, int index)
protected Object createWrapper(EObject object, EStructuralFeature feature, Object value, int index)
protected Object unwrap(Object object)
protected void disposeWrapper(Object object)
protected void disposeWrappers(List objects)
protected void adjustWrapperIndex(Object object, int increment)
protected void adjustWrapperIndices(List objects, int from, int increment)
protected void adjustWrapperIndices(List objects, int from, int to, int increment)
protected void updateChildren(Notification notification)
Existing children in the store that correspond to any set, removed or unset values are disposed before being removed from the store. When children are added to, removed from, or moved within a feature, the indices of any others affected are adjusted. Since this method is typically called from notifyChanged, which, in subclasses, is often invoked repeatedly up the inheritance chain, it can be safely called repeatedly for a single notification, and only the first such call will have an effect. Such repeated calls may not, however, safely be interleaved with calls for another notification.
protected CommandParameter unwrapCommandValues(CommandParameter commandParameter, Class commandClass)
protected Command wrapCommand(Command command, Object object, Class commandClass, CommandParameter commandParameter, CommandParameter oldCommandParameter)
protected Collection getWrappedValues(CommandParameter commandParameter)
|
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 |