Search in sources :

Example 1 with FontAwesomeIcon

use of de.jensd.fx.glyphs.fontawesome.FontAwesomeIcon in project dolphin-platform by canoo.

the class LogListView method update.

private void update() {
    final LogMessage message = logMessage.get();
    if (message == null) {
        messageLabel.setText(null);
        levelIconView.setIcon(FontAwesomeIcon.QUESTION);
        levelIconView.setFill(Color.TRANSPARENT);
        timestampLabel.setText(null);
        detailsLabel.setText(null);
        detailsLabel.setVisible(false);
        detailsLabel.setManaged(false);
    } else {
        messageLabel.setText(message.getMessage());
        final FontAwesomeIcon icon = Optional.ofNullable(message.getLevel()).map(l -> {
            if (l.equals(Level.INFO)) {
                return FontAwesomeIcon.INFO_CIRCLE;
            } else if (l.equals(Level.DEBUG)) {
                return FontAwesomeIcon.BUG;
            } else if (l.equals(Level.ERROR)) {
                return FontAwesomeIcon.TIMES_CIRCLE;
            } else if (l.equals(Level.TRACE)) {
                return FontAwesomeIcon.MINUS_CIRCLE;
            } else if (l.equals(Level.WARN)) {
                return FontAwesomeIcon.WARNING;
            } else {
                return FontAwesomeIcon.QUESTION;
            }
        }).orElse(FontAwesomeIcon.QUESTION);
        levelIconView.setIcon(icon);
        final Paint iconFill = Optional.ofNullable(message.getLevel()).map(l -> {
            if (l.equals(Level.INFO)) {
                return Color.LIGHTBLUE;
            } else if (l.equals(Level.DEBUG)) {
                return Color.LIGHTBLUE;
            } else if (l.equals(Level.ERROR)) {
                return Color.RED;
            } else if (l.equals(Level.TRACE)) {
                return Color.LIGHTBLUE;
            } else if (l.equals(Level.WARN)) {
                return Color.ORANGE;
            } else {
                return Color.LIGHTBLUE;
            }
        }).orElse(Color.LIGHTBLUE);
        levelIconView.setFill(iconFill);
        final String timestamp = Optional.ofNullable(message.getTimestamp()).map(t -> DateTimeFormatter.ofPattern("dd/MM/yyyy - hh:mm:ss.SSS").format(t)).orElse("unknown");
        timestampLabel.setText(timestamp);
        detailsLabel.setText(message.getExceptionDetail());
        if (Optional.ofNullable(detailsLabel.getText()).orElse("").length() == 0) {
            detailsLabel.setVisible(false);
            detailsLabel.setManaged(false);
        } else {
            detailsLabel.setVisible(true);
            detailsLabel.setManaged(true);
        }
    }
}
Also used : HBox(javafx.scene.layout.HBox) Color(javafx.scene.paint.Color) ObjectProperty(javafx.beans.property.ObjectProperty) Label(javafx.scene.control.Label) VBox(javafx.scene.layout.VBox) LogMessage(com.canoo.platform.logging.spi.LogMessage) Priority(javafx.scene.layout.Priority) Insets(javafx.geometry.Insets) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) Paint(javafx.scene.paint.Paint) Level(org.slf4j.event.Level) DateTimeFormatter(java.time.format.DateTimeFormatter) FontAwesomeIcon(de.jensd.fx.glyphs.fontawesome.FontAwesomeIcon) FontAwesomeIconView(de.jensd.fx.glyphs.fontawesome.FontAwesomeIconView) Optional(java.util.Optional) LogMessage(com.canoo.platform.logging.spi.LogMessage) FontAwesomeIcon(de.jensd.fx.glyphs.fontawesome.FontAwesomeIcon) Paint(javafx.scene.paint.Paint)

Aggregations

LogMessage (com.canoo.platform.logging.spi.LogMessage)1 FontAwesomeIcon (de.jensd.fx.glyphs.fontawesome.FontAwesomeIcon)1 FontAwesomeIconView (de.jensd.fx.glyphs.fontawesome.FontAwesomeIconView)1 DateTimeFormatter (java.time.format.DateTimeFormatter)1 Optional (java.util.Optional)1 ObjectProperty (javafx.beans.property.ObjectProperty)1 SimpleObjectProperty (javafx.beans.property.SimpleObjectProperty)1 Insets (javafx.geometry.Insets)1 Label (javafx.scene.control.Label)1 HBox (javafx.scene.layout.HBox)1 Priority (javafx.scene.layout.Priority)1 VBox (javafx.scene.layout.VBox)1 Color (javafx.scene.paint.Color)1 Paint (javafx.scene.paint.Paint)1 Level (org.slf4j.event.Level)1