mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-05-22 12:41:27 +00:00
Unify interface:
* move all buttons to one button bar * switch between runAll and runSelected, depending on list selection * add a little localization
This commit is contained in:
@@ -12,6 +12,9 @@ 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;
|
||||
@@ -19,6 +22,7 @@ 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;
|
||||
|
||||
@@ -32,27 +36,31 @@ public class CheckController implements FxController {
|
||||
private final ReportWriter reportWriter;
|
||||
private final ExecutorService executorService;
|
||||
private final ObjectProperty<HealthCheckTask> selectedTask;
|
||||
private final ResourceBundle resourceBundle;
|
||||
private final SimpleObjectProperty<Worker<?>> runningTask;
|
||||
private final Binding<Boolean> running;
|
||||
private final Binding<Boolean> finished;
|
||||
private final BooleanBinding anyCheckSelected;
|
||||
private final BooleanBinding readyToRun;
|
||||
private final StringProperty runButtonDescription;
|
||||
|
||||
/* FXML */
|
||||
public ListView<HealthCheckTask> checksListView;
|
||||
|
||||
|
||||
@Inject
|
||||
public CheckController(Lazy<Collection<HealthCheckTask>> tasks, ReportWriter reportWriteTask, ObjectProperty<HealthCheckTask> selectedTask, ExecutorService executorService) {
|
||||
public CheckController(Lazy<Collection<HealthCheckTask>> tasks, ReportWriter reportWriteTask, ObjectProperty<HealthCheckTask> selectedTask, ExecutorService executorService, ResourceBundle resourceBundle) {
|
||||
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.readyToRun = runningTask.isNull();
|
||||
this.anyCheckSelected = selectedTask.isNotNull();
|
||||
this.runButtonDescription = new SimpleStringProperty(resourceBundle.getString("health.check.runAllButton"));
|
||||
}
|
||||
|
||||
@FXML
|
||||
@@ -60,24 +68,33 @@ public class CheckController implements FxController {
|
||||
checksListView.setItems(tasks);
|
||||
checksListView.setCellFactory(ignored -> new CheckListCell());
|
||||
selectedTask.bind(checksListView.getSelectionModel().selectedItemProperty());
|
||||
selectedTask.addListener(this::updateRunButtonDescription);
|
||||
}
|
||||
|
||||
private void updateRunButtonDescription(ObservableValue<? extends HealthCheckTask> 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
|
||||
public synchronized void runSelectedChecks() {
|
||||
Preconditions.checkState(runningTask.get() == null);
|
||||
var batch = new BatchService(checksListView.getSelectionModel().getSelectedItems());
|
||||
batch.setExecutor(executorService);
|
||||
batch.start();
|
||||
runningTask.set(batch);
|
||||
startBatch(checksListView.getSelectionModel().getSelectedItems());
|
||||
}
|
||||
|
||||
@FXML
|
||||
public synchronized void runAllChecks() {
|
||||
startBatch(checksListView.getItems());
|
||||
}
|
||||
|
||||
private void startBatch(Iterable<HealthCheckTask> batch) {
|
||||
Preconditions.checkState(runningTask.get() == null);
|
||||
var batch = new BatchService(checksListView.getItems());
|
||||
batch.setExecutor(executorService);
|
||||
batch.start();
|
||||
runningTask.set(batch);
|
||||
var batchService = new BatchService(batch);
|
||||
batchService.setExecutor(executorService);
|
||||
batchService.start();
|
||||
runningTask.set(batchService);
|
||||
}
|
||||
|
||||
@FXML
|
||||
|
||||
@@ -18,20 +18,24 @@
|
||||
<Insets topRightBottomLeft="12"/>
|
||||
</padding>
|
||||
<children>
|
||||
<HBox>
|
||||
<VBox minWidth="80">
|
||||
<HBox spacing="12">
|
||||
<VBox minWidth="80" spacing="6">
|
||||
<Label fx:id="listHeading" text="Health checks"/>
|
||||
<ListView fx:id="checksListView"/>
|
||||
<!-- TODO: clean up button states: -->
|
||||
<Button text="TODO: run selected" onAction="#runSelectedChecks" disable="${!controller.anyCheckSelected}" visible="${controller.readyToRun}" managed="${controller.readyToRun}" maxWidth="Infinity"/>
|
||||
<Button text="TODO: run all" onAction="#runAllChecks" visible="${controller.readyToRun}" managed="${controller.readyToRun}" maxWidth="Infinity"/>
|
||||
<Button text="%generic.button.cancel" onAction="#cancelCheck" visible="${controller.running}" managed="${controller.running}" maxWidth="Infinity"/>
|
||||
</VBox>
|
||||
<fx:include source="/fxml/health_check_details.fxml" visible="${controller.anyCheckSelected}" managed="${controller.anyCheckSelected}"/>
|
||||
<!-- Maybe use class Seperator ?-->
|
||||
<fx:include source="/fxml/health_check_details.fxml" visible="${controller.anyCheckSelected}" managed="${controller.anyCheckSelected}"/>
|
||||
<VBox alignment="CENTER" >
|
||||
<Label text="TODO: Select a Check from the left list to get more info." wrapText="true" alignment="CENTER" visible="${!controller.anyCheckSelected}" managed="${!controller.anyCheckSelected}" />
|
||||
</VBox>
|
||||
</HBox>
|
||||
<ButtonBar buttonMinWidth="120" buttonOrder="+X">
|
||||
<ButtonBar buttonMinWidth="120" buttonOrder="+CX">
|
||||
<buttons>
|
||||
<Button text="TODO Export Results" ButtonBar.buttonData="NEXT_FORWARD" disable="${!controller.finished}" onAction="#exportResults"/>
|
||||
<!-- Buttons have a prefWidth to prevent uneven interface -->
|
||||
<Button prefWidth="20" text="%generic.button.cancel" ButtonBar.buttonData="CANCEL_CLOSE" onAction="#cancelCheck" visible="${controller.running}" managed="${controller.running}" />
|
||||
<Button prefWidth="20" text="TODO: run all" ButtonBar.buttonData="NEXT_FORWARD" onAction="#runAllChecks" visible="${controller.readyToRun && !controller.anyCheckSelected}" managed="${controller.readyToRun && !controller.anyCheckSelected}" />
|
||||
<Button prefWidth="20" text="TODO: run selected" ButtonBar.buttonData="NEXT_FORWARD" onAction="#runSelectedChecks" visible="${controller.readyToRun && controller.anyCheckSelected}" managed="${controller.readyToRun && controller.anyCheckSelected}" />
|
||||
<Button text="TODO Export Results" ButtonBar.buttonData="NEXT_FORWARD" disable="${!controller.finished}" visible="${!controller.readyToRun}" managed="${!controller.readyToRun}" onAction="#exportResults"/>
|
||||
</buttons>
|
||||
</ButtonBar>
|
||||
</children>
|
||||
|
||||
@@ -148,6 +148,8 @@ migration.impossible.moreInfo=The vault can still be opened with an older versio
|
||||
|
||||
# Health Check
|
||||
health.title=Vault Check
|
||||
health.check.runSingleButton=Run selected Check
|
||||
health.check.runAllButton=Run all Checks
|
||||
|
||||
# Preferences
|
||||
preferences.title=Preferences
|
||||
|
||||
Reference in New Issue
Block a user