Explorar o código

Add column with action button

Armin Schrenk %!s(int64=4) %!d(string=hai) anos
pai
achega
2b332c3831

+ 4 - 0
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<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 */
 

+ 30 - 0
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<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);
+		}
+	}
+
+}

+ 3 - 3
main/ui/src/main/resources/fxml/health_check_details.fxml

@@ -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>