public class ItemProviderAdapter extends AdapterImpl implements IChangeNotifier, IDisposable, CreateChildCommand.Helper, ResourceLocator
IItemLabelProvider
, IItemColorProvider
, IItemFontProvider
, 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.Modifier and Type | Class and Description |
---|---|
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<E>
A single-element implementation of
EList . |
class |
ItemProviderAdapter.ResultAndAffectedObjectsWrappingCommand
A
ResultAndAffectedObjectsWrappingCommand wraps another command to substitute IWrapperItemProvider s 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 IWrapperItemProvider s for its values, which have been
unwrapped for the command to operate on properly. |
Adapter.Internal
Modifier and Type | Field and Description |
---|---|
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<EStructuralFeature> |
childrenFeatures
This is used to store all the children features.
|
protected java.util.List<EReference> |
childrenReferences
Deprecated.
As of EMF 2.0, replaced by
childrenFeatures . |
protected java.util.Map<java.lang.Object,ItemProviderAdapter.ChildrenStore> |
childrenStoreMap
When
ItemProviderAdapter.ChildrenStore s are to be used to cache children (typically to hold wrappers for non-EObject
children), this maps adapted objects to their corresponding stores. |
protected java.util.List<IItemPropertyDescriptor> |
itemPropertyDescriptors
This is used to store all the property descriptors.
|
protected java.util.List<Notifier> |
targets
This keeps track of all the targets to which this adapter is set.
|
protected Disposable |
wrappers
|
protected java.lang.Boolean |
wrappingNeeded
This caches the result returned by
isWrappingNeeded so that it need not be recomputed
each time. |
target
Constructor and Description |
---|
ItemProviderAdapter(AdapterFactory adapterFactory)
An instance is created from an adapter factory.
|
Modifier and Type | Method and Description |
---|---|
void |
addListener(INotifyChangedListener listener)
This adds another listener.
|
protected void |
adjustWrapperIndex(java.lang.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(java.util.List<java.lang.Object> 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(java.util.List<java.lang.Object> 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(java.util.Collection<java.lang.Object> newChildDescriptors,
java.lang.Object object)
This adds to
newChildDescriptors , a collection of new child
descriptors. |
protected Command |
createAddCommand(EditingDomain domain,
EObject owner,
EReference feature,
java.util.Collection<?> collection,
int index)
Deprecated.
As of EMF 2.0, replaced by
createAddCommand . |
protected Command |
createAddCommand(EditingDomain domain,
EObject owner,
EStructuralFeature 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. |
protected ItemProviderAdapter.ChildrenStore |
createChildrenStore(java.lang.Object object)
Consults
isWrappingNeeded to decide whether to create a store for the children of the
given object. |
Command |
createCommand(java.lang.Object object,
EditingDomain domain,
java.lang.Class<? extends Command> 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)
Deprecated.
As of EMF 2.0, replaced by
createCreateChildCommand . |
protected Command |
createCreateChildCommand(EditingDomain domain,
EObject owner,
EStructuralFeature feature,
java.lang.Object 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 |
createDragAndDropCommand(EditingDomain domain,
ResourceSet resourceSet,
float location,
int operations,
int operation,
java.util.Collection<URI> collection)
Delegates command creation to the resource set of the editing domain for the case of a drag and drop command for a collection containing only URIs.
|
protected Command |
createInitializeCopyCommand(EditingDomain domain,
EObject owner,
CopyCommand.Helper helper)
This creates a primitive
InitializeCopyCommand . |
protected ItemPropertyDescriptor |
createItemPropertyDescriptor(AdapterFactory adapterFactory,
ResourceLocator resourceLocator,
java.lang.String displayName,
java.lang.String description,
EStructuralFeature feature,
boolean isSettable,
boolean multiLine,
boolean sortChoices,
java.lang.Object staticImage,
java.lang.String category,
java.lang.String[] filterFlags)
Creates an instance that uses a resource locator; indicates whether to be multi-line and to sort choices; specifies
a static image, a category, and filter flags; and determines the cell editor from the type of the structural feature.
|
protected ItemPropertyDescriptor |
createItemPropertyDescriptor(AdapterFactory adapterFactory,
ResourceLocator resourceLocator,
java.lang.String displayName,
java.lang.String description,
EStructuralFeature feature,
boolean isSettable,
java.lang.Object staticImage,
java.lang.String category,
java.lang.String[] filterFlags)
This creates an item provider descriptor that uses a resource locator; specifies a static image, a category, and filter flags;
and determines the cell editor from the type of the structural feature.
|
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,
java.lang.Object value,
int index)
This creates a primitive
MoveCommand . |
protected Command |
createRemoveCommand(EditingDomain domain,
EObject owner,
EReference feature,
java.util.Collection<?> collection)
Deprecated.
As of EMF 2.0, replaced by
createRemoveCommand . |
protected Command |
createRemoveCommand(EditingDomain domain,
EObject owner,
EStructuralFeature 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)
Deprecated.
As of EMF 2.0, replaced by
createReplaceCommand . |
protected Command |
createReplaceCommand(EditingDomain domain,
EObject owner,
EStructuralFeature feature,
EObject value,
java.util.Collection<?> collection)
Deprecated.
As of EMF 2.10, replaced by
createReplaceCommand(EditingDomain, EObject, EStructuralFeature, Object, Collection) . |
protected Command |
createReplaceCommand(EditingDomain domain,
EObject owner,
EStructuralFeature feature,
java.lang.Object value,
java.util.Collection<?> collection)
This creates a primitive
ReplaceCommand . |
protected Command |
createSetCommand(EditingDomain domain,
EObject owner,
EStructuralFeature feature,
java.lang.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,
java.lang.Object value,
int index)
This creates a primitive
SetCommand . |
protected java.lang.Object |
createWrapper(EObject object,
EStructuralFeature feature,
java.lang.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.
|
java.lang.String |
crop(java.lang.String text)
This crops the given text to exclude any control characters.
|
void |
dispose()
This will remove this adapter from all its the targets and dispose any
remaining children wrappers in the children store.
|
protected void |
disposeWrapper(java.lang.Object object)
If the given object implements
IWrapperItemProvider , it is disposed by calling dispose . |
protected void |
disposeWrappers(java.util.List<?> objects)
Each element of the given list that implements
IWrapperItemProvider is disposed by calling
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.
|
java.lang.Object |
getBackground(java.lang.Object object)
This implements
IItemColorProvider.getBackground by returning null; |
java.lang.Object |
getBackground(java.lang.Object object,
int columnIndex)
This implements
ITableItemColorProvider.getBackground by returning null; |
java.net.URL |
getBaseURL()
Get the base URL from the resource locator.
|
protected EStructuralFeature |
getChildFeature(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.
|
protected EReference |
getChildReference(java.lang.Object object,
java.lang.Object child)
Deprecated.
As of EMF 2.0, replaced by
getChildFeature . |
java.util.Collection<?> |
getChildren(java.lang.Object object)
This implements
ITreeItemContentProvider.getChildren . |
protected java.util.Collection<? extends EStructuralFeature> |
getChildrenFeatures(java.lang.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 java.util.Collection<? extends EReference> |
getChildrenReferences(java.lang.Object object)
Deprecated.
As of EMF 2.0, replaced by
getChildrenFeatures . |
protected ItemProviderAdapter.ChildrenStore |
getChildrenStore(java.lang.Object object)
Returns the store for the children of the given object, or null if no such store is being maintained.
|
java.lang.Object |
getColumnImage(java.lang.Object object,
int columnIndex)
This implements
ITableItemLabelProvider.getColumnImage by returning null. |
java.lang.String |
getColumnText(java.lang.Object object,
int columnIndex)
This implements
ITableItemLabelProvider.getColumnText by returning "" . |
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.
|
protected java.lang.Object |
getFeatureValue(EObject object,
EStructuralFeature feature)
This method is called by
factorRemoveCommand to retrieve the children objects of the
features returned from getChildrenFeatures . |
java.lang.Object |
getFont(java.lang.Object object)
This implements
IItemFontProvider.getFont by returning null; |
java.lang.Object |
getFont(java.lang.Object object,
int columnIndex)
This implements
ITableItemFontProvider.getFont by returning null; |
java.lang.Object |
getForeground(java.lang.Object object)
This implements
IItemColorProvider.getForeground by returning null; |
java.lang.Object |
getForeground(java.lang.Object object,
int columnIndex)
This implements
ITableItemColorProvider.getForeground by returning null; |
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 descriptors for 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 EMF object's
container. |
IItemPropertyDescriptor |
getPropertyDescriptor(java.lang.Object object,
java.lang.Object propertyId)
|
java.util.List<IItemPropertyDescriptor> |
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)
Deprecated.
As of EMF 2.0, replaced by
getFeatureValue . |
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 AdapterFactory |
getRootAdapterFactory()
Gets the root factory if this local adapter factory is composed,
otherwise just the local one.
|
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<? extends EStructuralFeature> |
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,
boolean translate)
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.
|
java.lang.String |
getString(java.lang.String key,
java.lang.Object[] substitutions,
boolean translate)
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,
boolean translate)
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.
|
protected java.lang.String |
getString(java.lang.String key,
java.lang.String s0,
java.lang.String s1,
boolean translate)
Get a translated string from the resource locator, substituting two
other such translated strings.
|
java.lang.Object |
getStyledText(java.lang.Object object)
This implements
IItemStyledLabelProvider.getStyledText by simply creating
an IStyledString from the value returned getText . |
java.lang.String |
getText(java.lang.Object object)
This implements
IItemLabelProvider.getText by simply calling toString on the argument. |
protected java.lang.String |
getTypeText(EAttribute attribute)
This looks up the name of the type of the specified attribute.
|
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) . |
protected java.lang.Object |
getValue(EObject eObject,
EStructuralFeature eStructuralFeature)
Returns the value of the feature.
|
protected java.util.Collection<? extends IWrapperItemProvider> |
getWrappedValues(CommandParameter commandParameter)
Returns a collection of any objects in the given command parameter's
collection and value , that implement IWrapperItemProvider . |
boolean |
hasChildren(java.lang.Object object)
This implements
ITreeItemContentProvider.hasChildren
by simply testing whether getChildren returns any children. |
protected boolean |
hasChildren(java.lang.Object object,
boolean optimized)
This implements
ITreeItemContentProvider.hasChildren . |
boolean |
isAdapterForType(java.lang.Object type)
The adapter factory is used as the type key.
|
protected boolean |
isEquivalentValue(java.lang.Object value,
java.lang.Object referenceValue)
Returns whether the given value is to be considered equivalent to the given reference value.
|
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
|
protected boolean |
isResolveProxies()
Returns whether proxies should be resolved when reflectively fetching values of features.
|
protected boolean |
isValidValue(java.lang.Object object,
java.lang.Object value,
EStructuralFeature feature)
This returns whether the given value is an appropriate instance for the given feature of the given object.
|
protected boolean |
isWrappingNeeded(java.lang.Object object)
Returns whether this item provider may need to use wrappers for some or all of the values it returns as
children . |
protected java.lang.Object |
overlayImage(java.lang.Object object,
java.lang.Object image)
This adds an overlay to the given image if the object is controlled.
|
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.
|
protected boolean |
shouldComposeCreationImage()
Indicates whether creation icon images should always be composed in
getCreateChildImage(Object, Object, Object, Collection) . |
protected boolean |
shouldTranslate()
Indicates whether strings should be translated by default.
|
void |
unsetTarget(Notifier target)
Unsets the target from which the adapter will receive notification.
|
protected java.lang.Object |
unwrap(java.lang.Object object)
If the given object implements
IWrapperItemProvider , it is unwrapped by obtaining a value from getValue . |
protected CommandParameter |
unwrapCommandValues(CommandParameter commandParameter,
java.lang.Class<? extends Command> 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 java.lang.Object |
wrap(EObject object,
EStructuralFeature feature,
java.lang.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,
java.lang.Object object,
java.lang.Class<? extends Command> 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.
|
getTarget, notifyChanged
protected AdapterFactory adapterFactory
protected java.util.List<IItemPropertyDescriptor> itemPropertyDescriptors
protected java.util.List<EStructuralFeature> childrenFeatures
@Deprecated protected java.util.List<EReference> childrenReferences
childrenFeatures
.protected IChangeNotifier changeNotifier
IChangeNotifier
.protected java.util.List<Notifier> targets
protected java.util.Map<java.lang.Object,ItemProviderAdapter.ChildrenStore> childrenStoreMap
ItemProviderAdapter.ChildrenStore
s are to be used to cache children (typically to hold wrappers for non-EObject
children), this maps adapted objects to their corresponding stores. Stores should be accessed and created
via getChildrenStore
and createChildrenStore
.protected Disposable wrappers
protected java.lang.Boolean wrappingNeeded
isWrappingNeeded
so that it need not be recomputed
each time.public ItemProviderAdapter(AdapterFactory adapterFactory)
protected boolean isResolveProxies()
protected java.lang.Object getValue(EObject eObject, EStructuralFeature eStructuralFeature)
proxies are not to be resolved
they won't be,
and in the case of a list value, a list that doesn't resolve proxies is returned.public boolean isAdapterForType(java.lang.Object type)
isAdapterForType
in interface Adapter
isAdapterForType
in class AdapterImpl
type
- the type.false
AdapterFactory.isFactoryForType(java.lang.Object)
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<IItemPropertyDescriptor> 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
. If children are
already cached in a ItemProviderAdapter.ChildrenStore
, they are returned. Otherwise, children are collected from the features
returned by getChildrenFeatures
. The collected children may or may not be cached,
depending on the result of createChildrenStore
; by default, no store is returned if
getChildrenFeatures
returns only containment references. All children are optionally
wrapped
before being cached and returned. Subclasses may override createWrapper
to specify when and with what to wrap 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 use the optimized approach offered by hasChildren(Object, boolean)
(i.e. by passing true
as the second argument).hasChildren(Object, boolean)
protected boolean hasChildren(java.lang.Object object, boolean optimized)
ITreeItemContentProvider.hasChildren
. The approach
taken depends on the value of optimized
. The traditional, non-optimized approach simply tests whether
whether getChildren
returns any children. The new, optimized approach actually iterates
through and tests the children features
directly, avoiding accessing the children
objects themselves, wherever possible.protected java.util.Collection<? extends EStructuralFeature> getChildrenFeatures(java.lang.Object object)
getChildren
, including in determining whether to cache children and, if so, in setting up the store. It is also
used to deduce the appropriate feature for an AddCommand
, RemoveCommand
or
MoveCommand
in createCommand
. If you override those methods, then you don't
need to implement this.@Deprecated protected java.util.Collection<? extends EReference> getChildrenReferences(java.lang.Object object)
getChildrenFeatures
.protected java.lang.Object getFeatureValue(EObject object, EStructuralFeature feature)
factorRemoveCommand
to retrieve the children objects of the
features returned from getChildrenFeatures
. For references, this default
implementation calls the deprecated getReferenceValue
to provide backwards
compatibility.@Deprecated protected java.lang.Object getReferenceValue(EObject object, EReference reference)
getFeatureValue
.protected EStructuralFeature getChildFeature(java.lang.Object object, java.lang.Object child)
getChildReference
, for backwards
compatibility. If that does not yield a non-null result, it returns the first feature returned by getChildrenFeatures
that has a type compatible with the child. You can override this to
return a better result or to compute it more efficiently.protected boolean isValidValue(java.lang.Object object, java.lang.Object value, EStructuralFeature feature)
@Deprecated protected EReference getChildReference(java.lang.Object object, java.lang.Object child)
getChildFeature
.protected java.util.Collection<? extends EStructuralFeature> 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 EMF 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.Object getColumnImage(java.lang.Object object, int columnIndex)
ITableItemLabelProvider.getColumnImage
by returning null.protected java.lang.Object overlayImage(java.lang.Object object, java.lang.Object image)
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 getColumnText(java.lang.Object object, int columnIndex)
ITableItemLabelProvider.getColumnText
by returning ""
.public java.lang.Object getFont(java.lang.Object object)
IItemFontProvider.getFont
by returning null;public java.lang.Object getFont(java.lang.Object object, int columnIndex)
ITableItemFontProvider.getFont
by returning null;public java.lang.Object getForeground(java.lang.Object object)
IItemColorProvider.getForeground
by returning null;public java.lang.Object getForeground(java.lang.Object object, int columnIndex)
ITableItemColorProvider.getForeground
by returning null;public java.lang.Object getBackground(java.lang.Object object)
IItemColorProvider.getBackground
by returning null;public java.lang.Object getBackground(java.lang.Object object, int columnIndex)
ITableItemColorProvider.getBackground
by returning null;public java.lang.Object getStyledText(java.lang.Object object)
IItemStyledLabelProvider.getStyledText
by simply creating
an IStyledString
from the value returned getText
.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.lang.String crop(java.lang.String text)
public java.util.Collection<?> getNewChildDescriptors(java.lang.Object object, EditingDomain editingDomain, java.lang.Object sibling)
IEditingDomainItemProvider.getNewChildDescriptors
, returning descriptors for all the possible children that
can be added to the specified object
. Usually, these descriptors will be instances of
CommandParameter
s, containing at least the child object and the feature
under which it should be added.
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(java.lang.Object value, java.lang.Object referenceValue)
protected void collectNewChildDescriptors(java.util.Collection<java.lang.Object> newChildDescriptors, java.lang.Object object)
newChildDescriptors
, a collection of new child
descriptors. Typically, CommandParameter
s
will be used as descriptors. 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<? extends Command> commandClass, CommandParameter commandParameter)
protected Command createSetCommand(EditingDomain domain, EObject owner, EStructuralFeature feature, java.lang.Object value, int index)
SetCommand
.protected Command createSetCommand(EditingDomain domain, EObject owner, EStructuralFeature feature, java.lang.Object value)
SetCommand
, but it has been replaced, since this
command can now take an index. The replacement method still calls this method when invoked with no index
, to provide backwards compatibility.
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)
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, EStructuralFeature feature, java.util.Collection<?> collection)
RemoveCommand
.@Deprecated protected Command createRemoveCommand(EditingDomain domain, EObject owner, EReference feature, java.util.Collection<?> collection)
createRemoveCommand
.RemoveCommand
, but it has been replaced since
this command is now used on attributes, too. The replacement method still calls this method for references, to
provide backwards compatibility.protected Command createReplaceCommand(EditingDomain domain, EObject owner, EStructuralFeature feature, java.lang.Object value, java.util.Collection<?> collection)
ReplaceCommand
.@Deprecated protected Command createReplaceCommand(EditingDomain domain, EObject owner, EStructuralFeature feature, EObject value, java.util.Collection<?> collection)
createReplaceCommand(EditingDomain, EObject, EStructuralFeature, Object, Collection)
.ReplaceCommand
.@Deprecated protected Command createReplaceCommand(EditingDomain domain, EObject owner, EReference feature, EObject value, java.util.Collection<?> collection)
createReplaceCommand
.ReplaceCommand
, but it has been replaced since
this command is now used on attributes, too. The replacement method still calls this method for references, to
provide backwards compatibility.protected Command createAddCommand(EditingDomain domain, EObject owner, EStructuralFeature feature, java.util.Collection<?> collection, int index)
AddCommand
.@Deprecated protected Command createAddCommand(EditingDomain domain, EObject owner, EReference feature, java.util.Collection<?> collection, int index)
createAddCommand
.AddCommand
, but it has been replaced since
this command is now used on attributes, too. The replacement method still calls this method for references, to
provide backwards compatibility.protected Command createMoveCommand(EditingDomain domain, EObject owner, EStructuralFeature feature, java.lang.Object value, int index)
MoveCommand
.@Deprecated protected Command createMoveCommand(EditingDomain domain, EObject owner, EReference feature, EObject value, int index)
createMoveCommand
.MoveCommand
, but it has been replaced since
this command is now used on attributes, too. The replacement method still calls this method for references, to
provide backwards compatibility.protected Command createDragAndDropCommand(EditingDomain domain, java.lang.Object owner, float location, int operations, int operation, java.util.Collection<?> collection)
DragAndDropCommand
.protected Command createDragAndDropCommand(EditingDomain domain, ResourceSet resourceSet, float location, int operations, int operation, java.util.Collection<URI> collection)
protected Command createCreateChildCommand(EditingDomain domain, EObject owner, EStructuralFeature feature, java.lang.Object value, int index, java.util.Collection<?> collection)
CreateChildCommand
.@Deprecated protected Command createCreateChildCommand(EditingDomain domain, EObject owner, EReference feature, EObject value, int index, java.util.Collection<?> collection)
createCreateChildCommand
.CreateChildCommand
, but it has been replaced since
this command is now used on attributes, too. The replacement method still calls this method for references, to
provide backwards compatibility.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 feature.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 feature.protected Command factorMoveCommand(EditingDomain domain, CommandParameter commandParameter)
MoveCommand
to determine the feature.public void setTarget(Notifier target)
Adapter
setTarget
in interface Adapter
setTarget
in class AdapterImpl
target
- the new notifier.Adapter.getTarget()
public void unsetTarget(Notifier target)
Adapter.Internal
unsetTarget
in interface Adapter.Internal
unsetTarget
in class AdapterImpl
target
- the old notifier.Adapter.getTarget()
,
Adapter.setTarget(Notifier)
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 boolean shouldComposeCreationImage()
getCreateChildImage(Object, Object, Object, Collection)
.protected java.lang.String getTypeText(java.lang.Object object)
protected java.lang.String getTypeText(EAttribute attribute)
protected java.lang.String getFeatureText(java.lang.Object feature)
protected ResourceLocator getResourceLocator()
protected ResourceLocator getResourceLocator(java.lang.Object anyObject)
protected AdapterFactory getRootAdapterFactory()
public java.net.URL getBaseURL()
getBaseURL
in interface ResourceLocator
public java.lang.Object getImage(java.lang.String key)
getImage
in interface ResourceLocator
key
- the key of the image resource.protected boolean shouldTranslate()
true
if strings should be translated by default; false
otherwise.public java.lang.String getString(java.lang.String key)
getString
in interface ResourceLocator
key
- the key of the string resource.public java.lang.String getString(java.lang.String key, boolean translate)
getString
in interface ResourceLocator
key
- the key of the string resource.translate
- whether the result is to be translated to the current locale.public java.lang.String getString(java.lang.String key, java.lang.Object[] substitutions)
getString
in interface ResourceLocator
key
- the key of the string.substitutions
- the message substitutions.ResourceLocator.getString(String)
,
MessageFormat.format(String, Object[])
public java.lang.String getString(java.lang.String key, java.lang.Object[] substitutions, boolean translate)
getString
in interface ResourceLocator
key
- the key of the string.substitutions
- the message substitutions.translate
- whether the result is to be translated to the current locale.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, boolean translate)
protected java.lang.String getString(java.lang.String key, java.lang.String s0, java.lang.String s1)
protected java.lang.String getString(java.lang.String key, java.lang.String s0, java.lang.String s1, boolean translate)
protected boolean isWrappingNeeded(java.lang.Object object)
children
. This is used to determine whether to use a store to keep track of children and whether to
use command wrappers that re-wrap results and affected objects. The default implementation of createWrapper
also tests this method and will not create any wrappers if it returns
false
.
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(java.lang.Object object)
protected ItemProviderAdapter.ChildrenStore createChildrenStore(java.lang.Object object)
isWrappingNeeded
to decide whether to create a store for the children of the
given object. If so, the new store is created, added to the collection being maintained, and returned. If not,
null is returned.protected java.lang.Object wrap(EObject object, EStructuralFeature feature, java.lang.Object value, int index)
createWrapper
to determine if the given value, at the given index in the given
feature of the given object, should be wrapped and to obtain the wrapper. If a wrapper is obtained, it is recorded
and returned. Otherwise, the original value is returned. Subclasses may override createWrapper
to specify when and with what to wrap values.protected java.lang.Object createWrapper(EObject object, EStructuralFeature feature, java.lang.Object value, int index)
isWrappingNeeded
and, if it is true
, creates different wrappers that implement
IWrapperItemProvider
for feature maps, simple attributes, and cross references.
By default, isWrappingNeeded
does not return true
unless there is at
least one feature map or simple attribute that contributes children, in order to maintain backwards compatibility.
As a result, it may be necessary to override that method in order to wrap cross-referenced model objects here.
Subclasses may also override this method, in order to create their own specialized wrappers.protected java.lang.Object unwrap(java.lang.Object object)
IWrapperItemProvider
, it is unwrapped by obtaining a value from getValue
. The unwrapping continues until a non-wrapper value is returned. This
iterative unwrapping is required because values may be repeatedly wrapped, as children of a delegating wrapper.protected void disposeWrapper(java.lang.Object object)
IWrapperItemProvider
, it is disposed by calling dispose
. It is also removed from wrappers
, as it will longer need to be
disposed along with this item provider.protected void disposeWrappers(java.util.List<?> objects)
IWrapperItemProvider
is disposed by calling
dispose
and is removed from wrappers
.protected void adjustWrapperIndex(java.lang.Object object, int increment)
IWrapperItemProvider
and specifies an index, that index is adjusted by the
given increment.protected void adjustWrapperIndices(java.util.List<java.lang.Object> objects, int from, int increment)
from
, that implements IWrapperItemProvider
and specifies an index, that index is adjusted by the given increment.protected void adjustWrapperIndices(java.util.List<java.lang.Object> objects, int from, int to, int increment)
from
and to
, that implements IWrapperItemProvider
and specifies an index, that index is adjusted by the given increment.protected void updateChildren(Notification notification)
ItemProviderAdapter.ChildrenStore
exists for its notifier,
then the children of the specified feature are updated.
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, java.lang.Class<? extends Command> commandClass)
collection
or in the value
that implement IWrapperItemProvider
will be unwrapped
. DragAndDropCommand
is never unwrapped.protected Command wrapCommand(Command command, java.lang.Object object, java.lang.Class<? extends Command> commandClass, CommandParameter commandParameter, CommandParameter oldCommandParameter)
isWrappingNeeded
returns true
, and never for a DragAndDropCommand
.protected java.util.Collection<? extends IWrapperItemProvider> getWrappedValues(CommandParameter commandParameter)
collection
and value
, that implement IWrapperItemProvider
.protected ItemPropertyDescriptor createItemPropertyDescriptor(AdapterFactory adapterFactory, ResourceLocator resourceLocator, java.lang.String displayName, java.lang.String description, EStructuralFeature feature, boolean isSettable, java.lang.Object staticImage, java.lang.String category, java.lang.String[] filterFlags)
Newly regenerated code will no longer use this method. You'll need to override this form
instead.
protected ItemPropertyDescriptor createItemPropertyDescriptor(AdapterFactory adapterFactory, ResourceLocator resourceLocator, java.lang.String displayName, java.lang.String description, EStructuralFeature feature, boolean isSettable, boolean multiLine, boolean sortChoices, java.lang.Object staticImage, java.lang.String category, java.lang.String[] filterFlags)