Skip to content

Commit f80d991

Browse files
authored
Merge pull request #220 from Dokyeongyun/ft-220421-alertLogMenuUI
Ft 220421 alert log menu UI
2 parents 2433140 + f63ce11 commit f80d991

File tree

6 files changed

+242
-108
lines changed

6 files changed

+242
-108
lines changed

src/main/java/root/core/domain/Log.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
@AllArgsConstructor
1212
@Data
1313
public class Log {
14+
private int index;
1415
private String logTimeStamp;
1516
private List<String> logContents;
1617

@@ -20,8 +21,11 @@ public int getTotalLineCount() {
2021

2122
public String getFullLogString() {
2223
StringBuffer result = new StringBuffer();
23-
for(String s : logContents) {
24-
result.append(s);
24+
for (int i = 0; i < logContents.size(); i++) {
25+
result.append(logContents.get(i));
26+
if (i != logContents.size()) {
27+
result.append(System.lineSeparator());
28+
}
2529
}
2630
return result.toString();
2731
}

src/main/java/root/core/usecase/implement/ServerMonitoringUsecaseImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ public AlertLog getAlertLogDuringPeriod(AlertLogCommand alc, String startDate, S
327327
}
328328

329329
if (i != readStartIndex) {
330-
alertLog.addLog(new Log(logTimeStamp, logContents));
330+
alertLog.addLog(new Log(alertLog.getAlertLogs().size(), logTimeStamp, logContents));
331331
logContents = new ArrayList<>();
332332
logTimeStamp = line;
333333
}

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

Lines changed: 70 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,48 +2,91 @@
22

33
import java.io.IOException;
44

5-
import com.jfoenix.controls.JFXTextArea;
6-
5+
import de.jensd.fx.glyphs.fontawesome.FontAwesomeIconView;
76
import javafx.fxml.FXML;
87
import javafx.fxml.FXMLLoader;
98
import javafx.scene.control.Label;
109
import javafx.scene.control.ListCell;
10+
import javafx.scene.control.TextArea;
1111
import javafx.scene.layout.AnchorPane;
12+
import javafx.scene.paint.Paint;
13+
import javafx.scene.text.Text;
14+
import lombok.extern.slf4j.Slf4j;
1215
import root.core.domain.Log;
1316
import root.javafx.DI.DependencyInjection;
1417

18+
@Slf4j
1519
public class AlertLogListViewCell extends ListCell<Log> {
1620
private FXMLLoader loader;
17-
18-
@FXML AnchorPane rootAP;
19-
@FXML Label logTimeLabel;
20-
@FXML JFXTextArea logContentTA;
21-
21+
22+
@FXML
23+
AnchorPane rootAP;
24+
@FXML
25+
Label logTimeLabel;
26+
@FXML
27+
Label logIndexLabel;
28+
@FXML
29+
FontAwesomeIconView logStatusIcon;
30+
@FXML
31+
TextArea logContentTA;
32+
33+
private Text textHolder = new Text();
34+
2235
@Override
23-
protected void updateItem(Log log, boolean empty) {
24-
super.updateItem(log, empty);
25-
26-
if(empty || log == null) {
27-
setText(null);
28-
setGraphic(null);
29-
} else {
30-
if (loader == null) {
31-
FXMLLoader loader = DependencyInjection.getLoader("/fxml/AlertLogListViewCell.fxml");
36+
protected void updateItem(Log logObj, boolean empty) {
37+
super.updateItem(logObj, empty);
38+
39+
if (empty || logObj == null) {
40+
setText(null);
41+
setGraphic(null);
42+
} else {
43+
if (loader == null) {
44+
FXMLLoader loader = DependencyInjection.getLoader("/fxml/AlertLogListViewCell.fxml");
3245
loader.setController(this);
33-
try {
46+
try {
3447
loader.load();
3548
} catch (IOException e) {
36-
e.printStackTrace();
49+
log.error(e.getMessage());
3750
}
38-
}
39-
40-
logTimeLabel.setText(log.getLogTimeStamp());
41-
logContentTA.setPrefRowCount(log.getTotalLineCount());
42-
logContentTA.setText(log.getFullLogString());
43-
44-
setText(null);
45-
setGraphic(rootAP);
46-
}
51+
}
52+
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
66+
logContentTA.widthProperty().addListener((observable, oldValue, newValue) -> {
67+
Text text = new Text();
68+
text.setWrappingWidth(newValue.doubleValue());
69+
text.setText(logContentTA.getText());
70+
logContentTA.setPrefHeight(text.getLayoutBounds().getHeight() * 1.35);
71+
});
72+
73+
if(isErrorLog) {
74+
logContentTA.setStyle("-fx-background-color: #ffbfbf");
75+
}
76+
logContentTA.setText(logObj.getFullLogString());
77+
logContentTA.setEditable(false);
78+
logContentTA.setWrapText(true);
79+
80+
textHolder.textProperty().bind(logContentTA.textProperty());
81+
82+
setText(null);
83+
setGraphic(rootAP);
84+
setStyle("-fx-padding: 0");
85+
}
4786
}
4887

88+
private boolean isErrorLog(String logContent) {
89+
// TODO Remove hard-coding that identifying error log
90+
return logContent.contains("ORA-");
91+
}
4992
}

src/main/resources/css/javaFx.css

Lines changed: 63 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55

66
.button-raised{
77
-fx-padding: 0.7em 0.57em;
8-
-fx-font-size: 14px;
8+
-fx-font-size: 14.0px;
99
-jfx-button-type: RAISED;
10-
-fx-background-color: rgb(77,102,204);
11-
-fx-pref-width: 200;
10+
-fx-background-color: rgb(77.0,102.0,204.0);
11+
-fx-pref-width: 200.0;
1212
-fx-text-fill: WHITE;
1313
}
1414

@@ -36,19 +36,19 @@
3636
/* TabPane */
3737
.tab-pane > .tab-header-area > .headers-region > .tab:top {
3838
-fx-border-color: #a3a7a8;
39-
-fx-border-radius: 5 5 0 0;
39+
-fx-border-radius: 5.0 5.0 0.0 0.0;
4040
-fx-background-color: transparent;
41-
-fx-pref-height: 40px;
42-
-fx-background-insets: 0;
41+
-fx-pref-height: 40.0px;
42+
-fx-background-insets: 0.0;
4343
}
4444

4545
.tab-pane > .tab-header-area > .headers-region > .tab:selected:top {
4646
-fx-border-color: #2381E9 #a3a7a8 #a3a7a8 #a3a7a8;
47-
-fx-border-width: 5 1 1 1;
48-
-fx-border-radius: 5 5 0 0;
47+
-fx-border-width: 5.0 1.0 1.0 1.0;
48+
-fx-border-radius: 5.0 5.0 0.0 0.0;
4949
-fx-background-color: white;
50-
-fx-pref-height: 40px;
51-
-fx-background-insets: 0;
50+
-fx-pref-height: 40.0px;
51+
-fx-background-insets: 0.0;
5252
}
5353

5454
.tab-pane > .tab-header-area > .headers-region > .tab:selected > .tab-container > .tab-label {
@@ -67,16 +67,16 @@
6767
.tab-pane > .tab-header-area > .tab-header-background {
6868
-fx-background-color: white;
6969
-fx-border-color: #a3a7a8;
70-
-fx-border-width: 0 0 1 0;
71-
-fx-background-insets: 0;
72-
-fx-pref-height: 45px;
70+
-fx-border-width: 0.0 0.0 1.0 0.0;
71+
-fx-background-insets: 0.0;
72+
-fx-pref-height: 45.0px;
7373
}
7474

7575
/* TextField */
7676
.text-field {
7777
-fx-background-color: -fx-text-box-border, white ;
78-
-fx-background-insets: 0, 0.5 0.5 0.5 0.5 ;
79-
-fx-background-radius: 0 ;
78+
-fx-background-insets: 0.0, 0.5 0.5 0.5 0.5 ;
79+
-fx-background-radius: 0.0 ;
8080
-fx-font-family: "Noto Sans Korean Regular";
8181
}
8282
.text-field:focused {
@@ -86,17 +86,17 @@
8686
/* Label */
8787
.gridTitleLabel {
8888
-fx-font-family: "Noto Sans Korean Regular";
89-
-fx-font-size: 11px;
90-
-fx-line-spacing: 0;
89+
-fx-font-size: 11.0px;
90+
-fx-line-spacing: 0.0;
9191
}
9292

9393
/* JFXComboBox */
9494
.jfx-combo-box {
9595
-fx-background-color: -fx-text-box-border, white ;
96-
-fx-background-insets: 0, 0.5 0.5 0.5 0.5 ;
97-
-fx-background-radius: 0 ;
96+
-fx-background-insets: 0.0, 0.5 0.5 0.5 0.5 ;
97+
-fx-background-radius: 0.0 ;
9898
-fx-font-family: "Noto Sans Korean Regular";
99-
-fx-font-size: 10px;
99+
-fx-font-size: 10.0px;
100100
}
101101

102102
.jfx-combo-box:focused {
@@ -111,9 +111,9 @@
111111

112112
.table-view .column-header-background {
113113
-fx-background-color: linear-gradient(to bottom, #1dbbdd44, #93f9b944);
114-
-fx-background-radius: 7px 7px 0px 0px;
115-
-fx-background-insets: 0 11px 0 0;
116-
-fx-padding: 0 0 5px 0;
114+
-fx-background-radius: 7.0px 7.0px 0.0px 0.0px;
115+
-fx-background-insets: 0.0 11.0px 0.0 0.0;
116+
-fx-padding: 0.0 0.0 5.0px 0.0;
117117
}
118118

119119
.table-view .column-header {
@@ -122,7 +122,7 @@
122122

123123
.table-view .table-cell{
124124
-fx-border-color: transparent;
125-
-fx-padding: 2 0 2 10px;
125+
-fx-padding: 2.0 0.0 2.0 10.0px;
126126
}
127127

128128
.table-row-cell: hover {
@@ -132,13 +132,13 @@
132132

133133
.table-row-cell: odd{
134134
-fx-background-color: #93f9b911;
135-
-fx-background-insets: 0, 0 0 1 0;
135+
-fx-background-insets: 0.0, 0.0 0.0 1.0 0.0;
136136
-fx-padding: 0.0em;
137137
}
138138

139139
.table-row-cell: even{
140140
-fx-background-color: #1dbbdd11;
141-
-fx-background-insets: 0, 0 0 1 0;
141+
-fx-background-insets: 0.0, 0.0 0.0 1.0 0.0;
142142
-fx-padding: 0.0em;
143143
}
144144

@@ -150,7 +150,7 @@
150150

151151
.table-view .show-hide-columns-button {
152152
-fx-background-color: linear-gradient(to bottom, #1dbbdd44, #93f9b944);
153-
-fx-background-insets: 2 0 0 2.5;
153+
-fx-background-insets: 2.0 0.0 0.0 2.5;
154154
}
155155

156156
.table-view .virtual-flow .scroll-bar:vertical,
@@ -164,8 +164,8 @@
164164

165165
.table-view .virtual-flow .scroll-bar .increment-button,
166166
.table-view .virtual-flow .scroll-bar .decrement-button {
167-
-fx-opacity: 0;
168-
-fx-padding: 2;
167+
-fx-opacity: 0.0;
168+
-fx-padding: 2.0;
169169
}
170170

171171
.table-view .virtual-flow .scroll-bar:vertical .thumb {
@@ -187,7 +187,7 @@
187187
/* Datepicker */
188188
.date-picker .arrow-button {
189189
-fx-background-color: -fx-primary-color;
190-
-fx-background-radius: 0;
190+
-fx-background-radius: 0.0;
191191
}
192192
.date-picker .arrow-button:hover {
193193
-fx-background-color: -fx-secondary-color;
@@ -235,4 +235,36 @@
235235

236236
.scroll-pane {
237237
-fx-background-color: transparent;
238-
}
238+
}
239+
240+
.gray-scrollbar .scroll-bar {
241+
-fx-background-color: white;
242+
}
243+
244+
.gray-scrollbar .scroll-bar:horizontal .track,
245+
.gray-scrollbar .scroll-bar:vertical .track{
246+
-fx-background-color: transparent;
247+
-fx-border-color: transparent;
248+
}
249+
250+
.gray-scrollbar .scroll-bar:horizontal .increment-button ,
251+
.gray-scrollbar .scroll-bar:horizontal .decrement-button {
252+
-fx-background-color: transparent;
253+
-fx-padding: 0.0 0.0 10.0 0.0;
254+
}
255+
256+
.gray-scrollbar .scroll-bar:vertical .increment-button ,
257+
.gray-scrollbar .scroll-bar:vertical .decrement-button {
258+
-fx-background-color: transparent;
259+
-fx-padding: 0.0 10.0 0.0 0.0;
260+
}
261+
262+
.gray-scrollbar .scroll-bar .increment-arrow,
263+
.gray-scrollbar .scroll-bar .decrement-arrow{
264+
-fx-padding: 2.0 0.0 2.0 0.0;
265+
}
266+
267+
.gray-scrollbar .scroll-bar:horizontal .thumb,
268+
.gray-scrollbar .scroll-bar:vertical .thumb {
269+
-fx-background-color: derive(gray,40.0%);
270+
}

0 commit comments

Comments
 (0)