mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-05-18 18:51:26 +00:00
hide results until task is started
This commit is contained in:
@@ -7,6 +7,7 @@ import org.cryptomator.ui.common.FxController;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javafx.beans.binding.Binding;
|
||||
import javafx.beans.binding.BooleanBinding;
|
||||
import javafx.beans.property.ObjectProperty;
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
import javafx.collections.FXCollections;
|
||||
@@ -18,10 +19,11 @@ import javafx.scene.control.TableView;
|
||||
|
||||
public class CheckDetailController implements FxController {
|
||||
|
||||
private final Binding<ObservableList<DiagnosticResult>> selectedResults;
|
||||
private final OptionalBinding<Worker.State> selectedTaskState;
|
||||
private final Binding<String> selectedTaskName;
|
||||
private final Binding<String> selectedTaskDescription;
|
||||
private final Binding<ObservableList<DiagnosticResult>> results;
|
||||
private final OptionalBinding<Worker.State> taskState;
|
||||
private final Binding<String> taskName;
|
||||
private final Binding<String> taskDescription;
|
||||
private final BooleanBinding producingResults;
|
||||
|
||||
public TableView<DiagnosticResult> resultsTableView;
|
||||
public TableColumn<DiagnosticResult, String> resultDescriptionColumn;
|
||||
@@ -29,35 +31,50 @@ public class CheckDetailController implements FxController {
|
||||
|
||||
@Inject
|
||||
public CheckDetailController(ObjectProperty<HealthCheckTask> selectedTask) {
|
||||
this.selectedResults = EasyBind.wrapNullable(selectedTask).map(HealthCheckTask::results).orElse(FXCollections.emptyObservableList());
|
||||
this.selectedTaskState = EasyBind.wrapNullable(selectedTask).mapObservable(HealthCheckTask::stateProperty);
|
||||
this.selectedTaskName = EasyBind.wrapNullable(selectedTask).map(HealthCheckTask::getTitle).orElse("");
|
||||
this.selectedTaskDescription = EasyBind.wrapNullable(selectedTask).map(task -> task.getCheck().toString()).orElse("");
|
||||
this.results = EasyBind.wrapNullable(selectedTask).map(HealthCheckTask::results).orElse(FXCollections.emptyObservableList());
|
||||
this.taskState = EasyBind.wrapNullable(selectedTask).mapObservable(HealthCheckTask::stateProperty);
|
||||
this.taskName = EasyBind.wrapNullable(selectedTask).map(HealthCheckTask::getTitle).orElse("");
|
||||
this.taskDescription = EasyBind.wrapNullable(selectedTask).map(task -> task.getCheck().toString()).orElse("");
|
||||
this.producingResults = taskState.filter(this::producesResults).isPresent();
|
||||
}
|
||||
|
||||
private boolean producesResults(Worker.State state) {
|
||||
return switch (state) {
|
||||
case SCHEDULED, RUNNING, SUCCEEDED -> true;
|
||||
case READY, CANCELLED, FAILED -> false;
|
||||
};
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void initialize() {
|
||||
resultsTableView.itemsProperty().bind(selectedResults);
|
||||
resultsTableView.itemsProperty().bind(results);
|
||||
resultDescriptionColumn.setCellValueFactory(cellFeatures -> new SimpleStringProperty(cellFeatures.getValue().toString()));
|
||||
resultSeverityColumn.setCellValueFactory(cellFeatures -> new SimpleStringProperty(cellFeatures.getValue().getServerity().name()));
|
||||
}
|
||||
|
||||
/* Getter/Setter */
|
||||
|
||||
public String getSelectedTaskName() {
|
||||
return selectedTaskName.getValue();
|
||||
|
||||
public String getTaskName() {
|
||||
return taskName.getValue();
|
||||
}
|
||||
|
||||
public Binding<String> selectedTaskNameProperty() {
|
||||
return selectedTaskName;
|
||||
public Binding<String> taskNameProperty() {
|
||||
return taskName;
|
||||
}
|
||||
|
||||
public String getSelectedTaskDescription() {
|
||||
return selectedTaskDescription.getValue();
|
||||
public String getTaskDescription() {
|
||||
return taskDescription.getValue();
|
||||
}
|
||||
|
||||
public Binding<String> selectedTaskDescriptionProperty() {
|
||||
return selectedTaskDescription;
|
||||
public Binding<String> taskDescriptionProperty() {
|
||||
return taskDescription;
|
||||
}
|
||||
|
||||
public boolean isProducingResults() {
|
||||
return producingResults.get();
|
||||
}
|
||||
|
||||
public BooleanBinding producingResultsProperty() {
|
||||
return producingResults;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,10 +9,9 @@
|
||||
xmlns="http://javafx.com/javafx"
|
||||
fx:controller="org.cryptomator.ui.health.CheckDetailController"
|
||||
spacing="6">
|
||||
<Label fx:id="checkTitle" styleClass="label-large" text="${controller.selectedTaskName}"/>
|
||||
<Text fx:id="checkDescription" styleClass="label" text="${controller.selectedTaskDescription}"/>
|
||||
<!-- TODO hide if state != succeeded: -->
|
||||
<TableView fx:id="resultsTableView">
|
||||
<Label fx:id="checkTitle" styleClass="label-large" text="${controller.taskName}"/>
|
||||
<Text fx:id="checkDescription" styleClass="label" text="${controller.taskDescription}"/>
|
||||
<TableView fx:id="resultsTableView" visible="${controller.producingResults}" managed="${controller.producingResults}">
|
||||
<columns>
|
||||
<TableColumn fx:id="resultDescriptionColumn" text="Info" editable="false"/>
|
||||
<TableColumn fx:id="resultSeverityColumn" text="Severity" editable="false"/>
|
||||
|
||||
Reference in New Issue
Block a user