private PushButton executeSynchronousButton = null;
private PushButton executeAsynchronousButton = null;
@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
WTKXSerializer wtkxSerializer = new WTKXSerializer();
window = (Window)wtkxSerializer.readObject(this, "background_tasks.wtkx");
activityIndicator = (ActivityIndicator)wtkxSerializer.get("activityIndicator");
executeSynchronousButton = (PushButton)wtkxSerializer.get("executeSynchronousButton");
executeSynchronousButton.getButtonPressListeners().add(new ButtonPressListener() {
@Override
public void buttonPressed(Button button) {
activityIndicator.setActive(true);
System.out.println("Starting synchronous task execution.");
SleepTask sleepTask = new SleepTask();
String result = null;
try {
result = sleepTask.execute();
} catch (TaskExecutionException exception) {
System.err.println(exception);
}
System.out.println("Synchronous task execution complete: \"" + result + "\"");
activityIndicator.setActive(false);
}
});
executeAsynchronousButton = (PushButton)wtkxSerializer.get("executeAsynchronousButton");
executeAsynchronousButton.getButtonPressListeners().add(new ButtonPressListener() {
@Override
public void buttonPressed(Button button) {
activityIndicator.setActive(true);
window.setEnabled(false);