Add icon to severity column

This commit is contained in:
Armin Schrenk
2021-05-18 17:12:37 +02:00
parent 168f9b9fb9
commit a7133dbebe
2 changed files with 38 additions and 2 deletions

View File

@@ -2,6 +2,7 @@ package org.cryptomator.ui.health;
import com.tobiasdiez.easybind.EasyBind;
import com.tobiasdiez.easybind.optional.OptionalBinding;
import org.cryptomator.cryptofs.health.api.DiagnosticResult;
import org.cryptomator.ui.common.FxController;
import javax.inject.Inject;
@@ -27,7 +28,7 @@ public class CheckDetailController implements FxController {
public TableView<DiagnosticResultAction> resultsTableView;
public TableColumn<DiagnosticResultAction, String> resultDescriptionColumn;
public TableColumn<DiagnosticResultAction, String> resultSeverityColumn;
public TableColumn<DiagnosticResultAction, DiagnosticResult.Severity> resultSeverityColumn;
public TableColumn<DiagnosticResultAction, Runnable> resultActionColumn;
@Inject
@@ -50,7 +51,8 @@ public class CheckDetailController implements FxController {
public void initialize() {
resultsTableView.itemsProperty().bind(results);
resultDescriptionColumn.setCellValueFactory(cellFeatures -> new SimpleStringProperty(cellFeatures.getValue().getDescription()));
resultSeverityColumn.setCellValueFactory(cellFeatures -> new SimpleStringProperty(cellFeatures.getValue().getSeverity().name()));
resultSeverityColumn.setCellValueFactory(cellFeatures -> new SimpleObjectProperty<>(cellFeatures.getValue().getSeverity()));
resultSeverityColumn.setCellFactory(column -> new ResultSeverityTableCell());
resultActionColumn.setCellValueFactory(cellFeatures -> new SimpleObjectProperty<>(cellFeatures.getValue()));
resultActionColumn.setCellFactory(column -> new ResultActionTableCell());
}

View File

@@ -0,0 +1,34 @@
package org.cryptomator.ui.health;
import org.cryptomator.cryptofs.health.api.DiagnosticResult;
import org.cryptomator.ui.controls.FontAwesome5Icon;
import org.cryptomator.ui.controls.FontAwesome5IconView;
import javafx.scene.control.TableCell;
public class ResultSeverityTableCell extends TableCell<DiagnosticResultAction, DiagnosticResult.Severity> {
private FontAwesome5IconView iconView;
ResultSeverityTableCell() {
iconView = new FontAwesome5IconView();
}
@Override
protected void updateItem(DiagnosticResult.Severity item, boolean empty) {
super.updateItem(item, empty);
if (empty || item == null) {
setText(null);
setGraphic(null);
} else {
iconView.glyphProperty().set(switch (item) {
case INFO -> FontAwesome5Icon.INFO_CIRCLE;
case GOOD -> FontAwesome5Icon.CHECK;
case WARN -> FontAwesome5Icon.EXCLAMATION_TRIANGLE;
case CRITICAL -> FontAwesome5Icon.TIMES;
});
setGraphic(iconView);
setText(item.name());
}
}
}