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