This commit is contained in:
Anthony Stirling 2024-12-13 11:31:49 +00:00
parent 1ccdc1697b
commit 43c4ec1089
3 changed files with 26 additions and 13 deletions

View File

@ -27,7 +27,7 @@ ext {
} }
group = "stirling.software" group = "stirling.software"
version = "0.36.0" version = "0.36.1"
java { java {
@ -117,7 +117,11 @@ jpackage {
// JVM Options // JVM Options
javaOptions = [ javaOptions = [
"-DBROWSER_OPEN=true", "-DBROWSER_OPEN=true",
"-DSTIRLING_PDF_DESKTOP_UI=true" "-DSTIRLING_PDF_DESKTOP_UI=true",
"-Djava.awt.headless=false",
"--add-opens", "java.base/java.lang=ALL-UNNAMED",
"--add-opens", "java.desktop/java.awt.event=ALL-UNNAMED",
"--add-opens", "java.desktop/sun.awt=ALL-UNNAMED"
] ]
// Enable verbose output // Enable verbose output
@ -127,8 +131,9 @@ jpackage {
// Windows-specific configuration // Windows-specific configuration
windows { windows {
launcherAsService = false
appVersion = project.version appVersion = project.version
winConsole = true winConsole = false
winDirChooser = true winDirChooser = true
winMenu = true winMenu = true
winShortcut = true winShortcut = true

View File

@ -79,11 +79,11 @@ public class SPdfApplication {
Properties props = new Properties(); Properties props = new Properties();
if ("true".equals(System.getenv("STIRLING_PDF_DESKTOP_UI"))) { if (Boolean.parseBoolean(System.getProperty("STIRLING_PDF_DESKTOP_UI", "false"))) {
System.setProperty("java.awt.headless", "false"); System.setProperty("java.awt.headless", "false");
app.setHeadless(false); app.setHeadless(false);
// props.put("java.awt.headless", "false"); props.put("java.awt.headless", "false");
// props.put("spring.main.web-application-type", "servlet"); props.put("spring.main.web-application-type", "servlet");
} }
app.setAdditionalProfiles("default"); app.setAdditionalProfiles("default");
@ -118,7 +118,7 @@ public class SPdfApplication {
propertyFiles.get("spring.config.additional-location"))); propertyFiles.get("spring.config.additional-location")));
} }
if (props.isEmpty()) { if (!props.isEmpty()) {
finalProps.putAll(props); finalProps.putAll(props);
} }
app.setDefaultProperties(finalProps); app.setDefaultProperties(finalProps);
@ -147,9 +147,13 @@ public class SPdfApplication {
@PostConstruct @PostConstruct
public void init() { public void init() {
log.info(
"1 STIRLING_PDF_DESKTOP_UI={}",
Boolean.parseBoolean(System.getProperty("STIRLING_PDF_DESKTOP_UI", "false")));
baseUrlStatic = this.baseUrl; baseUrlStatic = this.baseUrl;
String url = baseUrl + ":" + getStaticPort(); String url = baseUrl + ":" + getStaticPort();
if (webBrowser != null && "true".equals(System.getenv("STIRLING_PDF_DESKTOP_UI"))) { if (webBrowser != null
&& Boolean.parseBoolean(System.getProperty("STIRLING_PDF_DESKTOP_UI", "false"))) {
webBrowser.initWebUI(url); webBrowser.initWebUI(url);
} }

View File

@ -58,10 +58,12 @@ public class DesktopBrowser implements WebBrowser {
private static SystemTray systemTray; private static SystemTray systemTray;
public DesktopBrowser() { public DesktopBrowser() {
log.info("DesktopBrowser 1");
SwingUtilities.invokeLater( SwingUtilities.invokeLater(
() -> { () -> {
loadingWindow = new LoadingWindow(null, "Initializing..."); loadingWindow = new LoadingWindow(null, "Initializing...");
loadingWindow.setVisible(true); loadingWindow.setVisible(true);
log.info("DesktopBrowser 2");
}); });
} }
@ -69,6 +71,7 @@ public class DesktopBrowser implements WebBrowser {
CompletableFuture.runAsync( CompletableFuture.runAsync(
() -> { () -> {
try { try {
log.info("DesktopBrowser 4");
CefAppBuilder builder = new CefAppBuilder(); CefAppBuilder builder = new CefAppBuilder();
configureCefSettings(builder); configureCefSettings(builder);
@ -91,7 +94,7 @@ public class DesktopBrowser implements WebBrowser {
// Show the frame immediately but transparent // Show the frame immediately but transparent
frame.setVisible(true); frame.setVisible(true);
}); });
log.info("DesktopBrowser 5");
} catch (Exception e) { } catch (Exception e) {
log.error("Error initializing JCEF browser: ", e); log.error("Error initializing JCEF browser: ", e);
cleanup(); cleanup();
@ -153,27 +156,28 @@ public class DesktopBrowser implements WebBrowser {
Objects.requireNonNull(state, "state cannot be null"); Objects.requireNonNull(state, "state cannot be null");
SwingUtilities.invokeLater( SwingUtilities.invokeLater(
() -> { () -> {
log.info("state {}", state.name());
if (loadingWindow != null) { if (loadingWindow != null) {
switch (state) { switch (state) {
case LOCATING: case LOCATING:
loadingWindow.setStatus("Locating Chromium..."); loadingWindow.setStatus("Locating Files...");
loadingWindow.setProgress(0); loadingWindow.setProgress(0);
break; break;
case DOWNLOADING: case DOWNLOADING:
if (percent >= 0) { if (percent >= 0) {
loadingWindow.setStatus( loadingWindow.setStatus(
String.format( String.format(
"Downloading Chromium: %.0f%%", "Downloading additional files: %.0f%%",
percent)); percent));
loadingWindow.setProgress((int) percent); loadingWindow.setProgress((int) percent);
} }
break; break;
case EXTRACTING: case EXTRACTING:
loadingWindow.setStatus("Extracting Chromium..."); loadingWindow.setStatus("Extracting files...");
loadingWindow.setProgress(60); loadingWindow.setProgress(60);
break; break;
case INITIALIZING: case INITIALIZING:
loadingWindow.setStatus("Initializing browser..."); loadingWindow.setStatus("Initializing UI...");
loadingWindow.setProgress(80); loadingWindow.setProgress(80);
break; break;
case INITIALIZED: case INITIALIZED: