Skip to content
This repository has been archived by the owner on Nov 20, 2024. It is now read-only.

Commit

Permalink
Replace smblib library with nexus-utilities and nexus-desktop (upgrad…
Browse files Browse the repository at this point in the history
…ing zyndex-java)
  • Loading branch information
danieldieeins committed Aug 31, 2024
1 parent 1b85685 commit 6462fea
Show file tree
Hide file tree
Showing 13 changed files with 138 additions and 292 deletions.
12 changes: 9 additions & 3 deletions application-main/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,15 @@

<dependencies>
<dependency>
<groupId>com.zyneonstudios</groupId>
<artifactId>nexus-zyndex</artifactId>
<version>2024.8</version>
<groupId>com.zyneonstudios.nexus</groupId>
<artifactId>zyndex-java</artifactId>
<version>2024.8.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.zyneonstudios.nexus</groupId>
<artifactId>base-desktop</artifactId>
<version>2024.9-alpha.5</version>
<scope>compile</scope>
</dependency>
</dependencies>
Expand Down
3 changes: 2 additions & 1 deletion application-main/src/main/java/com/zyneonstudios/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

import com.zyneonstudios.application.frame.ZyneonSplash;
import com.zyneonstudios.application.main.NexusApplication;

import com.zyneonstudios.nexus.desktop.NexusDesktop;
import java.net.MalformedURLException;

