|
|||||||||
PREV CLASS SOURCE NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.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.
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 java.util.List |
childrenReferences
This is used to store all the children references. |
protected java.util.List |
itemPropertyDescriptors
This is used to store all the property descriptors. |
protected java.util.Collection |
targets
This keeps track of all the targets to which this adapter is set. |
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 |
collectNewChildDescriptors(java.util.Collection newChildDescriptors,
java.lang.Object object)
This adds to newChildDescriptors , a collection of CommandParameter s, 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,
java.util.Collection collection,
int index)
This creates a primitive AddCommand . |
protected CommandParameter |
createChildParameter(java.lang.Object feature,
java.lang.Object child)
This is a convenience method that creates a CommandParameter
for a given parent feature and child object. |
Command |
createCommand(java.lang.Object object,
EditingDomain domain,
java.lang.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,
java.util.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,
java.lang.Object owner,
float location,
int operations,
int operation,
java.util.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)
This creates a primitive MoveCommand . |
protected Command |
createRemoveCommand(EditingDomain domain,
EObject owner,
EReference feature,
java.util.Collection collection)
This creates a primitive RemoveCommand . |
protected Command |
createReplaceCommand(EditingDomain domain,
EObject owner,
EReference feature,
EObject value,
java.util.Collection collection)
This creates a primitive ReplaceCommand . |
protected Command |
createSetCommand(EditingDomain domain,
EObject owner,
EStructuralFeature feature,
java.lang.Object value)
This creates a primitive SetCommand . |
void |
dispose()
This will remove this adapter from all its the targets. |
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 reference. |
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 reference. |
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. |
java.net.URL |
getBaseURL()
Get the base URL from the resource locator. |
protected EReference |
getChildReference(java.lang.Object object,
java.lang.Object child)
This returns the most appropriate feature of the object into which the given child could be added. |
java.util.Collection |
getChildren(java.lang.Object object)
This implements ITreeItemContentProvider.getChildren
by calling getChildrenReferences and using those to collect the children. |
protected java.util.Collection |
getChildrenReferences(java.lang.Object object)
If this is defined to be something other than an empty list, it is used to implement getChildren
and to deduce the EMF feature in the AddCommand and RemoveCommand in createCommand . |
java.lang.String |
getCreateChildDescription(java.lang.Object owner,
java.lang.Object feature,
java.lang.Object child,
java.util.Collection selection)
This returns the description for CreateChildCommand . |
java.lang.Object |
getCreateChildImage(java.lang.Object owner,
java.lang.Object feature,
java.lang.Object child,
java.util.Collection selection)
This returns the icon image for CreateChildCommand . |
java.util.Collection |
getCreateChildResult(java.lang.Object child)
This returns the result collection for CreateChildCommand . |
java.lang.String |
getCreateChildText(java.lang.Object owner,
java.lang.Object feature,
java.lang.Object child,
java.util.Collection selection)
This returns the label for CreateChildCommand . |
java.lang.String |
getCreateChildToolTipText(java.lang.Object owner,
java.lang.Object feature,
java.lang.Object child,
java.util.Collection selection)
This returns the tool tip text for CreateChildCommand . |
java.lang.Object |
getEditableValue(java.lang.Object object)
This implements IItemPropertySource.getEditableValue
by simply returning the object itself. |
java.util.Collection |
getElements(java.lang.Object object)
This implements IStructuredItemContentProvider.getElements
by forwarding the call to getChildren . |
protected java.lang.String |
getFeatureText(java.lang.Object feature)
This looks up the name of the specified feature. |
java.lang.Object |
getImage(java.lang.Object object)
This implements IItemLabelProvider.getImage by returning null. |
java.lang.Object |
getImage(java.lang.String key)
Get an image from the resource locator. |
java.util.Collection |
getNewChildDescriptors(java.lang.Object object,
EditingDomain editingDomain,
java.lang.Object sibling)
This implements IEditingDomainItemProvider.getNewChildDescriptors , returning
CommandParameter s to
describe all the possible children that can be added to the specified
object . |
java.lang.Object |
getParent(java.lang.Object object)
This implements ITreeItemContentProvider.getParent by returning the MOF object's
container. |
IItemPropertyDescriptor |
getPropertyDescriptor(java.lang.Object object,
java.lang.Object propertyId)
This convenience method finds a particular descriptor given its property name. |
java.util.List |
getPropertyDescriptors(java.lang.Object object)
This implements IItemPropertySource.getPropertyDescriptors
by returning the locally stored vector of descriptors. |
java.lang.Object |
getPropertyValue(java.lang.Object object,
java.lang.String property)
This implements a PropertySource by delegating to the descriptor, which is assumed to support the IItemPropertyDescriptor interface |
protected java.lang.Object |
getReferenceValue(EObject object,
EReference reference)
This method is called by factorRemoveCommand to retrieve the children objects
of the references returned from getChildrenReferences . |
protected ResourceLocator |
getResourceLocator()
Get the resource locator for this adapter's resources. |
protected ResourceLocator |
getResourceLocator(java.lang.Object anyObject)
Get the resource locator from the adapter of the object, if possible. |
protected EStructuralFeature |
getSetFeature(java.lang.Object object,
java.lang.Object value)
This returns the most appropriate feature of the object into which the value be set. |
protected java.util.Collection |
getSetFeatures(java.lang.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 . |
java.lang.String |
getString(java.lang.String key)
Get a translated string from the resource locator. |
java.lang.String |
getString(java.lang.String key,
java.lang.Object[] substitutions)
Get a translated string from the resource locator, with substitutions. |
protected java.lang.String |
getString(java.lang.String key,
java.lang.String s0)
Get a translated string from the resource locator, substituting another such translated string. |
protected java.lang.String |
getString(java.lang.String key,
java.lang.String s0,
java.lang.String s1)
Get a translated string from the resource locator, substituting two other such translated strings. |
java.lang.String |
getText(java.lang.Object object)
This implements IItemLabelProvider.getText by simply calling toString on the argument. |
protected java.lang.String |
getTypeText(java.lang.Object object)
This looks up the name of the type of the specified object. |
java.lang.String |
getUpdateableText(java.lang.Object object)
This implements IUpdateableItemText.getUpdateableText
by simply calling getText(java.lang.Object) . |
boolean |
hasChildren(java.lang.Object object)
This implements ITreeItemContentProvider.hasChildren
by simply testing whether getChildren returns any children. |
boolean |
isAdapterForType(java.lang.Object type)
The adapter factory is used as the type key. |
boolean |
isPropertySet(java.lang.Object object,
java.lang.String property)
This implements PropertySource by delegating to the descriptor, which is assumed to support the IItemPropertyDescriptor interface |
void |
removeListener(INotifyChangedListener listener)
This removes a listener. |
void |
resetPropertyValue(java.lang.Object object,
java.lang.String property)
This implements PropertySource.resetPropertyValue by delegating to the descriptor, which is assumed to support the IItemPropertyDescriptor interface |
void |
setPropertyValue(java.lang.Object object,
java.lang.String property,
java.lang.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. |
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 java.util.List itemPropertyDescriptors
protected java.util.List childrenReferences
protected IChangeNotifier changeNotifier
IChangeNotifier
.protected java.util.Collection targets
Constructor Detail |
public ItemProviderAdapter(AdapterFactory adapterFactory)
Method Detail |
public boolean isAdapterForType(java.lang.Object type)
isAdapterForType
in class AdapterImpl
org.eclipse.emf.common.notify.impl.AdapterImpl
type
- the type.false
public AdapterFactory getAdapterFactory()
public void addListener(INotifyChangedListener listener)
IChangeNotifier
addListener
in interface IChangeNotifier
public void removeListener(INotifyChangedListener listener)
IChangeNotifier
removeListener
in interface IChangeNotifier
public void fireNotifyChanged(Notification notification)
Notifier
.fireNotifyChanged
in interface IChangeNotifier
public java.lang.Object getEditableValue(java.lang.Object object)
IItemPropertySource.getEditableValue
by simply returning the object itself.public java.util.List getPropertyDescriptors(java.lang.Object object)
IItemPropertySource.getPropertyDescriptors
by returning the locally stored vector of descriptors.
This vector could be populated in the constructor of a derived class
but it's probably more efficient to create them only on demand by overriding this method.
You'll probably want to call super.getPropertyDescriptors if you do this,
since you may have one adapter derive from another.public IItemPropertyDescriptor getPropertyDescriptor(java.lang.Object object, java.lang.Object propertyId)
public java.lang.Object getPropertyValue(java.lang.Object object, java.lang.String property)
public boolean isPropertySet(java.lang.Object object, java.lang.String property)
public void resetPropertyValue(java.lang.Object object, java.lang.String property)
public void setPropertyValue(java.lang.Object object, java.lang.String property, java.lang.Object value)
public java.util.Collection getElements(java.lang.Object object)
IStructuredItemContentProvider.getElements
by forwarding the call to getChildren
.
It seems that you almost always want getElements and getChildren to return the same thing, so this makes that easy.public java.util.Collection getChildren(java.lang.Object object)
ITreeItemContentProvider.getChildren
by calling getChildrenReferences
and using those to collect the children.public boolean hasChildren(java.lang.Object object)
ITreeItemContentProvider.hasChildren
by simply testing whether getChildren
returns any children.
This implementation will always be right, however, for efficiency you may want to override it to return false
or to compute the result in some other efficient way.protected java.util.Collection getChildrenReferences(java.lang.Object object)
getChildren
and to deduce the EMF feature in the AddCommand and RemoveCommand in createCommand
.
If you override those, then you don't need to implement this.protected java.lang.Object getReferenceValue(EObject object, EReference reference)
factorRemoveCommand
to retrieve the children objects
of the references returned from getChildrenReferences
.protected EReference getChildReference(java.lang.Object object, java.lang.Object child)
getChildrenReferences
that has a type compatible with the child.
You can override this to return a better result or to compute it more efficiently.protected java.util.Collection getSetFeatures(java.lang.Object object)
getSetFeature
and to deduce the EMF feature in the SetCommand createCommand
.
If you override those, then you don't need to implement this.protected EStructuralFeature getSetFeature(java.lang.Object object, java.lang.Object value)
getSetFeatures
that has a type compatible with the value.
You can override this to return a better result or to compute it more efficiently.public java.lang.Object getParent(java.lang.Object object)
ITreeItemContentProvider.getParent
by returning the MOF object's
container. This is used by certain commands to find an owner, where
none is specified, and by the viewers, when trying to locate an
arbitrary object within the view (i.e. during select and reveal
operation).public java.lang.Object getImage(java.lang.Object object)
IItemLabelProvider.getImage
by returning null.
Most things really should have an icon, but not having one is technically correct too.public java.lang.String getText(java.lang.Object object)
IItemLabelProvider.getText
by simply calling toString on the argument.
This will often be correct as is.public java.lang.String getUpdateableText(java.lang.Object object)
IUpdateableItemText.getUpdateableText
by simply calling getText(java.lang.Object)
.
This will often be correct as is.public java.util.Collection getNewChildDescriptors(java.lang.Object object, EditingDomain editingDomain, java.lang.Object sibling)
IEditingDomainItemProvider.getNewChildDescriptors
, returning
CommandParameter
s to
describe all the possible children that can be added to the specified
object
.
This implementation invokes collectNewChildDescriptors(java.util.Collection, java.lang.Object)
,
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
reference
, to ensure that the new child object gets
added in the right position.
protected void collectNewChildDescriptors(java.util.Collection newChildDescriptors, java.lang.Object object)
newChildDescriptors
, a collection of CommandParameter
s, parameters for
possible children of the specified object
, when viewed as
an instance of the type for which this is an item provider. This
implementation adds nothing to the collection, but derived classes
should override this method, invoking the superclass implementation and
then adding to the collection.public Command createCommand(java.lang.Object object, EditingDomain domain, java.lang.Class commandClass, CommandParameter commandParameter)
protected Command createSetCommand(EditingDomain domain, EObject owner, EStructuralFeature feature, java.lang.Object value)
SetCommand
.protected Command createCopyCommand(EditingDomain domain, EObject owner, CopyCommand.Helper helper)
CopyCommand
.protected Command createCreateCopyCommand(EditingDomain domain, EObject owner, CopyCommand.Helper helper)
CreateCopyCommand
.protected Command createInitializeCopyCommand(EditingDomain domain, EObject owner, CopyCommand.Helper helper)
InitializeCopyCommand
.protected Command createRemoveCommand(EditingDomain domain, EObject owner, EReference feature, java.util.Collection collection)
RemoveCommand
.protected Command createReplaceCommand(EditingDomain domain, EObject owner, EReference feature, EObject value, java.util.Collection collection)
ReplaceCommand
.protected Command createAddCommand(EditingDomain domain, EObject owner, EReference feature, java.util.Collection collection, int index)
AddCommand
.protected Command createMoveCommand(EditingDomain domain, EObject owner, EReference feature, EObject value, int index)
MoveCommand
.protected Command createDragAndDropCommand(EditingDomain domain, java.lang.Object owner, float location, int operations, int operation, java.util.Collection collection)
DragAndDropCommand
.protected Command createCreateChildCommand(EditingDomain domain, EObject owner, EReference feature, EObject value, int index, java.util.Collection collection)
CreateChildCommand
.protected Command factorRemoveCommand(EditingDomain domain, CommandParameter commandParameter)
RemoveCommand
for a collection of objects
into one or more primitive remove commands,
i.e., one per unique reference.protected Command factorAddCommand(EditingDomain domain, CommandParameter commandParameter)
AddCommand
for a collection of objects
into one or more primitive add command,
i.e., one per unique reference.protected Command factorMoveCommand(EditingDomain domain, CommandParameter commandParameter)
MoveCommand
to determine the feature.public void setTarget(Notifier target)
Adapter
setTarget
in class AdapterImpl
org.eclipse.emf.common.notify.Adapter
newTarget
- the new notifier.Adapter.getTarget()
public void dispose()
dispose
in interface IDisposable
protected CommandParameter createChildParameter(java.lang.Object feature, java.lang.Object child)
CommandParameter
for a given parent feature and child object.public java.util.Collection getCreateChildResult(java.lang.Object child)
CreateChildCommand
.getCreateChildResult
in interface CreateChildCommand.Helper
public java.lang.String getCreateChildText(java.lang.Object owner, java.lang.Object feature, java.lang.Object child, java.util.Collection selection)
CreateChildCommand
.getCreateChildText
in interface CreateChildCommand.Helper
public java.lang.String getCreateChildDescription(java.lang.Object owner, java.lang.Object feature, java.lang.Object child, java.util.Collection selection)
CreateChildCommand
.getCreateChildDescription
in interface CreateChildCommand.Helper
public java.lang.String getCreateChildToolTipText(java.lang.Object owner, java.lang.Object feature, java.lang.Object child, java.util.Collection selection)
CreateChildCommand
.getCreateChildToolTipText
in interface CreateChildCommand.Helper
public java.lang.Object getCreateChildImage(java.lang.Object owner, java.lang.Object feature, java.lang.Object child, java.util.Collection selection)
CreateChildCommand
.getCreateChildImage
in interface CreateChildCommand.Helper
protected java.lang.String getTypeText(java.lang.Object object)
protected java.lang.String getFeatureText(java.lang.Object feature)
protected ResourceLocator getResourceLocator()
protected ResourceLocator getResourceLocator(java.lang.Object anyObject)
public java.net.URL getBaseURL()
getBaseURL
in interface ResourceLocator
org.eclipse.emf.common.util.ResourceLocator
public java.lang.Object getImage(java.lang.String key)
getImage
in interface ResourceLocator
org.eclipse.emf.common.util.ResourceLocator
key
- the key of the image resource.public java.lang.String getString(java.lang.String key)
getString
in interface ResourceLocator
org.eclipse.emf.common.util.ResourceLocator
key
- the key of the string resource.public java.lang.String getString(java.lang.String key, java.lang.Object[] substitutions)
getString
in interface ResourceLocator
org.eclipse.emf.common.util.ResourceLocator
key
- the key of the string.substitutions
- the message substitutions.ResourceLocator.getString(String)
,
MessageFormat.format(String, Object[])
protected java.lang.String getString(java.lang.String key, java.lang.String s0)
protected java.lang.String getString(java.lang.String key, java.lang.String s0, java.lang.String s1)
|
Copyright 2001-2003 IBM Corporation and others. All Rights Reserved. |
||||||||
PREV CLASS SOURCE NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |