Skip to content

Commit 8f2b5ea

Browse files
committed
UI/UX: Add index and log status icon at result of alert log monitoring
1 parent 2886b1a commit 8f2b5ea

File tree

2 files changed

+60
-10
lines changed

2 files changed

+60
-10
lines changed

src/main/java/root/javafx/CustomView/AlertLogListViewCell.java

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22

33
import java.io.IOException;
44

5+
import de.jensd.fx.glyphs.fontawesome.FontAwesomeIconView;
56
import javafx.fxml.FXML;
67
import javafx.fxml.FXMLLoader;
78
import javafx.scene.control.Label;
89
import javafx.scene.control.ListCell;
910
import javafx.scene.control.TextArea;
1011
import javafx.scene.layout.AnchorPane;
12+
import javafx.scene.paint.Paint;
1113
import javafx.scene.text.Text;
1214
import lombok.extern.slf4j.Slf4j;
1315
import 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
}

src/main/resources/fxml/AlertLogListViewCell.fxml

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,55 @@
33
<?import com.jfoenix.controls.JFXTextArea?>
44
<?import de.jensd.fx.glyphs.fontawesome.FontAwesomeIconView?>
55
<?import java.lang.String?>
6+
<?import javafx.geometry.Insets?>
67
<?import javafx.scene.control.Label?>
78
<?import javafx.scene.control.Separator?>
89
<?import javafx.scene.layout.AnchorPane?>
910
<?import javafx.scene.layout.HBox?>
1011

1112
<AnchorPane fx:id="rootAP" stylesheets="@../css/javaFx.css" xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1">
1213
<children>
13-
<HBox maxHeight="15.0" minHeight="15.0" prefHeight="15.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
14+
<AnchorPane AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
1415
<children>
15-
<Label fx:id="logTimeLabel" graphicTextGap="8.0" maxHeight="15.0" minHeight="15.0" prefHeight="15.0" stylesheets="@../css/javaFx.css">
16-
<graphic>
17-
<FontAwesomeIconView fill="#183279" glyphName="CLOCK_ALT" size="10" />
18-
</graphic>
16+
<HBox alignment="CENTER_LEFT" AnchorPane.bottomAnchor="5.0" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="5.0">
17+
<children>
18+
<Label fx:id="logTimeLabel" graphicTextGap="8.0" maxHeight="15.0" minHeight="15.0" minWidth="200.0" mnemonicParsing="true" prefHeight="15.0" stylesheets="@../css/javaFx.css" text="logTimeStamp" wrapText="true" HBox.hgrow="ALWAYS">
19+
<graphic>
20+
<FontAwesomeIconView fill="#183279" glyphName="CLOCK_ALT" size="10" />
21+
</graphic>
22+
<styleClass>
23+
<String fx:value="basic-font" />
24+
<String fx:value="bold" />
25+
</styleClass>
26+
</Label>
27+
</children>
28+
</HBox>
29+
<Label fx:id="logIndexLabel" alignment="CENTER" contentDisplay="RIGHT" style="-fx-font-size: 10px;" text="logIndex" AnchorPane.bottomAnchor="5.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="5.0">
30+
<padding>
31+
<Insets right="5.0" />
32+
</padding>
1933
<styleClass>
2034
<String fx:value="basic-font" />
2135
<String fx:value="bold" />
2236
</styleClass>
37+
<graphic>
38+
<FontAwesomeIconView fx:id="logStatusIcon" fill="#d92a2a" glyphName="CIRCLE" size="10" />
39+
</graphic>
2340
</Label>
41+
<Separator AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" />
2442
</children>
25-
</HBox>
26-
<Separator AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="16.0" />
27-
<JFXTextArea fx:id="logContentTA" labelFloat="true" prefColumnCount="1" prefRowCount="1" stylesheets="@../css/javaFx.css" wrapText="true" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="17.0">
43+
<padding>
44+
<Insets left="5.0" right="5.0" />
45+
</padding>
46+
</AnchorPane>
47+
<JFXTextArea fx:id="logContentTA" editable="false" focusTraversable="false" labelFloat="true" pickOnBounds="false" prefColumnCount="1" prefRowCount="1" stylesheets="@../css/javaFx.css" wrapText="true" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="22.0">
2848
<styleClass>
2949
<String fx:value="basic-font" />
3050
<String fx:value="gray-scrollbar" />
3151
</styleClass>
52+
<padding>
53+
<Insets left="5.0" right="5.0" top="2.0" />
54+
</padding>
3255
</JFXTextArea>
3356
</children>
3457
</AnchorPane>

0 commit comments

Comments
 (0)