mirror of
https://github.com/sirjonasxx/G-Earth.git
synced 2025-01-19 08:36:27 +01:00
packetlogger fixes
This commit is contained in:
parent
26e273f2b5
commit
4470f6e223
@ -57,7 +57,7 @@ public class UiLogger extends ExtensionForm implements PacketLogger {
|
|||||||
@Override
|
@Override
|
||||||
protected void onEndConnection() {
|
protected void onEndConnection() {
|
||||||
controller.onDisconnect();
|
controller.onDisconnect();
|
||||||
controller.setPacketInfoManager(new PacketInfoManager(new ArrayList<>()));
|
controller.setPacketInfoManager(PacketInfoManager.EMPTY);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -45,6 +45,7 @@ public class UiLoggerController implements Initializable {
|
|||||||
public CheckMenuItem chkMessageHash;
|
public CheckMenuItem chkMessageHash;
|
||||||
public Label lblPacketInfo;
|
public Label lblPacketInfo;
|
||||||
public CheckMenuItem chkUseNewStructures;
|
public CheckMenuItem chkUseNewStructures;
|
||||||
|
public CheckMenuItem chkAlwaysOnTop;
|
||||||
|
|
||||||
public CheckMenuItem chkOpenOnConnect;
|
public CheckMenuItem chkOpenOnConnect;
|
||||||
public CheckMenuItem chkResetOnConnect;
|
public CheckMenuItem chkResetOnConnect;
|
||||||
@ -71,15 +72,6 @@ public class UiLoggerController implements Initializable {
|
|||||||
private Stage stage;
|
private Stage stage;
|
||||||
private PacketInfoManager packetInfoManager = null;
|
private PacketInfoManager packetInfoManager = null;
|
||||||
|
|
||||||
private boolean viewIncoming = true;
|
|
||||||
private boolean viewOutgoing = true;
|
|
||||||
private boolean displayStructure = true;
|
|
||||||
private boolean autoScroll = true;
|
|
||||||
private boolean skiphugepackets = true;
|
|
||||||
private boolean viewMessageName = true;
|
|
||||||
private boolean viewMessageHash = false;
|
|
||||||
private boolean alwaysOnTop = false;
|
|
||||||
|
|
||||||
private int skipped = 0;
|
private int skipped = 0;
|
||||||
|
|
||||||
private volatile boolean initialized = false;
|
private volatile boolean initialized = false;
|
||||||
@ -137,7 +129,10 @@ public class UiLoggerController implements Initializable {
|
|||||||
loadAllMenuItems();
|
loadAllMenuItems();
|
||||||
|
|
||||||
for (MenuItem item : allMenuItems) {
|
for (MenuItem item : allMenuItems) {
|
||||||
item.setOnAction(event -> saveAllMenuItems());
|
item.setOnAction(event -> {
|
||||||
|
saveAllMenuItems();
|
||||||
|
updateLoggerInfo();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
area = new StyleClassedTextArea();
|
area = new StyleClassedTextArea();
|
||||||
@ -204,20 +199,20 @@ public class UiLoggerController implements Initializable {
|
|||||||
boolean filter = checkFilter(packet);
|
boolean filter = checkFilter(packet);
|
||||||
if (filter) {
|
if (filter) {
|
||||||
skipped++;
|
skipped++;
|
||||||
lblSkipped.setText("Skipped: " + skipped);
|
updateLoggerInfo();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isIncoming && !viewIncoming) return;
|
if (isIncoming && !chkViewIncoming.isSelected()) return;
|
||||||
if (!isIncoming && !viewOutgoing) return;
|
if (!isIncoming && !chkViewOutgoing.isSelected()) return;
|
||||||
|
|
||||||
ArrayList<Element> elements = new ArrayList<>();
|
ArrayList<Element> elements = new ArrayList<>();
|
||||||
|
|
||||||
|
|
||||||
boolean packetInfoAvailable = packetInfoManager.getPacketInfoList().size() > 0;
|
boolean packetInfoAvailable = packetInfoManager.getPacketInfoList().size() > 0;
|
||||||
|
|
||||||
if ((viewMessageName || viewMessageHash) && packetInfoAvailable) {
|
if ((chkMessageName.isSelected() || chkMessageHash.isSelected()) && packetInfoAvailable) {
|
||||||
List<PacketInfo> messages = packetInfoManager.getAllPacketInfoFromHeaderId(
|
List<PacketInfo> messages = packetInfoManager.getAllPacketInfoFromHeaderId(
|
||||||
(isIncoming ? HMessage.Direction.TOCLIENT : HMessage.Direction.TOSERVER),
|
(isIncoming ? HMessage.Direction.TOCLIENT : HMessage.Direction.TOSERVER),
|
||||||
packet.headerId()
|
packet.headerId()
|
||||||
@ -228,11 +223,11 @@ public class UiLoggerController implements Initializable {
|
|||||||
.filter(Objects::nonNull).distinct().collect(Collectors.toList());
|
.filter(Objects::nonNull).distinct().collect(Collectors.toList());
|
||||||
|
|
||||||
boolean addedSomething = false;
|
boolean addedSomething = false;
|
||||||
if (viewMessageName && names.size() > 0) {
|
if (chkMessageName.isSelected() && names.size() > 0) {
|
||||||
for (String name : names) {elements.add(new Element("["+name+"]", "messageinfo")); }
|
for (String name : names) {elements.add(new Element("["+name+"]", "messageinfo")); }
|
||||||
addedSomething = true;
|
addedSomething = true;
|
||||||
}
|
}
|
||||||
if (viewMessageHash && hashes.size() > 0) {
|
if (chkMessageHash.isSelected() && hashes.size() > 0) {
|
||||||
for (String hash : hashes) {elements.add(new Element("["+hash+"]", "messageinfo")); }
|
for (String hash : hashes) {elements.add(new Element("["+hash+"]", "messageinfo")); }
|
||||||
addedSomething = true;
|
addedSomething = true;
|
||||||
}
|
}
|
||||||
@ -253,7 +248,7 @@ public class UiLoggerController implements Initializable {
|
|||||||
elements.add(new Element("]", "incoming"));
|
elements.add(new Element("]", "incoming"));
|
||||||
|
|
||||||
elements.add(new Element(" <- ", ""));
|
elements.add(new Element(" <- ", ""));
|
||||||
if (skiphugepackets && packet.length() > 4000) {
|
if (chkSkipBigPackets.isSelected() && packet.length() > 4000) {
|
||||||
elements.add(new Element("<packet skipped>", "skipped"));
|
elements.add(new Element("<packet skipped>", "skipped"));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -266,7 +261,7 @@ public class UiLoggerController implements Initializable {
|
|||||||
|
|
||||||
elements.add(new Element(" -> ", ""));
|
elements.add(new Element(" -> ", ""));
|
||||||
|
|
||||||
if (skiphugepackets && packet.length() > 4000) {
|
if (chkSkipBigPackets.isSelected() && packet.length() > 4000) {
|
||||||
elements.add(new Element("<packet skipped>", "skipped"));
|
elements.add(new Element("<packet skipped>", "skipped"));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -278,7 +273,7 @@ public class UiLoggerController implements Initializable {
|
|||||||
String expr = packet.toExpression(isIncoming ? HMessage.Direction.TOCLIENT : HMessage.Direction.TOSERVER, packetInfoManager, chkUseNewStructures.isSelected());
|
String expr = packet.toExpression(isIncoming ? HMessage.Direction.TOCLIENT : HMessage.Direction.TOSERVER, packetInfoManager, chkUseNewStructures.isSelected());
|
||||||
String cleaned = cleanTextContent(expr);
|
String cleaned = cleanTextContent(expr);
|
||||||
if (cleaned.equals(expr)) {
|
if (cleaned.equals(expr)) {
|
||||||
if (!expr.equals("") && displayStructure)
|
if (!expr.equals("") && chkDisplayStructure.isSelected())
|
||||||
elements.add(new Element("\n" + cleanTextContent(expr), "structure"));
|
elements.add(new Element("\n" + cleanTextContent(expr), "structure"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -313,7 +308,7 @@ public class UiLoggerController implements Initializable {
|
|||||||
// System.out.println(sb.toString());
|
// System.out.println(sb.toString());
|
||||||
area.setStyleSpans(oldLen, styleSpansBuilder.create());
|
area.setStyleSpans(oldLen, styleSpansBuilder.create());
|
||||||
|
|
||||||
if (autoScroll) {
|
if (chkAutoscroll.isSelected()) {
|
||||||
// area.moveTo(area.getLength());
|
// area.moveTo(area.getLength());
|
||||||
area.requestFollowCaret();
|
area.requestFollowCaret();
|
||||||
}
|
}
|
||||||
@ -324,51 +319,25 @@ public class UiLoggerController implements Initializable {
|
|||||||
this.stage = stage;
|
this.stage = stage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPacketInfoManager(PacketInfoManager packetInfoManager) {
|
public void updateLoggerInfo() {
|
||||||
this.packetInfoManager = packetInfoManager;
|
|
||||||
Platform.runLater(() -> {
|
Platform.runLater(() -> {
|
||||||
|
lblViewIncoming.setText("View Incoming: " + (chkViewIncoming.isSelected() ? "True" : "False"));
|
||||||
|
lblViewOutgoing.setText("View Outgoing: " + (chkViewOutgoing.isSelected() ? "True" : "False"));
|
||||||
|
lblAutoScrolll.setText("Autoscroll: " + (chkAutoscroll.isSelected() ? "True" : "False"));
|
||||||
|
lblSkipped.setText("Skipped: " + skipped);
|
||||||
|
|
||||||
boolean packetInfoAvailable = packetInfoManager.getPacketInfoList().size() > 0;
|
boolean packetInfoAvailable = packetInfoManager.getPacketInfoList().size() > 0;
|
||||||
lblPacketInfo.setText("Packet info: " + (packetInfoAvailable ? "True" : "False"));
|
lblPacketInfo.setText("Packet info: " + (packetInfoAvailable ? "True" : "False"));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void toggleViewIncoming() {
|
public void setPacketInfoManager(PacketInfoManager packetInfoManager) {
|
||||||
viewIncoming = !viewIncoming;
|
this.packetInfoManager = packetInfoManager;
|
||||||
lblViewIncoming.setText("View Incoming: " + (viewIncoming ? "True" : "False"));
|
Platform.runLater(this::updateLoggerInfo);
|
||||||
// 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void toggleAutoscroll(ActionEvent actionEvent) {
|
|
||||||
autoScroll = !autoScroll;
|
|
||||||
lblAutoScrolll.setText("Autoscroll: " + (autoScroll ? "True" : "False"));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void toggleSkipPackets(ActionEvent actionEvent) {
|
|
||||||
skiphugepackets = !skiphugepackets;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void toggleMessageName(ActionEvent actionEvent) {
|
|
||||||
viewMessageName = !viewMessageName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void toggleMessageHash(ActionEvent actionEvent) {
|
|
||||||
viewMessageHash = !viewMessageHash;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void toggleAlwaysOnTop(ActionEvent actionEvent) {
|
public void toggleAlwaysOnTop(ActionEvent actionEvent) {
|
||||||
stage.setAlwaysOnTop(!alwaysOnTop);
|
stage.setAlwaysOnTop(chkAlwaysOnTop.isSelected());
|
||||||
alwaysOnTop = !alwaysOnTop;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearText(ActionEvent actionEvent) {
|
public void clearText(ActionEvent actionEvent) {
|
||||||
|
@ -26,15 +26,15 @@
|
|||||||
</items>
|
</items>
|
||||||
</Menu>
|
</Menu>
|
||||||
<Menu mnemonicParsing="false" text="View">
|
<Menu mnemonicParsing="false" text="View">
|
||||||
<CheckMenuItem fx:id="chkViewIncoming" mnemonicParsing="false" onAction="#toggleViewIncoming" selected="true" text="View Incoming">
|
<CheckMenuItem fx:id="chkViewIncoming" mnemonicParsing="false" selected="true" text="View Incoming">
|
||||||
<accelerator>
|
<accelerator>
|
||||||
<KeyCodeCombination alt="UP" code="I" control="DOWN" meta="UP" shift="UP" shortcut="UP" />
|
<KeyCodeCombination alt="UP" code="I" control="DOWN" meta="UP" shift="UP" shortcut="UP" />
|
||||||
</accelerator></CheckMenuItem>
|
</accelerator></CheckMenuItem>
|
||||||
<CheckMenuItem fx:id="chkViewOutgoing" mnemonicParsing="false" onAction="#toggleViewOutgoing" selected="true" text="View Outgoing">
|
<CheckMenuItem fx:id="chkViewOutgoing" mnemonicParsing="false" selected="true" text="View Outgoing">
|
||||||
<accelerator>
|
<accelerator>
|
||||||
<KeyCodeCombination alt="UP" code="O" control="DOWN" meta="UP" shift="UP" shortcut="UP" />
|
<KeyCodeCombination alt="UP" code="O" control="DOWN" meta="UP" shift="UP" shortcut="UP" />
|
||||||
</accelerator></CheckMenuItem>
|
</accelerator></CheckMenuItem>
|
||||||
<CheckMenuItem fx:id="chkAutoscroll" mnemonicParsing="false" onAction="#toggleAutoscroll" selected="true" text="Autoscroll">
|
<CheckMenuItem fx:id="chkAutoscroll" mnemonicParsing="false" selected="true" text="Autoscroll">
|
||||||
<accelerator>
|
<accelerator>
|
||||||
<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>
|
||||||
@ -47,10 +47,10 @@
|
|||||||
<items>
|
<items>
|
||||||
<Menu mnemonicParsing="false" text="Display Details">
|
<Menu mnemonicParsing="false" text="Display Details">
|
||||||
<items>
|
<items>
|
||||||
<CheckMenuItem fx:id="chkDisplayStructure" mnemonicParsing="false" onAction="#toggleDisplayStructure" selected="true" text="Structure" />
|
<CheckMenuItem fx:id="chkDisplayStructure" mnemonicParsing="false" selected="true" text="Structure" />
|
||||||
<CheckMenuItem fx:id="chkMessageName" mnemonicParsing="false" onAction="#toggleMessageName" selected="true" text="Message Name" />
|
<CheckMenuItem fx:id="chkMessageName" mnemonicParsing="false" selected="true" text="Message Name" />
|
||||||
<CheckMenuItem fx:id="chkMessageHash" mnemonicParsing="false" onAction="#toggleMessageHash" text="Message Hash" />
|
<CheckMenuItem fx:id="chkMessageHash" mnemonicParsing="false" text="Message Hash" />
|
||||||
<CheckMenuItem fx:id="chkUseNewStructures" mnemonicParsing="false" onAction="#toggleMessageHash" selected="true" text="New structures" />
|
<CheckMenuItem fx:id="chkUseNewStructures" mnemonicParsing="false" selected="true" text="New structures" />
|
||||||
</items>
|
</items>
|
||||||
</Menu>
|
</Menu>
|
||||||
<Menu mnemonicParsing="false" text="Anti-spam filter">
|
<Menu mnemonicParsing="false" text="Anti-spam filter">
|
||||||
@ -66,7 +66,7 @@
|
|||||||
<RadioMenuItem fx:id="chkAntiSpam_ultra" mnemonicParsing="false" text="Ultra" toggleGroup="$antispam" />
|
<RadioMenuItem fx:id="chkAntiSpam_ultra" mnemonicParsing="false" text="Ultra" toggleGroup="$antispam" />
|
||||||
</items>
|
</items>
|
||||||
</Menu>
|
</Menu>
|
||||||
<CheckMenuItem fx:id="chkSkipBigPackets" mnemonicParsing="false" onAction="#toggleSkipPackets" selected="true" text="Skip big packets" />
|
<CheckMenuItem fx:id="chkSkipBigPackets" mnemonicParsing="false" selected="true" text="Skip big packets" />
|
||||||
</items>
|
</items>
|
||||||
</Menu>
|
</Menu>
|
||||||
</MenuBar>
|
</MenuBar>
|
||||||
|
Loading…
Reference in New Issue
Block a user