@Beta public class DelegateCommand extends CommandBase
Command
implementation that encapsulates an action (Runnable
). It is possible to define that the
action should be executed in the background (not on the JavaFX thread) so that long running actions can be
implemented that aren't blocking the ui thread.executableProperty, runningProperty
executable, running
Constructor and Description |
---|
DelegateCommand(Runnable action)
Creates a command without a condition about the executability.
|
DelegateCommand(Runnable action,
boolean inBackground)
Creates a command without an condition about the executability.
|
DelegateCommand(Runnable action,
javafx.beans.value.ObservableBooleanValue executableBinding)
Creates a command with a condition about the executability by using the #executableBinding parameter.
|
DelegateCommand(Runnable action,
javafx.beans.value.ObservableBooleanValue executableBinding,
boolean inBackground)
Creates a command with a condition about the executability by using the #executableBinding parameter.
|
Modifier and Type | Method and Description |
---|---|
void |
execute()
This method will be called when the command is invoked.
|
executableProperty, isExecutable, isRunning, runningProperty
public DelegateCommand(Runnable action)
Command
.action
- which should executepublic DelegateCommand(Runnable action, boolean inBackground)
true
to the
inBackground
parameter to run the Command
in a background thread.
IF YOU USE THE BACKGROUND THREAD: Your provided action will perform in a background thread. If you
manipulate data in your action, which will be propagated to the UI, use Platform.runLater(Runnable)
for
this manipulation, otherwise you get an Exception.action
- which should executeinBackground
- defines whether the execution execute()
is performed in a background thread or notpublic DelegateCommand(Runnable action, javafx.beans.value.ObservableBooleanValue executableBinding)
Command
.action
- which should executeexecutableBinding
- which defines whether the Command
can executepublic DelegateCommand(Runnable action, javafx.beans.value.ObservableBooleanValue executableBinding, boolean inBackground)
true
to the #inBackground parameter to run the Command
in a background thread.
IF YOU USE THE BACKGROUND THREAD: don't forget to return to the UI-thread by using
Platform.runLater(Runnable)
, otherwise you get an Exception.public void execute()
Command
execute
in interface Command
execute
in class CommandBase
Command.execute()
Copyright © 2015 Saxonia Systems AG. All rights reserved.