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 ofIAdaptable
supported by this class. If passed-in adapters implement theIAdaptable.Bound
interface, the generic type parameter ofIAdaptable.Bound
has 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
TypePropertyDescriptionjavafx.beans.property.ReadOnlyMapProperty<AdapterKey<?>,
Object> Returns a read-only map property, containing the adapters mapped to their keys. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionjavafx.beans.property.ReadOnlyMapProperty<AdapterKey<?>,
Object> Returns a read-only map property, containing the adapters mapped to their keys.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
).<T> T
getAdapter
(TypeToken<T> key) Returns an adapter for the givenTypeToken
key if one can unambiguously be retrieved.<T> T
getAdapter
(Class<T> key) Returns an adapter for the givenClass
key if one can unambiguously be retrieved.<T> T
getAdapter
(AdapterKey<T> key) Returns an adapter for the givenAdapterKey
if 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 respectiveAdapterKey
s they are registered.<T> Map<AdapterKey<? extends T>,
T> getAdapters
(TypeToken<? super T> key) Returns all adapters 'matching' the givenTypeToken
key, i.e. all adapters whoseAdapterKey
'sTypeToken
keyAdapterKey.getKey()
) refers to the same or a sub-type or of the givenTypeToken
key.<T> Map<AdapterKey<? extends T>,
T> getAdapters
(Class<? super T> key) Returns all adapters 'matching' the givenClass
key, i.e. all adapters whoseAdapterKey
'sTypeToken
keyAdapterKey.getKey()
) refers to the same or a sub-type of the givenClass
key.<T> void
setAdapter
(TypeToken<T> adapterType, T adapter) Registers the given adapter under anAdapterKey
, which will use the givenTypeToken
key as well as the default role (seeAdapterKey.DEFAULT_ROLE
.<T> void
setAdapter
(TypeToken<T> adapterType, T adapter, String role) Registers the given adapter under the givenAdapterKey
.<T> void
setAdapter
(T adapter) Registers the given adapter under the default role (seeAdapterKey.DEFAULT_ROLE
.<T> void
setAdapter
(T adapter, String role) Registers the given adapter under the given role .<T> void
unsetAdapter
(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
- TheIAdaptable
that 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:
dispose
in interfaceIDisposable
-
getAdapter
Returns an adapter for the givenAdapterKey
if 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
- TheAdapterKey
used to retrieve a registered adapter.- Returns:
- The unambiguously retrievable adapter for the given
AdapterKey
ornull
if none could be retrieved. - See Also:
-
getAdapter
Returns an adapter for the givenClass
key if one can unambiguously be retrieved. That is, if there is only a single adapter that 'matches' the givenClass
key, this adapter is returned, ignoring the role under which it is registered (seeAdapterKey.getRole()
). -
getAdapter
Returns an adapter for the givenTypeToken
key if one can unambiguously be retrieved. That is, if there is only a single adapter that 'matches' the givenTypeToken
key, 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
AdapterKey
under which the respective adapter is bound, ornull
if the adapter is not registered.
-
getAdapters
Retrieves all registered adapters, mapped to the respectiveAdapterKey
s they are registered.- Returns:
- An unmodifiable observable map containing the registered adapters
under their
AdapterKey
s as a copy.
-
getAdapters
Returns all adapters 'matching' the givenClass
key, i.e. all adapters whoseAdapterKey
'sTypeToken
keyAdapterKey.getKey()
) refers to the same or a sub-type of the givenClass
key.- Type Parameters:
T
- The adapter type.- Parameters:
key
- TheClass
key to retrieve adapters for.- Returns:
- A
Map
containing all those adapters registered at thisAdaptableSupport
, whoseAdapterKey
'sTypeToken
key (AdapterKey.getKey()
) refers to the same or a sub-type of the givenClass
key, qualified by their respectiveAdapterKey
s. - See Also:
-
getAdapters
Returns all adapters 'matching' the givenTypeToken
key, i.e. all adapters whoseAdapterKey
'sTypeToken
keyAdapterKey.getKey()
) refers to the same or a sub-type or of the givenTypeToken
key.- Type Parameters:
T
- The adapter type.- Parameters:
key
- TheTypeToken
key to retrieve adapters for.- Returns:
- A
Map
containing all those adapters registered at thisAdaptableSupport
, whoseAdapterKey
'sTypeToken
key (AdapterKey.getKey()
) refers to the same or a sub-type of the givenTypeToken
key, qualified by their respectiveAdapterKey
s. - 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 givenClass
key.- 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 givenTypeToken
key as well as the default role (seeAdapterKey.DEFAULT_ROLE
.- Type Parameters:
T
- The adapter type.- Parameters:
adapterType
- TheTypeToken
reflecting the actual type of the adapter.adapter
- The adapter to register.
-
setAdapter
Registers the given adapter under the givenAdapterKey
. TheAdapterKey
should provide the actual type of the adapter plus a role.- Type Parameters:
T
- The adapter type.- Parameters:
adapterType
- ATypeToken
representing 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:
-