mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-08-20 06:06:02 +00:00
Add column with action button
This commit is contained in:
@@ -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<DiagnosticResultAction> resultsTableView;
|
||||
public TableColumn<DiagnosticResultAction, String> resultDescriptionColumn;
|
||||
public TableColumn<DiagnosticResultAction, String> resultSeverityColumn;
|
||||
public TableColumn<DiagnosticResultAction, Runnable> resultActionColumn;
|
||||
|
||||
@Inject
|
||||
public CheckDetailController(ObjectProperty<HealthCheckTask> 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 */
|
||||
|
||||
|
||||
@@ -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<DiagnosticResultAction, Runnable> {
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -13,9 +13,9 @@
|
||||
<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"/>
|
||||
<!--TableColumn fx:id="resultAction" text="Action" /-->
|
||||
<TableColumn fx:id="resultDescriptionColumn" text="Info" editable="false" maxWidth="Infinity"/>
|
||||
<TableColumn fx:id="resultSeverityColumn" text="Severity" editable="false" />
|
||||
<TableColumn fx:id="resultActionColumn" text="Action" editable="false"/>
|
||||
</columns>
|
||||
</TableView>
|
||||
</VBox>
|
||||
Reference in New Issue
Block a user