mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-04-23 11:06:56 -04:00
hide/disable elements if not relevant in current state
This commit is contained in:
@@ -33,10 +33,12 @@ public class CheckListController implements FxController {
|
||||
private final SimpleObjectProperty<Worker<?>> runningTask;
|
||||
private final Binding<Boolean> running;
|
||||
private final BooleanBinding anyCheckSelected;
|
||||
private final BooleanBinding readyToRun;
|
||||
|
||||
/* FXML */
|
||||
public ListView<HealthCheckTask> checksListView;
|
||||
|
||||
|
||||
@Inject
|
||||
public CheckListController(Lazy<Collection<HealthCheckTask>> tasks, ReportWriter reportWriteTask, ObjectProperty<HealthCheckTask> selectedTask, ExecutorService executorService) {
|
||||
this.tasks = FXCollections.observableArrayList(tasks.get());
|
||||
@@ -46,6 +48,7 @@ public class CheckListController implements FxController {
|
||||
this.runningTask = new SimpleObjectProperty<>();
|
||||
this.running = EasyBind.wrapNullable(runningTask).mapObservable(Worker::runningProperty).orElse(false);
|
||||
this.anyCheckSelected = selectedTask.isNotNull();
|
||||
this.readyToRun = runningTask.isNull();
|
||||
}
|
||||
|
||||
@FXML
|
||||
@@ -87,9 +90,17 @@ 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();
|
||||
}
|
||||
@@ -105,5 +116,4 @@ public class CheckListController implements FxController {
|
||||
public BooleanBinding anyCheckSelectedProperty() {
|
||||
return anyCheckSelected;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -23,9 +23,9 @@
|
||||
<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.running || !controller.anyCheckSelected}" maxWidth="Infinity"/>
|
||||
<Button text="TODO: run all" onAction="#runAllChecks" disable="${controller.running}" maxWidth="Infinity"/>
|
||||
<Button text="%generic.button.cancel" onAction="#cancelCheck" disable="${!controller.running}" maxWidth="Infinity"/>
|
||||
<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}"/>
|
||||
</HBox>
|
||||
|
||||
Reference in New Issue
Block a user