diff --git a/pom.xml b/pom.xml index a01ab95..23be82b 100644 --- a/pom.xml +++ b/pom.xml @@ -108,7 +108,7 @@ org.openautonomousconnection protocol - 1.0.0-BETA.6.0 + 1.0.0-BETA.6.1 org.projectlombok diff --git a/src/main/java/org/openautonomousconnection/webclient/network/WebClient.java b/src/main/java/org/openautonomousconnection/webclient/network/WebClient.java index 7484d4c..096b7a7 100644 --- a/src/main/java/org/openautonomousconnection/webclient/network/WebClient.java +++ b/src/main/java/org/openautonomousconnection/webclient/network/WebClient.java @@ -16,6 +16,7 @@ import org.openautonomousconnection.webclient.network.type.NetTransmitFile; import javax.swing.text.Document; import java.io.IOException; +import java.net.ConnectException; import java.net.Inet4Address; import java.net.URL; import java.util.HashMap; @@ -46,6 +47,12 @@ public class WebClient extends ProtocolWebClient { // UDP is always preset this.buildServerConnection(host, port, DEFAULT_WEB_PORT_UDP); + + try { + this.getClientServerConnection().connect(); + } catch (ConnectException e) { + throw new RuntimeException(e); + } } /** @@ -59,6 +66,12 @@ public class WebClient extends ProtocolWebClient { // UDP is always preset this.buildServerConnection(ip, port, DEFAULT_INS_PORT_UDP); + + try { + this.getClientINSConnection().connect(); + } catch (ConnectException e) { + throw new RuntimeException(e); + } } /** @@ -156,6 +169,8 @@ public class WebClient extends ProtocolWebClient { System.out.println(promise(NTFType.DOCUMENT).getClass().getSimpleName()); + + return null;//(Promise>) promise(NTFType.DOCUMENT); } diff --git a/src/main/java/org/openautonomousconnection/webclient/ui/MainFrame.java b/src/main/java/org/openautonomousconnection/webclient/ui/MainFrame.java index 4af9f7c..9727af0 100644 --- a/src/main/java/org/openautonomousconnection/webclient/ui/MainFrame.java +++ b/src/main/java/org/openautonomousconnection/webclient/ui/MainFrame.java @@ -30,7 +30,7 @@ public final class MainFrame extends BrowserFrame { try { this.openTab = new Tab( - URI.create("web://open-autonomous-connection.org").toURL() + URI.create("web://127.0.0.1").toURL() ); } catch (MalformedURLException e) { throw new RuntimeException(e); diff --git a/src/main/java/org/openautonomousconnection/webclient/ui/dom/HTMLRenderer.java b/src/main/java/org/openautonomousconnection/webclient/ui/dom/HTMLRenderer.java deleted file mode 100644 index cf9bd75..0000000 --- a/src/main/java/org/openautonomousconnection/webclient/ui/dom/HTMLRenderer.java +++ /dev/null @@ -1,90 +0,0 @@ -package org.openautonomousconnection.webclient.ui.dom; - -import org.jsoup.nodes.Attributes; -import org.jsoup.nodes.Document; -import org.jsoup.nodes.Element; -import org.openautonomousconnection.webclient.ui.dom.renderers.HTMLTextRenderer; - - -import javax.swing.*; -import java.util.ArrayList; -import java.util.List; - -@Deprecated(forRemoval = true) -public class HTMLRenderer { - public static JPanel render(Document html) { - JPanel panel = new JPanel(); - - for(JComponent component : renderHead(html.head())) - panel.add(component); - - for(JComponent component : renderBody(html.body())) - panel.add(component); - - return panel; - } - - private static List renderHead(Element head) { - List result = new ArrayList<>(); - return result; - } - - private static List renderBody(Element body) { - return renderAndChildren(body); - } - - private static List renderAndChildren(Element element) { - List result = new ArrayList<>(); - - - element.children().forEach(e -> { - if(!e.children().isEmpty()) - result.addAll(renderAndChildren(e)); - - result.add(renderElement(e)); - }); - - return result; - } - - private static JComponent renderElement(Element element) { - String tagName = element.tagName().toLowerCase(); - - String text = element.text(); - - Attributes attributes = element.attributes(); - - String className = element.className(); - - switch (tagName) { - case "p": - case "u": - case "var": - case "span": - case "h1": - case "h2": - case "h3": - case "em": - case "del": - case "ins": - case "q": - case "sub": - case "sup": - case "cite": - case "code": - case "b": - case "i": - case "strong": - case "blockquote": - return HTMLTextRenderer.render( - HTMLTextRenderer.TEXTTYPE.of(tagName), - text, - attributes, - className - ); - - default: - return new JPanel(); - } - } -} diff --git a/src/main/java/org/openautonomousconnection/webclient/ui/dom/renderers/HTMLTextRenderer.java b/src/main/java/org/openautonomousconnection/webclient/ui/dom/renderers/HTMLTextRenderer.java deleted file mode 100644 index b59b57e..0000000 --- a/src/main/java/org/openautonomousconnection/webclient/ui/dom/renderers/HTMLTextRenderer.java +++ /dev/null @@ -1,98 +0,0 @@ -package org.openautonomousconnection.webclient.ui.dom.renderers; - -import lombok.Getter; -import org.jsoup.nodes.Attributes; - -import javax.swing.*; -import java.awt.*; - -@Deprecated(forRemoval = true) -public class HTMLTextRenderer { - - - public static JComponent render(TEXTTYPE texttype, String text, Attributes attributes, String className) { - // TODO: Implementation - return switch (texttype) { - case P, VAR, SPAN, H1, H2, H3 -> renderSimple(text, "", attributes, className); - case U -> renderSimple(text, "underlined", attributes, className); - case INS -> null; - case Q -> null; - case SUB -> null; - case SUP -> null; - case CITE -> null; - case CODE -> null; - // remember: b = bold text, Strong = bold & emphasized, like with TTS - case B, STRONG -> renderSimple(text, "bold", attributes, className); - case I -> renderSimple(text, "italic", attributes, className); - case EM -> renderSimple(text, "bold italic", attributes, className); - case DEL -> renderSimple(text, "strikethrough", attributes, className); - case BLOCKQUOTE -> null; - }; - } - - private static JComponent renderSimple(String text, String decoration, Attributes attributes, String className) { - JTextArea label = new JTextArea(text); - - label.setEditable(false); - label.setLineWrap(true); - label.setWrapStyleWord(true); - label.setBorder(null); - label.setOpaque(false); - label.setCaretColor(new Color(0, 0, 0, 0)); - int d = Font.PLAIN; - - Font font = new Font(Font.SERIF, Font.PLAIN, 15); - - -// try { TODO: implement css -// font = new Font( -// attributes.get("font"), -// Font.PLAIN, -// 0); -// } catch (Exception ignored) { -// font = new Font(Font.SERIF, Font.PLAIN, 0); -// -// } - - label.setFont(font); - - return label; - } - - public enum TEXTTYPE { - P("p"), - U("u"), - VAR("var"), - SPAN("span"), - H1("h1"), - H2("h2"), - H3("h3"), - EM("em"), - DEL("del"), - INS("ins"), - Q("q"), - SUB("sub"), - SUP("sup"), - CITE("cite"), - CODE("code"), - B("b"), - I("i"), - STRONG("strong"), - BLOCKQUOTE("blockquote"); - - public static TEXTTYPE of(String name) { - for(TEXTTYPE texttype : values()) - if(texttype.name.equals(name)) - return texttype; - - return null; - } - - @Getter - private final String name; - - TEXTTYPE(String name) { - this.name = name; - } - } -}