From 0d7c7b07efb5da95d64c6ad68f668f1f4920e73b Mon Sep 17 00:00:00 2001 From: sirjonasxx <36828922+sirjonasxx@users.noreply.github.com> Date: Mon, 5 Nov 2018 23:25:19 +0100 Subject: [PATCH] fix frozen packetlogger by giving option to skip big packets in logger (auto-enabled & with indication) --- .../java/gearth/ui/UiLoggerController.java | 24 ++++++++++++++++--- .../gearth/ui/logger/uilogger/UiLogger.fxml | 1 + .../gearth/ui/logger/uilogger/logger.css | 2 +- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/G-Earth/src/main/java/gearth/ui/UiLoggerController.java b/G-Earth/src/main/java/gearth/ui/UiLoggerController.java index 9e7a4b5..327d5b8 100644 --- a/G-Earth/src/main/java/gearth/ui/UiLoggerController.java +++ b/G-Earth/src/main/java/gearth/ui/UiLoggerController.java @@ -26,6 +26,7 @@ public class UiLoggerController implements Initializable { public CheckMenuItem chkDisplayStructure; public Label lblAutoScrolll; public CheckMenuItem chkAutoscroll; + public CheckMenuItem chkSkipBigPackets; private StyleClassedTextArea area; @@ -33,6 +34,8 @@ public class UiLoggerController implements Initializable { private boolean viewOutgoing = true; private boolean displayStructure = true; private boolean autoScroll = true; + private boolean skiphugepackets = true; + private volatile boolean initialized = false; private final List appendLater = new ArrayList<>(); @@ -78,16 +81,27 @@ public class UiLoggerController implements Initializable { elements.add(new Element("]", "incoming")); elements.add(new Element(" <- ", "")); - elements.add(new Element(packet.toString(), "incoming")); + if (skiphugepackets && packet.length() > 8000) { + elements.add(new Element("", "skipped")); + } + else { + elements.add(new Element(packet.toString(), "incoming")); + } } else { elements.add(new Element("Outgoing[", "outgoing")); elements.add(new Element(String.valueOf(packet.headerId()), "")); elements.add(new Element("]", "outgoing")); elements.add(new Element(" -> ", "")); - elements.add(new Element(packet.toString(), "outgoing")); + + if (skiphugepackets && packet.length() > 8000) { + elements.add(new Element("", "skipped")); + } + else { + elements.add(new Element(packet.toString(), "outgoing")); + } } - if (!expr.equals("") && displayStructure) + if (!expr.equals("") && displayStructure && (!skiphugepackets || packet.length() <= 8000)) elements.add(new Element("\n" + expr, "structure")); elements.add(new Element("\n--------------------\n", "")); @@ -146,6 +160,10 @@ public class UiLoggerController implements Initializable { autoScroll = !autoScroll; lblAutoScrolll.setText("Autoscroll: " + (autoScroll ? "True" : "False")); } + + public void toggleSkipPackets(ActionEvent actionEvent) { + skiphugepackets = !skiphugepackets; + } } class Element { diff --git a/G-Earth/src/main/resources/gearth/ui/logger/uilogger/UiLogger.fxml b/G-Earth/src/main/resources/gearth/ui/logger/uilogger/UiLogger.fxml index 1c426bc..e5419fa 100644 --- a/G-Earth/src/main/resources/gearth/ui/logger/uilogger/UiLogger.fxml +++ b/G-Earth/src/main/resources/gearth/ui/logger/uilogger/UiLogger.fxml @@ -30,6 +30,7 @@ + diff --git a/G-Earth/src/main/resources/gearth/ui/logger/uilogger/logger.css b/G-Earth/src/main/resources/gearth/ui/logger/uilogger/logger.css index 4aeba12..a389cda 100644 --- a/G-Earth/src/main/resources/gearth/ui/logger/uilogger/logger.css +++ b/G-Earth/src/main/resources/gearth/ui/logger/uilogger/logger.css @@ -15,7 +15,7 @@ -fx-fill: #0066cc; } -.structure { +.structure, .skipped { -fx-fill: cyan; }