Skip to content

Commit 8b5ca8a

Browse files
committed
Fixed error popups
1 parent 7504776 commit 8b5ca8a

9 files changed

Lines changed: 68 additions & 51 deletions

File tree

src/main/java/com/funkylogclient/FunkyLogSorter.java

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,8 @@
1010
import java.util.concurrent.ScheduledExecutorService;
1111
import java.util.concurrent.TimeUnit;
1212

13-
import javafx.animation.PauseTransition;
14-
import javafx.scene.control.Alert;
15-
import javafx.scene.control.Alert.AlertType;
1613
import javafx.stage.FileChooser;
1714
import javafx.stage.Stage;
18-
import javafx.util.Duration;
1915

2016
public class FunkyLogSorter {
2117
private static int MAX_LEN = 1200;
@@ -24,13 +20,13 @@ public class FunkyLogSorter {
2420
private static boolean allowWarnings = true;
2521
private static boolean allowLogs = true;
2622

23+
public static LinkedList<Message> errors = new LinkedList<>();
24+
2725
private static String searchTerm = "";
2826

2927
public static LinkedList<Message> messages = new LinkedList<>();
3028
public static LinkedList<Message> filtered = new LinkedList<>();
3129

32-
public static int num_open_alerts = 0;
33-
3430
public static String log_file_directory = System.getProperty("user.dir") + "/logs846";
3531
public static FileWriter log_file;
3632

@@ -105,27 +101,7 @@ public static void addMessage(Message m) {
105101
}
106102

107103
if (m.isError()) {
108-
if (num_open_alerts < 5) {
109-
Alert alert = new Alert(AlertType.ERROR);
110-
alert.setTitle("FunkyLogs Error Notification");
111-
alert.setHeaderText(m.getSender());
112-
alert.setContentText(m.getContent());
113-
114-
alert.setX(alert.getX() + (num_open_alerts * 70));
115-
alert.setY(alert.getY() + (num_open_alerts * 70));
116-
117-
alert.show();
118-
119-
PauseTransition delay = new PauseTransition(Duration.seconds(5));
120-
121-
delay.setOnFinished(event -> {
122-
alert.close();
123-
FunkyLogSorter.num_open_alerts--;
124-
});
125-
126-
delay.play();
127-
128-
}
104+
errors.add(m);
129105
}
130106

131107
if (!checkMessageBySearch(m)) {

src/main/java/com/funkylogclient/FunkyLogs.java

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
package com.funkylogclient;
22

3+
import java.util.Iterator;
34
import java.util.LinkedList;
45

6+
import javafx.animation.PauseTransition;
57
import javafx.application.Application;
68
import javafx.application.Platform;
79
import javafx.concurrent.Task;
810
import javafx.geometry.*;
911
import javafx.scene.Scene;
12+
import javafx.scene.control.Alert;
13+
import javafx.scene.control.Alert.AlertType;
1014
import javafx.scene.control.ScrollPane;
1115
import javafx.scene.control.TextField;
1216
import javafx.scene.layout.BorderPane;
@@ -15,6 +19,7 @@
1519
import javafx.scene.paint.Color;
1620
import javafx.stage.Stage;
1721
import javafx.stage.StageStyle;
22+
import javafx.util.Duration;
1823
import javafx.scene.Cursor;
1924
import javafx.scene.text.*;
2025

@@ -34,6 +39,8 @@ public class FunkyLogs extends Application {
3439
private static String serverIP = UDPClient.serverIP;
3540
private static int port = UDPClient.port;
3641

42+
private static int num_open_alerts = 0;
43+
3744
@Override
3845
public void start(Stage primaryStage) {
3946
FunkyLogSorter.makeNewLogFile();
@@ -118,6 +125,37 @@ protected Void call() throws Exception {
118125
Thread.sleep(200);
119126
try {
120127
FunkyLogs.updateMessageZone(primaryStage);
128+
129+
Platform.runLater(() -> {
130+
Iterator<Message> iterator = FunkyLogSorter.errors.iterator();
131+
while (iterator.hasNext()) {
132+
Message x = iterator.next();
133+
if (num_open_alerts < 5) {
134+
Alert alert = new Alert(AlertType.ERROR);
135+
alert.setTitle("FunkyLogs Error Notification");
136+
alert.setHeaderText(x.getSender());
137+
alert.setContentText(x.getContent());
138+
139+
alert.setX(alert.getX() + (num_open_alerts * 70));
140+
alert.setY(alert.getY() + (num_open_alerts * 70));
141+
142+
alert.show();
143+
144+
num_open_alerts += 1;
145+
146+
PauseTransition delay = new PauseTransition(Duration.seconds(5));
147+
148+
delay.setOnFinished(event -> {
149+
num_open_alerts--;
150+
alert.close();
151+
});
152+
153+
delay.play();
154+
155+
iterator.remove();
156+
}
157+
}
158+
});
121159
} catch (Exception exc) {
122160
System.out.println(exc);
123161
}

src/main/java/com/funkylogclient/Message.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,19 +136,22 @@ public Node getComponent() {
136136

137137
HBox topBox = new HBox();
138138
topBox.setPadding(new Insets(0, 0, 5, 0));
139-
topBox.setSpacing(400);
139+
topBox.setSpacing(20);
140140

141141
Text top = new Text(
142-
new BigDecimal(this.time).setScale(1, RoundingMode.HALF_UP).toString() + " [" + sender + "]");
143-
top.setStyle(Styles.TEXT_STYLE + Styles.TEXT_SMALL);
142+
"SYS " + new BigDecimal(this.time).setScale(1, RoundingMode.HALF_UP).toString());
143+
top.setStyle(Styles.TEXT_STYLE + Styles.TEXT_SMALLER);
144144

145-
Text topRight = new Text(getPeriodName() + " " + new BigDecimal(this.period_timestamp)
145+
Text topMid = new Text(getPeriodName() + " " + new BigDecimal(this.period_timestamp)
146146
.setScale(0, RoundingMode.HALF_UP).toString());
147-
topRight.setStyle(Styles.TEXT_STYLE + Styles.TEXT_SMALLER);
147+
topMid.setStyle(Styles.TEXT_STYLE + Styles.TEXT_SMALLER);
148+
149+
Text topRight = new Text(sender);
150+
topRight.setStyle(Styles.TEXT_STYLE + Styles.TEXT_SMALL);
148151
HBox.setHgrow(topRight, Priority.ALWAYS);
149152
topRight.setTextAlignment(TextAlignment.RIGHT);
150153

151-
topBox.getChildren().addAll(top, topRight);
154+
topBox.getChildren().addAll(top, topMid, topRight);
152155

153156
HBox body = new HBox();
154157
body.setPadding(new Insets(5, 5, 5, 30));

src/main/java/com/funkylogclient/SidebarOtherSettings.java

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -55,27 +55,27 @@ public static VBox getSidebarOtherSettings(ChangeListener<Boolean> autoScrollCha
5555
});
5656
otherSettingsBox.getChildren().add(fileSelectionDialog);
5757

58-
Region testLogButtonspacing = new Region();
59-
testLogButtonspacing.setMinHeight(20);
60-
otherSettingsBox.getChildren().add(testLogButtonspacing);
58+
// Region testLogButtonspacing = new Region();
59+
// testLogButtonspacing.setMinHeight(20);
60+
// otherSettingsBox.getChildren().add(testLogButtonspacing);
6161

62-
Button testLogButton = new Button("Test Log");
63-
testLogButton.setOnAction((ev) -> {
64-
FunkyLogSorter.createTestLog(primaryStage);
65-
});
66-
otherSettingsBox.getChildren().add(testLogButton);
62+
// Button testLogButton = new Button("Test Log");
63+
// testLogButton.setOnAction((ev) -> {
64+
// FunkyLogSorter.createTestLog(primaryStage);
65+
// });
66+
// otherSettingsBox.getChildren().add(testLogButton);
6767

68-
Button testWarningButton = new Button("Test Warning");
69-
testWarningButton.setOnAction((ev) -> {
70-
FunkyLogSorter.createTestWarning(primaryStage);
71-
});
72-
otherSettingsBox.getChildren().add(testWarningButton);
68+
// Button testWarningButton = new Button("Test Warning");
69+
// testWarningButton.setOnAction((ev) -> {
70+
// FunkyLogSorter.createTestWarning(primaryStage);
71+
// });
72+
// otherSettingsBox.getChildren().add(testWarningButton);
7373

74-
Button testErrorButton = new Button("Test Error");
75-
testErrorButton.setOnAction((ev) -> {
76-
FunkyLogSorter.createTestError(primaryStage);
77-
});
78-
otherSettingsBox.getChildren().add(testErrorButton);
74+
// Button testErrorButton = new Button("Test Error");
75+
// testErrorButton.setOnAction((ev) -> {
76+
// FunkyLogSorter.createTestError(primaryStage);
77+
// });
78+
// otherSettingsBox.getChildren().add(testErrorButton);
7979

8080
return otherSettingsBox;
8181
}
-1.2 KB
Binary file not shown.
2.48 KB
Binary file not shown.
44 Bytes
Binary file not shown.
48 Bytes
Binary file not shown.
-761 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)