From 20f88e203a0ab341c587be7d4ee40b1ae1931376 Mon Sep 17 00:00:00 2001 From: Armin Schrenk Date: Tue, 18 May 2021 13:40:56 +0200 Subject: [PATCH] simplification and cleanup --- .../ui/health/CheckListController.java | 23 +++---------------- .../resources/fxml/health_check_list.fxml | 4 ++-- 2 files changed, 5 insertions(+), 22 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 cf73e1127..48e846f60 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 @@ -12,9 +12,6 @@ import javafx.beans.binding.Binding; import javafx.beans.binding.BooleanBinding; import javafx.beans.property.ObjectProperty; import javafx.beans.property.SimpleObjectProperty; -import javafx.beans.property.SimpleStringProperty; -import javafx.beans.property.StringProperty; -import javafx.beans.value.ObservableValue; import javafx.collections.FXCollections; import javafx.collections.ObservableList; import javafx.concurrent.Worker; @@ -22,7 +19,6 @@ import javafx.fxml.FXML; import javafx.scene.control.ListView; import java.io.IOException; import java.util.Collection; -import java.util.ResourceBundle; import java.util.Set; import java.util.concurrent.ExecutorService; @@ -30,37 +26,33 @@ import java.util.concurrent.ExecutorService; 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 static final Set END_STATES = Set.of(Worker.State.FAILED, Worker.State.CANCELLED, Worker.State.SUCCEEDED); private final ObservableList tasks; private final ReportWriter reportWriter; private final ExecutorService executorService; private final ObjectProperty selectedTask; - private final ResourceBundle resourceBundle; private final SimpleObjectProperty> runningTask; private final Binding running; private final Binding finished; private final BooleanBinding anyCheckSelected; private final BooleanBinding readyToRun; - private final StringProperty runButtonDescription; /* FXML */ public ListView checksListView; @Inject - public CheckListController(Lazy> tasks, ReportWriter reportWriteTask, ObjectProperty selectedTask, ExecutorService executorService, ResourceBundle resourceBundle) { + public CheckListController(Lazy> tasks, ReportWriter reportWriteTask, ObjectProperty selectedTask, ExecutorService executorService) { this.tasks = FXCollections.observableArrayList(tasks.get()); this.reportWriter = reportWriteTask; this.executorService = executorService; this.selectedTask = selectedTask; - this.resourceBundle = resourceBundle; 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.finished = EasyBind.wrapNullable(runningTask).mapObservable(Worker::stateProperty).map(END_STATES::contains).orElse(false); this.readyToRun = runningTask.isNull(); this.anyCheckSelected = selectedTask.isNotNull(); - this.runButtonDescription = new SimpleStringProperty(resourceBundle.getString("health.check.runAllButton")); } @FXML @@ -68,15 +60,6 @@ public class CheckListController implements FxController { checksListView.setItems(tasks); checksListView.setCellFactory(ignored -> new CheckListCell()); selectedTask.bind(checksListView.getSelectionModel().selectedItemProperty()); - selectedTask.addListener(this::updateRunButtonDescription); - } - - private void updateRunButtonDescription(ObservableValue observable, HealthCheckTask oldTask, HealthCheckTask newTask) { - if (newTask == null) { - runButtonDescription.set(resourceBundle.getString("health.check.runSingleButton")); - } else if (oldTask == null && newTask != null) { - runButtonDescription.set(resourceBundle.getString("health.check.runAllButton")); - } } @FXML 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 67f770304..7df32221b 100644 --- a/main/ui/src/main/resources/fxml/health_check_list.fxml +++ b/main/ui/src/main/resources/fxml/health_check_list.fxml @@ -33,8 +33,8 @@