");
String expr = packet.toExpression(isIncoming ? HMessage.Direction.TOCLIENT : HMessage.Direction.TOSERVER);
@@ -104,84 +103,57 @@ public class UiLoggerController implements Initializable {
packet.headerId()
);
- if ( message != null && !(viewMessageName && !viewMessageHash && message.getName() == null)) {
+ if (message != null && !(viewMessageName && !viewMessageHash && message.getName() == null)) {
if (viewMessageName && message.getName() != null) {
- elements.add(new Element("["+message.getName()+"]", "messageinfo"));
+ packetHtml.append(divWithClass("[" + message.getName() + "]", "messageinfo"));
}
if (viewMessageHash) {
- elements.add(new Element("["+message.getHash()+"]", "messageinfo"));
+ packetHtml.append(divWithClass("[" + message.getHash() + "]", "messageinfo"));
}
- elements.add(new Element("\n", ""));
}
}
- if (isBlocked) elements.add(new Element("[Blocked]\n", "blocked"));
- else if (isReplaced) elements.add(new Element("[Replaced]\n", "replaced"));
+ if (isBlocked) packetHtml.append(divWithClass("[Blocked]", "blocked"));
+ else if (isReplaced) packetHtml.append(divWithClass("[Replaced]", "replaced"));
- if (isIncoming) {
- // handle skipped eventually
- elements.add(new Element("Incoming[", "incoming"));
- elements.add(new Element(String.valueOf(packet.headerId()), ""));
- elements.add(new Element("]", "incoming"));
- elements.add(new Element(" <- ", ""));
- if (skiphugepackets && packet.length() > 8000) {
- elements.add(new Element("
", "skipped"));
- }
- else {
- elements.add(new Element(packet.toString(), "incoming"));
- }
- } else {
- elements.add(new Element("Outgoing[", "outgoing"));
- elements.add(new Element(String.valueOf(packet.headerId()), ""));
- elements.add(new Element("]", "outgoing"));
+ packetHtml
+ .append("")
+ .append(isIncoming ? spanWithClass("Incoming[", "incoming") :
+ spanWithClass("Outgoing[", "outgoing"))
+ .append(packet.headerId())
+ .append(spanWithClass("]", isIncoming ? "incoming" : "outgoing"))
+ .append(isIncoming ? " <- " : " -> ")
+ .append(skiphugepackets && packet.length() > 8000 ?
+ divWithClass("
", "skipped") :
+ divWithClass(packet.toString(), isIncoming ? "incoming" : "outgoing"));
- elements.add(new Element(" -> ", ""));
-
- if (skiphugepackets && packet.length() > 8000) {
- elements.add(new Element("", "skipped"));
- }
- else {
- elements.add(new Element(packet.toString(), "outgoing"));
- }
- }
String cleaned = cleanTextContent(expr);
if (cleaned.equals(expr)) {
if (!expr.equals("") && displayStructure && packet.length() <= 2000)
- elements.add(new Element("\n" + cleanTextContent(expr), "structure"));
+ packetHtml.append(divWithClass(cleanTextContent(expr), "structure"));
}
- elements.add(new Element("\n--------------------\n", ""));
+ packetHtml.append(divWithClass("--------------------", ""));
synchronized (appendLater) {
if (initialized) {
- appendLog(elements);
- }
- else {
- appendLater.addAll(elements);
+ appendLog(Collections.singletonList(packetHtml.toString()));
+ } else {
+ appendLater.add(packetHtml.toString());
}
}
-
}
- private synchronized void appendLog(List elements) {
+ private synchronized void appendLog(List html) {
Platform.runLater(() -> {
-
- for (Element element : elements) {
- String script = "$('#output').append('"
- + escapeMessage(element.text) + "');";
-
- try {
- executejQuery(webView.getEngine(), script);
- } catch (Exception e) {
- System.out.println("Malformed JS message " + script);
- }
- }
+ String script = "document.getElementById('output').innerHTML += '" + String.join("", html) + "';";
+ webView.getEngine().executeScript(script);
if (autoScroll) {
- webView.getEngine().executeScript("window.scrollTo(0, document.body.scrollHeight);");
+ executejQuery(webView.getEngine(), "$('html, body').animate({scrollTop:$(document).height()}, 'slow');");
}
});
}
@@ -260,6 +232,14 @@ public class UiLoggerController implements Initializable {
}
public void clearText(ActionEvent actionEvent) {
- webView.getEngine().executeScript("$('#output').html = \\'\\'");
+ executejQuery(webView.getEngine(), "$('#output').empty();");
+ }
+
+ private String divWithClass(String content, String klass) {
+ return escapeMessage("" + content + "
");
+ }
+
+ private String spanWithClass(String content, String klass) {
+ return escapeMessage("" + content + "");
}
}
diff --git a/G-Earth/src/main/resources/gearth/ui/logger/uilogger/logger.css b/G-Earth/src/main/resources/gearth/ui/logger/uilogger/logger.css
index d83a56d..5831a15 100644
--- a/G-Earth/src/main/resources/gearth/ui/logger/uilogger/logger.css
+++ b/G-Earth/src/main/resources/gearth/ui/logger/uilogger/logger.css
@@ -38,7 +38,7 @@
.menu-bar .text, .menu .text {
color: #000000 !important;
- padding: -2px 0 -2px 0 !important;
+ /*padding: -2px 0 -2px 0 !important;*/
}
.scroll-bar:vertical {