From c2e5e0fa0d3c0d576b854ac365e44b4eb9d7221a Mon Sep 17 00:00:00 2001 From: crschnick Date: Mon, 4 Dec 2023 16:40:30 +0000 Subject: [PATCH] Small browser fixes --- .../main/java/io/xpipe/app/browser/BrowserFileListComp.java | 1 + .../java/io/xpipe/app/browser/BrowserFileListCompEntry.java | 5 +++++ .../main/java/io/xpipe/app/browser/action/LeafAction.java | 5 +++++ app/src/main/java/io/xpipe/app/fxcomps/util/Shortcuts.java | 1 - 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/io/xpipe/app/browser/BrowserFileListComp.java b/app/src/main/java/io/xpipe/app/browser/BrowserFileListComp.java index 90e7239d3..fcacbe50e 100644 --- a/app/src/main/java/io/xpipe/app/browser/BrowserFileListComp.java +++ b/app/src/main/java/io/xpipe/app/browser/BrowserFileListComp.java @@ -190,6 +190,7 @@ final class BrowserFileListComp extends SimpleComp { browserAction.execute(fileList.getFileSystemModel(), selected); }); }); + event.consume(); }); } diff --git a/app/src/main/java/io/xpipe/app/browser/BrowserFileListCompEntry.java b/app/src/main/java/io/xpipe/app/browser/BrowserFileListCompEntry.java index 1fe5c27b2..e7a7bb44f 100644 --- a/app/src/main/java/io/xpipe/app/browser/BrowserFileListCompEntry.java +++ b/app/src/main/java/io/xpipe/app/browser/BrowserFileListCompEntry.java @@ -10,6 +10,7 @@ import lombok.Getter; import java.io.File; import java.util.ArrayList; +import java.util.Objects; import java.util.Timer; import java.util.TimerTask; @@ -97,6 +98,10 @@ public class BrowserFileListCompEntry { return false; } + if (!Objects.equals(model.getFileSystemModel().getFileSystem(), cb.getEntries().get(0).getFileSystem())) { + return true; + } + // Prevent drag and drops of files into the current directory if (cb.getBaseDirectory() != null && cb .getBaseDirectory() diff --git a/app/src/main/java/io/xpipe/app/browser/action/LeafAction.java b/app/src/main/java/io/xpipe/app/browser/action/LeafAction.java index 20ee866c4..bb40daaf0 100644 --- a/app/src/main/java/io/xpipe/app/browser/action/LeafAction.java +++ b/app/src/main/java/io/xpipe/app/browser/action/LeafAction.java @@ -20,6 +20,11 @@ public interface LeafAction extends BrowserAction { default Button toButton(OpenFileSystemModel model, List selected) { var b = new Button(); b.setOnAction(event -> { + // Only accept shortcut actions in the current tab + if (!model.equals(model.getBrowserModel().getSelected().getValue())) { + return; + } + ThreadHelper.runFailableAsync(() -> { BooleanScope.execute(model.getBusy(), () -> { execute(model, selected); diff --git a/app/src/main/java/io/xpipe/app/fxcomps/util/Shortcuts.java b/app/src/main/java/io/xpipe/app/fxcomps/util/Shortcuts.java index 316c4e95c..291e9533e 100644 --- a/app/src/main/java/io/xpipe/app/fxcomps/util/Shortcuts.java +++ b/app/src/main/java/io/xpipe/app/fxcomps/util/Shortcuts.java @@ -24,7 +24,6 @@ public class Shortcuts { public static void addShortcut(T region, KeyCombination comb, Consumer exec) { var filter = new EventHandler() { public void handle(KeyEvent ke) { - var target = ke.getTarget(); if (!region.isVisible() || !region.isManaged() || region.isDisabled()) { return; }