This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void runOnUiToolkitThreadAndWait(Runnable runnable); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
default void runOnUiToolkitThreadAndWait(Runnable runnable) throws InterruptedException, ExecutionException { | |
FutureTask<Void> future = new FutureTask<>(runnable, null); | |
runOnUiToolkitThread(future); | |
future.get(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void runningOnBackgroundThread() { | |
String userInput = runOnUiToolkitThreadAndWait(() -> textfield.getText()); | |
callWebservice(userInput); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<T> T runOnUiToolkitThreadAndWait(Callable<T> callable); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<T> Provider<T> runOnUiToolkitThread(Callable<T> callable); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface UIThread { | |
void runOnUiToolkitThread(Runnable runnable); | |
<T> Provider<T> runOnUiToolkitThread(Callable<T> callable); | |
void runOnUiToolkitThreadAndWait(Runnable runnable); | |
<T> T runOnUiToolkitThreadAndWait(Callable<T> callable); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface UIThread { | |
void runOnUiToolkitThread(Runnable runnable); | |
default <T> Future<T> runOnUiToolkitThread(Callable<T> callable) { | |
FutureTask<T> future = new FutureTask<>(callable); | |
runOnUiToolkitThread(future); | |
return future; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ViewController("main.fxml") | |
public class MainController { | |
@ViewNode | |
private RadioButton radioButton1; | |
@ViewNode | |
private RadioButton radioButton2; | |
@ViewNode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
flowActionHandler.handle("actionId"); | |
flowActionHandler.navigate(NextController.class); | |
flowActionHandler.navigateBack(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ViewController("view.fxml") | |
public class MyController { | |
@ActionHandler | |
protected FlowActionHandler actionHandler; | |
public void doSomething() { | |
actionHandler.handle("actionId"); | |
//or | |
actionHandler.navigate(NextController.class); |