mirror of
https://github.com/xpipe-io/xpipe.git
synced 2026-06-21 14:00:57 -04:00
Various fixes
This commit is contained in:
@@ -99,7 +99,6 @@ public class GuiDsStoreCreator extends MultiStepComp.Step<CompStructure<?>> {
|
||||
e.applyChanges(newE);
|
||||
if (!DataStorage.get().getStoreEntries().contains(e)) {
|
||||
DataStorage.get().addStoreEntry(e);
|
||||
ScanAlert.showIfNeeded(e.getStore(), true);
|
||||
}
|
||||
DataStorage.get().refresh();
|
||||
});
|
||||
|
||||
@@ -19,6 +19,7 @@ import io.xpipe.app.fxcomps.util.PlatformThread;
|
||||
import io.xpipe.app.fxcomps.util.SimpleChangeListener;
|
||||
import io.xpipe.app.prefs.AppPrefs;
|
||||
import io.xpipe.app.storage.DataStorage;
|
||||
import io.xpipe.app.storage.DataStoreEntry;
|
||||
import io.xpipe.app.util.DesktopHelper;
|
||||
import io.xpipe.app.util.ThreadHelper;
|
||||
import javafx.beans.binding.Bindings;
|
||||
@@ -156,6 +157,10 @@ public class StoreEntryComp extends SimpleComp {
|
||||
event.consume();
|
||||
ThreadHelper.runFailableAsync(() -> {
|
||||
var found = entry.getDefaultActionProvider().getValue();
|
||||
if (entry.getState().getValue().equals(DataStoreEntry.State.COMPLETE_BUT_INVALID) || found == null) {
|
||||
entry.getEntry().refresh(true);
|
||||
}
|
||||
|
||||
if (found != null) {
|
||||
entry.getEntry().updateLastUsed();
|
||||
found.createAction(entry.getEntry().getStore().asNeeded()).execute();
|
||||
|
||||
@@ -65,6 +65,7 @@ public class StoreEntryWrapper implements StorageFilter.Filterable {
|
||||
}
|
||||
|
||||
public void delete() {
|
||||
DataStorage.get().deleteChildren(this.entry, true);
|
||||
DataStorage.get().deleteStoreEntry(this.entry);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import io.xpipe.app.fxcomps.SimpleComp;
|
||||
import io.xpipe.app.storage.DataStorage;
|
||||
import io.xpipe.app.util.CustomComboBoxBuilder;
|
||||
import io.xpipe.app.util.XPipeDaemon;
|
||||
import io.xpipe.core.store.DataStore;
|
||||
import io.xpipe.core.store.ShellStore;
|
||||
import javafx.beans.property.Property;
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
@@ -22,27 +23,33 @@ import java.util.Optional;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
@AllArgsConstructor
|
||||
public class ShellStoreChoiceComp<T extends ShellStore> extends SimpleComp {
|
||||
public class DataStoreChoiceComp<T extends DataStore> extends SimpleComp {
|
||||
|
||||
public static ShellStoreChoiceComp<ShellStore> proxy(Property<ShellStore> selected) {
|
||||
return new ShellStoreChoiceComp<>(Mode.PROXY_CHOICE, null, selected, ShellStore.class, shellStore -> true);
|
||||
public static DataStoreChoiceComp<ShellStore> proxy(Property<ShellStore> selected) {
|
||||
return new DataStoreChoiceComp<>(Mode.PROXY, null, selected, ShellStore.class, shellStore -> true);
|
||||
}
|
||||
|
||||
public static ShellStoreChoiceComp<ShellStore> host(Property<ShellStore> selected) {
|
||||
return new ShellStoreChoiceComp<>(Mode.HOST_CHOICE, null, selected, ShellStore.class, shellStore -> true);
|
||||
public static DataStoreChoiceComp<ShellStore> host(Property<ShellStore> selected) {
|
||||
return new DataStoreChoiceComp<>(Mode.HOST, null, selected, ShellStore.class, shellStore -> true);
|
||||
}
|
||||
|
||||
public static ShellStoreChoiceComp<ShellStore> proxy(ShellStore self, Property<ShellStore> selected) {
|
||||
return new ShellStoreChoiceComp<>(Mode.PROXY_CHOICE, self, selected, ShellStore.class, shellStore -> true);
|
||||
public static DataStoreChoiceComp<ShellStore> environment(ShellStore self, Property<ShellStore> selected) {
|
||||
return new DataStoreChoiceComp<>(Mode.ENVIRONMENT, self, selected, ShellStore.class, shellStore -> true);
|
||||
}
|
||||
|
||||
public static ShellStoreChoiceComp<ShellStore> host(ShellStore self, Property<ShellStore> selected) {
|
||||
return new ShellStoreChoiceComp<>(Mode.HOST_CHOICE, self, selected, ShellStore.class, shellStore -> true);
|
||||
public static DataStoreChoiceComp<ShellStore> proxy(ShellStore self, Property<ShellStore> selected) {
|
||||
return new DataStoreChoiceComp<>(Mode.PROXY, self, selected, ShellStore.class, shellStore -> true);
|
||||
}
|
||||
|
||||
public static DataStoreChoiceComp<ShellStore> host(ShellStore self, Property<ShellStore> selected) {
|
||||
return new DataStoreChoiceComp<>(Mode.HOST, self, selected, ShellStore.class, shellStore -> true);
|
||||
}
|
||||
|
||||
public static enum Mode {
|
||||
HOST_CHOICE,
|
||||
PROXY_CHOICE
|
||||
HOST,
|
||||
ENVIRONMENT,
|
||||
OTHER,
|
||||
PROXY
|
||||
}
|
||||
|
||||
private final Mode mode;
|
||||
@@ -60,7 +67,7 @@ public class ShellStoreChoiceComp<T extends ShellStore> extends SimpleComp {
|
||||
.filter(e -> e.equals(s))
|
||||
.findAny()
|
||||
.flatMap(store -> {
|
||||
if (ShellStore.isLocal(store.asNeeded()) && mode == Mode.PROXY_CHOICE) {
|
||||
if (ShellStore.isLocal(store.asNeeded()) && mode == Mode.PROXY) {
|
||||
return Optional.of(AppI18n.get("none"));
|
||||
}
|
||||
|
||||
@@ -97,7 +104,7 @@ public class ShellStoreChoiceComp<T extends ShellStore> extends SimpleComp {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!((ShellStore) s).canHaveSubs()) {
|
||||
if (!(mode == Mode.ENVIRONMENT) && !((ShellStore) s).canHaveSubs()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import io.xpipe.core.source.DataSource;
|
||||
import io.xpipe.core.source.DataSourceId;
|
||||
import io.xpipe.core.source.DataSourceReference;
|
||||
import io.xpipe.core.store.DataStore;
|
||||
import io.xpipe.core.store.FixedHierarchyStore;
|
||||
import lombok.Getter;
|
||||
import lombok.NonNull;
|
||||
|
||||
@@ -95,6 +96,36 @@ public abstract class DataStorage {
|
||||
return internalCollection;
|
||||
}
|
||||
|
||||
public synchronized void refreshChildren(DataStoreEntry e) {
|
||||
if (!(e.getStore() instanceof FixedHierarchyStore)) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
var newChildren = ((FixedHierarchyStore) e.getStore()).listChildren();
|
||||
deleteChildren(e, true);
|
||||
newChildren.forEach((key, value) -> {
|
||||
try {
|
||||
addStoreEntry(key, value);
|
||||
} catch (Exception ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
});
|
||||
} catch (Exception ex) {
|
||||
ErrorEvent.fromThrowable(ex).handle();
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void deleteChildren(DataStoreEntry e, boolean deep) {
|
||||
getStoreChildren(e,deep).forEach(entry -> {
|
||||
if (!entry.getConfiguration().isDeletable()) {
|
||||
return;
|
||||
}
|
||||
|
||||
deleteStoreEntry(entry);
|
||||
});
|
||||
}
|
||||
|
||||
public synchronized List<DataStoreEntry> getStoreChildren(DataStoreEntry entry, boolean deep) {
|
||||
var children = new ArrayList<>(getStoreEntries().stream().filter(other -> {
|
||||
if (!other.getState().isUsable()) {
|
||||
|
||||
@@ -10,6 +10,7 @@ import io.xpipe.app.ext.DataStoreProvider;
|
||||
import io.xpipe.app.ext.DataStoreProviders;
|
||||
import io.xpipe.app.issue.ErrorEvent;
|
||||
import io.xpipe.core.store.DataStore;
|
||||
import io.xpipe.core.store.FixedHierarchyStore;
|
||||
import io.xpipe.core.util.JacksonMapper;
|
||||
import lombok.*;
|
||||
import lombok.experimental.NonFinal;
|
||||
@@ -218,6 +219,11 @@ public class DataStoreEntry extends StorageElement {
|
||||
state = State.VALIDATING;
|
||||
listeners.forEach(l -> l.onUpdate());
|
||||
store.validate();
|
||||
|
||||
if (store instanceof FixedHierarchyStore) {
|
||||
DataStorage.get().refreshChildren(this);
|
||||
}
|
||||
|
||||
state = State.COMPLETE_AND_VALID;
|
||||
information = getProvider().queryInformationString(getStore(), 50);
|
||||
dirty = true;
|
||||
|
||||
Reference in New Issue
Block a user