From 4b263adb163a421ceb9122c3e572ef986e314453 Mon Sep 17 00:00:00 2001 From: crschnick Date: Fri, 14 Jun 2024 13:04:47 +0000 Subject: [PATCH] More rework --- .../java/io/xpipe/app/browser/BrowserTransferComp.java | 9 +-------- .../java/io/xpipe/app/browser/file/LocalFileSystem.java | 5 ++--- .../java/io/xpipe/app/comp/base/ListBoxViewComp.java | 9 +++++---- .../java/io/xpipe/app/comp/store/StoreEntryComp.java | 2 +- .../main/java/io/xpipe/app/core/AppExtensionManager.java | 2 +- .../main/java/io/xpipe/app/ext/ExtensionException.java | 2 +- .../java/io/xpipe/app/fxcomps/impl/IconButtonComp.java | 8 ++++---- core/src/main/java/io/xpipe/core/store/FilePath.java | 1 - ext/base/src/main/java/module-info.java | 4 ++-- lang/proc/strings/translations_en.properties | 3 ++- 10 files changed, 19 insertions(+), 26 deletions(-) diff --git a/app/src/main/java/io/xpipe/app/browser/BrowserTransferComp.java b/app/src/main/java/io/xpipe/app/browser/BrowserTransferComp.java index 988b8e55..553aae3d 100644 --- a/app/src/main/java/io/xpipe/app/browser/BrowserTransferComp.java +++ b/app/src/main/java/io/xpipe/app/browser/BrowserTransferComp.java @@ -10,7 +10,6 @@ import io.xpipe.app.fxcomps.augment.DragOverPseudoClassAugment; import io.xpipe.app.fxcomps.impl.*; import io.xpipe.app.fxcomps.util.DerivedObservableList; import io.xpipe.app.fxcomps.util.PlatformThread; -import io.xpipe.core.process.OsType; import javafx.beans.binding.Bindings; import javafx.collections.FXCollections; import javafx.geometry.Insets; @@ -183,13 +182,7 @@ public class BrowserTransferComp extends SimpleComp { event.consume(); }); struc.get().setOnDragDone(event -> { - // macOS does always report false here, which is unfortunate - if (!event.isAccepted() && !OsType.getLocal().equals(OsType.MACOS)) { - return; - } - - // Don't clear, it might be more convenient to keep the contents - // model.clear(); + model.clear(); event.consume(); }); }), diff --git a/app/src/main/java/io/xpipe/app/browser/file/LocalFileSystem.java b/app/src/main/java/io/xpipe/app/browser/file/LocalFileSystem.java index 2fe56c18..50650aad 100644 --- a/app/src/main/java/io/xpipe/app/browser/file/LocalFileSystem.java +++ b/app/src/main/java/io/xpipe/app/browser/file/LocalFileSystem.java @@ -4,7 +4,6 @@ import io.xpipe.core.store.FileKind; import io.xpipe.core.store.FileSystem; import io.xpipe.core.store.LocalStore; -import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; @@ -19,13 +18,13 @@ public class LocalFileSystem { } } - public static FileSystem.FileEntry getLocalFileEntry(Path file) throws IOException { + public static FileSystem.FileEntry getLocalFileEntry(Path file) throws Exception { if (localFileSystem == null) { throw new IllegalStateException(); } return new FileSystem.FileEntry( - localFileSystem, + localFileSystem.open(), file.toString(), Files.getLastModifiedTime(file).toInstant(), Files.isHidden(file), diff --git a/app/src/main/java/io/xpipe/app/comp/base/ListBoxViewComp.java b/app/src/main/java/io/xpipe/app/comp/base/ListBoxViewComp.java index 3ae12f70..b64fcac0 100644 --- a/app/src/main/java/io/xpipe/app/comp/base/ListBoxViewComp.java +++ b/app/src/main/java/io/xpipe/app/comp/base/ListBoxViewComp.java @@ -13,6 +13,7 @@ import javafx.scene.control.ScrollPane; import javafx.scene.layout.Region; import javafx.scene.layout.VBox; +import java.util.ArrayList; import java.util.IdentityHashMap; import java.util.List; import java.util.Map; @@ -65,11 +66,11 @@ public class ListBoxViewComp extends Comp> { VBox listView, List shown, List all, Map cache, boolean asynchronous) { Runnable update = () -> { // Clear cache of unused values - if (cache.keySet().removeIf(t -> !all.contains(t))) { - int a = 0; - } + cache.keySet().removeIf(t -> !all.contains(t)); - var newShown = shown.stream() + // Create copy to reduce chances of concurrent modification + var shownCopy = new ArrayList<>(shown); + var newShown = shownCopy.stream() .map(v -> { if (!cache.containsKey(v)) { var comp = compFunction.apply(v); diff --git a/app/src/main/java/io/xpipe/app/comp/store/StoreEntryComp.java b/app/src/main/java/io/xpipe/app/comp/store/StoreEntryComp.java index 8ac3bfa5..b12f80c9 100644 --- a/app/src/main/java/io/xpipe/app/comp/store/StoreEntryComp.java +++ b/app/src/main/java/io/xpipe/app/comp/store/StoreEntryComp.java @@ -262,7 +262,7 @@ public abstract class StoreEntryComp extends SimpleComp { } protected Comp createSettingsButton() { - var settingsButton = new IconButtonComp("mdi2d-dots-horizontal-circle-outline", () -> {}); + var settingsButton = new IconButtonComp("mdi2d-dots-horizontal-circle-outline", null); settingsButton.styleClass("settings"); settingsButton.accessibleText("More"); settingsButton.apply(new ContextMenuAugment<>( diff --git a/app/src/main/java/io/xpipe/app/core/AppExtensionManager.java b/app/src/main/java/io/xpipe/app/core/AppExtensionManager.java index 9f7de75d..b3238678 100644 --- a/app/src/main/java/io/xpipe/app/core/AppExtensionManager.java +++ b/app/src/main/java/io/xpipe/app/core/AppExtensionManager.java @@ -72,7 +72,7 @@ public class AppExtensionManager { private void loadBaseExtension() { var baseModule = findAndParseExtension("base", ModuleLayer.boot()); if (baseModule.isEmpty()) { - throw new ExtensionException("Missing base module. Is the installation corrupt?"); + throw new ExtensionException("Missing base module. Is the installation data corrupt?"); } baseLayer = baseModule.get().getModule().getLayer(); diff --git a/app/src/main/java/io/xpipe/app/ext/ExtensionException.java b/app/src/main/java/io/xpipe/app/ext/ExtensionException.java index bd7b0c23..e26db767 100644 --- a/app/src/main/java/io/xpipe/app/ext/ExtensionException.java +++ b/app/src/main/java/io/xpipe/app/ext/ExtensionException.java @@ -21,6 +21,6 @@ public class ExtensionException extends RuntimeException { } public static ExtensionException corrupt(String message) { - return new ExtensionException(message + ". Is the installation corrupt?"); + return new ExtensionException(message + ". Is the installation data corrupt?"); } } diff --git a/app/src/main/java/io/xpipe/app/fxcomps/impl/IconButtonComp.java b/app/src/main/java/io/xpipe/app/fxcomps/impl/IconButtonComp.java index 94c05144..438247b0 100644 --- a/app/src/main/java/io/xpipe/app/fxcomps/impl/IconButtonComp.java +++ b/app/src/main/java/io/xpipe/app/fxcomps/impl/IconButtonComp.java @@ -53,12 +53,12 @@ public class IconButtonComp extends Comp> { }); // fi.iconColorProperty().bind(button.textFillProperty()); button.setGraphic(fi); - button.setOnAction(e -> { - if (listener != null) { + if (listener != null) { + button.setOnAction(e -> { listener.run(); e.consume(); - } - }); + }); + } button.getStyleClass().add("icon-button-comp"); return new SimpleCompStructure<>(button); } diff --git a/core/src/main/java/io/xpipe/core/store/FilePath.java b/core/src/main/java/io/xpipe/core/store/FilePath.java index 74b35584..7e0b0231 100644 --- a/core/src/main/java/io/xpipe/core/store/FilePath.java +++ b/core/src/main/java/io/xpipe/core/store/FilePath.java @@ -42,7 +42,6 @@ public final class FilePath { return this; } - var backslash = value.contains("\\"); var p = Pattern.compile("[^/\\\\]+"); var m = p.matcher(value); var replaced = m.replaceAll(matchResult -> osType.makeFileSystemCompatible(matchResult.group())); diff --git a/ext/base/src/main/java/module-info.java b/ext/base/src/main/java/module-info.java index 29be2492..c5b541e9 100644 --- a/ext/base/src/main/java/module-info.java +++ b/ext/base/src/main/java/module-info.java @@ -59,10 +59,10 @@ open module io.xpipe.ext.base { JavapAction, JarAction; provides ActionProvider with ServiceOpenAction, ServiceCopyUrlAction, - CloneStoreAction, RefreshChildrenStoreAction, ScanStoreAction, LaunchStoreAction, + CloneStoreAction, RefreshChildrenStoreAction, LaunchStoreAction, XPipeUrlAction, EditStoreAction, DeleteChildrenStoreAction, - BrowseStoreAction; + BrowseStoreAction, ScanStoreAction; provides DataStoreProvider with FixedServiceGroupStoreProvider, ServiceGroupStoreProvider, CustomServiceStoreProvider, MappedServiceStoreProvider, FixedServiceStoreProvider, SimpleScriptStoreProvider, DesktopEnvironmentStoreProvider, DesktopApplicationStoreProvider, DesktopCommandStoreProvider, ScriptGroupStoreProvider; provides DataStorageExtensionProvider with ScriptDataStorageProvider; } diff --git a/lang/proc/strings/translations_en.properties b/lang/proc/strings/translations_en.properties index d986d2bb..ea2b419a 100644 --- a/lang/proc/strings/translations_en.properties +++ b/lang/proc/strings/translations_en.properties @@ -332,4 +332,5 @@ dockerContext.displayDescription=Interact with containers located in a specific containerActions=Container actions vmActions=VM actions dockerContextActions=Context actions -k8sPodActions=Pod actions \ No newline at end of file +k8sPodActions=Pod actions +openVnc=Set up VNC \ No newline at end of file