diff --git a/main/ui/src/main/java/org/cryptomator/ui/controls/FontAwesome5Icon.java b/main/ui/src/main/java/org/cryptomator/ui/controls/FontAwesome5Icon.java index e48818c1e..13c583c0e 100644 --- a/main/ui/src/main/java/org/cryptomator/ui/controls/FontAwesome5Icon.java +++ b/main/ui/src/main/java/org/cryptomator/ui/controls/FontAwesome5Icon.java @@ -9,6 +9,7 @@ public enum FontAwesome5Icon { BAN("\uF05E"), // BUG("\uF188"), // CHECK("\uF00C"), // + CLOCK("\uF017"), // COG("\uF013"), // COGS("\uF085"), // COPY("\uF0C5"), // diff --git a/main/ui/src/main/java/org/cryptomator/ui/health/CheckListCell.java b/main/ui/src/main/java/org/cryptomator/ui/health/CheckListCell.java index d3f6712a4..d4270c40c 100644 --- a/main/ui/src/main/java/org/cryptomator/ui/health/CheckListCell.java +++ b/main/ui/src/main/java/org/cryptomator/ui/health/CheckListCell.java @@ -20,6 +20,9 @@ class CheckListCell extends ListCell { item.stateProperty().addListener(this::stateChanged); setGraphic(stateIcon); stateIcon.setGlyph(glyphForState(item.getState())); + if (item.getState() == Worker.State.READY) { + stateIcon.setVisible(false); + } setContentDisplay(ContentDisplay.LEFT); } else { setText(null); @@ -29,12 +32,14 @@ class CheckListCell extends ListCell { private void stateChanged(ObservableValue observable, Worker.State oldState, Worker.State newState) { stateIcon.setGlyph(glyphForState(newState)); + stateIcon.setVisible(true); } private FontAwesome5Icon glyphForState(Worker.State state) { // TODO choose appropriate glyphs return switch (state) { - case READY, SCHEDULED -> FontAwesome5Icon.ANCHOR; + case READY -> FontAwesome5Icon.COG; //just a placeholder + case SCHEDULED -> FontAwesome5Icon.CLOCK; case RUNNING -> FontAwesome5Icon.SPINNER; case FAILED -> FontAwesome5Icon.EXCLAMATION_TRIANGLE; case CANCELLED -> FontAwesome5Icon.BAN; 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 48e846f60..600549237 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 @@ -10,15 +10,22 @@ import org.slf4j.LoggerFactory; import javax.inject.Inject; import javafx.beans.binding.Binding; import javafx.beans.binding.BooleanBinding; +import javafx.beans.property.BooleanProperty; +import javafx.beans.property.IntegerProperty; import javafx.beans.property.ObjectProperty; +import javafx.beans.property.SimpleBooleanProperty; +import javafx.beans.property.SimpleIntegerProperty; import javafx.beans.property.SimpleObjectProperty; import javafx.collections.FXCollections; import javafx.collections.ObservableList; import javafx.concurrent.Worker; import javafx.fxml.FXML; import javafx.scene.control.ListView; +import javafx.scene.control.cell.CheckBoxListCell; import java.io.IOException; import java.util.Collection; +import java.util.HashMap; +import java.util.Map; import java.util.Set; import java.util.concurrent.ExecutorService; @@ -35,8 +42,10 @@ public class CheckListController implements FxController { private final SimpleObjectProperty> runningTask; private final Binding running; private final Binding finished; + private final Map listPickIndicators; + private final IntegerProperty numberOfPickedChecks; private final BooleanBinding anyCheckSelected; - private final BooleanBinding readyToRun; + private final BooleanProperty showResultScreen; /* FXML */ public ListView checksListView; @@ -51,33 +60,35 @@ public class CheckListController implements FxController { this.runningTask = new SimpleObjectProperty<>(); this.running = EasyBind.wrapNullable(runningTask).mapObservable(Worker::runningProperty).orElse(false); this.finished = EasyBind.wrapNullable(runningTask).mapObservable(Worker::stateProperty).map(END_STATES::contains).orElse(false); - this.readyToRun = runningTask.isNull(); + this.listPickIndicators = new HashMap<>(); + this.numberOfPickedChecks = new SimpleIntegerProperty(0); + this.tasks.forEach(task -> { + var entrySelectedProp = new SimpleBooleanProperty(false); + entrySelectedProp.addListener((observable, oldValue, newValue) -> numberOfPickedChecks.set(numberOfPickedChecks.get() + (newValue ? 1 : -1))); + listPickIndicators.put(task, entrySelectedProp); + }); this.anyCheckSelected = selectedTask.isNotNull(); + this.showResultScreen = new SimpleBooleanProperty(false); } @FXML public void initialize() { checksListView.setItems(tasks); - checksListView.setCellFactory(ignored -> new CheckListCell()); + checksListView.setCellFactory(CheckBoxListCell.forListView(listPickIndicators::get)); selectedTask.bind(checksListView.getSelectionModel().selectedItemProperty()); } @FXML - public synchronized void runSelectedChecks() { - startBatch(checksListView.getSelectionModel().getSelectedItems()); - } - - @FXML - public synchronized void runAllChecks() { - startBatch(checksListView.getItems()); - } - - private void startBatch(Iterable batch) { + public void runSelectedChecks() { Preconditions.checkState(runningTask.get() == null); + var batch = checksListView.getItems().filtered(item -> listPickIndicators.get(item).get()); var batchService = new BatchService(batch); batchService.setExecutor(executorService); batchService.start(); runningTask.set(batchService); + checksListView.setCellFactory(view -> new CheckListCell()); + showResultScreen.set(true); + checksListView.getSelectionModel().select(batch.getViewIndex(0)); } @FXML @@ -95,17 +106,8 @@ public class CheckListController implements FxController { LOG.error("Failed to write health check report.", e); } } + /* Getter/Setter */ - - - public boolean isReadyToRun() { - return readyToRun.get(); - } - - public BooleanBinding readyToRunProperty() { - return readyToRun; - } - public boolean isRunning() { return running.getValue(); } @@ -130,4 +132,21 @@ public class CheckListController implements FxController { return anyCheckSelected; } + public boolean getShowResultScreen() { + return showResultScreen.get(); + } + + public BooleanProperty showResultScreenProperty() { + return showResultScreen; + } + + public int getNumberOfPickedChecks() { + return numberOfPickedChecks.get(); + } + + public IntegerProperty numberOfPickedChecksProperty() { + return numberOfPickedChecks; + } + + } 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 4524da92c..ba2778476 100644 --- a/main/ui/src/main/resources/fxml/health_check_list.fxml +++ b/main/ui/src/main/resources/fxml/health_check_list.fxml @@ -7,6 +7,7 @@ + + + + - - - - + + + + + - -