VR
- The visual root node of the UI toolkit used, e.g.
javafx.scene.Node in case of JavaFX.public abstract class AbstractDomain<VR> extends java.lang.Object implements IDomain<VR>
IAdaptable.Bound<A extends IAdaptable>
Modifier and Type | Field and Description |
---|---|
protected java.beans.PropertyChangeSupport |
pcs
A
PropertyChangeSupport that is used as a delegate to notify
listeners about changes to this object. |
ADAPTERS_PROPERTY
ACTIVE_PROPERTY
Constructor and Description |
---|
AbstractDomain()
Creates a new
AbstractDomain instance, setting the
AdaptableScope for each of its IAdaptable -compliant types
(super classes implementing IAdaptable and super-interfaces
extending IAdaptable ) to the newly created instance (see
AdaptableScopes#scopeTo(IAdaptable)). |
Modifier and Type | Method and Description |
---|---|
void |
activate() |
void |
addPropertyChangeListener(java.beans.PropertyChangeListener listener) |
void |
closeExecutionTransaction(ITool<VR> tool)
Closes the active execution transaction, removes the given
ITool
from the transaction context, and opens a new execution transaction if
there are any tools remaining in the context. |
protected ForwardUndoCompositeOperation |
createExecutionTransaction()
Creates a
ForwardUndoCompositeOperation which is used to store
the operations within an execution transaction. |
void |
deactivate() |
void |
dispose() |
void |
execute(IUndoableOperation operation)
Will execute the given
IUndoableOperation on the
IOperationHistory used by this IDomain (see
IDomain.getOperationHistory() ), using the IUndoContext of this
IDomain . |
<T> T |
getAdapter(AdapterKey<? super T> key) |
<T> T |
getAdapter(java.lang.Class<? super T> classKey) |
<T> T |
getAdapter(com.google.common.reflect.TypeToken<? super T> key) |
<T> java.util.Map<AdapterKey<? extends T>,T> |
getAdapters(java.lang.Class<? super T> classKey) |
<T> java.util.Map<AdapterKey<? extends T>,T> |
getAdapters(com.google.common.reflect.TypeToken<? super T> key) |
IOperationHistory |
getOperationHistory()
Returns the
IOperationHistory that is used by this domain. |
java.util.Map<AdapterKey<? extends ITool<VR>>,ITool<VR>> |
getTools()
Returns the
ITool s registered at this IDomain (via
IAdaptable.setAdapter(AdapterKey, Object) ) with the AdapterKey s
used for registration. |
IUndoContext |
getUndoContext()
Returns the
UndoContext that is used by this domain. |
java.util.Map<AdapterKey<? extends IViewer<VR>>,IViewer<VR>> |
getViewers()
Returns the
IViewer s registered at this IDomain (via
IAdaptable.setAdapter(AdapterKey, Object) ) with the AdapterKey s
used for registration. |
boolean |
isActive() |
protected boolean |
isExecutionTransactionOpen()
Returns
true if an execution transaction is currently open. |
boolean |
isExecutionTransactionOpen(ITool<VR> tool)
Returns
true if the given ITool is taking part in
the currently open execution transaction. |
void |
openExecutionTransaction(ITool<VR> tool)
Opens a new transaction or adds the given
ITool to the currently
opened transaction for executing operations (via
IDomain.execute(IUndoableOperation) ) on the IOperationHistory
used by this IDomain (see IDomain.getOperationHistory() ), using
the IUndoContext of this IDomain . |
void |
removePropertyChangeListener(java.beans.PropertyChangeListener listener) |
<T> void |
setAdapter(AdapterKey<? super T> key,
T adapter) |
<T> void |
setAdapter(java.lang.Class<? super T> key,
T adapter) |
<T> void |
setAdapter(com.google.common.reflect.TypeToken<? super T> key,
T adapter) |
void |
setAdapters(java.util.Map<AdapterKey<?>,java.lang.Object> adaptersWithKeys)
Adds the set of adapters to this
IAdaptable . |
void |
setOperationHistory(IOperationHistory stack)
Sets the
IOperationHistory that is used by this
AbstractDomain to the given value. |
void |
setUndoContext(IUndoContext undoContext)
Sets the
IUndoContext that is used by this AbstractDomain
to the given value. |
<T> T |
unsetAdapter(AdapterKey<? super T> key) |
protected java.beans.PropertyChangeSupport pcs
PropertyChangeSupport
that is used as a delegate to notify
listeners about changes to this object. May be used by subclasses to
trigger the notification of listeners.public AbstractDomain()
AbstractDomain
instance, setting the
AdaptableScope
for each of its IAdaptable
-compliant types
(super classes implementing IAdaptable
and super-interfaces
extending IAdaptable
) to the newly created instance (see
AdaptableScopes#scopeTo(IAdaptable)).public void activate()
activate
in interface IActivatable
public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
addPropertyChangeListener
in interface IPropertyChangeNotifier
public void closeExecutionTransaction(ITool<VR> tool)
IDomain
ITool
from the transaction context, and opens a new execution transaction if
there are any tools remaining in the context.closeExecutionTransaction
in interface IDomain<VR>
tool
- The ITool
that should be removed from the transaction
context.IDomain.openExecutionTransaction(ITool)
protected ForwardUndoCompositeOperation createExecutionTransaction()
ForwardUndoCompositeOperation
which is used to store
the operations within an execution transaction. The operation is opened
on the operation history
.ForwardUndoCompositeOperation
which is configured
to store the operations within an execution transaction.public void deactivate()
deactivate
in interface IActivatable
public void dispose()
dispose
in interface IDisposable
public void execute(IUndoableOperation operation)
IDomain
IUndoableOperation
on the
IOperationHistory
used by this IDomain
(see
IDomain.getOperationHistory()
), using the IUndoContext
of this
IDomain
.
In case an execution transaction is currently open (see
IDomain.openExecutionTransaction(ITool)
,
IDomain.closeExecutionTransaction(ITool)
) the enclosing transaction will
refer to the IUndoContext
used by this IDomain
) (so that
no specific IUndoContext
is set on the passed in
IUndoableOperation
). If no transaction is currently open, the
IUndoContext
of this IDomain
will be set on the passed in
IUndoableOperation
.execute
in interface IDomain<VR>
operation
- The IUndoableOperation
to be executed on the
IOperationHistory
of this IDomain
.public <T> T getAdapter(AdapterKey<? super T> key)
getAdapter
in interface IAdaptable
public <T> T getAdapter(java.lang.Class<? super T> classKey)
getAdapter
in interface IAdaptable
public <T> T getAdapter(com.google.common.reflect.TypeToken<? super T> key)
getAdapter
in interface IAdaptable
public <T> java.util.Map<AdapterKey<? extends T>,T> getAdapters(java.lang.Class<? super T> classKey)
getAdapters
in interface IAdaptable
public <T> java.util.Map<AdapterKey<? extends T>,T> getAdapters(com.google.common.reflect.TypeToken<? super T> key)
getAdapters
in interface IAdaptable
public IOperationHistory getOperationHistory()
IDomain
IOperationHistory
that is used by this domain.getOperationHistory
in interface IDomain<VR>
IOperationHistory
.public java.util.Map<AdapterKey<? extends ITool<VR>>,ITool<VR>> getTools()
IDomain
ITool
s registered at this IDomain
(via
IAdaptable.setAdapter(AdapterKey, Object)
) with the AdapterKey
s
used for registration.getTools
in interface IDomain<VR>
Map
containing the registered ITool
s mapped to
their respective AdapterKey
s.IAdaptable.setAdapter(AdapterKey, Object)
public IUndoContext getUndoContext()
IDomain
UndoContext
that is used by this domain.getUndoContext
in interface IDomain<VR>
UndoContext
.public java.util.Map<AdapterKey<? extends IViewer<VR>>,IViewer<VR>> getViewers()
IDomain
IViewer
s registered at this IDomain
(via
IAdaptable.setAdapter(AdapterKey, Object)
) with the AdapterKey
s
used for registration.getViewers
in interface IDomain<VR>
Map
containing the registered IViewer
s mapped
to their respective AdapterKey
s.IAdaptable.setAdapter(AdapterKey, Object)
public boolean isActive()
isActive
in interface IActivatable
protected boolean isExecutionTransactionOpen()
true
if an execution transaction is currently open.
Otherwise returns false
.true
if an execution transaction is currently open,
otherwise false
.public boolean isExecutionTransactionOpen(ITool<VR> tool)
IDomain
true
if the given ITool
is taking part in
the currently open execution transaction. Otherwise returns
false
.isExecutionTransactionOpen
in interface IDomain<VR>
tool
- The ITool
that is checked.true
if the given ITool
is taking part in
the currently open execution transaction, otherwise
false
.public void openExecutionTransaction(ITool<VR> tool)
IDomain
ITool
to the currently
opened transaction for executing operations (via
IDomain.execute(IUndoableOperation)
) on the IOperationHistory
used by this IDomain
(see IDomain.getOperationHistory()
), using
the IUndoContext
of this IDomain
.openExecutionTransaction
in interface IDomain<VR>
tool
- The ITool
starting/joining the transaction.public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
removePropertyChangeListener
in interface IPropertyChangeNotifier
public <T> void setAdapter(AdapterKey<? super T> key, T adapter)
setAdapter
in interface IAdaptable
public <T> void setAdapter(java.lang.Class<? super T> key, T adapter)
setAdapter
in interface IAdaptable
public <T> void setAdapter(com.google.common.reflect.TypeToken<? super T> key, T adapter)
setAdapter
in interface IAdaptable
@Inject(optional=true) public void setAdapters(@AdapterMap java.util.Map<AdapterKey<?>,java.lang.Object> adaptersWithKeys)
IAdaptable
. This method should
not be used by clients but is intended for injection of adapters by means
of an AdapterMapInjector
.
IMPORTANT: If sub-classes override this method, they will have to transfer the inject annotation to the overwritten method to ensure that adapter map injection is still functional.
adaptersWithKeys
- The adapters to add to this IAdaptable
(by means of
injection)AdapterMap
@Inject public void setOperationHistory(IOperationHistory stack)
IOperationHistory
that is used by this
AbstractDomain
to the given value. Operation history listeners
are un-/registered accordingly.stack
- The new IOperationHistory
for this domain.@Inject public void setUndoContext(IUndoContext undoContext)
IUndoContext
that is used by this AbstractDomain
to the given value.undoContext
- The new IUndoContext
for this domain.public <T> T unsetAdapter(AdapterKey<? super T> key)
unsetAdapter
in interface IAdaptable
Copyright (c) 2014 itemis AG and others. All rights reserved.