public class Main {

public static ZyneonSplash splash = null;

public static void main(String[] args) throws MalformedURLException {
NexusDesktop.init();
splash = new ZyneonSplash();
splash.setVisible(true);
NexusApplication application = new NexusApplication(args);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public boolean start() {
setFinished(true);
} catch (IOException e) {
state = DownloadManager.DownloadState.FAILED;
NexusApplication.getLogger().error("Couldn't download \""+url+"\" to \""+path.toString()+"\": " + e.getMessage());
NexusApplication.getLogger().err("Couldn't download \""+url+"\" to \""+path.toString()+"\": " + e.getMessage());
return false;
}
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ public FrameConnector(ApplicationFrame frame,NexusApplication application) {

public void resolveRequest(String request) {
if(ApplicationStorage.test) {
NexusApplication.getLogger().error("[CONNECTOR] (Request-Reader) resolving "+request+"...");
NexusApplication.getLogger().err("[CONNECTOR] (Request-Reader) resolving "+request+"...");
} else {
NexusApplication.getLogger().debug("[CONNECTOR] (Request-Reader) resolving "+request+"...");
NexusApplication.getLogger().dbg("[CONNECTOR] (Request-Reader) resolving "+request+"...");
}

if(request.startsWith("sync.")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,38 @@
import com.zyneonstudios.application.frame.FrameConnector;
import com.zyneonstudios.application.main.ApplicationStorage;
import com.zyneonstudios.application.main.NexusApplication;
import com.zyneonstudios.nexus.desktop.frame.web.NexusWebFrame;
import org.cef.CefClient;
import org.cef.CefSettings;
import org.cef.browser.CefBrowser;
import org.cef.browser.CefFrame;
import org.cef.handler.CefDisplayHandlerAdapter;
import org.cef.handler.CefLoadHandler;
import org.cef.network.CefRequest;

import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.Objects;
import java.util.concurrent.CompletableFuture;

@SuppressWarnings("unused")
public class ApplicationFrame extends WebFrame implements ComponentListener {
public class ApplicationFrame extends NexusWebFrame implements ComponentListener {

private final FrameConnector connector;
private final Dimension minSize = new Dimension(640,360);

public ApplicationFrame(NexusApplication application, String url, String jcefPath) {
super(url, jcefPath, application);
public ApplicationFrame(NexusApplication application, String url, CefClient client) {
super(client, url, true);
try {
setIconImage(ImageIO.read(Objects.requireNonNull(getClass().getResource("/logo.png"))).getScaledInstance(32, 32, Image.SCALE_SMOOTH));
} catch (Exception ignore) {}
addComponentListener(this);
this.connector = new FrameConnector(this,application);
getClient().addDisplayHandler(new CefDisplayHandlerAdapter() {
client.addDisplayHandler(new CefDisplayHandlerAdapter() {
@Override
public boolean onConsoleMessage(CefBrowser browser, CefSettings.LogSeverity level, String message, String source, int line) {
if (message.startsWith("[CONNECTOR] ")) {
Expand All @@ -36,16 +45,22 @@ public boolean onConsoleMessage(CefBrowser browser, CefSettings.LogSeverity leve
} else if (message.startsWith("[LOG] ")) {
NexusApplication.getLogger().log(message.replace("[LOG] ",""));
} else if (message.startsWith("[ERR] ")) {
NexusApplication.getLogger().error(message.replace("[ERR] ",""));
NexusApplication.getLogger().err(message.replace("[ERR] ",""));
} else if (message.startsWith("[DEB] ")) {
NexusApplication.getLogger().debug(message.replace("[DEB] ",""));
NexusApplication.getLogger().dbg(message.replace("[DEB] ",""));
} else {
NexusApplication.getLogger().debug("[FRAME] (Console) "+message);
NexusApplication.getLogger().dbg("[FRAME] (Console) "+message);
}
return super.onConsoleMessage(browser, level, message, source, line);
}
});
getClient().addLoadHandler(new CefLoadHandler() {
addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
NexusApplication.stop();
}
});
client.addLoadHandler(new CefLoadHandler() {
@Override
public void onLoadingStateChange(CefBrowser cefBrowser, boolean b, boolean b1, boolean b2) {

Expand Down Expand Up @@ -86,6 +101,12 @@ public void setTitlebar(String title, Color background, Color foreground) {
setTitleForeground(foreground);
}

@Override
public void setTitleColors(Color background, Color foreground) {
setBackground(background);
super.setTitleColors(background, foreground);
}

public void setTitleBackground(Color color) {
setBackground(color);
getRootPane().putClientProperty("JRootPane.titleBarBackground", color);
Expand All @@ -95,14 +116,14 @@ public void setTitleForeground(Color color) {
getRootPane().putClientProperty("JRootPane.titleBarForeground", color);
}

public void executeJavaScript(String command) {
getBrowser().executeJavaScript(command,getBrowser().getURL(),5);
}

public void openCustomPage(String title, String pageId, String url) {
getBrowser().loadURL(ApplicationStorage.urlBase+ ApplicationStorage.language+"/custom.html?title="+title+"&id="+pageId+"&url="+url);
}

public void executeJavaScript(String script) {
super.executeJavaScript(script);
}

@Override
public void componentResized(ComponentEvent e) {
double zoomLevel = ApplicationStorage.getZoomLevel();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.zyneonstudios.application.main.ApplicationStorage;
import com.zyneonstudios.application.main.NexusApplication;
import org.cef.CefClient;

import javax.swing.*;
import java.awt.*;
Expand All @@ -15,8 +16,8 @@ public class CustomApplicationFrame extends ApplicationFrame {
private JPanel titleBar;
private boolean border;

public CustomApplicationFrame(NexusApplication application, String url, String jcefPath) {
super(application,url,jcefPath);
public CustomApplicationFrame(NexusApplication application, String url, CefClient client) {
super(application,url,client);
setUndecorated(true);
title = " Zyneon Application (v"+ ApplicationStorage.getApplicationVersion()+", "+ ApplicationStorage.getOS()+")";
JPanel customTitleBar = createCustomTitleBar();
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
import com.zyneonstudios.application.download.Download;
import com.zyneonstudios.application.download.DownloadManager;
import com.zyneonstudios.application.frame.web.ApplicationFrame;
import live.nerotv.shademebaby.utils.GsonUtil;
import com.zyneonstudios.nexus.utilities.json.GsonUtility;

import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -119,21 +118,21 @@ protected void run() {
}

try {
JsonObject json = new Gson().fromJson(GsonUtil.getFromURL("https://raw.githubusercontent.com/zyneonstudios/nexus-nex/main/application/index.json"), JsonObject.class).getAsJsonArray("versions").get(0).getAsJsonObject();
JsonObject json = new Gson().fromJson(GsonUtility.getFromURL("https://raw.githubusercontent.com/zyneonstudios/nexus-nex/main/application/index.json"), JsonObject.class).getAsJsonArray("versions").get(0).getAsJsonObject();
checkVersion(json);
} catch (Exception ignore) {
}
}

private boolean runUpdateCheck(JsonObject json) {
if (!ApplicationStorage.test) {
NexusApplication.getLogger().debug("[RUNNER] Checking for Updates...");
NexusApplication.getLogger().debug("[RUNNER] Parsed JSON Data...");
NexusApplication.getLogger().dbg("[RUNNER] Checking for Updates...");
NexusApplication.getLogger().dbg("[RUNNER] Parsed JSON Data...");
String v = json.get("info").getAsJsonObject().get("version").getAsString();
NexusApplication.getLogger().debug("[RUNNER] Latest version: " + v + "...");
NexusApplication.getLogger().debug("[RUNNER] Current version: " + version + "...");
NexusApplication.getLogger().dbg("[RUNNER] Latest version: " + v + "...");
NexusApplication.getLogger().dbg("[RUNNER] Current version: " + version + "...");
if (!v.equals(version)) {
NexusApplication.getLogger().debug("[RUNNER] The application is not up to date!");
NexusApplication.getLogger().dbg("[RUNNER] The application is not up to date!");
return true;
}
}
Expand All @@ -145,7 +144,7 @@ private void checkVersion(JsonObject json) {
if (u > 120) {
u = 0;
if (runUpdateCheck(json)) {
NexusApplication.getLogger().debug("[RUNNER] Sending notification...");
NexusApplication.getLogger().dbg("[RUNNER] Sending notification...");
//TODO: Application.getFrame().sendNotification("Update available!", "Version " + v + " has been released!", "<a onclick=\"callJavaMethod('button.exit');\" class='button'>Install</a><a onclick=\"callJavaMethod('button.online');\" class='button'>Dynamic update</a>", v, true);
}
}
Expand Down
Loading

0 comments on commit 6462fea

Please sign in to comment.