Allow setting the packetlogger always on top

Signed-off-by: Eduardo Alonso <edu@error404software.com>
This commit is contained in:
Eduardo Alonso 2018-12-31 13:09:45 +01:00
parent 21ea7ff70a
commit cf4aa16148
3 changed files with 18 additions and 1 deletions

View File

@ -2,6 +2,7 @@ package gearth.ui.logger.loggerdisplays.uilogger;
import gearth.protocol.HPacket; import gearth.protocol.HPacket;
import gearth.ui.logger.loggerdisplays.PacketLogger; import gearth.ui.logger.loggerdisplays.PacketLogger;
import javafx.event.ActionEvent;
import javafx.event.Event; import javafx.event.Event;
import javafx.fxml.FXMLLoader; import javafx.fxml.FXMLLoader;
import javafx.scene.Parent; import javafx.scene.Parent;
@ -38,6 +39,8 @@ public class UiLogger implements PacketLogger {
Scene scene = new Scene(root); Scene scene = new Scene(root);
scene.getStylesheets().add("/gearth/ui/bootstrap3.css"); scene.getStylesheets().add("/gearth/ui/bootstrap3.css");
scene.getStylesheets().add("/gearth/ui/logger/uilogger/logger.css"); scene.getStylesheets().add("/gearth/ui/logger/uilogger/logger.css");
UiLoggerController controller = (UiLoggerController) loader.getController();
controller.setStage(stage);
// scene.addEventFilter(KeyEvent.KEY_PRESSED, new EventHandler<KeyEvent>() { // scene.addEventFilter(KeyEvent.KEY_PRESSED, new EventHandler<KeyEvent>() {
// final KeyCombination keyCombIncoming = new KeyCodeCombination(KeyCode.I, // final KeyCombination keyCombIncoming = new KeyCodeCombination(KeyCode.I,

View File

@ -12,6 +12,7 @@ import javafx.scene.control.CheckMenuItem;
import javafx.scene.control.Label; import javafx.scene.control.Label;
import javafx.scene.layout.BorderPane; import javafx.scene.layout.BorderPane;
import javafx.scene.layout.FlowPane; import javafx.scene.layout.FlowPane;
import javafx.stage.Stage;
import org.fxmisc.flowless.VirtualizedScrollPane; import org.fxmisc.flowless.VirtualizedScrollPane;
import org.fxmisc.richtext.StyleClassedTextArea; import org.fxmisc.richtext.StyleClassedTextArea;
import org.fxmisc.richtext.model.StyleSpansBuilder; import org.fxmisc.richtext.model.StyleSpansBuilder;
@ -36,6 +37,8 @@ public class UiLoggerController implements Initializable {
private StyleClassedTextArea area; private StyleClassedTextArea area;
private Stage stage;
private boolean viewIncoming = true; private boolean viewIncoming = true;
private boolean viewOutgoing = true; private boolean viewOutgoing = true;
private boolean displayStructure = true; private boolean displayStructure = true;
@ -43,6 +46,7 @@ public class UiLoggerController implements Initializable {
private boolean skiphugepackets = true; private boolean skiphugepackets = true;
private boolean viewMessageName = true; private boolean viewMessageName = true;
private boolean viewMessageHash = false; private boolean viewMessageHash = false;
private boolean alwaysOnTop = false;
private volatile boolean initialized = false; private volatile boolean initialized = false;
private final List<Element> appendLater = new ArrayList<>(); private final List<Element> appendLater = new ArrayList<>();
@ -181,6 +185,10 @@ public class UiLoggerController implements Initializable {
}); });
} }
public void setStage(Stage stage) {
this.stage = stage;
}
public void toggleViewIncoming() { public void toggleViewIncoming() {
viewIncoming = !viewIncoming; viewIncoming = !viewIncoming;
lblViewIncoming.setText("View Incoming: " + (viewIncoming ? "True" : "False")); lblViewIncoming.setText("View Incoming: " + (viewIncoming ? "True" : "False"));
@ -214,4 +222,9 @@ public class UiLoggerController implements Initializable {
public void toggleMessageHash(ActionEvent actionEvent) { public void toggleMessageHash(ActionEvent actionEvent) {
viewMessageHash = !viewMessageHash; viewMessageHash = !viewMessageHash;
} }
public void toggleAlwaysOnTop(ActionEvent actionEvent) {
stage.setAlwaysOnTop(!alwaysOnTop);
alwaysOnTop = !alwaysOnTop;
}
} }

View File

@ -9,7 +9,7 @@
<?import javafx.scene.layout.BorderPane?> <?import javafx.scene.layout.BorderPane?>
<?import javafx.scene.layout.FlowPane?> <?import javafx.scene.layout.FlowPane?>
<BorderPane fx:id="borderPane" prefHeight="560.0" prefWidth="820.0" xmlns="http://javafx.com/javafx/10.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="gearth.ui.logger.loggerdisplays.uilogger.UiLoggerController"> <BorderPane fx:id="borderPane" prefHeight="560.0" prefWidth="820.0" xmlns="http://javafx.com/javafx/8.0.121" xmlns:fx="http://javafx.com/fxml/1" fx:controller="gearth.ui.logger.loggerdisplays.uilogger.UiLoggerController">
<top> <top>
<MenuBar BorderPane.alignment="CENTER"> <MenuBar BorderPane.alignment="CENTER">
<Menu mnemonicParsing="false" text="View"> <Menu mnemonicParsing="false" text="View">
@ -33,6 +33,7 @@
<KeyCodeCombination alt="UP" code="L" control="DOWN" meta="UP" shift="UP" shortcut="UP" /> <KeyCodeCombination alt="UP" code="L" control="DOWN" meta="UP" shift="UP" shortcut="UP" />
</accelerator></CheckMenuItem> </accelerator></CheckMenuItem>
<CheckMenuItem fx:id="chkSkipBigPackets" mnemonicParsing="false" onAction="#toggleSkipPackets" selected="true" text="Skip big packets" /> <CheckMenuItem fx:id="chkSkipBigPackets" mnemonicParsing="false" onAction="#toggleSkipPackets" selected="true" text="Skip big packets" />
<CheckMenuItem fx:id="chkAlwaysOnTop" mnemonicParsing="false" onAction="#toggleAlwaysOnTop" text="Always on top" />
</Menu> </Menu>
</MenuBar> </MenuBar>
</top> </top>