22
33import java .io .IOException ;
44
5+ import de .jensd .fx .glyphs .fontawesome .FontAwesomeIconView ;
56import javafx .fxml .FXML ;
67import javafx .fxml .FXMLLoader ;
78import javafx .scene .control .Label ;
89import javafx .scene .control .ListCell ;
910import javafx .scene .control .TextArea ;
1011import javafx .scene .layout .AnchorPane ;
12+ import javafx .scene .paint .Paint ;
1113import javafx .scene .text .Text ;
1214import lombok .extern .slf4j .Slf4j ;
1315import root .core .domain .Log ;
@@ -22,6 +24,10 @@ public class AlertLogListViewCell extends ListCell<Log> {
2224 @ FXML
2325 Label logTimeLabel ;
2426 @ FXML
27+ Label logIndexLabel ;
28+ @ FXML
29+ FontAwesomeIconView logStatusIcon ;
30+ @ FXML
2531 TextArea logContentTA ;
2632
2733 private Text textHolder = new Text ();
@@ -44,14 +50,29 @@ protected void updateItem(Log logObj, boolean empty) {
4450 }
4551 }
4652
53+
54+ boolean isErrorLog = isErrorLog (logObj .getFullLogString ());
55+
56+ // logTimeStamp
57+ logTimeLabel .setText (logObj .getLogTimeStamp ());
58+
59+ // logIndex
60+ logIndexLabel .setText (String .valueOf (logObj .getIndex () + 1 ));
61+
62+ // logStatusIcon
63+ logStatusIcon .setFill (Paint .valueOf (isErrorLog ? "#d92a2a" : "#4d9c84" ));
64+
65+ // logContent
4766 logContentTA .widthProperty ().addListener ((observable , oldValue , newValue ) -> {
4867 Text text = new Text ();
4968 text .setWrappingWidth (newValue .doubleValue ());
5069 text .setText (logContentTA .getText ());
5170 logContentTA .setPrefHeight (text .getLayoutBounds ().getHeight () * 1.35 );
5271 });
53-
54- logTimeLabel .setText (logObj .getLogTimeStamp ());
72+
73+ if (isErrorLog ) {
74+ logContentTA .setStyle ("-fx-background-color: #ffbfbf" );
75+ }
5576 logContentTA .setText (logObj .getFullLogString ());
5677 logContentTA .setEditable (false );
5778 logContentTA .setWrapText (true );
@@ -60,6 +81,12 @@ protected void updateItem(Log logObj, boolean empty) {
6081
6182 setText (null );
6283 setGraphic (rootAP );
84+ setStyle ("-fx-padding: 0" );
6385 }
6486 }
87+
88+ private boolean isErrorLog (String logContent ) {
89+ // TODO Remove hard-coding that identifying error log
90+ return logContent .contains ("ORA-" );
91+ }
6592}
0 commit comments