diff --git a/G-Earth/src/main/java/gearth/ui/injection/Injection.java b/G-Earth/src/main/java/gearth/ui/injection/Injection.java index 9dea343..7952e80 100644 --- a/G-Earth/src/main/java/gearth/ui/injection/Injection.java +++ b/G-Earth/src/main/java/gearth/ui/injection/Injection.java @@ -25,19 +25,32 @@ public class Injection extends SubForm { } private void updateUI() { - HPacket packet = new HPacket(inputPacket.getText()); - if (!packet.isCorrupted()) { - lbl_corrruption.setText("isCorrupted: False"); - lbl_corrruption.setFill(Paint.valueOf("Green")); - lbl_pcktInfo.setText("header (id:"+packet.headerId()+", length:"+packet.length()+")"); + boolean dirty = false; + String[] rawPackets = inputPacket.getText().split("\n"); + HPacket[] packets = new HPacket[rawPackets.length]; + lbl_corrruption.setText("isCorrupted: False"); + lbl_corrruption.setFill(Paint.valueOf("Green")); + + for (int i = 0; i < packets.length; i++) { + packets[i] = new HPacket(rawPackets[i]); + if (packets[i].isCorrupted()) { + if (!dirty) { + lbl_corrruption.setText("isCorrupted: True -> " + i); + lbl_corrruption.setFill(Paint.valueOf("#ee0404b2")); + dirty = true; + } else + lbl_corrruption.setText(lbl_corrruption.getText() + ", " + i); + } + } + + if (!dirty) { btn_sendToClient.setDisable(getHConnection().getState() != HConnection.State.CONNECTED); btn_sendToServer.setDisable(getHConnection().getState() != HConnection.State.CONNECTED); - } - else { - lbl_corrruption.setText("isCorrupted: True"); - lbl_corrruption.setFill(Paint.valueOf("#ee0404b2")); - lbl_pcktInfo.setText("header (id:NULL, length:"+packet.getBytesLength()+")"); + lbl_pcktInfo.setText("header (id:" + packets[packets.length - 1].headerId() + ", length:" + + packets[packets.length - 1].length() + ")"); + } else { + lbl_pcktInfo.setText("header (id:NULL, length:" + packets[packets.length - 1].getBytesLength()+")"); btn_sendToClient.setDisable(true); btn_sendToServer.setDisable(true); @@ -46,14 +59,20 @@ public class Injection extends SubForm { } public void sendToServer_clicked(ActionEvent actionEvent) { - HPacket packet = new HPacket(inputPacket.getText()); - getHConnection().sendToServerAsync(packet); - writeToLog(Color.BLUE, "SS -> packet with id: " + packet.headerId()); + String[] rawPackets = inputPacket.getText().split("\n"); + for (String rawPacket : rawPackets) { + HPacket packet = new HPacket(rawPacket); + getHConnection().sendToServerAsync(packet); + writeToLog(Color.BLUE, "SS -> packet with id: " + packet.headerId()); + } } public void sendToClient_clicked(ActionEvent actionEvent) { - HPacket packet = new HPacket(inputPacket.getText()); - getHConnection().sendToClientAsync(packet); - writeToLog(Color.RED, "CS -> packet with id: " + packet.headerId()); + String[] rawPackets = inputPacket.getText().split("\n"); + for (String rawPacket : rawPackets) { + HPacket packet = new HPacket(rawPacket); + getHConnection().sendToClientAsync(packet); + writeToLog(Color.RED, "CS -> packet with id: " + packet.headerId()); + } } } diff --git a/G-Earth/src/main/java/gearth/ui/logger/loggerdisplays/uilogger/UiLogger.java b/G-Earth/src/main/java/gearth/ui/logger/loggerdisplays/uilogger/UiLogger.java index 0c03e3d..c12432a 100644 --- a/G-Earth/src/main/java/gearth/ui/logger/loggerdisplays/uilogger/UiLogger.java +++ b/G-Earth/src/main/java/gearth/ui/logger/loggerdisplays/uilogger/UiLogger.java @@ -2,6 +2,7 @@ package gearth.ui.logger.loggerdisplays.uilogger; import gearth.protocol.HPacket; import gearth.ui.logger.loggerdisplays.PacketLogger; +import javafx.event.ActionEvent; import javafx.event.Event; import javafx.fxml.FXMLLoader; import javafx.scene.Parent; @@ -38,6 +39,8 @@ public class UiLogger implements PacketLogger { Scene scene = new Scene(root); scene.getStylesheets().add("/gearth/ui/bootstrap3.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() { // final KeyCombination keyCombIncoming = new KeyCodeCombination(KeyCode.I, diff --git a/G-Earth/src/main/java/gearth/ui/logger/loggerdisplays/uilogger/UiLoggerController.java b/G-Earth/src/main/java/gearth/ui/logger/loggerdisplays/uilogger/UiLoggerController.java index 2b0f5e0..a839ce7 100644 --- a/G-Earth/src/main/java/gearth/ui/logger/loggerdisplays/uilogger/UiLoggerController.java +++ b/G-Earth/src/main/java/gearth/ui/logger/loggerdisplays/uilogger/UiLoggerController.java @@ -12,6 +12,7 @@ import javafx.scene.control.CheckMenuItem; import javafx.scene.control.Label; import javafx.scene.layout.BorderPane; import javafx.scene.layout.FlowPane; +import javafx.stage.Stage; import org.fxmisc.flowless.VirtualizedScrollPane; import org.fxmisc.richtext.StyleClassedTextArea; import org.fxmisc.richtext.model.StyleSpansBuilder; @@ -36,6 +37,8 @@ public class UiLoggerController implements Initializable { private StyleClassedTextArea area; + private Stage stage; + private boolean viewIncoming = true; private boolean viewOutgoing = true; private boolean displayStructure = true; @@ -43,6 +46,7 @@ public class UiLoggerController implements Initializable { private boolean skiphugepackets = true; private boolean viewMessageName = true; private boolean viewMessageHash = false; + private boolean alwaysOnTop = false; private volatile boolean initialized = false; private final List appendLater = new ArrayList<>(); @@ -181,6 +185,10 @@ public class UiLoggerController implements Initializable { }); } + public void setStage(Stage stage) { + this.stage = stage; + } + public void toggleViewIncoming() { viewIncoming = !viewIncoming; lblViewIncoming.setText("View Incoming: " + (viewIncoming ? "True" : "False")); @@ -214,4 +222,13 @@ public class UiLoggerController implements Initializable { public void toggleMessageHash(ActionEvent actionEvent) { viewMessageHash = !viewMessageHash; } + + public void toggleAlwaysOnTop(ActionEvent actionEvent) { + stage.setAlwaysOnTop(!alwaysOnTop); + alwaysOnTop = !alwaysOnTop; + } + + public void clearText(ActionEvent actionEvent) { + area.clear(); + } } diff --git a/G-Earth/src/main/resources/gearth/ui/injection/Injection.fxml b/G-Earth/src/main/resources/gearth/ui/injection/Injection.fxml index c1e3dfd..cd58ec6 100644 --- a/G-Earth/src/main/resources/gearth/ui/injection/Injection.fxml +++ b/G-Earth/src/main/resources/gearth/ui/injection/Injection.fxml @@ -9,6 +9,7 @@ + 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 4580284..0e51efc 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 @@ -9,7 +9,7 @@ - + @@ -33,6 +33,11 @@ + + + + +