From 749e0ac02d0f3832d683ff83692e9022ef2a504b Mon Sep 17 00:00:00 2001 From: Armin Schrenk Date: Mon, 17 May 2021 12:40:29 +0200 Subject: [PATCH] disable export-button as long as no batch run is finished --- .../cryptomator/ui/health/CheckListController.java | 12 ++++++++++++ .../src/main/resources/fxml/health_check_list.fxml | 3 +-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/main/ui/src/main/java/org/cryptomator/ui/health/CheckListController.java b/main/ui/src/main/java/org/cryptomator/ui/health/CheckListController.java index 700230e45..2982f01a6 100644 --- a/main/ui/src/main/java/org/cryptomator/ui/health/CheckListController.java +++ b/main/ui/src/main/java/org/cryptomator/ui/health/CheckListController.java @@ -19,12 +19,14 @@ import javafx.fxml.FXML; import javafx.scene.control.ListView; import java.io.IOException; import java.util.Collection; +import java.util.Set; import java.util.concurrent.ExecutorService; @HealthCheckScoped public class CheckListController implements FxController { private static final Logger LOG = LoggerFactory.getLogger(CheckListController.class); + private static final Set endStates = Set.of(Worker.State.FAILED, Worker.State.CANCELLED, Worker.State.SUCCEEDED); private final ObservableList tasks; private final ReportWriter reportWriter; @@ -32,6 +34,7 @@ public class CheckListController implements FxController { private final ObjectProperty selectedTask; private final SimpleObjectProperty> runningTask; private final Binding running; + private final Binding finished; private final BooleanBinding anyCheckSelected; private final BooleanBinding readyToRun; @@ -47,6 +50,7 @@ public class CheckListController implements FxController { this.selectedTask = selectedTask; this.runningTask = new SimpleObjectProperty<>(); this.running = EasyBind.wrapNullable(runningTask).mapObservable(Worker::runningProperty).orElse(false); + this.finished = EasyBind.wrapNullable(runningTask).mapObservable(Worker::stateProperty).map(endStates::contains).orElse(false); this.anyCheckSelected = selectedTask.isNotNull(); this.readyToRun = runningTask.isNull(); } @@ -109,6 +113,14 @@ public class CheckListController implements FxController { return running; } + public boolean isFinished() { + return finished.getValue(); + } + + public Binding finishedProperty() { + return finished; + } + public boolean isAnyCheckSelected() { return anyCheckSelected.get(); } diff --git a/main/ui/src/main/resources/fxml/health_check_list.fxml b/main/ui/src/main/resources/fxml/health_check_list.fxml index 377b93724..93ceaaae7 100644 --- a/main/ui/src/main/resources/fxml/health_check_list.fxml +++ b/main/ui/src/main/resources/fxml/health_check_list.fxml @@ -31,8 +31,7 @@ - -