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
Nested ClassesModifier and TypeClassDescriptionstatic final classA property descriptor created byAnnotationItemProviderAdapterFactory#getPropertyDescriptorsand used byAnnotationItemProvider.SourcePropertyDescriptor#createPropertyValueWrapper(Object, Object).static final classA convenient implementation of a property source with an explicit list of property descriptors that can bepopulatedafter construction.static classAn item property descriptor decorator implementation used byAnnotationItemProviderAdapterFactory.createPropertyDescriptorDecoratorto create anassistant-aware decorator.static classA reflective implementation of an annotation item provider adapter factory. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected AdapterThis keeps track of the one adapter used for allAnnotationinstances.protected final BasicAnnotationValidator.AssistantThe assistant provided in the constructor and returned bygetAssistant().protected final IChangeNotifierThis is used to implementIChangeNotifier.protected final DisposableThis is used to implementIDisposable.protected EtypesItemProviderAdapterFactoryThis 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 Stringprotected final ResourceLocatorThe resource locator provided in the constructor and returned bygetResourceLocator().protected AdapterThis keeps track of the one adapter used for allMap.Entryinstances.protected final Collection<Object>This keeps track of all the supported types checked byisFactoryForType. -
Constructor Summary
ConstructorsConstructorDescriptionAnnotationItemProviderAdapterFactory(ResourceLocator resourceLocator, BasicAnnotationValidator.Assistant assistant) This constructs an instance given a resource locator and an annotation assistant. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(INotifyChangedListener notifyChangedListener) This adds a listener.protected voidCreates an annotation item provider adapter factory for the givenannotation source.protected AdaptercreateAdapter(Notifier target) This creates an adapter for aAnnotationby 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 apropertyof themodeled objectcorresponding to the given key and feature for the given annotation.This creates an adapter for aMap.Entryby callingdoCreateStringToStringMapEntryAdapter().voiddispose()This disposes all of the item providers created by this factory.protected AdapterCreates the adapter for anAnnotation.protected AdapterCreates the adapter for an annotation'sdetails.voidfireNotifyChanged(Notification notification) This delegates tochangeNotifierand 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 apropertyof themodeled objectcorresponding 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 objectrepresenting 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.booleanisFactoryForType(Object type) booleanisShowInstances(Annotation annotation) Returns whetherAnnotationItemProvider.SourcePropertyDescriptor#createPropertyValueWrapper(Object, Object)should show themodeled objectin the property tree.voidremoveListener(INotifyChangedListener notifyChangedListener) This removes a listener.voidsetParentAdapterFactory(EtypesItemProviderAdapterFactory etypesItemProviderAdapterFactory) Sets the Etypes item provider adapter factory that uses this factory.voidsetParentAdapterFactory(ComposedAdapterFactory parentAdapterFactory) This operation is not supported.Methods inherited from class org.eclipse.emf.common.notify.impl.AdapterFactoryImpl
adaptAllNew, adaptNew, createAdapter, resolveMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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 allAnnotationinstances. -
stringToStringMapEntryItemProvider
This keeps track of the one adapter used for allMap.Entryinstances.
-
-
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
AnnotationItemProviderandStringToStringMapEntryItemProvider.- 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 objectin the property tree.This implementation always returns
trueifBasicAnnotationValidator.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 aAnnotationby 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.Entryby 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:
getRootAdapterFactoryin 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:
setParentAdapterFactoryin 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:
isFactoryForTypein interfaceAdapterFactory- Overrides:
isFactoryForTypein classAdapterFactoryImpl
-
createAdapter
- Overrides:
createAdapterin classAdapterFactoryImpl
-
adapt
This implementation substitutes the factory itself as the key for the adapter.
- Specified by:
adaptin interfaceAdapterFactory- Overrides:
adaptin classAdapterFactoryImpl
-
adapt
- Specified by:
adaptin interfaceAdapterFactory- Overrides:
adaptin classAdapterFactoryImpl
-
associate
This implementation also adds the adapter to the
disposable, if it's anIDisposable.- Overrides:
associatein classAdapterFactoryImpl
-
addListener
This adds a listener.- Specified by:
addListenerin interfaceIChangeNotifier
-
removeListener
This removes a listener.- Specified by:
removeListenerin interfaceIChangeNotifier
-
fireNotifyChanged
This delegates tochangeNotifierand toetypesItemProviderAdapterFactory.- Specified by:
fireNotifyChangedin interfaceIChangeNotifier
-
dispose
public void dispose()This disposes all of the item providers created by this factory.- Specified by:
disposein interfaceIDisposable
-
getPropertyDescriptors
public List<IItemPropertyDescriptor> getPropertyDescriptors(EObject eObject, Annotation annotation, ResourceLocator resourceLocator) Returns a list of property descriptors for themodeled objectrepresenting the given annotation.This implementation uses the
applicable propertiesof the modeled object, callinggetPropertyDescriptorto create each property descriptor. If that method returns one, it callscreatePropertyDescriptorDecoratorto 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 apropertyof themodeled objectcorresponding to the given key and feature for the given annotation.This method adapts the object to an
IItemPropertySource,fetchingthe property descriptor from that, if available. This implementation is sufficient if the model is generated or if theReflectiveItemProviderAdapterFactoryis 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 apropertyof themodeled objectcorresponding to the given key and feature for the given annotation.This implementation creates an instance of
AnnotationItemProviderAdapterFactory.ModeledItemPropertyDescriptorDecoratorwhich uses the assistant toconvertthe 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 propertiesassociated 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
nullif there is no registered factory.
-