Class AnnotationItemProviderAdapterFactory
- All Implemented Interfaces:
AdapterFactory
,ComposeableAdapterFactory
,IChangeNotifier
,IDisposable
- Direct Known Subclasses:
AnnotationItemProviderAdapterFactory.Reflective
AnnotationItemProvider
and StringToStringMapEntryItemProvider
.
The EtypesItemProviderAdapterFactory
has a specialized adapt
method that uses this class' create(String)
method to create specialized
implementations of this factory depending on the annotation's source
.
Before creating
an AnnotationItemProvider
or creating
an StringToStringMapEntryItemProvider,
EtypesItemProviderAdapterFactory will call createAnnotationAdapter()
or createStringToStringMapEntryAdapter()
on this factory.
If this factory returns one, that one will be used.
When EtypesItemProviderAdapterFactory creates an instance of this class,
it calls setParentAdapterFactory(EtypesItemProviderAdapterFactory)
so that this factory has a path back to the getRootAdapterFactory()
.
When EtypesItemProviderAdapterFactory is disposed
it will dispose
this factory.
createAnnotationAdapter()
and the createStringToStringMapEntryAdapter()
simply create an AnnotationItemProvider or an
StringToStringMapEntryItemProvider, passing in this factory to the constructors.
All methods are implemented by this class,
but the factory is abstract because it's expected that a derived class will specialize some of the methods.
A derived class could override doCreateAnnotationAdapter()
, doCreateStringToStringMapEntryAdapter()
, or both in order to support
specialized stateless adapters. A derived class could instead override createAnnotationAdapter()
, createStringToStringMapEntryAdapter()
,
or both in order to support specialized stateful adapters. However, based on AnnotationItemProvider.getAnnotationItemProviderAdapterFactory()
and
StringToStringMapEntryItemProvider.getAnnotationItemProviderAdapterFactory()
, both existing implementations are specialized to delegate back to
this factory's getPropertyDescriptor
,
getPropertyDescriptors
,
and createPropertyDescriptorDecorator
methods, so those are the methods most likely to be specialized.
It's generally expected that there will be a corresponding AnnotationValidator
also associated with the annotation source which which this
factory provides specialized adapters. That annotation validator's assistant
is used to drive much of the specialized behavior.
- Since:
- 4.6
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
A property descriptor created byAnnotationItemProviderAdapterFactory#getPropertyDescriptors
and used byAnnotationItemProvider.SourcePropertyDescriptor#createPropertyValueWrapper(Object, Object)
.static final class
A convenient implementation of a property source with an explicit list of property descriptors that can bepopulated
after construction.static class
An item property descriptor decorator implementation used byAnnotationItemProviderAdapterFactory.createPropertyDescriptorDecorator
to create anassistant
-aware decorator.static class
A reflective implementation of an annotation item provider adapter factory. -
Field Summary
Modifier and TypeFieldDescriptionprotected Adapter
This keeps track of the one adapter used for allAnnotation
instances.protected final BasicAnnotationValidator.Assistant
The assistant provided in the constructor and returned bygetAssistant()
.protected final IChangeNotifier
This is used to implementIChangeNotifier
.protected final Disposable
This is used to implementIDisposable
.protected EtypesItemProviderAdapterFactory
This keeps track of the Etypes item provider adapter factory that delegates to this adapter factory.protected final EtypesSwitch<Adapter>
The switch that delegates tocreateAnnotationAdapter()
orcreateStringToStringMapEntryAdapter()
as appropriate.static final String
protected final ResourceLocator
The resource locator provided in the constructor and returned bygetResourceLocator()
.protected Adapter
This keeps track of the one adapter used for allMap.Entry
instances.protected final Collection<Object>
This keeps track of all the supported types checked byisFactoryForType
. -
Constructor Summary
ConstructorDescriptionAnnotationItemProviderAdapterFactory
(ResourceLocator resourceLocator, BasicAnnotationValidator.Assistant assistant) This constructs an instance given a resource locator and an annotation assistant. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addListener
(INotifyChangedListener notifyChangedListener) This adds a listener.protected void
Creates an annotation item provider adapter factory for the givenannotation source
.protected Adapter
createAdapter
(Notifier target) This creates an adapter for aAnnotation
by callingdoCreateAnnotationAdapter()
.createPropertyDescriptorDecorator
(IItemPropertyDescriptor propertyDescriptor, EObject eObject, String key, EStructuralFeature eStructuralFeature, Annotation annotation, ResourceLocator resourceLocator, EditingDomain domain) Creates a property descriptor decorator for the property descriptor of aproperty
of themodeled object
corresponding to the given key and feature for the given annotation.This creates an adapter for aMap.Entry
by callingdoCreateStringToStringMapEntryAdapter()
.void
dispose()
This disposes all of the item providers created by this factory.protected Adapter
Creates the adapter for anAnnotation
.protected Adapter
Creates the adapter for an annotation'sdetails
.void
fireNotifyChanged
(Notification notification) This delegates tochangeNotifier
and toetypesItemProviderAdapterFactory
.Returns the assistant.getGroupName
(EObject instance) Returns the group name associated with the given instance object.getPropertyDescriptor
(EObject eObject, String key, EStructuralFeature eStructuralFeature, Annotation annotation, ResourceLocator resourceLocator) Creates a property descriptor for aproperty
of themodeled object
corresponding to the given key and feature for the given annotation.getPropertyDescriptors
(EObject eObject, Annotation annotation, ResourceLocator resourceLocator) Returns a list of property descriptors for themodeled object
representing the given annotation.Returns the resource locator uses by this annotation item provider adapter factory.This returns the root adapter factory that contains this factory.boolean
isFactoryForType
(Object type) boolean
isShowInstances
(Annotation annotation) Returns whetherAnnotationItemProvider.SourcePropertyDescriptor#createPropertyValueWrapper(Object, Object)
should show themodeled object
in the property tree.void
removeListener
(INotifyChangedListener notifyChangedListener) This removes a listener.void
setParentAdapterFactory
(EtypesItemProviderAdapterFactory etypesItemProviderAdapterFactory) Sets the Etypes item provider adapter factory that uses this factory.void
setParentAdapterFactory
(ComposedAdapterFactory parentAdapterFactory) This operation is not supported.Methods inherited from class org.eclipse.emf.common.notify.impl.AdapterFactoryImpl
adaptAllNew, adaptNew, createAdapter, resolve
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.eclipse.emf.common.notify.AdapterFactory
adaptAllNew, adaptNew
-
Field Details
-
PRODUCT_GROUP
- See Also:
-
changeNotifier
This is used to implementIChangeNotifier
. -
supportedTypes
This keeps track of all the supported types checked byisFactoryForType
. -
disposable
This is used to implementIDisposable
. -
modelSwitch
The switch that delegates tocreateAnnotationAdapter()
orcreateStringToStringMapEntryAdapter()
as appropriate. -
assistant
The assistant provided in the constructor and returned bygetAssistant()
. -
resourceLocator
The resource locator provided in the constructor and returned bygetResourceLocator()
. -
etypesItemProviderAdapterFactory
This keeps track of the Etypes item provider adapter factory that delegates to this adapter factory. -
annotationItemProvider
This keeps track of the one adapter used for allAnnotation
instances. -
stringToStringMapEntryItemProvider
This keeps track of the one adapter used for allMap.Entry
instances.
-
-
Constructor Details
-
AnnotationItemProviderAdapterFactory
public AnnotationItemProviderAdapterFactory(ResourceLocator resourceLocator, BasicAnnotationValidator.Assistant assistant) This constructs an instance given a resource locator and an annotation assistant.
-
-
Method Details
-
getAssistant
Returns the assistant.The assistant is used by the implementations of
AnnotationItemProvider
andStringToStringMapEntryItemProvider
.- Returns:
- the assistant.
- See Also:
-
AnnotationItemProvider.SourcePropertyDescriptor#getAssistant()
AnnotationItemProvider.addReferencesPropertyDescriptor(Object)
StringToStringMapEntryItemProvider.createValuePropertyDescriptor(Map.Entry)
StringToStringMapEntryItemProvider.getKeyChoiceOfValues(Map.Entry)
-
isShowInstances
Returns whetherAnnotationItemProvider.SourcePropertyDescriptor#createPropertyValueWrapper(Object, Object)
should show themodeled object
in the property tree.This implementation always returns
true
ifBasicAnnotationValidator.Assistant.getPropertyClasses(ModelElement)
returns more than one class.- Returns:
- whether the modeled objects should be explicitly shown in the property tree or should be omitted.
- See Also:
-
AnnotationItemProvider.SourcePropertyDescriptor#createPropertyValueWrapper(Object, Object)
-
createAnnotationAdapter
This creates an adapter for aAnnotation
by callingdoCreateAnnotationAdapter()
. Override this to create stateful adapters.- Returns:
- the adapter or
null
.
-
doCreateAnnotationAdapter
Creates the adapter for anAnnotation
. Typically this will be a subclass ofAnnotationItemProvider
. Override this to create stateless adapters. This implementation always simply creates an AnnotationItemProvider.- Returns:
- the adapter or
null
.
-
createStringToStringMapEntryAdapter
This creates an adapter for aMap.Entry
by callingdoCreateStringToStringMapEntryAdapter()
. Override this to create stateful adapters.- Returns:
- the adapter or
null
.
-
doCreateStringToStringMapEntryAdapter
Creates the adapter for an annotation'sdetails
. Typically this will be a subclass ofStringToStringMapEntryItemProvider
. Override this to create stateless adapters. This implementation always simply creates an StringToStringMapEntryItemProvider.- Returns:
- the adapter or
null
.
-
getRootAdapterFactory
This returns the root adapter factory that contains this factory.- Specified by:
getRootAdapterFactory
in interfaceComposeableAdapterFactory
-
setParentAdapterFactory
This operation is not supported. An AnnotationItemProviderAdapterFactory should not be directly composed. InsteadsetParentAdapterFactory(EtypesItemProviderAdapterFactory)
should be called to set the Etypes item provider adapter factory that uses this factory.- Specified by:
setParentAdapterFactory
in interfaceComposeableAdapterFactory
-
setParentAdapterFactory
public void setParentAdapterFactory(EtypesItemProviderAdapterFactory etypesItemProviderAdapterFactory) Sets the Etypes item provider adapter factory that uses this factory.- Parameters:
etypesItemProviderAdapterFactory
- the Etypes item provider adapter factory that uses this factory.
-
getResourceLocator
Returns the resource locator uses by this annotation item provider adapter factory.- Returns:
- the resource locator.
-
isFactoryForType
- Specified by:
isFactoryForType
in interfaceAdapterFactory
- Overrides:
isFactoryForType
in classAdapterFactoryImpl
-
createAdapter
- Overrides:
createAdapter
in classAdapterFactoryImpl
-
adapt
This implementation substitutes the factory itself as the key for the adapter.
- Specified by:
adapt
in interfaceAdapterFactory
- Overrides:
adapt
in classAdapterFactoryImpl
-
adapt
- Specified by:
adapt
in interfaceAdapterFactory
- Overrides:
adapt
in classAdapterFactoryImpl
-
associate
This implementation also adds the adapter to the
disposable
, if it's anIDisposable
.- Overrides:
associate
in classAdapterFactoryImpl
-
addListener
This adds a listener.- Specified by:
addListener
in interfaceIChangeNotifier
-
removeListener
This removes a listener.- Specified by:
removeListener
in interfaceIChangeNotifier
-
fireNotifyChanged
This delegates tochangeNotifier
and toetypesItemProviderAdapterFactory
.- Specified by:
fireNotifyChanged
in interfaceIChangeNotifier
-
dispose
public void dispose()This disposes all of the item providers created by this factory.- Specified by:
dispose
in interfaceIDisposable
-
getPropertyDescriptors
public List<IItemPropertyDescriptor> getPropertyDescriptors(EObject eObject, Annotation annotation, ResourceLocator resourceLocator) Returns a list of property descriptors for themodeled object
representing the given annotation.This implementation uses the
applicable properties
of the modeled object, callinggetPropertyDescriptor
to create each property descriptor. If that method returns one, it callscreatePropertyDescriptorDecorator
to decorate it, and then wraps that in aAnnotationItemProviderAdapterFactory.DecategorizingItemPropertyDescritorDecorator
. This implementation is likely sufficient for most purposes.- Parameters:
eObject
- the modeled object.annotation
- the annotation that it models.resourceLocator
- the resource locator from which to acquire resources.
-
getPropertyDescriptor
public IItemPropertyDescriptor getPropertyDescriptor(EObject eObject, String key, EStructuralFeature eStructuralFeature, Annotation annotation, ResourceLocator resourceLocator) Creates a property descriptor for aproperty
of themodeled object
corresponding to the given key and feature for the given annotation.This method adapts the object to an
IItemPropertySource
,fetching
the property descriptor from that, if available. This implementation is sufficient if the model is generated or if theReflectiveItemProviderAdapterFactory
is available and provides sufficient support.- Parameters:
eObject
- the modeled object.key
- the key of the property.eStructuralFeature
- the structure feature of the property.annotation
- the annotation that the modeled object models.resourceLocator
- the resource locator from which to acquire resources.- Returns:
- a property descriptor or
null
.
-
createPropertyDescriptorDecorator
public IItemPropertyDescriptor createPropertyDescriptorDecorator(IItemPropertyDescriptor propertyDescriptor, EObject eObject, String key, EStructuralFeature eStructuralFeature, Annotation annotation, ResourceLocator resourceLocator, EditingDomain domain) Creates a property descriptor decorator for the property descriptor of aproperty
of themodeled object
corresponding to the given key and feature for the given annotation.This implementation creates an instance of
AnnotationItemProviderAdapterFactory.ModeledItemPropertyDescriptorDecorator
which uses the assistant toconvert
the model object's value to a literal.- Parameters:
propertyDescriptor
- the property descriptor to be decorated.eObject
- the modeled object.key
- the key of the property.eStructuralFeature
- the structure feature of the property.annotation
- the annotation that the modeled object models.resourceLocator
- the resource locator from which to acquire resources.domain
- the editing domain to be used to modify the annotation.- Returns:
- a property descriptor or
null
.
-
getGroupName
Returns the group name associated with the given instance object. This will typically be the name of theinstances's class
. If instances areshown
, this name will be shown for thegroup of properties
associated with that instance.- Parameters:
instance
-- Returns:
- the group name associated with the given instance object.
- See Also:
-
create
Creates an annotation item provider adapter factory for the givenannotation source
.- Parameters:
annotationSoure
- the annotation source.- Returns:
- an annotation item provider adapter factory or
null
if there is no registered factory.
-