Package org.eclipse.gef.common.adapt
Class AdaptableSupport<A extends IAdaptable>
java.lang.Object
org.eclipse.gef.common.adapt.AdaptableSupport<A>
- Type Parameters:
A- The type ofIAdaptablesupported by this class. If passed-in adapters implement theIAdaptable.Boundinterface, the generic type parameter ofIAdaptable.Boundhas to match this one.
- All Implemented Interfaces:
IDisposable
A support class to manage adapters for a source
IAdaptable. It offers
all methods defined by IAdaptable, while not formally implementing
the interface, and can thus be used by a source IAdaptable as a
delegate.-
Property Summary
PropertiesTypePropertyDescriptionjavafx.beans.property.ReadOnlyMapProperty<AdapterKey<?>,Object> Returns a read-only map property, containing the adapters mapped to their keys. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionjavafx.beans.property.ReadOnlyMapProperty<AdapterKey<?>,Object> Returns a read-only map property, containing the adapters mapped to their keys.voiddispose()Disposes thisAdaptableSupport, which will unregister all currently registered adapters, unbind them from their sourceIAdaptable(in case they areIAdaptable.Bound), and dispose them (if they areIDisposable).<T> TgetAdapter(TypeToken<T> key) Returns an adapter for the givenTypeTokenkey if one can unambiguously be retrieved.<T> TgetAdapter(Class<T> key) Returns an adapter for the givenClasskey if one can unambiguously be retrieved.<T> TgetAdapter(AdapterKey<T> key) Returns an adapter for the givenAdapterKeyif one can unambiguously be retrieved, i.e. if there is only a single adapter registered under a key that 'matches' the givenAdapterKey.<T> AdapterKey<T>getAdapterKey(T adapter) Returns the key under which the given adapter is bound.javafx.collections.ObservableMap<AdapterKey<?>,Object> Retrieves all registered adapters, mapped to the respectiveAdapterKeys they are registered.<T> Map<AdapterKey<? extends T>,T> getAdapters(TypeToken<? super T> key) Returns all adapters 'matching' the givenTypeTokenkey, i.e. all adapters whoseAdapterKey'sTypeTokenkeyAdapterKey.getKey()) refers to the same or a sub-type or of the givenTypeTokenkey.<T> Map<AdapterKey<? extends T>,T> getAdapters(Class<? super T> key) Returns all adapters 'matching' the givenClasskey, i.e. all adapters whoseAdapterKey'sTypeTokenkeyAdapterKey.getKey()) refers to the same or a sub-type of the givenClasskey.<T> voidsetAdapter(TypeToken<T> adapterType, T adapter) Registers the given adapter under anAdapterKey, which will use the givenTypeTokenkey as well as the default role (seeAdapterKey.DEFAULT_ROLE.<T> voidsetAdapter(TypeToken<T> adapterType, T adapter, String role) Registers the given adapter under the givenAdapterKey.<T> voidsetAdapter(T adapter) Registers the given adapter under the default role (seeAdapterKey.DEFAULT_ROLE.<T> voidsetAdapter(T adapter, String role) Registers the given adapter under the given role .<T> voidunsetAdapter(T adapter) Unregisters the adapter, returning it for convenience.
-
Property Details
-
adapters
Returns a read-only map property, containing the adapters mapped to their keys.- See Also:
-
-
Constructor Details
-
AdaptableSupport
- Parameters:
source- TheIAdaptablethat encloses the to be createdAdaptableSupport, delegating calls to it. May not benull
-
-
Method Details
-
adaptersProperty
Returns a read-only map property, containing the adapters mapped to their keys.- See Also:
-
dispose
public void dispose()Disposes thisAdaptableSupport, which will unregister all currently registered adapters, unbind them from their sourceIAdaptable(in case they areIAdaptable.Bound), and dispose them (if they areIDisposable).- Specified by:
disposein interfaceIDisposable
-
getAdapter
Returns an adapter for the givenAdapterKeyif one can unambiguously be retrieved, i.e. if there is only a single adapter registered under a key that 'matches' the givenAdapterKey.- Type Parameters:
T- The adapter type.- Parameters:
key- TheAdapterKeyused to retrieve a registered adapter.- Returns:
- The unambiguously retrievable adapter for the given
AdapterKeyornullif none could be retrieved. - See Also:
-
getAdapter
Returns an adapter for the givenClasskey if one can unambiguously be retrieved. That is, if there is only a single adapter that 'matches' the givenClasskey, this adapter is returned, ignoring the role under which it is registered (seeAdapterKey.getRole()). -
getAdapter
Returns an adapter for the givenTypeTokenkey if one can unambiguously be retrieved. That is, if there is only a single adapter that 'matches' the givenTypeTokenkey, this adapter is returned, ignoring the role under which it is registered (seeAdapterKey.getRole()). -
getAdapterKey
Returns the key under which the given adapter is bound.- Type Parameters:
T- The adapter type.- Parameters:
adapter- The adapter whose key to retrieve.- Returns:
- The
AdapterKeyunder which the respective adapter is bound, ornullif the adapter is not registered.
-
getAdapters
Retrieves all registered adapters, mapped to the respectiveAdapterKeys they are registered.- Returns:
- An unmodifiable observable map containing the registered adapters
under their
AdapterKeys as a copy.
-
getAdapters
Returns all adapters 'matching' the givenClasskey, i.e. all adapters whoseAdapterKey'sTypeTokenkeyAdapterKey.getKey()) refers to the same or a sub-type of the givenClasskey.- Type Parameters:
T- The adapter type.- Parameters:
key- TheClasskey to retrieve adapters for.- Returns:
- A
Mapcontaining all those adapters registered at thisAdaptableSupport, whoseAdapterKey'sTypeTokenkey (AdapterKey.getKey()) refers to the same or a sub-type of the givenClasskey, qualified by their respectiveAdapterKeys. - See Also:
-
getAdapters
Returns all adapters 'matching' the givenTypeTokenkey, i.e. all adapters whoseAdapterKey'sTypeTokenkeyAdapterKey.getKey()) refers to the same or a sub-type or of the givenTypeTokenkey.- Type Parameters:
T- The adapter type.- Parameters:
key- TheTypeTokenkey to retrieve adapters for.- Returns:
- A
Mapcontaining all those adapters registered at thisAdaptableSupport, whoseAdapterKey'sTypeTokenkey (AdapterKey.getKey()) refers to the same or a sub-type of the givenTypeTokenkey, qualified by their respectiveAdapterKeys. - See Also:
-
setAdapter
public <T> void setAdapter(T adapter) Registers the given adapter under the default role (seeAdapterKey.DEFAULT_ROLE.- Type Parameters:
T- The adapter type.- Parameters:
adapter- The adapter to register under the givenClasskey.- See Also:
-
setAdapter
Registers the given adapter under the given role .- Type Parameters:
T- The adapter type.- Parameters:
adapter- The adapter to register.role- The role to register this adapter with.- See Also:
-
setAdapter
Registers the given adapter under anAdapterKey, which will use the givenTypeTokenkey as well as the default role (seeAdapterKey.DEFAULT_ROLE.- Type Parameters:
T- The adapter type.- Parameters:
adapterType- TheTypeTokenreflecting the actual type of the adapter.adapter- The adapter to register.
-
setAdapter
Registers the given adapter under the givenAdapterKey. TheAdapterKeyshould provide the actual type of the adapter plus a role.- Type Parameters:
T- The adapter type.- Parameters:
adapterType- ATypeTokenrepresenting the actual type of the given adapter.adapter- The adapter to register.role- The role under which to register the adapter.
-
unsetAdapter
public <T> void unsetAdapter(T adapter) Unregisters the adapter, returning it for convenience.- Type Parameters:
T- The adapter type.- Parameters:
adapter- The adapter to unregister.- See Also:
-