mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-05-17 18:21:26 +00:00
Add icon to severity column
This commit is contained in:
@@ -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());
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user