From 230121dfdc1c2d81e692066f0c757441da7d4f33 Mon Sep 17 00:00:00 2001 From: Scott Stamp Date: Mon, 15 Oct 2018 18:40:50 -0230 Subject: [PATCH] Added toggle for view structure and fixed menu text color --- ...ontroller.java => UiLoggerController.java} | 19 ++++++++++++++++--- .../ui/logger/loggerdisplays/UiLogger.java | 10 +++++++--- .../main/resources/gearth/ui/UiLogger.fxml | 17 +++++++++++------ .../main/resources/gearth/ui/bootstrap3.css | 4 ++-- .../src/main/resources/gearth/ui/logger.css | 6 +++++- 5 files changed, 41 insertions(+), 15 deletions(-) rename G-Earth-UI/src/main/java/gearth/ui/{LoggerController.java => UiLoggerController.java} (85%) diff --git a/G-Earth-UI/src/main/java/gearth/ui/LoggerController.java b/G-Earth-UI/src/main/java/gearth/ui/UiLoggerController.java similarity index 85% rename from G-Earth-UI/src/main/java/gearth/ui/LoggerController.java rename to G-Earth-UI/src/main/java/gearth/ui/UiLoggerController.java index 59668e9..a37d15e 100644 --- a/G-Earth-UI/src/main/java/gearth/ui/LoggerController.java +++ b/G-Earth-UI/src/main/java/gearth/ui/UiLoggerController.java @@ -2,7 +2,9 @@ package gearth.ui; import gearth.protocol.HPacket; import gearth.ui.logger.loggerdisplays.PacketLogger; +import javafx.event.ActionEvent; import javafx.fxml.Initializable; +import javafx.scene.control.CheckMenuItem; import javafx.scene.control.Label; import javafx.scene.layout.BorderPane; import javafx.scene.layout.FlowPane; @@ -16,16 +18,20 @@ import java.util.Collection; import java.util.Collections; import java.util.ResourceBundle; -public class LoggerController implements Initializable { +public class UiLoggerController implements Initializable { public FlowPane flowPane; public BorderPane borderPane; public Label lblViewIncoming; public Label lblViewOutgoing; + public CheckMenuItem chkViewIncoming; + public CheckMenuItem chkViewOutgoing; + public CheckMenuItem chkDisplayStructure; private StyleClassedTextArea area; private boolean viewIncoming = true; private boolean viewOutgoing = true; + private boolean displayStructure = true; @Override public void initialize(URL arg0, ResourceBundle arg1) { @@ -61,7 +67,7 @@ public class LoggerController implements Initializable { elements.add(new Element(" <- ", "")); elements.add(new Element(packet.toString(), "incoming")); - if (!expr.equals("")) + if (!expr.equals("") && displayStructure) elements.add(new Element("\n" + expr, "incoming")); } else { elements.add(new Element("Outgoing[", "outgoing")); @@ -71,7 +77,7 @@ public class LoggerController implements Initializable { elements.add(new Element(" -> ", "")); elements.add(new Element(packet.toString(), "outgoing")); - if (!expr.equals("")) + if (!expr.equals("") && displayStructure) elements.add(new Element("\n" + expr, "outgoing")); } @@ -99,11 +105,18 @@ public class LoggerController implements Initializable { public void toggleViewIncoming() { viewIncoming = !viewIncoming; lblViewIncoming.setText("View Incoming: " + (viewIncoming ? "True" : "False")); + chkViewIncoming.setSelected(viewIncoming); } public void toggleViewOutgoing() { viewOutgoing = !viewOutgoing; lblViewOutgoing.setText("View Outgoing: " + (viewOutgoing ? "True" : "False")); + chkViewOutgoing.setSelected(viewOutgoing); + } + + public void toggleDisplayStructure() { + displayStructure = !displayStructure; + chkDisplayStructure.setSelected(displayStructure); } } diff --git a/G-Earth-UI/src/main/java/gearth/ui/logger/loggerdisplays/UiLogger.java b/G-Earth-UI/src/main/java/gearth/ui/logger/loggerdisplays/UiLogger.java index 68b33cb..65bc058 100644 --- a/G-Earth-UI/src/main/java/gearth/ui/logger/loggerdisplays/UiLogger.java +++ b/G-Earth-UI/src/main/java/gearth/ui/logger/loggerdisplays/UiLogger.java @@ -1,7 +1,7 @@ package gearth.ui.logger.loggerdisplays; import gearth.protocol.HPacket; -import gearth.ui.LoggerController; +import gearth.ui.UiLoggerController; import javafx.application.Platform; import javafx.event.Event; import javafx.event.EventHandler; @@ -14,12 +14,13 @@ import javafx.scene.input.KeyCombination; import javafx.scene.input.KeyEvent; import javafx.stage.Modality; import javafx.stage.Stage; +import org.scenicview.ScenicView; import java.io.IOException; public class UiLogger implements PacketLogger { private Stage stage; - private LoggerController controller; + private UiLoggerController controller; @Override public void start() { @@ -55,6 +56,8 @@ public class UiLogger implements PacketLogger { stage.setScene(scene); +// ScenicView.show(scene); + // don't let the user close this window on their own stage.setOnCloseRequest(Event::consume); @@ -66,7 +69,8 @@ public class UiLogger implements PacketLogger { @Override public void stop() { - stage.close(); + if (stage != null) + stage.close(); } @Override diff --git a/G-Earth-UI/src/main/resources/gearth/ui/UiLogger.fxml b/G-Earth-UI/src/main/resources/gearth/ui/UiLogger.fxml index 1e68b34..94b77a2 100644 --- a/G-Earth-UI/src/main/resources/gearth/ui/UiLogger.fxml +++ b/G-Earth-UI/src/main/resources/gearth/ui/UiLogger.fxml @@ -1,26 +1,31 @@ + - - + - - + + + + + + + - + - +