Refractors
This commit is contained in:
11
pom.xml
11
pom.xml
@@ -12,7 +12,7 @@
|
|||||||
<url>https://open-autonomous-connection.org/</url>
|
<url>https://open-autonomous-connection.org/</url>
|
||||||
</organization>
|
</organization>
|
||||||
<url>https://open-autonomous-connection.org/</url>
|
<url>https://open-autonomous-connection.org/</url>
|
||||||
<description>The default WebClient-Server</description>
|
<description>The default WebClient</description>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source>23</maven.compiler.source>
|
<maven.compiler.source>23</maven.compiler.source>
|
||||||
@@ -70,7 +70,7 @@
|
|||||||
</license>
|
</license>
|
||||||
<license>
|
<license>
|
||||||
<name>WTPL License</name>
|
<name>WTPL License</name>
|
||||||
<url>https://github.com/ronmamo/reflections/tree/master?tab=WTFPL-1-ov-file</url>
|
<url>https://github.com/ronmamo/reflections/tree/master?webTab=WTFPL-1-ov-file</url>
|
||||||
</license>
|
</license>
|
||||||
<license>
|
<license>
|
||||||
<name>Apache License 2.0</name>
|
<name>Apache License 2.0</name>
|
||||||
@@ -86,7 +86,7 @@
|
|||||||
</license>
|
</license>
|
||||||
<license>
|
<license>
|
||||||
<name>projectlombok</name>
|
<name>projectlombok</name>
|
||||||
<url>https://github.com/projectlombok/lombok?tab=License-1-ov-file</url>
|
<url>https://github.com/projectlombok/lombok?webTab=License-1-ov-file</url>
|
||||||
</license>
|
</license>
|
||||||
<license>
|
<license>
|
||||||
<name>Eclipse Public License v2.0</name>
|
<name>Eclipse Public License v2.0</name>
|
||||||
@@ -110,6 +110,11 @@
|
|||||||
<artifactId>Protocol</artifactId>
|
<artifactId>Protocol</artifactId>
|
||||||
<version>1.0.0-BETA.7.4</version>
|
<version>1.0.0-BETA.7.4</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.openautonomousconnection</groupId>
|
||||||
|
<artifactId>OACSwing</artifactId>
|
||||||
|
<version>1.0.0-BETA.1.1</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.projectlombok</groupId>
|
<groupId>org.projectlombok</groupId>
|
||||||
<artifactId>lombok</artifactId>
|
<artifactId>lombok</artifactId>
|
||||||
|
|||||||
@@ -7,6 +7,9 @@ package org.openautonomousconnection.webclient;
|
|||||||
import dev.unlegitdqrk.unlegitlibrary.event.EventManager;
|
import dev.unlegitdqrk.unlegitlibrary.event.EventManager;
|
||||||
import dev.unlegitdqrk.unlegitlibrary.network.system.packets.PacketHandler;
|
import dev.unlegitdqrk.unlegitlibrary.network.system.packets.PacketHandler;
|
||||||
import org.openautonomousconnection.infonamelib.InfoNames;
|
import org.openautonomousconnection.infonamelib.InfoNames;
|
||||||
|
import org.openautonomousconnection.oacswing.component.design.Design;
|
||||||
|
import org.openautonomousconnection.oacswing.component.design.DesignManager;
|
||||||
|
import org.openautonomousconnection.oacswing.component.design.OACColor;
|
||||||
import org.openautonomousconnection.protocol.ProtocolBridge;
|
import org.openautonomousconnection.protocol.ProtocolBridge;
|
||||||
import org.openautonomousconnection.protocol.ProtocolValues;
|
import org.openautonomousconnection.protocol.ProtocolValues;
|
||||||
import org.openautonomousconnection.protocol.versions.ProtocolVersion;
|
import org.openautonomousconnection.protocol.versions.ProtocolVersion;
|
||||||
@@ -14,6 +17,7 @@ import org.openautonomousconnection.webclient.network.WebClient;
|
|||||||
import org.openautonomousconnection.webclient.network.handlers.ServerPacketHandler;
|
import org.openautonomousconnection.webclient.network.handlers.ServerPacketHandler;
|
||||||
import org.openautonomousconnection.webclient.packetlistener.listeners.WebPacketListener;
|
import org.openautonomousconnection.webclient.packetlistener.listeners.WebPacketListener;
|
||||||
import org.openautonomousconnection.webclient.ui.MainFrame;
|
import org.openautonomousconnection.webclient.ui.MainFrame;
|
||||||
|
import org.openautonomousconnection.webclient.ui.dom.DOMContainerPanel;
|
||||||
|
|
||||||
import java.beans.EventHandler;
|
import java.beans.EventHandler;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -44,6 +48,11 @@ public class Main {
|
|||||||
}
|
}
|
||||||
registerPacketListeners();
|
registerPacketListeners();
|
||||||
|
|
||||||
|
/* Darkmode, wohoo! */
|
||||||
|
initDesigns();
|
||||||
|
|
||||||
|
DesignManager.setGlobalDesign(Design.DARK);
|
||||||
|
|
||||||
mainFrame = new MainFrame();
|
mainFrame = new MainFrame();
|
||||||
|
|
||||||
mainFrame.setVisible(true);
|
mainFrame.setVisible(true);
|
||||||
@@ -82,4 +91,10 @@ public class Main {
|
|||||||
private static void registerPacketListeners() {
|
private static void registerPacketListeners() {
|
||||||
ServerPacketHandler.registerPacketListener(new WebPacketListener());
|
ServerPacketHandler.registerPacketListener(new WebPacketListener());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void initDesigns() {
|
||||||
|
//TODO
|
||||||
|
|
||||||
|
DesignManager.getInstance().registerComponent(DOMContainerPanel.class, OACColor.DARK_BACKGROUND);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ import org.openautonomousconnection.webclient.network.type.NetTransmitFile;
|
|||||||
import javax.swing.text.Document;
|
import javax.swing.text.Document;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.ConnectException;
|
import java.net.ConnectException;
|
||||||
import java.net.Inet4Address;
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.security.KeyManagementException;
|
import java.security.KeyManagementException;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
@@ -38,24 +37,6 @@ public class WebClient extends ProtocolClient {
|
|||||||
*/
|
*/
|
||||||
public static final int TIMEOUT = 30;
|
public static final int TIMEOUT = 30;
|
||||||
|
|
||||||
/**
|
|
||||||
* Connect to Webserver with URLs (info name based)
|
|
||||||
* @param url url containing host and port (port optional)
|
|
||||||
*/
|
|
||||||
public void connectToWebServer(URL url) throws Exception {
|
|
||||||
String host = url.getHost();
|
|
||||||
|
|
||||||
int port = url.getPort() != -1 ? url.getPort() : DEFAULT_WEB_PORT_TCP;
|
|
||||||
|
|
||||||
// UDP is always preset
|
|
||||||
this.buildServerConnection(null, true);
|
|
||||||
|
|
||||||
try {
|
|
||||||
this.getClientServerConnection().connect(host, DEFAULT_WEB_PORT_TCP);
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Connect to INServer with URLs (ip based)
|
* Connect to INServer with URLs (ip based)
|
||||||
@@ -115,21 +96,15 @@ public class WebClient extends ProtocolClient {
|
|||||||
public void onResponse(INSResponseStatus insResponseStatus, List<INSRecord> list) {
|
public void onResponse(INSResponseStatus insResponseStatus, List<INSRecord> list) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Just an example (ui would be better than console)
|
|
||||||
@Override
|
@Override
|
||||||
public boolean trustINS(String caFingerprint) {
|
public boolean trustINS(String caFingerprint) {
|
||||||
getProtocolBridge().getLogger().info("You never connected to this INS before.\n" +
|
//TODO
|
||||||
"Fingerprint: " + caFingerprint + "\n" +
|
|
||||||
"Do you want to connect? (y/N)");
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean trustNewINSFingerprint(String oldCAFingerprint, String newCAFingerprint) {
|
public boolean trustNewINSFingerprint(String oldCAFingerprint, String newCAFingerprint) {
|
||||||
getProtocolBridge().getLogger().warn("INS root Certificate changed.\n" +
|
//TODO
|
||||||
"Old fingerprint: " + oldCAFingerprint + "\n" +
|
|
||||||
"New fingerprint: " + newCAFingerprint + "\n" +
|
|
||||||
"Do you want to connect? (y/N)");
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,75 +1,14 @@
|
|||||||
/* Author: Maple
|
|
||||||
* Dec. 12 2025
|
|
||||||
* */
|
|
||||||
|
|
||||||
package org.openautonomousconnection.webclient.network.website.tab;
|
package org.openautonomousconnection.webclient.network.website.tab;
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
import org.openautonomousconnection.webclient.Main;
|
|
||||||
import org.openautonomousconnection.webclient.network.website.WebSite;
|
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
@Getter @Setter
|
public interface Tab {
|
||||||
public final class Tab {
|
Icon getFavicon();
|
||||||
private URL infoName;
|
void setFavicon(Icon favicon);
|
||||||
private Icon favicon;
|
|
||||||
private WebSite webSite;
|
|
||||||
|
|
||||||
public Tab(URL infoName, Icon favicon) throws Exception {
|
URL getInfoName();
|
||||||
Main.client.connectToWebServer(infoName);
|
void setInfoName(URL infoName);
|
||||||
|
|
||||||
this.infoName = infoName;
|
void refresh() throws Exception;
|
||||||
this.favicon = favicon;
|
|
||||||
this.webSite = new WebSite(infoName);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Tab(URL infoName) throws Exception {
|
|
||||||
Main.client.connectToWebServer(infoName);
|
|
||||||
|
|
||||||
this.infoName = infoName;
|
|
||||||
this.favicon = WebSite.getFavIcon(infoName);
|
|
||||||
this.webSite = new WebSite(infoName);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Tab(WebSite webSite) throws Exception {
|
|
||||||
Main.client.connectToWebServer(webSite.getInfoName());
|
|
||||||
|
|
||||||
this.infoName = webSite.getInfoName();
|
|
||||||
this.favicon = webSite.getFavIcon();
|
|
||||||
this.webSite = webSite;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void refresh() {
|
|
||||||
this.webSite.requestNewDom();
|
|
||||||
this.favicon = this.webSite.getFavIcon();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object obj) {
|
|
||||||
if (obj == this) return true;
|
|
||||||
if (obj == null || obj.getClass() != this.getClass()) return false;
|
|
||||||
var that = (Tab) obj;
|
|
||||||
return Objects.equals(this.infoName, that.infoName) &&
|
|
||||||
Objects.equals(this.favicon, that.favicon) &&
|
|
||||||
Objects.equals(this.webSite, that.webSite);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return Objects.hash(this.infoName, this.favicon, this.webSite);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "Tab{" +
|
|
||||||
"infoName=" + this.infoName +
|
|
||||||
", favicon=" + this.favicon +
|
|
||||||
", webSite=" + this.webSite +
|
|
||||||
'}';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,90 @@
|
|||||||
|
/* Author: Maple
|
||||||
|
* Dec. 12 2025
|
||||||
|
* */
|
||||||
|
|
||||||
|
package org.openautonomousconnection.webclient.network.website.tab;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import org.openautonomousconnection.webclient.network.WebClient;
|
||||||
|
import org.openautonomousconnection.webclient.network.website.WebSite;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
import static org.openautonomousconnection.webclient.Main.DEFAULT_WEB_PORT_TCP;
|
||||||
|
|
||||||
|
public final class WebTab implements Tab {
|
||||||
|
@Getter @Setter
|
||||||
|
private URL infoName;
|
||||||
|
|
||||||
|
@Getter @Setter
|
||||||
|
private Icon favicon;
|
||||||
|
|
||||||
|
@Getter @Setter
|
||||||
|
private WebSite webSite;
|
||||||
|
|
||||||
|
private WebClient client;
|
||||||
|
|
||||||
|
public WebTab(URL infoName, Icon favicon) throws Exception {
|
||||||
|
refresh();
|
||||||
|
|
||||||
|
this.infoName = infoName;
|
||||||
|
this.favicon = favicon;
|
||||||
|
this.webSite = new WebSite(infoName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public WebTab(URL infoName) throws Exception {
|
||||||
|
refresh();
|
||||||
|
|
||||||
|
this.infoName = infoName;
|
||||||
|
this.favicon = WebSite.getFavIcon(infoName);
|
||||||
|
this.webSite = new WebSite(infoName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public WebTab(WebSite webSite) throws Exception {
|
||||||
|
refresh();
|
||||||
|
|
||||||
|
this.infoName = webSite.getInfoName();
|
||||||
|
this.favicon = webSite.getFavIcon();
|
||||||
|
this.webSite = webSite;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void refresh() throws Exception {
|
||||||
|
if (client.getClientServerConnection().isConnected()) client.getClientServerConnection().disconnect();
|
||||||
|
int port = infoName.getPort() == -1 ? DEFAULT_WEB_PORT_TCP : infoName.getPort();
|
||||||
|
client.buildServerConnection(null, true);
|
||||||
|
|
||||||
|
try {
|
||||||
|
client.getClientServerConnection().connect(infoName.getHost(), port);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.webSite.requestNewDom();
|
||||||
|
this.favicon = this.webSite.getFavIcon();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
|
WebTab webTab = (WebTab) o;
|
||||||
|
return Objects.equals(infoName, webTab.infoName) && Objects.equals(favicon, webTab.favicon) && Objects.equals(webSite, webTab.webSite) && Objects.equals(client, webTab.client);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(infoName, favicon, webSite, client);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "WebTab{" +
|
||||||
|
"infoName=" + infoName +
|
||||||
|
", favicon=" + favicon +
|
||||||
|
", webSite=" + webSite +
|
||||||
|
", client=" + client +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -14,144 +14,9 @@ import java.awt.event.MouseAdapter;
|
|||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
import java.awt.geom.RoundRectangle2D;
|
import java.awt.geom.RoundRectangle2D;
|
||||||
|
|
||||||
public abstract class BrowserFrame extends JFrame {
|
public abstract class BrowserFrame extends OACFrame {
|
||||||
private static final int RESIZE_MARGIN = 8;
|
|
||||||
|
|
||||||
private Point dragStart;
|
|
||||||
private Rectangle startBounds;
|
|
||||||
private int resizeCursor = Cursor.DEFAULT_CURSOR;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
protected TopBar topBar;
|
|
||||||
|
|
||||||
protected BrowserFrame() {
|
protected BrowserFrame() {
|
||||||
this(new TopBar());
|
|
||||||
|
|
||||||
this.topBar.initButtonPanel(BorderLayout.NORTH);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected BrowserFrame(TopBar topBar) {
|
|
||||||
|
|
||||||
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
|
|
||||||
|
|
||||||
this.setLayout(new BorderLayout());
|
|
||||||
|
|
||||||
this.setUndecorated(true);
|
|
||||||
|
|
||||||
this.topBar = topBar;
|
|
||||||
|
|
||||||
this.setShape(new RoundRectangle2D.Double(
|
|
||||||
0, 0,
|
|
||||||
this.getWidth(),
|
|
||||||
this.getHeight(),
|
|
||||||
30, 30
|
|
||||||
));
|
|
||||||
|
|
||||||
this.setLocationRelativeTo(null);
|
|
||||||
|
|
||||||
this.init();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void init() {
|
|
||||||
this.addComponentListener(new ComponentAdapter() {
|
|
||||||
@Override
|
|
||||||
public void componentResized(ComponentEvent e) {
|
|
||||||
setShape(new RoundRectangle2D.Double(
|
|
||||||
0, 0,
|
|
||||||
getWidth(),
|
|
||||||
getHeight(),
|
|
||||||
30, 30
|
|
||||||
));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
MouseAdapter adapter = new MouseAdapter() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mouseMoved(MouseEvent e) {
|
|
||||||
resizeCursor = getResizeCursor(e);
|
|
||||||
|
|
||||||
setCursor(Cursor.getPredefinedCursor(resizeCursor));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mousePressed(MouseEvent e) {
|
|
||||||
dragStart = e.getLocationOnScreen();
|
|
||||||
startBounds = getBounds();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mouseDragged(MouseEvent e) {
|
|
||||||
if (resizeCursor == Cursor.DEFAULT_CURSOR) return;
|
|
||||||
|
|
||||||
Point dragNow = e.getLocationOnScreen();
|
|
||||||
int dx = dragNow.x - dragStart.x;
|
|
||||||
int dy = dragNow.y - dragStart.y;
|
|
||||||
|
|
||||||
Rectangle newBounds = new Rectangle(startBounds);
|
|
||||||
|
|
||||||
switch (resizeCursor) {
|
|
||||||
case Cursor.E_RESIZE_CURSOR -> newBounds.width += dx;
|
|
||||||
case Cursor.S_RESIZE_CURSOR -> newBounds.height += dy;
|
|
||||||
case Cursor.SE_RESIZE_CURSOR -> {
|
|
||||||
newBounds.width += dx;
|
|
||||||
newBounds.height += dy;
|
|
||||||
}
|
|
||||||
case Cursor.W_RESIZE_CURSOR -> {
|
|
||||||
newBounds.x += dx;
|
|
||||||
newBounds.width -= dx;
|
|
||||||
}
|
|
||||||
case Cursor.N_RESIZE_CURSOR -> {
|
|
||||||
newBounds.y += dy;
|
|
||||||
newBounds.height -= dy;
|
|
||||||
}
|
|
||||||
case Cursor.NW_RESIZE_CURSOR -> {
|
|
||||||
newBounds.x += dx;
|
|
||||||
newBounds.y += dy;
|
|
||||||
newBounds.width -= dx;
|
|
||||||
newBounds.height -= dy;
|
|
||||||
}
|
|
||||||
case Cursor.NE_RESIZE_CURSOR -> {
|
|
||||||
newBounds.y += dy;
|
|
||||||
newBounds.width += dx;
|
|
||||||
newBounds.height -= dy;
|
|
||||||
}
|
|
||||||
case Cursor.SW_RESIZE_CURSOR -> {
|
|
||||||
newBounds.x += dx;
|
|
||||||
newBounds.width -= dx;
|
|
||||||
newBounds.height += dy;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
setBounds(newBounds);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
addMouseListener(adapter);
|
|
||||||
addMouseMotionListener(adapter);
|
|
||||||
}
|
|
||||||
|
|
||||||
private int getResizeCursor(MouseEvent e) {
|
|
||||||
int x = e.getX();
|
|
||||||
int y = e.getY();
|
|
||||||
int w = e.getComponent().getWidth();
|
|
||||||
int h = e.getComponent().getHeight();
|
|
||||||
|
|
||||||
boolean left = x < RESIZE_MARGIN;
|
|
||||||
boolean right = x > w - RESIZE_MARGIN;
|
|
||||||
boolean top = y < RESIZE_MARGIN;
|
|
||||||
boolean bottom = y > h - RESIZE_MARGIN;
|
|
||||||
|
|
||||||
if (left && top) return Cursor.NW_RESIZE_CURSOR;
|
|
||||||
if (right && top) return Cursor.NE_RESIZE_CURSOR;
|
|
||||||
if (left && bottom) return Cursor.SW_RESIZE_CURSOR;
|
|
||||||
if (right && bottom) return Cursor.SE_RESIZE_CURSOR;
|
|
||||||
if (left) return Cursor.W_RESIZE_CURSOR;
|
|
||||||
if (right) return Cursor.E_RESIZE_CURSOR;
|
|
||||||
if (top) return Cursor.N_RESIZE_CURSOR;
|
|
||||||
if (bottom) return Cursor.S_RESIZE_CURSOR;
|
|
||||||
|
|
||||||
return Cursor.DEFAULT_CURSOR;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,26 +5,21 @@
|
|||||||
package org.openautonomousconnection.webclient.ui;
|
package org.openautonomousconnection.webclient.ui;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.openautonomousconnection.webclient.network.website.tab.Tab;
|
import org.openautonomousconnection.webclient.network.website.tab.WebTab;
|
||||||
import org.openautonomousconnection.webclient.ui.dom.DOMContainerPanel;
|
import org.openautonomousconnection.webclient.ui.dom.DOMContainerPanel;
|
||||||
import org.openautonomousconnection.webclient.ui.tab.TabButton;
|
|
||||||
import org.openautonomousconnection.webclient.ui.tab.TabButtonView;
|
|
||||||
|
|
||||||
import javax.swing.*;
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.net.MalformedURLException;
|
|
||||||
import java.net.URI;
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
|
||||||
public final class MainFrame extends BrowserFrame {
|
public final class MainFrame extends BrowserFrame {
|
||||||
@Getter
|
@Getter
|
||||||
private Tab openTab;
|
private WebTab openWebTab;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private final DOMContainerPanel domContainerPanel;
|
private final DOMContainerPanel domContainerPanel;
|
||||||
|
|
||||||
public MainFrame() {
|
public MainFrame() {
|
||||||
super(new TabButtonView());
|
super();
|
||||||
|
|
||||||
this.setSize(800, 600);
|
this.setSize(800, 600);
|
||||||
|
|
||||||
@@ -34,47 +29,42 @@ public final class MainFrame extends BrowserFrame {
|
|||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.add(this.topBar, BorderLayout.NORTH);
|
|
||||||
this.domContainerPanel = new DOMContainerPanel();
|
this.domContainerPanel = new DOMContainerPanel();
|
||||||
this.add(this.domContainerPanel, BorderLayout.CENTER);
|
this.add(this.domContainerPanel, BorderLayout.CENTER);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void init() {
|
private void init() {
|
||||||
this.open(this.openTab);
|
this.open(this.openWebTab);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void setOpenWebTab(int index) {
|
||||||
public TabButtonView getTopBar() {
|
//TODO
|
||||||
return (TabButtonView) this.topBar;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOpenTab(int index) {
|
public void setOpenWebTab(WebTab webTab) {
|
||||||
this.openTab = this.getTopBar().getButton(index).getTab();
|
//TODO
|
||||||
|
// for(TabButton button : this.getTopBar().getTabButtons())
|
||||||
this.getTopBar().getButton(index).grabFocus();
|
// if(button.getTab().equals(tab)) {
|
||||||
}
|
// this.openTab = button.getTab();
|
||||||
|
// button.grabFocus();
|
||||||
public void setOpenTab(Tab tab) {
|
// }
|
||||||
for(TabButton button : this.getTopBar().getTabButtons())
|
|
||||||
if(button.getTab().equals(tab)) {
|
|
||||||
this.openTab = button.getTab();
|
|
||||||
button.grabFocus();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void open(URL url) throws Exception {
|
public void open(URL url) throws Exception {
|
||||||
TabButton button = new TabButton(url);
|
//TODO
|
||||||
|
// TabButton button = new TabButton(url);
|
||||||
this.getTopBar().addButton(button);
|
//
|
||||||
|
// this.getTopBar().addButton(button);
|
||||||
button.grabFocus();
|
//
|
||||||
|
// button.grabFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void open(Tab tab) {
|
public void open(WebTab webTab) {
|
||||||
TabButton button = new TabButton(tab);
|
//TODO
|
||||||
|
// TabButton button = new TabButton(tab);
|
||||||
this.getTopBar().addButton(button);
|
//
|
||||||
|
// this.getTopBar().addButton(button);
|
||||||
button.grabFocus();
|
//
|
||||||
|
// button.grabFocus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,12 +10,13 @@ import javafx.scene.Scene;
|
|||||||
import javafx.scene.web.WebEngine;
|
import javafx.scene.web.WebEngine;
|
||||||
import javafx.scene.web.WebView;
|
import javafx.scene.web.WebView;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
import org.openautonomousconnection.oacswing.component.OACPanel;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
|
||||||
public class DOMContainerPanel extends JPanel {
|
public class DOMContainerPanel extends OACPanel {
|
||||||
@Getter
|
@Getter
|
||||||
private final JFXPanel dom;
|
private final JFXPanel dom;
|
||||||
|
|
||||||
@@ -36,6 +37,7 @@ public class DOMContainerPanel extends JPanel {
|
|||||||
public DOMContainerPanel() {
|
public DOMContainerPanel() {
|
||||||
this.setBackground(Color.LIGHT_GRAY);
|
this.setBackground(Color.LIGHT_GRAY);
|
||||||
|
|
||||||
|
//TODO: Turn this into designable OAC-JFXpanel
|
||||||
this.dom = new JFXPanel();
|
this.dom = new JFXPanel();
|
||||||
|
|
||||||
Platform.runLater(() -> {
|
Platform.runLater(() -> {
|
||||||
|
|||||||
@@ -7,10 +7,10 @@ package org.openautonomousconnection.webclient.ui.tab;
|
|||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import org.openautonomousconnection.webclient.network.website.tab.Tab;
|
import org.openautonomousconnection.oacswing.component.OACButton;
|
||||||
|
import org.openautonomousconnection.webclient.network.website.tab.WebTab;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.net.MalformedURLException;
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
|
||||||
@@ -18,18 +18,18 @@ import java.net.URL;
|
|||||||
* Button that contains Tab data
|
* Button that contains Tab data
|
||||||
*/
|
*/
|
||||||
@Getter @Setter
|
@Getter @Setter
|
||||||
public class TabButton extends JButton {
|
public class TabButton extends OACButton {
|
||||||
private Tab tab;
|
private WebTab webTab;
|
||||||
|
|
||||||
public TabButton(@NonNull String infoName) throws Exception {
|
public TabButton(@NonNull String infoName) throws Exception {
|
||||||
this(URI.create(infoName).toURL());
|
this(URI.create(infoName).toURL());
|
||||||
}
|
}
|
||||||
|
|
||||||
public TabButton(@NonNull URL infoName) throws Exception {
|
public TabButton(@NonNull URL infoName) throws Exception {
|
||||||
this.tab = new Tab(infoName);
|
this.webTab = new WebTab(infoName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TabButton(@NonNull Tab tab) {
|
public TabButton(@NonNull WebTab webTab) {
|
||||||
this.tab = tab;
|
this.webTab = webTab;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
package org.openautonomousconnection.webclient.ui.tab;
|
package org.openautonomousconnection.webclient.ui.tab;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.openautonomousconnection.webclient.ui.TopBar;
|
import org.openautonomousconnection.oacswing.component.OACTitleBar;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -14,8 +14,10 @@ import java.util.List;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* View at the top of the screen that contains the tabs
|
* View at the top of the screen that contains the tabs
|
||||||
|
* @deprecated the OAC-Swing library's solution fits better and works globally
|
||||||
*/
|
*/
|
||||||
public class TabButtonView extends TopBar {
|
@Deprecated(forRemoval = true, since = "1.0.0-BETA.1.4")
|
||||||
|
public class TabButtonView extends OACTitleBar {
|
||||||
@Getter
|
@Getter
|
||||||
private final List<TabButton> tabButtons;
|
private final List<TabButton> tabButtons;
|
||||||
|
|
||||||
@@ -28,7 +30,7 @@ public class TabButtonView extends TopBar {
|
|||||||
* @param tabButtons already created buttons
|
* @param tabButtons already created buttons
|
||||||
*/
|
*/
|
||||||
public TabButtonView(Collection<TabButton> tabButtons) {
|
public TabButtonView(Collection<TabButton> tabButtons) {
|
||||||
super();
|
super(null);
|
||||||
this.tabButtons = (List<TabButton>) tabButtons;
|
this.tabButtons = (List<TabButton>) tabButtons;
|
||||||
|
|
||||||
FlowLayout layoutStyle = new FlowLayout(FlowLayout.RIGHT, 0, 0);
|
FlowLayout layoutStyle = new FlowLayout(FlowLayout.RIGHT, 0, 0);
|
||||||
@@ -36,10 +38,6 @@ public class TabButtonView extends TopBar {
|
|||||||
this.setLayout(layoutStyle);
|
this.setLayout(layoutStyle);
|
||||||
|
|
||||||
this.setBackground(Color.gray);
|
this.setBackground(Color.gray);
|
||||||
|
|
||||||
this.add(this.getButtonPanel());
|
|
||||||
|
|
||||||
this.getButtonPanel().setBackground(this.getBackground());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addButton(TabButton tabButton) {
|
public void addButton(TabButton tabButton) {
|
||||||
|
|||||||
Reference in New Issue
Block a user