From 2b332c3831898c625408d3c3f86fb265fbf4d6b2 Mon Sep 17 00:00:00 2001 From: Armin Schrenk Date: Tue, 18 May 2021 16:53:48 +0200 Subject: [PATCH] Add column with action button --- .../ui/health/CheckDetailController.java | 4 +++ .../ui/health/ResultActionTableCell.java | 30 +++++++++++++++++++ .../resources/fxml/health_check_details.fxml | 6 ++-- 3 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 main/ui/src/main/java/org/cryptomator/ui/health/ResultActionTableCell.java diff --git a/main/ui/src/main/java/org/cryptomator/ui/health/CheckDetailController.java b/main/ui/src/main/java/org/cryptomator/ui/health/CheckDetailController.java index a7212681a..c4943d9c8 100644 --- a/main/ui/src/main/java/org/cryptomator/ui/health/CheckDetailController.java +++ b/main/ui/src/main/java/org/cryptomator/ui/health/CheckDetailController.java @@ -8,6 +8,7 @@ import javax.inject.Inject; 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.collections.FXCollections; import javafx.collections.ObservableList; @@ -27,6 +28,7 @@ public class CheckDetailController implements FxController { public TableView resultsTableView; public TableColumn resultDescriptionColumn; public TableColumn resultSeverityColumn; + public TableColumn resultActionColumn; @Inject public CheckDetailController(ObjectProperty selectedTask) { @@ -49,6 +51,8 @@ public class CheckDetailController implements FxController { resultsTableView.itemsProperty().bind(results); resultDescriptionColumn.setCellValueFactory(cellFeatures -> new SimpleStringProperty(cellFeatures.getValue().getDescription())); resultSeverityColumn.setCellValueFactory(cellFeatures -> new SimpleStringProperty(cellFeatures.getValue().getSeverity().name())); + resultActionColumn.setCellValueFactory(cellFeatures -> new SimpleObjectProperty<>(cellFeatures.getValue())); + resultActionColumn.setCellFactory(column -> new ResultActionTableCell()); } /* Getter/Setter */ diff --git a/main/ui/src/main/java/org/cryptomator/ui/health/ResultActionTableCell.java b/main/ui/src/main/java/org/cryptomator/ui/health/ResultActionTableCell.java new file mode 100644 index 000000000..5781e514b --- /dev/null +++ b/main/ui/src/main/java/org/cryptomator/ui/health/ResultActionTableCell.java @@ -0,0 +1,30 @@ +package org.cryptomator.ui.health; + +import javafx.geometry.Pos; +import javafx.scene.control.Button; +import javafx.scene.control.TableCell; + +class ResultActionTableCell extends TableCell { + + private Button button; + + ResultActionTableCell() { + button = new Button(); + setGraphic(null); + } + + @Override + protected void updateItem(Runnable item, boolean empty) { + super.updateItem(item, empty); + if (empty || item == null) { + setText(null); + setGraphic(null); + } else { + setGraphic(button); + button.setOnAction(event -> item.run()); + button.setText("FIXME"); //FIXME + button.setAlignment(Pos.CENTER); + } + } + +} diff --git a/main/ui/src/main/resources/fxml/health_check_details.fxml b/main/ui/src/main/resources/fxml/health_check_details.fxml index bf884f6dc..1cff49dd8 100644 --- a/main/ui/src/main/resources/fxml/health_check_details.fxml +++ b/main/ui/src/main/resources/fxml/health_check_details.fxml @@ -13,9 +13,9 @@ - - - + + + \ No newline at end of file