From ca2d750e4371c07cdd35946dd80a2427fd5a9563 Mon Sep 17 00:00:00 2001 From: sirjonasxx <36828922+sirjonasxx@users.noreply.github.com> Date: Mon, 5 Nov 2018 21:45:03 +0100 Subject: [PATCH] reimplement hotkeys, autoscrol checkbox, tweaks --- .../java/gearth/ui/UiLoggerController.java | 31 ++++++++++------ .../ui/logger/loggerdisplays/UiLogger.java | 36 +++++++++---------- .../ui/{ => logger/uilogger}/UiLogger.fxml | 23 ++++++++++-- .../ui/{ => logger/uilogger}/logger.css | 12 ++++++- 4 files changed, 69 insertions(+), 33 deletions(-) rename G-Earth/src/main/resources/gearth/ui/{ => logger/uilogger}/UiLogger.fxml (63%) rename G-Earth/src/main/resources/gearth/ui/{ => logger/uilogger}/logger.css (73%) diff --git a/G-Earth/src/main/java/gearth/ui/UiLoggerController.java b/G-Earth/src/main/java/gearth/ui/UiLoggerController.java index a37d15e..9869b79 100644 --- a/G-Earth/src/main/java/gearth/ui/UiLoggerController.java +++ b/G-Earth/src/main/java/gearth/ui/UiLoggerController.java @@ -3,9 +3,11 @@ package gearth.ui; import gearth.protocol.HPacket; import gearth.ui.logger.loggerdisplays.PacketLogger; import javafx.event.ActionEvent; +import javafx.event.EventHandler; import javafx.fxml.Initializable; import javafx.scene.control.CheckMenuItem; import javafx.scene.control.Label; +import javafx.scene.input.ScrollEvent; import javafx.scene.layout.BorderPane; import javafx.scene.layout.FlowPane; import org.fxmisc.flowless.VirtualizedScrollPane; @@ -26,12 +28,15 @@ public class UiLoggerController implements Initializable { public CheckMenuItem chkViewIncoming; public CheckMenuItem chkViewOutgoing; public CheckMenuItem chkDisplayStructure; + public Label lblAutoScrolll; + public CheckMenuItem chkAutoscroll; private StyleClassedTextArea area; private boolean viewIncoming = true; private boolean viewOutgoing = true; private boolean displayStructure = true; + private boolean autoScroll = true; @Override public void initialize(URL arg0, ResourceBundle arg1) { @@ -66,9 +71,6 @@ public class UiLoggerController implements Initializable { elements.add(new Element(" <- ", "")); elements.add(new Element(packet.toString(), "incoming")); - - if (!expr.equals("") && displayStructure) - elements.add(new Element("\n" + expr, "incoming")); } else { elements.add(new Element("Outgoing[", "outgoing")); elements.add(new Element(String.valueOf(packet.headerId()), "")); @@ -76,10 +78,9 @@ public class UiLoggerController implements Initializable { elements.add(new Element(" -> ", "")); elements.add(new Element(packet.toString(), "outgoing")); - - if (!expr.equals("") && displayStructure) - elements.add(new Element("\n" + expr, "outgoing")); } + if (!expr.equals("") && displayStructure) + elements.add(new Element("\n" + expr, "structure")); elements.add(new Element("\n--------------------\n", "")); AppendLog(elements); @@ -98,25 +99,33 @@ public class UiLoggerController implements Initializable { area.appendText(sb.toString()); area.setStyleSpans(oldLen, styleSpansBuilder.create()); - area.moveTo(area.getLength()); - area.requestFollowCaret(); + if (autoScroll) { + area.moveTo(area.getLength()); + area.requestFollowCaret(); + } + } public void toggleViewIncoming() { viewIncoming = !viewIncoming; lblViewIncoming.setText("View Incoming: " + (viewIncoming ? "True" : "False")); - chkViewIncoming.setSelected(viewIncoming); +// chkViewIncoming.setSelected(viewIncoming); } public void toggleViewOutgoing() { viewOutgoing = !viewOutgoing; lblViewOutgoing.setText("View Outgoing: " + (viewOutgoing ? "True" : "False")); - chkViewOutgoing.setSelected(viewOutgoing); +// chkViewOutgoing.setSelected(viewOutgoing); } public void toggleDisplayStructure() { displayStructure = !displayStructure; - chkDisplayStructure.setSelected(displayStructure); +// chkDisplayStructure.setSelected(displayStructure); + } + + public void toggleAutoscroll(ActionEvent actionEvent) { + autoScroll = !autoScroll; + lblAutoScrolll.setText("Autoscroll: " + (autoScroll ? "True" : "False")); } } diff --git a/G-Earth/src/main/java/gearth/ui/logger/loggerdisplays/UiLogger.java b/G-Earth/src/main/java/gearth/ui/logger/loggerdisplays/UiLogger.java index 997ee41..630f385 100644 --- a/G-Earth/src/main/java/gearth/ui/logger/loggerdisplays/UiLogger.java +++ b/G-Earth/src/main/java/gearth/ui/logger/loggerdisplays/UiLogger.java @@ -23,7 +23,7 @@ public class UiLogger implements PacketLogger { @Override public void start() { - FXMLLoader loader = new FXMLLoader(getClass().getResource("/gearth/ui/UiLogger.fxml")); + FXMLLoader loader = new FXMLLoader(getClass().getResource("/gearth/ui/logger/uilogger/UiLogger.fxml")); try { Parent root = loader.load(); @@ -34,24 +34,24 @@ public class UiLogger implements PacketLogger { Scene scene = new Scene(root); scene.getStylesheets().add("/gearth/ui/bootstrap3.css"); - scene.getStylesheets().add("/gearth/ui/logger.css"); + scene.getStylesheets().add("/gearth/ui/logger/uilogger/logger.css"); - scene.addEventFilter(KeyEvent.KEY_PRESSED, new EventHandler() { - final KeyCombination keyCombIncoming = new KeyCodeCombination(KeyCode.I, - KeyCombination.CONTROL_DOWN); - final KeyCombination keyCombOutgoing = new KeyCodeCombination(KeyCode.O, - KeyCombination.CONTROL_DOWN); - - public void handle(KeyEvent ke) { - if (keyCombIncoming.match(ke)) { - controller.toggleViewIncoming(); - ke.consume(); - } else if (keyCombOutgoing.match(ke)) { - controller.toggleViewOutgoing(); - ke.consume(); - } - } - }); +// scene.addEventFilter(KeyEvent.KEY_PRESSED, new EventHandler() { +// final KeyCombination keyCombIncoming = new KeyCodeCombination(KeyCode.I, +// KeyCombination.CONTROL_DOWN); +// final KeyCombination keyCombOutgoing = new KeyCodeCombination(KeyCode.O, +// KeyCombination.CONTROL_DOWN); +// +// public void handle(KeyEvent ke) { +// if (keyCombIncoming.match(ke)) { +// controller.toggleViewIncoming(); +// ke.consume(); +// } else if (keyCombOutgoing.match(ke)) { +// controller.toggleViewOutgoing(); +// ke.consume(); +// } +// } +// }); stage.setScene(scene); diff --git a/G-Earth/src/main/resources/gearth/ui/UiLogger.fxml b/G-Earth/src/main/resources/gearth/ui/logger/uilogger/UiLogger.fxml similarity index 63% rename from G-Earth/src/main/resources/gearth/ui/UiLogger.fxml rename to G-Earth/src/main/resources/gearth/ui/logger/uilogger/UiLogger.fxml index 4fb5b4c..1c426bc 100644 --- a/G-Earth/src/main/resources/gearth/ui/UiLogger.fxml +++ b/G-Earth/src/main/resources/gearth/ui/logger/uilogger/UiLogger.fxml @@ -5,10 +5,11 @@ + - + @@ -17,8 +18,18 @@ - - + + + + + + + + + + + + @@ -42,6 +53,12 @@ + + diff --git a/G-Earth/src/main/resources/gearth/ui/logger.css b/G-Earth/src/main/resources/gearth/ui/logger/uilogger/logger.css similarity index 73% rename from G-Earth/src/main/resources/gearth/ui/logger.css rename to G-Earth/src/main/resources/gearth/ui/logger/uilogger/logger.css index 3bf1c3a..4aeba12 100644 --- a/G-Earth/src/main/resources/gearth/ui/logger.css +++ b/G-Earth/src/main/resources/gearth/ui/logger/uilogger/logger.css @@ -15,6 +15,10 @@ -fx-fill: #0066cc; } +.structure { + -fx-fill: cyan; +} + .dark { -fx-background-color: #000000; } @@ -30,4 +34,10 @@ .menu-bar .text, .menu .text { -fx-text-fill: #000000 !important; -fx-fill: #000000 !important; -} \ No newline at end of file + -fx-padding: -2 0 -2 0 !important; +} + +.scroll-bar:vertical { + -fx-pref-width: 16.5; + -fx-padding: 1; +}