From a097ae7a41131fa358b5343345557ad00a45c309 Mon Sep 17 00:00:00 2001 From: crschnick Date: Tue, 4 Jul 2023 05:42:00 +0000 Subject: [PATCH] Rework lxd connections --- .../app/comp/storage/store/StoreIntroComp.java | 2 +- .../io/xpipe/app/comp/store/GuiDsStoreCreator.java | 4 +++- .../main/java/io/xpipe/app/ext/ScanProvider.java | 4 ++-- app/src/main/java/io/xpipe/app/util/ScanAlert.java | 14 +++++++------- .../java/io/xpipe/ext/base/action/ScanAction.java | 2 +- 5 files changed, 14 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/io/xpipe/app/comp/storage/store/StoreIntroComp.java b/app/src/main/java/io/xpipe/app/comp/storage/store/StoreIntroComp.java index a61a15fc5..13f1b8637 100644 --- a/app/src/main/java/io/xpipe/app/comp/storage/store/StoreIntroComp.java +++ b/app/src/main/java/io/xpipe/app/comp/storage/store/StoreIntroComp.java @@ -36,7 +36,7 @@ public class StoreIntroComp extends SimpleComp { }); var scanButton = new Button(AppI18n.get("detectConnections"), new FontIcon("mdi2m-magnify")); - scanButton.setOnAction(event -> ScanAlert.showAsync(DataStorage.get().getStoreEntry(new LocalStore()), false)); + scanButton.setOnAction(event -> ScanAlert.showAsync(DataStorage.get().getStoreEntry(new LocalStore()))); var scanPane = new StackPane(scanButton); scanPane.setAlignment(Pos.CENTER); diff --git a/app/src/main/java/io/xpipe/app/comp/store/GuiDsStoreCreator.java b/app/src/main/java/io/xpipe/app/comp/store/GuiDsStoreCreator.java index a36038fb6..0c17c8b33 100644 --- a/app/src/main/java/io/xpipe/app/comp/store/GuiDsStoreCreator.java +++ b/app/src/main/java/io/xpipe/app/comp/store/GuiDsStoreCreator.java @@ -123,7 +123,9 @@ public class GuiDsStoreCreator extends MultiStepComp.Step> { e -> { try { DataStorage.get().addStoreEntry(e); - ScanAlert.showAsync(e, true); + if (e.getProvider().shouldHaveSubShells()) { + ScanAlert.showAsync(e); + } } catch (Exception ex) { ErrorEvent.fromThrowable(ex).handle(); } diff --git a/app/src/main/java/io/xpipe/app/ext/ScanProvider.java b/app/src/main/java/io/xpipe/app/ext/ScanProvider.java index 729a5b374..77cdd3d8c 100644 --- a/app/src/main/java/io/xpipe/app/ext/ScanProvider.java +++ b/app/src/main/java/io/xpipe/app/ext/ScanProvider.java @@ -49,11 +49,11 @@ public abstract class ScanProvider { return ALL; } - public ScanOperation create(DataStore store, boolean automatic) { + public ScanOperation create(DataStore store) { return null; } - public ScanOperation create(DataStoreEntry entry, ShellControl sc, boolean automatic) throws Exception { + public ScanOperation create(DataStoreEntry entry, ShellControl sc) throws Exception { return null; } } diff --git a/app/src/main/java/io/xpipe/app/util/ScanAlert.java b/app/src/main/java/io/xpipe/app/util/ScanAlert.java index dc9d3d3e8..5c2e154e2 100644 --- a/app/src/main/java/io/xpipe/app/util/ScanAlert.java +++ b/app/src/main/java/io/xpipe/app/util/ScanAlert.java @@ -29,34 +29,34 @@ import java.util.function.Supplier; public class ScanAlert { - public static void showAsync(DataStoreEntry entry, boolean automatic) { + public static void showAsync(DataStoreEntry entry) { ThreadHelper.runAsync(() -> { if (entry.getStore() instanceof ShellStore) { - showForShellStore(entry, automatic); + showForShellStore(entry); } else { - showForOtherStore(entry, automatic); + showForOtherStore(entry); } }); } - private static void showForOtherStore(DataStoreEntry entry, boolean automatic) { + private static void showForOtherStore(DataStoreEntry entry) { showIfNeeded(() -> { var providers = ScanProvider.getAll(); var applicable = providers.stream() - .map(scanProvider -> scanProvider.create(entry.getStore(), automatic)) + .map(scanProvider -> scanProvider.create(entry.getStore())) .filter(scanOperation -> scanOperation != null) .toList(); return applicable; }); } - private static void showForShellStore(DataStoreEntry entry, boolean automatic) { + private static void showForShellStore(DataStoreEntry entry) { showIfNeeded(() -> { try (var sc = ((ShellStore) entry.getStore()).control().start()) { var providers = ScanProvider.getAll(); var applicable = new ArrayList(); for (ScanProvider scanProvider : providers) { - ScanProvider.ScanOperation operation = scanProvider.create(entry, sc, automatic); + ScanProvider.ScanOperation operation = scanProvider.create(entry, sc); if (operation != null) { applicable.add(operation); } diff --git a/ext/base/src/main/java/io/xpipe/ext/base/action/ScanAction.java b/ext/base/src/main/java/io/xpipe/ext/base/action/ScanAction.java index aefc0e288..404ec4cc7 100644 --- a/ext/base/src/main/java/io/xpipe/ext/base/action/ScanAction.java +++ b/ext/base/src/main/java/io/xpipe/ext/base/action/ScanAction.java @@ -24,7 +24,7 @@ public class ScanAction implements ActionProvider { @Override public void execute() { - ScanAlert.showAsync(entry, false); + ScanAlert.showAsync(entry); } }