Usable
This commit is contained in:
@@ -2,7 +2,6 @@ package org.openautonomousconnection.webclient;
|
||||
|
||||
import dev.unlegitdqrk.unlegitlibrary.event.Listener;
|
||||
import org.openautonomousconnection.infonamelib.OacWebUrlInstaller;
|
||||
import org.openautonomousconnection.infonamelib.ProtocolHandlerPackages;
|
||||
import org.openautonomousconnection.oacswing.component.OACOptionPane;
|
||||
import org.openautonomousconnection.protocol.side.client.ProtocolClient;
|
||||
import org.openautonomousconnection.protocol.side.client.events.ConnectedToProtocolINSServerEvent;
|
||||
@@ -58,8 +57,10 @@ public class ClientImpl extends ProtocolClient {
|
||||
public void onConnected(ConnectedToProtocolINSServerEvent event) {
|
||||
try {
|
||||
buildServerConnection(null, getProtocolBridge().getProtocolValues().ssl);
|
||||
ProtocolHandlerPackages.installPackage("org.openautonomousconnection.infonamelib");
|
||||
|
||||
//ProtocolHandlerPackages.installPackage("org.openautonomousconnection.infonamelib");
|
||||
OacWebUrlInstaller.installOnce(getProtocolBridge().getProtocolValues().eventManager, this);
|
||||
|
||||
SwingUtilities.invokeLater(() -> Main.getUi().openNewTab("web://info.oac/"));
|
||||
} catch (Exception e) {
|
||||
Main.getClient().getProtocolBridge().getLogger().exception("Failed to build Server connection", e);
|
||||
|
||||
@@ -14,6 +14,9 @@ import org.openautonomousconnection.webclient.ui.FxBootstrap;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.io.File;
|
||||
import java.net.CookieHandler;
|
||||
import java.net.CookieManager;
|
||||
import java.net.CookiePolicy;
|
||||
|
||||
public class Main {
|
||||
|
||||
@@ -47,9 +50,18 @@ public class Main {
|
||||
}
|
||||
}
|
||||
|
||||
private static void installDefaultCookieManager() {
|
||||
if (CookieHandler.getDefault() != null) return;
|
||||
|
||||
CookieManager cm = new CookieManager();
|
||||
cm.setCookiePolicy(CookiePolicy.ACCEPT_ALL);
|
||||
CookieHandler.setDefault(cm);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
initProtocol();
|
||||
FxBootstrap.ensureInitialized();
|
||||
installDefaultCookieManager();
|
||||
DesignManager.setGlobalDesign(Design.DARK);
|
||||
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
package org.openautonomousconnection.webclient.lua.hosts;
|
||||
|
||||
public class FxFormNavigationBridge {
|
||||
}
|
||||
@@ -25,7 +25,7 @@ public final class UiHostImpl implements UiHost {
|
||||
* Creates a new UI host.
|
||||
*
|
||||
* @param engine web engine
|
||||
* @param view web view
|
||||
* @param view web view
|
||||
* @param dom dom host
|
||||
*/
|
||||
public UiHostImpl(WebEngine engine, WebView view, FxDomHost dom) {
|
||||
@@ -34,6 +34,36 @@ public final class UiHostImpl implements UiHost {
|
||||
this.dom = Objects.requireNonNull(dom, "dom");
|
||||
}
|
||||
|
||||
private static boolean hasClassToken(String classAttr, String cls) {
|
||||
String[] parts = classAttr.trim().split("\\s+");
|
||||
for (String p : parts) {
|
||||
if (p.equals(cls)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static String removeCssProp(String style, String propLower) {
|
||||
if (style == null || style.isBlank()) return "";
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
for (String part : style.split(";")) {
|
||||
String p = part.trim();
|
||||
if (p.isEmpty()) continue;
|
||||
int idx = p.indexOf(':');
|
||||
if (idx <= 0) continue;
|
||||
|
||||
String k = p.substring(0, idx).trim().toLowerCase();
|
||||
if (k.equals(propLower)) continue;
|
||||
|
||||
if (!sb.isEmpty()) sb.append(';');
|
||||
sb.append(p);
|
||||
}
|
||||
|
||||
String out = sb.toString().trim();
|
||||
if (!out.isEmpty() && !out.endsWith(";")) out += ";";
|
||||
return out;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void alert(String message) {
|
||||
// No JS: use simple JavaFX dialog-less fallback (log-style). You can replace with real Dialogs later.
|
||||
@@ -279,34 +309,4 @@ public final class UiHostImpl implements UiHost {
|
||||
public long nowMillis() {
|
||||
return System.currentTimeMillis();
|
||||
}
|
||||
|
||||
private static boolean hasClassToken(String classAttr, String cls) {
|
||||
String[] parts = classAttr.trim().split("\\s+");
|
||||
for (String p : parts) {
|
||||
if (p.equals(cls)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static String removeCssProp(String style, String propLower) {
|
||||
if (style == null || style.isBlank()) return "";
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
for (String part : style.split(";")) {
|
||||
String p = part.trim();
|
||||
if (p.isEmpty()) continue;
|
||||
int idx = p.indexOf(':');
|
||||
if (idx <= 0) continue;
|
||||
|
||||
String k = p.substring(0, idx).trim().toLowerCase();
|
||||
if (k.equals(propLower)) continue;
|
||||
|
||||
if (!sb.isEmpty()) sb.append(';');
|
||||
sb.append(p);
|
||||
}
|
||||
|
||||
String out = sb.toString().trim();
|
||||
if (!out.isEmpty() && !out.endsWith(";")) out += ";";
|
||||
return out;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ public final class FxEngine implements AutoCloseable {
|
||||
/**
|
||||
* Creates an integration engine with default UI execution policy.
|
||||
*
|
||||
* @param engine web engine
|
||||
* @param engine web engine
|
||||
* @param webView web view
|
||||
*/
|
||||
public FxEngine(WebEngine engine, WebView webView, WebLogger logger) {
|
||||
@@ -47,9 +47,9 @@ public final class FxEngine implements AutoCloseable {
|
||||
/**
|
||||
* Creates an integration engine with a custom execution policy.
|
||||
*
|
||||
* @param engine web engine
|
||||
* @param engine web engine
|
||||
* @param webView web view
|
||||
* @param policy execution policy
|
||||
* @param policy execution policy
|
||||
*/
|
||||
public FxEngine(WebEngine engine, WebView webView, LuaExecutionPolicy policy, WebLogger logger) {
|
||||
this.engine = Objects.requireNonNull(engine, "engine");
|
||||
|
||||
@@ -107,7 +107,8 @@ public class BrowserTab {
|
||||
private final TabView fixedView;
|
||||
|
||||
private BrowserTabKeyed(String fixedKey, TabView fixedView) {
|
||||
super("about:blank", s -> { });
|
||||
super("about:blank", s -> {
|
||||
});
|
||||
this.fixedKey = Objects.requireNonNull(fixedKey, "fixedKey");
|
||||
this.fixedView = Objects.requireNonNull(fixedView, "fixedView");
|
||||
}
|
||||
|
||||
@@ -116,6 +116,18 @@ public class BrowserUI extends OACFrame {
|
||||
DesignManager.apply(this);
|
||||
}
|
||||
|
||||
private static String normalizeUrl(String input) {
|
||||
String s = input == null ? "" : input.trim();
|
||||
if (s.isEmpty()) return "web://info.oac/";
|
||||
if (s.startsWith("web://")) {
|
||||
// Ensure trailing slash for "host only" URLs
|
||||
String rest = s.substring("web://".length());
|
||||
if (!rest.contains("/")) return s + "/";
|
||||
return s;
|
||||
}
|
||||
return "web://" + s + (s.contains("/") ? "" : "/");
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens a new tab and navigates to the given URL.
|
||||
*
|
||||
@@ -222,16 +234,4 @@ public class BrowserUI extends OACFrame {
|
||||
tabCounter++;
|
||||
return "Tab " + tabCounter;
|
||||
}
|
||||
|
||||
private static String normalizeUrl(String input) {
|
||||
String s = input == null ? "" : input.trim();
|
||||
if (s.isEmpty()) return "web://info.oac/";
|
||||
if (s.startsWith("web://")) {
|
||||
// Ensure trailing slash for "host only" URLs
|
||||
String rest = s.substring("web://".length());
|
||||
if (!rest.contains("/")) return s + "/";
|
||||
return s;
|
||||
}
|
||||
return "web://" + s + (s.contains("/") ? "" : "/");
|
||||
}
|
||||
}
|
||||
@@ -24,21 +24,18 @@ import java.util.function.Consumer;
|
||||
public final class TabView extends OACPanel {
|
||||
|
||||
private final AtomicBoolean initialized = new AtomicBoolean(false);
|
||||
|
||||
private final Consumer<String> onLocationChanged;
|
||||
private final WebLogger webLogger;
|
||||
private JFXPanel fxPanel;
|
||||
private WebView webView;
|
||||
private WebEngine engine;
|
||||
|
||||
private final Consumer<String> onLocationChanged;
|
||||
private final WebLogger webLogger;
|
||||
|
||||
private volatile FxEngine luaEngine;
|
||||
|
||||
/**
|
||||
* Creates a new tab view.
|
||||
*
|
||||
* @param onLocationChanged callback invoked when the WebEngine location changes
|
||||
* @param url callback invoked on URL changes
|
||||
* @param url callback invoked on URL changes
|
||||
*/
|
||||
public TabView(Consumer<String> onLocationChanged, String url) {
|
||||
super();
|
||||
|
||||
Reference in New Issue
Block a user