mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-11-25 00:50:31 +00:00
Rework lxd connections
This commit is contained in:
parent
75e85f3764
commit
a097ae7a41
5 changed files with 14 additions and 12 deletions
|
@ -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);
|
||||
|
||||
|
|
|
@ -123,7 +123,9 @@ public class GuiDsStoreCreator extends MultiStepComp.Step<CompStructure<?>> {
|
|||
e -> {
|
||||
try {
|
||||
DataStorage.get().addStoreEntry(e);
|
||||
ScanAlert.showAsync(e, true);
|
||||
if (e.getProvider().shouldHaveSubShells()) {
|
||||
ScanAlert.showAsync(e);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ErrorEvent.fromThrowable(ex).handle();
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<ScanProvider.ScanOperation>();
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ public class ScanAction implements ActionProvider {
|
|||
|
||||
@Override
|
||||
public void execute() {
|
||||
ScanAlert.showAsync(entry, false);
|
||||
ScanAlert.showAsync(entry);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue