From 7c14e917499fcb5e3679e6fa02d8a3187c953a83 Mon Sep 17 00:00:00 2001 From: crschnick Date: Wed, 20 Nov 2024 08:36:09 +0000 Subject: [PATCH] Small fixes --- app/build.gradle | 2 +- .../app/beacon/impl/AskpassExchangeImpl.java | 4 ++ .../app/browser/BrowserFullSessionModel.java | 4 +- .../xpipe/app/core/AppDesktopIntegration.java | 4 +- .../core/check/AppHomebrewCoreutilsCheck.java | 54 +++++++++++++++++++ .../java/io/xpipe/app/core/mode/BaseMode.java | 1 + dist/licenses/commons-io.properties | 2 +- gradle/gradle_scripts/extension.gradle | 2 +- 8 files changed, 67 insertions(+), 6 deletions(-) create mode 100644 app/src/main/java/io/xpipe/app/core/check/AppHomebrewCoreutilsCheck.java diff --git a/app/build.gradle b/app/build.gradle index 9565904eb..6315ebe3b 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -57,7 +57,7 @@ dependencies { } api 'org.apache.commons:commons-lang3:3.17.0' api 'io.sentry:sentry:7.17.0' - api 'commons-io:commons-io:2.17.0' + api 'commons-io:commons-io:2.18.0' api group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: "2.18.1" api group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-jsr310', version: "2.18.1" api group: 'org.kordamp.ikonli', name: 'ikonli-material2-pack', version: "12.2.0" diff --git a/app/src/main/java/io/xpipe/app/beacon/impl/AskpassExchangeImpl.java b/app/src/main/java/io/xpipe/app/beacon/impl/AskpassExchangeImpl.java index 40cc48259..4213c0c7c 100644 --- a/app/src/main/java/io/xpipe/app/beacon/impl/AskpassExchangeImpl.java +++ b/app/src/main/java/io/xpipe/app/beacon/impl/AskpassExchangeImpl.java @@ -40,6 +40,10 @@ public class AskpassExchangeImpl extends AskpassExchange { } private void focusTerminalIfNeeded(long pid) { + if (TerminalView.get() == null) { + return; + } + var found = TerminalView.get().findSession(pid); if (found.isEmpty()) { return; diff --git a/app/src/main/java/io/xpipe/app/browser/BrowserFullSessionModel.java b/app/src/main/java/io/xpipe/app/browser/BrowserFullSessionModel.java index a053d2b31..bb79c4331 100644 --- a/app/src/main/java/io/xpipe/app/browser/BrowserFullSessionModel.java +++ b/app/src/main/java/io/xpipe/app/browser/BrowserFullSessionModel.java @@ -135,8 +135,8 @@ public class BrowserFullSessionModel extends BrowserAbstractSessionModel browserSessionTab != tab).toList(); - var prev = previousOthers.getLast(); - if (prev != null) { + if (previousOthers.size() > 0) { + var prev = previousOthers.getLast(); getSelectedEntry().setValue(prev); } } diff --git a/app/src/main/java/io/xpipe/app/core/AppDesktopIntegration.java b/app/src/main/java/io/xpipe/app/core/AppDesktopIntegration.java index 7397f3504..c0832b2a8 100644 --- a/app/src/main/java/io/xpipe/app/core/AppDesktopIntegration.java +++ b/app/src/main/java/io/xpipe/app/core/AppDesktopIntegration.java @@ -55,7 +55,9 @@ public class AppDesktopIntegration { return; } - AppLayoutModel.get().selectSettings(); + if (AppLayoutModel.get() != null) { + AppLayoutModel.get().selectSettings(); + } }); // URL open operations have to be handled in a special way on macOS! diff --git a/app/src/main/java/io/xpipe/app/core/check/AppHomebrewCoreutilsCheck.java b/app/src/main/java/io/xpipe/app/core/check/AppHomebrewCoreutilsCheck.java new file mode 100644 index 000000000..88db9a488 --- /dev/null +++ b/app/src/main/java/io/xpipe/app/core/check/AppHomebrewCoreutilsCheck.java @@ -0,0 +1,54 @@ +package io.xpipe.app.core.check; + +import io.xpipe.app.comp.base.MarkdownComp; +import io.xpipe.app.core.AppI18n; +import io.xpipe.app.core.AppProperties; +import io.xpipe.app.core.AppStyle; +import io.xpipe.app.core.mode.OperationMode; +import io.xpipe.app.core.window.AppWindowHelper; +import io.xpipe.app.issue.ErrorEvent; +import io.xpipe.app.prefs.AppPrefs; +import io.xpipe.app.resources.AppResources; +import io.xpipe.app.util.PlatformState; +import io.xpipe.app.util.WindowsRegistry; +import io.xpipe.core.process.OsType; +import javafx.geometry.Insets; +import javafx.scene.control.Alert; +import javafx.scene.control.ButtonBar; +import javafx.scene.control.ButtonType; +import lombok.Getter; + +import java.nio.file.Files; +import java.util.Optional; +import java.util.concurrent.TimeUnit; + +public class AppHomebrewCoreutilsCheck { + + public static boolean getResult() { + var fc = new ProcessBuilder("which", "stat").redirectErrorStream(true); + try { + var proc = fc.start(); + var out = new String(proc.getInputStream().readAllBytes()); + proc.waitFor(1, TimeUnit.SECONDS); + var first = out.lines().findFirst(); + return first.map(s -> s.contains("coreutils")).orElse(false); + } catch (Exception e) { + return false; + } + } + + public static void check() { + if (!OsType.getLocal().equals(OsType.MACOS)) { + return; + } + + if (!getResult()) { + ErrorEvent.fromMessage("You have the homebrew coreutils package installed and added to your PATH." + + " The coreutils commands overwrite and are incompatible to the native macOS commands, which XPipe expects." + + " Please remove the coreutils commands from your PATH prior to launching XPipe.") + .noDefaultActions() + .term() + .handle(); + } + } +} diff --git a/app/src/main/java/io/xpipe/app/core/mode/BaseMode.java b/app/src/main/java/io/xpipe/app/core/mode/BaseMode.java index 3d2232e9b..2707647fe 100644 --- a/app/src/main/java/io/xpipe/app/core/mode/BaseMode.java +++ b/app/src/main/java/io/xpipe/app/core/mode/BaseMode.java @@ -48,6 +48,7 @@ public class BaseMode extends OperationMode { LicenseProvider.get().init(); AppCertutilCheck.check(); AppBundledToolsCheck.check(); + AppHomebrewCoreutilsCheck.check(); AppAvCheck.check(); AppJavaOptionsCheck.check(); AppSid.init(); diff --git a/dist/licenses/commons-io.properties b/dist/licenses/commons-io.properties index 7e399cf46..8fab7f1b2 100644 --- a/dist/licenses/commons-io.properties +++ b/dist/licenses/commons-io.properties @@ -1,4 +1,4 @@ name=Commons IO -version=2.15.1 +version=2.18.0 license=Apache License 2.0 link=https://commons.apache.org/proper/commons-io/ \ No newline at end of file diff --git a/gradle/gradle_scripts/extension.gradle b/gradle/gradle_scripts/extension.gradle index 80645304d..7841e6a4c 100644 --- a/gradle/gradle_scripts/extension.gradle +++ b/gradle/gradle_scripts/extension.gradle @@ -76,7 +76,7 @@ dependencies { exclude group: 'org.openjfx', module: 'javafx-base' exclude group: 'org.openjfx', module: 'javafx-controls' } - compileOnly 'commons-io:commons-io:2.17.0' + compileOnly 'commons-io:commons-io:2.18.0' compileOnly group: 'org.kordamp.ikonli', name: 'ikonli-javafx', version: "12.2.0" if (project != project(':base')) {