Skip to content

Commit 444ce1f

Browse files
committed
UI/UX: Change the UI of the alert log error preview region (ListView → Custom ExpandableListView)
1 parent 7a5c696 commit 444ce1f

File tree

2 files changed

+30
-15
lines changed

2 files changed

+30
-15
lines changed

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

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,19 @@
66
import java.util.List;
77
import java.util.ResourceBundle;
88

9+
import de.jensd.fx.glyphs.fontawesome.FontAwesomeIcon;
910
import javafx.beans.property.SimpleDoubleProperty;
1011
import javafx.beans.property.SimpleIntegerProperty;
1112
import javafx.collections.FXCollections;
1213
import javafx.fxml.FXML;
1314
import javafx.fxml.FXMLLoader;
1415
import javafx.fxml.Initializable;
1516
import javafx.scene.control.Label;
16-
import javafx.scene.control.ListView;
1717
import javafx.scene.control.TableColumn;
1818
import javafx.scene.control.TableView;
1919
import javafx.scene.layout.AnchorPane;
20+
import javafx.scene.layout.VBox;
21+
import javafx.scene.paint.Paint;
2022
import lombok.Data;
2123
import lombok.extern.slf4j.Slf4j;
2224
import root.core.domain.AlertLog;
@@ -26,6 +28,9 @@
2628
@Slf4j
2729
public class AlertLogMonitoringSummaryAP extends AnchorPane implements Initializable {
2830

31+
@FXML
32+
VBox wrapVBox;
33+
2934
@FXML
3035
Label alertLogFileLB;
3136

@@ -43,12 +48,11 @@ public class AlertLogMonitoringSummaryAP extends AnchorPane implements Initializ
4348

4449
@FXML
4550
private TableColumn<AlertLogSummary, Double> errorRateCL;
46-
47-
@FXML
48-
private ListView<Log> errorLogLV;
49-
51+
52+
private ExpandableListView<Log> errorLogLV;
53+
5054
private AlertLog alertLog;
51-
55+
5256
private List<Log> errorLogs = new ArrayList<>();
5357

5458
public AlertLogMonitoringSummaryAP(AlertLog alertLog) {
@@ -71,8 +75,21 @@ public void initialize(URL location, ResourceBundle resources) {
7175
errorCL.setCellValueFactory(cellData -> cellData.getValue().getErrorLogCount().asObject());
7276
errorRateCL.setCellValueFactory(cellData -> cellData.getValue().getErrorRate().asObject());
7377

74-
// Set cell factory of error log listview
75-
errorLogLV.setCellFactory(categoryList -> new AlertLogListViewCell());
78+
errorLogLV = new ExpandableListView<>(FontAwesomeIcon.CLOCK_ALT, Paint.valueOf("#183279"));
79+
80+
// Set content provider for expandable listview
81+
errorLogLV.setContentProvider(new ExpandableListView.ContentProvider<Log>() {
82+
@Override
83+
public String getTitleOf(final Log log) {
84+
return log.getLogTimeStamp() + "\t(Index: " + (log.getIndex() + 1) + ")";
85+
}
86+
87+
@Override
88+
public String getContentOf(final Log log) {
89+
return log.getFullLogString();
90+
}
91+
});
92+
wrapVBox.getChildren().add(errorLogLV);
7693

7794
render();
7895
}
@@ -83,7 +100,8 @@ private void render() {
83100

84101
// Set summary tableview value
85102
summaryTV.setItems(FXCollections.observableArrayList(List.of(getSummaryData())));
86-
103+
104+
// Set errorLog listview values
87105
errorLogLV.getItems().addAll(errorLogs);
88106
}
89107

src/main/resources/fxml/AlertLogMonitoringSummary.fxml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22

3-
<?import com.jfoenix.controls.JFXListView?>
43
<?import de.jensd.fx.glyphs.fontawesome.FontAwesomeIconView?>
54
<?import java.lang.String?>
65
<?import javafx.geometry.Insets?>
@@ -14,7 +13,7 @@
1413

1514
<fx:root styleClass="basic-font" stylesheets="@../css/javaFx.css" type="AnchorPane" xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1">
1615
<children>
17-
<VBox layoutX="10.0" layoutY="10.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
16+
<VBox fx:id="wrapVBox" layoutX="10.0" layoutY="10.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
1817
<children>
1918
<HBox alignment="CENTER_LEFT">
2019
<children>
@@ -61,12 +60,10 @@
6160
<graphic>
6261
<FontAwesomeIconView glyphName="ASTERISK" size="8" />
6362
</graphic>
64-
</Label>
65-
<JFXListView fx:id="errorLogLV" styleClass="gray-scrollbar">
6663
<VBox.margin>
67-
<Insets top="5.0" />
64+
<Insets bottom="5.0" />
6865
</VBox.margin>
69-
</JFXListView>
66+
</Label>
7067
</children>
7168
</VBox>
7269
</children>

0 commit comments

Comments
 (0)