public final class ConcurrencyController extends Object
IInputMode
implementation.
The controller will be passed to its associated IInputMode
in the input mode's IInputMode.install(IInputModeContext, ConcurrencyController)
method. The associated mode can request
an input mutex to deactivate
other
modes added to the same MultiplexingInputMode
and using Exclusive
controllers. Releasing the mutex
will reactivate the controller of other modes.
IInputMode
,
MultiplexingInputMode
Constructor and Description |
---|
ConcurrencyController(IInputMode mode)
Creates an instance that can be used to
IInputMode.install(com.yworks.yfiles.view.input.IInputModeContext, ConcurrencyController)
the given mode . |
Modifier and Type | Method and Description |
---|---|
void |
addActiveChangedListener(IEventHandler<IEventArgs> activeChangedEvent)
Adds the given listener for the
ActiveChanged event that occurs the Active property
changes. |
void |
addMutexObtainedListener(IEventHandler<IEventArgs> mutexObtainedEvent)
Adds the given listener for the
MutexObtained event that occurs when the mutex has been successfully obtained. |
void |
addMutexReleasedListener(IEventHandler<IEventArgs> mutexReleasedEvent)
Adds the given listener for the
MutexReleased event that occurs when the mutex has been released. |
void |
addPreferredCursorChangedListener(IEventHandler<IEventArgs> preferredCursorChangedEvent)
Adds the given listener for the
PreferredCursorChanged event that occurs when the PreferredCursor
property changes. |
void |
addPriorityChangedListener(IEventHandler<IEventArgs> priorityChangedEvent)
Adds the given listener for the
PriorityChanged event that occurs when onPriorityChanged() is called by
the associated mode. |
boolean |
canRequestMutex()
Determines if the mutex can be successfully requested currently.
|
IInputMode |
getMutexOwner()
Gets the current owner of the input mutex or
null if no mode currently owns the mutex. |
Cursor |
getPreferredCursor()
Returns the cursor the associated mode of this controller would like to have displayed in the
CanvasControl . |
boolean |
hasMutex()
Determines whether this instance owns the input mutex.
|
boolean |
isActive()
Returns if this controller is active.
|
boolean |
isEnabled()
Gets if this controller is enabled.
|
boolean |
isExclusive()
Gets a value indicating whether this controller will be the only one running when it has the mutex.
|
void |
onPriorityChanged()
Triggers a
PriorityChanged event with IEventArgs.EMPTY . |
void |
releaseMutex()
Releases the input mutex.
|
void |
removeActiveChangedListener(IEventHandler<IEventArgs> activeChangedEvent)
Removes the given listener for the
ActiveChanged event that occurs the Active property
changes. |
void |
removeMutexObtainedListener(IEventHandler<IEventArgs> mutexObtainedEvent)
Removes the given listener for the
MutexObtained event that occurs when the mutex has been successfully
obtained. |
void |
removeMutexReleasedListener(IEventHandler<IEventArgs> mutexReleasedEvent)
Removes the given listener for the
MutexReleased event that occurs when the mutex has been released. |
void |
removePreferredCursorChangedListener(IEventHandler<IEventArgs> preferredCursorChangedEvent)
Removes the given listener for the
PreferredCursorChanged event that occurs when the PreferredCursor
property changes. |
void |
removePriorityChangedListener(IEventHandler<IEventArgs> priorityChangedEvent)
Removes the given listener for the
PriorityChanged event that occurs when onPriorityChanged() is called
by the associated mode. |
void |
requestMutex()
Can be called to request an input mutex for the input mode.
|
void |
setEnabled(boolean value)
Sets if this controller is enabled.
|
void |
setExclusive(boolean value)
Sets a value indicating whether this controller will be the only one running when it has the mutex.
|
void |
setPreferredCursor(Cursor value)
Returns the cursor the associated mode of this controller would like to have displayed in the
CanvasControl . |
public ConcurrencyController(IInputMode mode)
IInputMode.install(com.yworks.yfiles.view.input.IInputModeContext, ConcurrencyController)
the given mode
.
The returned ConcurrencyController
is not synchronized with any other one so the mode
will effectively
run in a non-exclusive
mode.
mode
- The mode, the ConcurrencyController
shall be created for.public final void addActiveChangedListener(IEventHandler<IEventArgs> activeChangedEvent)
ActiveChanged
event that occurs the Active
property
changes.
This event is invoked with IEventArgs.EMPTY
per default.
activeChangedEvent
- The listener to add.removeActiveChangedListener(IEventHandler)
public final void addMutexObtainedListener(IEventHandler<IEventArgs> mutexObtainedEvent)
MutexObtained
event that occurs when the mutex has been successfully obtained.
This event is invoked with IEventArgs.EMPTY
per default.
mutexObtainedEvent
- The listener to add.removeMutexObtainedListener(IEventHandler)
public final void addMutexReleasedListener(IEventHandler<IEventArgs> mutexReleasedEvent)
MutexReleased
event that occurs when the mutex has been released.
This event is invoked with IEventArgs.EMPTY
per default.
mutexReleasedEvent
- The listener to add.removeMutexReleasedListener(IEventHandler)
public final void addPreferredCursorChangedListener(IEventHandler<IEventArgs> preferredCursorChangedEvent)
PreferredCursorChanged
event that occurs when the PreferredCursor
property changes.
MultiplexingInputMode
listens to property changes of the controller of its sub modes. properties. This event is
invoked with IEventArgs.EMPTY
per default.
preferredCursorChangedEvent
- The listener to add.removePreferredCursorChangedListener(IEventHandler)
public final void addPriorityChangedListener(IEventHandler<IEventArgs> priorityChangedEvent)
PriorityChanged
event that occurs when onPriorityChanged()
is called by
the associated mode.
MultiplexingInputMode
listens to priority changes of the controller of its sub modes.
priorityChangedEvent
- The listener to add.removePriorityChangedListener(IEventHandler)
public final boolean canRequestMutex()
This will return true
, iff this instance is Active
and doesn't hold the mutex.
requestMutex()
would currently succeed.public final IInputMode getMutexOwner()
null
if no mode currently owns the mutex.public final Cursor getPreferredCursor()
CanvasControl
.
To indicate that the mode does not have any preferences the property should be set to null
.
setPreferredCursor(Cursor)
public final boolean hasMutex()
The instance owns the input mutex if it has successfully requested
the mutex in the past and not
yet released
it.
public final boolean isActive()
An IInputMode
should only handle events and gestures if this property on its associated ConcurrencyController
is set to true
.
If this controller is set as non-exclusive
by its input mode it is active iff it is
Enabled
. Otherwise it has to be Enabled
and no other input mode may have
the input mutex
.
true
if the associated input mode should handle events and gestures.addActiveChangedListener(IEventHandler)
public final boolean isEnabled()
The default state is disabled. A disabled controller is always inactive
.
When the controller is installed
and the input mode is ready for editing, it has to set this property to true
if it wants to use the input
mutex.
isActive()
,
addActiveChangedListener(IEventHandler)
,
setEnabled(boolean)
public final boolean isExclusive()
If this controller is marked as exclusive and has the mutex, all controllers of other modes added
to the same MultiplexingInputMode
will be
deactivated
. Otherwise it will always run concurrently with all other controllers.
Changing this property will temporarily disable
the controller.
setExclusive(boolean)
public final void onPriorityChanged()
PriorityChanged
event with IEventArgs.EMPTY
.
This method should be called by the associated mode if its Priority
has changed.
public final void releaseMutex()
Modes should call this method when they have finished editing the contents exclusively. This will reactivate those modes
whose controller that had been deactivated
at the time the mutex has been requested.
public final void removeActiveChangedListener(IEventHandler<IEventArgs> activeChangedEvent)
ActiveChanged
event that occurs the Active
property
changes.
This event is invoked with IEventArgs.EMPTY
per default.
activeChangedEvent
- The listener to remove.addActiveChangedListener(IEventHandler)
public final void removeMutexObtainedListener(IEventHandler<IEventArgs> mutexObtainedEvent)
MutexObtained
event that occurs when the mutex has been successfully
obtained.
This event is invoked with IEventArgs.EMPTY
per default.
mutexObtainedEvent
- The listener to remove.addMutexObtainedListener(IEventHandler)
public final void removeMutexReleasedListener(IEventHandler<IEventArgs> mutexReleasedEvent)
MutexReleased
event that occurs when the mutex has been released.
This event is invoked with IEventArgs.EMPTY
per default.
mutexReleasedEvent
- The listener to remove.addMutexReleasedListener(IEventHandler)
public final void removePreferredCursorChangedListener(IEventHandler<IEventArgs> preferredCursorChangedEvent)
PreferredCursorChanged
event that occurs when the PreferredCursor
property changes.
MultiplexingInputMode
listens to property changes of the controller of its sub modes. properties. This event is
invoked with IEventArgs.EMPTY
per default.
preferredCursorChangedEvent
- The listener to remove.addPreferredCursorChangedListener(IEventHandler)
public final void removePriorityChangedListener(IEventHandler<IEventArgs> priorityChangedEvent)
PriorityChanged
event that occurs when onPriorityChanged()
is called
by the associated mode.
MultiplexingInputMode
listens to priority changes of the controller of its sub modes.
priorityChangedEvent
- The listener to remove.addPriorityChangedListener(IEventHandler)
public final void requestMutex()
Modes should call this method to request exclusive editing for a canvas control. canRequestMutex()
should be
called before requesting the mutex. If the mutex cannot be obtained, this method will trigger an exception.
RuntimeException
- If the mutex could not be obtained.public final void setEnabled(boolean value)
The default state is disabled. A disabled controller is always inactive
.
When the controller is installed
and the input mode is ready for editing, it has to set this property to true
if it wants to use the input
mutex.
value
- The Enabled to set.isActive()
,
addActiveChangedListener(IEventHandler)
,
isEnabled()
public final void setExclusive(boolean value)
If this controller is marked as exclusive and has the mutex, all controllers of other modes added
to the same MultiplexingInputMode
will be
deactivated
. Otherwise it will always run concurrently with all other controllers.
Changing this property will temporarily disable
the controller.
value
- The Exclusive to set.isExclusive()
public final void setPreferredCursor(Cursor value)
CanvasControl
.
To indicate that the mode does not have any preferences the property should be set to null
.
value
- The PreferredCursor to set.getPreferredCursor()