This commit is contained in:
crschnick 2023-10-14 21:24:46 +00:00
parent ee740b43f8
commit 1e990389f4
20 changed files with 117 additions and 319 deletions

View file

@ -25,6 +25,7 @@ public class ListBoxViewComp<T> extends Comp<CompStructure<ScrollPane>> {
private final ObservableList<T> shown;
private final ObservableList<T> all;
private final Function<T, Comp<?>> compFunction;
private int limit = Integer.MAX_VALUE;
public ListBoxViewComp(ObservableList<T> shown, ObservableList<T> all, Function<T, Comp<?>> compFunction) {
this.shown = PlatformThread.sync(shown);
@ -32,6 +33,11 @@ public class ListBoxViewComp<T> extends Comp<CompStructure<ScrollPane>> {
this.compFunction = compFunction;
}
public ListBoxViewComp<T> withLimit(int limit) {
this.limit = limit;
return this;
}
@Override
public CompStructure<ScrollPane> createBase() {
Map<T, Region> cache = new IdentityHashMap<>();
@ -74,6 +80,7 @@ public class ListBoxViewComp<T> extends Comp<CompStructure<ScrollPane>> {
return cache.get(v);
})
.filter(region -> region != null)
.limit(limit)
.toList();
for (int i = 0; i < newShown.size(); i++) {

View file

@ -192,7 +192,7 @@ public abstract class StoreEntryComp extends SimpleComp {
var list = new ArrayList<Comp<?>>();
for (var p : wrapper.getActionProviders().entrySet()) {
var actionProvider = p.getKey().getDataStoreCallSite();
if (!actionProvider.isMajor(wrapper.getEntry().getStore().asNeeded())) {
if (!actionProvider.isMajor(wrapper.getEntry().ref())) {
continue;
}
@ -202,15 +202,15 @@ public abstract class StoreEntryComp extends SimpleComp {
}
var button = new IconButtonComp(
actionProvider.getIcon(wrapper.getEntry().getStore().asNeeded()), () -> {
actionProvider.getIcon(wrapper.getEntry().ref()), () -> {
ThreadHelper.runFailableAsync(() -> {
var action = actionProvider.createAction(
wrapper.getEntry().getStore().asNeeded());
wrapper.getEntry().ref());
action.execute();
});
});
button.apply(new FancyTooltipAugment<>(
actionProvider.getName(wrapper.getEntry().getStore().asNeeded())));
actionProvider.getName(wrapper.getEntry().ref())));
if (actionProvider.activeType() == ActionProvider.DataStoreCallSite.ActiveType.ONLY_SHOW_IF_ENABLED) {
button.hide(Bindings.not(p.getValue()));
} else if (actionProvider.activeType() == ActionProvider.DataStoreCallSite.ActiveType.ALWAYS_SHOW) {
@ -256,7 +256,7 @@ public abstract class StoreEntryComp extends SimpleComp {
var hasSep = false;
for (var p : wrapper.getActionProviders().entrySet()) {
var actionProvider = p.getKey().getDataStoreCallSite();
if (actionProvider.isMajor(wrapper.getEntry().getStore().asNeeded())) {
if (actionProvider.isMajor(wrapper.getEntry().ref())) {
continue;
}
@ -267,8 +267,8 @@ public abstract class StoreEntryComp extends SimpleComp {
hasSep = true;
}
var name = actionProvider.getName(wrapper.getEntry().getStore().asNeeded());
var icon = actionProvider.getIcon(wrapper.getEntry().getStore().asNeeded());
var name = actionProvider.getName(wrapper.getEntry().ref());
var icon = actionProvider.getIcon(wrapper.getEntry().ref());
var item = actionProvider.canLinkTo()
? new Menu(null, new FontIcon(icon))
: new MenuItem(null, new FontIcon(icon));
@ -281,7 +281,7 @@ public abstract class StoreEntryComp extends SimpleComp {
contextMenu.hide();
ThreadHelper.runFailableAsync(() -> {
var action = actionProvider.createAction(
wrapper.getEntry().getStore().asNeeded());
wrapper.getEntry().ref());
action.execute();
});
});
@ -298,7 +298,7 @@ public abstract class StoreEntryComp extends SimpleComp {
run.textProperty().bind(AppI18n.observable("base.execute"));
run.setOnAction(event -> {
ThreadHelper.runFailableAsync(() -> {
p.getKey().getDataStoreCallSite().createAction(wrapper.getEntry().getStore().asNeeded()).execute();
p.getKey().getDataStoreCallSite().createAction(wrapper.getEntry().ref()).execute();
});
});
menu.getItems().add(run);
@ -311,7 +311,7 @@ public abstract class StoreEntryComp extends SimpleComp {
sc.setOnAction(event -> {
ThreadHelper.runFailableAsync(() -> {
DesktopShortcuts.create(url,
wrapper.nameProperty().getValue() + " (" + p.getKey().getDataStoreCallSite().getName(wrapper.getEntry().getStore().asNeeded()).getValue() + ")");
wrapper.nameProperty().getValue() + " (" + p.getKey().getDataStoreCallSite().getName(wrapper.getEntry().ref()).getValue() + ")");
});
});
menu.getItems().add(sc);

View file

@ -176,7 +176,7 @@ public class StoreEntryWrapper {
.getApplicableClass()
.isAssignableFrom(entry.getStore().getClass())
&& e.getDefaultDataStoreCallSite()
.isApplicable(entry.getStore().asNeeded()))
.isApplicable(entry.ref()))
.findFirst()
.map(ActionProvider::getDefaultDataStoreCallSite)
.orElse(null);
@ -191,7 +191,7 @@ public class StoreEntryWrapper {
.isAssignableFrom(entry.getStore().getClass())
&& dataStoreActionProvider
.getDataStoreCallSite()
.isApplicable(entry.getStore().asNeeded()));
.isApplicable(entry.ref()));
} catch (Exception ex) {
ErrorEvent.fromThrowable(ex).handle();
actionProviders.get(dataStoreActionProvider).set(false);
@ -210,7 +210,7 @@ public class StoreEntryWrapper {
var found = getDefaultActionProvider().getValue();
entry.updateLastUsed();
if (found != null) {
found.createAction(entry.getStore().asNeeded()).execute();
found.createAction(entry.ref()).execute();
} else {
entry.setExpanded(!entry.isExpanded());
}

View file

@ -60,7 +60,7 @@ public class StoreSectionComp extends Comp<CompStructure<VBox>> {
var content = new ListBoxViewComp<>(section.getShownChildren(), section.getAllChildren(), (StoreSection e) -> {
return StoreSection.customSection(e, false).apply(GrowAugment.create(true, false));
}).hgrow();
}).withLimit(100).hgrow();
var expanded = Bindings.createBooleanBinding(() -> {
return section.getWrapper().getExpanded().get() && section.getShownChildren().size() > 0;

View file

@ -43,7 +43,7 @@ public class StoreSectionMiniComp extends Comp<CompStructure<VBox>> {
public CompStructure<VBox> createBase() {
var content = new ListBoxViewComp<>(section.getShownChildren(), section.getAllChildren(), (StoreSection e) -> {
return StoreSectionMiniComp.builder().section(e).augment(this.augment).build();
})
}).withLimit(100)
.hgrow();
var list = new ArrayList<Comp<?>>();

View file

@ -1,6 +1,7 @@
package io.xpipe.app.ext;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.storage.DataStoreEntryRef;
import io.xpipe.core.store.DataStore;
import io.xpipe.core.util.ModuleLayerLoader;
import javafx.beans.value.ObservableValue;
@ -92,11 +93,11 @@ public interface ActionProvider {
interface DefaultDataStoreCallSite<T extends DataStore> {
Action createAction(T store);
Action createAction(DataStoreEntryRef<T> store);
Class<T> getApplicableClass();
default boolean isApplicable(T o) {
default boolean isApplicable(DataStoreEntryRef<T> o) {
return true;
}
}
@ -117,21 +118,21 @@ public interface ActionProvider {
return false;
}
Action createAction(T store);
Action createAction(DataStoreEntryRef<T> store);
Class<T> getApplicableClass();
default boolean isMajor(T o) {
default boolean isMajor(DataStoreEntryRef<T> o) {
return false;
}
default boolean isApplicable(T o) {
default boolean isApplicable(DataStoreEntryRef<T> o) {
return true;
}
ObservableValue<String> getName(T store);
ObservableValue<String> getName(DataStoreEntryRef<T> store);
String getIcon(T store);
String getIcon(DataStoreEntryRef<T> store);
default ActiveType activeType() {
return ActiveType.ONLY_SHOW_IF_ENABLED;

View file

@ -4,8 +4,8 @@ import io.xpipe.app.browser.BrowserModel;
import io.xpipe.app.core.AppI18n;
import io.xpipe.app.core.AppLayoutModel;
import io.xpipe.app.ext.ActionProvider;
import io.xpipe.app.storage.DataStorage;
import io.xpipe.app.storage.DataStoreEntry;
import io.xpipe.app.storage.DataStoreEntryRef;
import io.xpipe.core.store.ShellStore;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.value.ObservableValue;
@ -35,23 +35,23 @@ public class BrowseStoreAction implements ActionProvider {
return new DataStoreCallSite<ShellStore>() {
@Override
public boolean isMajor(ShellStore o) {
public boolean isMajor(DataStoreEntryRef<ShellStore> o) {
return true;
}
@Override
public ObservableValue<String> getName(ShellStore store) {
public ObservableValue<String> getName(DataStoreEntryRef<ShellStore> store) {
return AppI18n.observable("browseFiles");
}
@Override
public String getIcon(ShellStore store) {
public String getIcon(DataStoreEntryRef<ShellStore> store) {
return "mdi2f-folder-open-outline";
}
@Override
public ActionProvider.Action createAction(ShellStore store) {
return new Action(DataStorage.get().getStoreEntry(store));
public ActionProvider.Action createAction(DataStoreEntryRef<ShellStore> store) {
return new Action(store.get());
}
@Override

View file

@ -4,6 +4,7 @@ import io.xpipe.app.core.AppI18n;
import io.xpipe.app.ext.ActionProvider;
import io.xpipe.app.storage.DataStorage;
import io.xpipe.app.storage.DataStoreEntry;
import io.xpipe.app.storage.DataStoreEntryRef;
import io.xpipe.core.store.DataStore;
import io.xpipe.app.util.FixedHierarchyStore;
import javafx.beans.value.ObservableValue;
@ -37,8 +38,8 @@ public class DeleteStoreChildrenAction implements ActionProvider {
}
@Override
public ActionProvider.Action createAction(DataStore store) {
return new Action(DataStorage.get().getStoreEntry(store));
public ActionProvider.Action createAction(DataStoreEntryRef<DataStore> store) {
return new Action(store.get());
}
@Override
@ -47,20 +48,20 @@ public class DeleteStoreChildrenAction implements ActionProvider {
}
@Override
public boolean isApplicable(DataStore o) {
return !(o instanceof FixedHierarchyStore) && DataStorage.get()
.getStoreChildren(DataStorage.get().getStoreEntry(o), true)
public boolean isApplicable(DataStoreEntryRef<DataStore> o) {
return !(o.getStore() instanceof FixedHierarchyStore) && DataStorage.get()
.getStoreChildren(o.get(), true)
.size()
> 1;
}
@Override
public ObservableValue<String> getName(DataStore store) {
public ObservableValue<String> getName(DataStoreEntryRef<DataStore> store) {
return AppI18n.observable("base.deleteChildren");
}
@Override
public String getIcon(DataStore store) {
public String getIcon(DataStoreEntryRef<DataStore> store) {
return "mdal-delete_outline";
}
};

View file

@ -3,9 +3,8 @@ package io.xpipe.ext.base.action;
import io.xpipe.app.comp.store.GuiDsStoreCreator;
import io.xpipe.app.core.AppI18n;
import io.xpipe.app.ext.ActionProvider;
import io.xpipe.app.ext.DataStoreProviders;
import io.xpipe.app.storage.DataStorage;
import io.xpipe.app.storage.DataStoreEntry;
import io.xpipe.app.storage.DataStoreEntryRef;
import io.xpipe.core.store.DataStore;
import javafx.beans.value.ObservableValue;
import lombok.Value;
@ -32,18 +31,15 @@ public class EditStoreAction implements ActionProvider {
public DefaultDataStoreCallSite<?> getDefaultDataStoreCallSite() {
return new DefaultDataStoreCallSite<>() {
@Override
public boolean isApplicable(DataStore o) {
return DataStorage.get()
.getStoreEntryIfPresent(o)
.orElseThrow()
public boolean isApplicable(DataStoreEntryRef<DataStore> o) {
return o.get()
.getValidity()
.equals(DataStoreEntry.Validity.INCOMPLETE);
}
@Override
public ActionProvider.Action createAction(DataStore store) {
return new Action(
DataStorage.get().getStoreEntryIfPresent(store).orElseThrow());
public ActionProvider.Action createAction(DataStoreEntryRef<DataStore> store) {
return new Action(store.get());
}
@Override
@ -58,8 +54,8 @@ public class EditStoreAction implements ActionProvider {
return new DataStoreCallSite<>() {
@Override
public boolean isMajor(DataStore o) {
var provider = DataStoreProviders.byStore(o);
public boolean isMajor(DataStoreEntryRef<DataStore> o) {
var provider = o.get().getProvider();
return provider.shouldEdit();
}
@ -74,8 +70,8 @@ public class EditStoreAction implements ActionProvider {
}
@Override
public ActionProvider.Action createAction(DataStore store) {
return new Action(DataStorage.get().getStoreEntry(store));
public ActionProvider.Action createAction(DataStoreEntryRef<DataStore> store) {
return new Action(store.get());
}
@Override
@ -84,12 +80,12 @@ public class EditStoreAction implements ActionProvider {
}
@Override
public ObservableValue<String> getName(DataStore store) {
public ObservableValue<String> getName(DataStoreEntryRef<DataStore> store) {
return AppI18n.observable("base.edit");
}
@Override
public String getIcon(DataStore store) {
public String getIcon(DataStoreEntryRef<DataStore> store) {
return "mdal-edit";
}
};

View file

@ -1,62 +0,0 @@
package io.xpipe.ext.base.action;
import io.xpipe.app.core.AppI18n;
import io.xpipe.app.ext.ActionProvider;
import io.xpipe.app.util.DesktopHelper;
import io.xpipe.core.store.FileStore;
import io.xpipe.core.store.LocalStore;
import javafx.beans.value.ObservableValue;
import lombok.Value;
import java.nio.file.Files;
import java.nio.file.Path;
public class FileBrowseAction implements ActionProvider {
@Value
static class Action implements ActionProvider.Action {
FileStore store;
@Override
public boolean requiresJavaFXPlatform() {
return false;
}
@Override
public void execute() {
DesktopHelper.browseFileInDirectory(Path.of(store.getPath()));
}
}
@Override
public DataStoreCallSite<?> getDataStoreCallSite() {
return new DataStoreCallSite<FileStore>() {
@Override
public ActionProvider.Action createAction(FileStore store) {
return new Action(store);
}
@Override
public Class<FileStore> getApplicableClass() {
return FileStore.class;
}
@Override
public boolean isApplicable(FileStore o) {
return o.getFileSystem().equals(new LocalStore()) && Files.exists(Path.of(o.getPath()));
}
@Override
public ObservableValue<String> getName(FileStore store) {
return AppI18n.observable("base.browseFile");
}
@Override
public String getIcon(FileStore store) {
return "mdi2f-folder-open-outline";
}
};
}
}

View file

@ -1,62 +0,0 @@
package io.xpipe.ext.base.action;
import io.xpipe.app.core.AppI18n;
import io.xpipe.app.ext.ActionProvider;
import io.xpipe.app.util.FileOpener;
import io.xpipe.core.store.FileStore;
import io.xpipe.core.store.LocalStore;
import io.xpipe.core.store.DataFlow;
import javafx.beans.value.ObservableValue;
import lombok.Value;
public class FileEditAction implements ActionProvider {
@Value
static class Action implements ActionProvider.Action {
FileStore store;
@Override
public boolean requiresJavaFXPlatform() {
return false;
}
@Override
public void execute() {
if (store.getFileSystem().equals(new LocalStore())) {
FileOpener.openInTextEditor(store.getPath());
}
}
}
@Override
public DataStoreCallSite<?> getDataStoreCallSite() {
return new DataStoreCallSite<FileStore>() {
@Override
public ActionProvider.Action createAction(FileStore store) {
return new Action(store);
}
@Override
public Class<FileStore> getApplicableClass() {
return FileStore.class;
}
@Override
public boolean isApplicable(FileStore o) {
return o.getFlow().equals(DataFlow.INPUT_OUTPUT);
}
@Override
public ObservableValue<String> getName(FileStore store) {
return AppI18n.observable("base.editFile");
}
@Override
public String getIcon(FileStore store) {
return "mdal-edit";
}
};
}
}

View file

@ -4,6 +4,7 @@ import io.xpipe.app.core.AppI18n;
import io.xpipe.app.ext.ActionProvider;
import io.xpipe.app.storage.DataStorage;
import io.xpipe.app.storage.DataStoreEntry;
import io.xpipe.app.storage.DataStoreEntryRef;
import io.xpipe.app.util.TerminalHelper;
import io.xpipe.core.store.LaunchableStore;
import io.xpipe.core.store.ShellStore;
@ -52,18 +53,15 @@ public class LaunchAction implements ActionProvider {
}
@Override
public boolean isApplicable(LaunchableStore o) {
return DataStorage.get()
.getStoreEntryIfPresent(o)
.orElseThrow()
public boolean isApplicable(DataStoreEntryRef<LaunchableStore> o) {
return o.get()
.getValidity()
.isUsable() && o.canLaunch();
.isUsable() && o.getStore().canLaunch();
}
@Override
public ActionProvider.Action createAction(LaunchableStore store) {
return new Action(
DataStorage.get().getStoreEntryIfPresent(store).orElseThrow());
public ActionProvider.Action createAction(DataStoreEntryRef<LaunchableStore> store) {
return new Action(store.get());
}
@Override
@ -72,12 +70,12 @@ public class LaunchAction implements ActionProvider {
}
@Override
public ObservableValue<String> getName(LaunchableStore store) {
public ObservableValue<String> getName(DataStoreEntryRef<LaunchableStore> store) {
return AppI18n.observable("launch");
}
@Override
public String getIcon(LaunchableStore store) {
public String getIcon(DataStoreEntryRef<LaunchableStore> store) {
return "mdi2p-play";
}
};
@ -93,17 +91,15 @@ public class LaunchAction implements ActionProvider {
return new DefaultDataStoreCallSite<LaunchableStore>() {
@Override
public boolean isApplicable(LaunchableStore o) {
return DataStorage.get()
.getStoreEntryIfPresent(o)
.orElseThrow()
public boolean isApplicable(DataStoreEntryRef<LaunchableStore> o) {
return o.get()
.getValidity()
.isUsable() && o.canLaunch();
.isUsable() && o.getStore().canLaunch();
}
@Override
public ActionProvider.Action createAction(LaunchableStore store) {
return new Action(DataStorage.get().getStoreEntryIfPresent(store).orElseThrow());
public ActionProvider.Action createAction(DataStoreEntryRef<LaunchableStore> store) {
return new Action(store.get());
}
@Override

View file

@ -2,8 +2,8 @@ package io.xpipe.ext.base.action;
import io.xpipe.app.core.AppI18n;
import io.xpipe.app.ext.ActionProvider;
import io.xpipe.app.storage.DataStorage;
import io.xpipe.app.storage.DataStoreEntry;
import io.xpipe.app.storage.DataStoreEntryRef;
import io.xpipe.app.util.DesktopShortcuts;
import io.xpipe.core.store.LaunchableStore;
import javafx.beans.value.ObservableValue;
@ -32,8 +32,8 @@ public class LaunchShortcutAction implements ActionProvider {
return new DataStoreCallSite<LaunchableStore>() {
@Override
public Action createAction(LaunchableStore store) {
return new Action(DataStorage.get().getStoreEntry(store));
public Action createAction(DataStoreEntryRef<LaunchableStore> store) {
return new Action(store.get());
}
@Override
@ -42,12 +42,12 @@ public class LaunchShortcutAction implements ActionProvider {
}
@Override
public ObservableValue<String> getName(LaunchableStore store) {
public ObservableValue<String> getName(DataStoreEntryRef<LaunchableStore> store) {
return AppI18n.observable("createShortcut");
}
@Override
public String getIcon(LaunchableStore store) {
public String getIcon(DataStoreEntryRef<LaunchableStore> store) {
return "mdi2c-code-greater-than";
}

View file

@ -2,6 +2,7 @@ package io.xpipe.ext.base.action;
import io.xpipe.app.core.AppI18n;
import io.xpipe.app.ext.ActionProvider;
import io.xpipe.app.storage.DataStoreEntryRef;
import io.xpipe.app.util.ObservableDataStore;
import javafx.beans.value.ObservableValue;
import lombok.Value;
@ -11,7 +12,7 @@ public class ObserveStoreAction implements ActionProvider {
@Value
static class Action implements ActionProvider.Action {
ObservableDataStore store;
DataStoreEntryRef<ObservableDataStore> store;
@Override
public boolean requiresJavaFXPlatform() {
@ -20,7 +21,7 @@ public class ObserveStoreAction implements ActionProvider {
@Override
public void execute() {
store.toggleObserverState(!store.getObserverState());
store.getStore().toggleObserverState(!store.getStore().getObserverState());
}
}
@ -29,7 +30,7 @@ public class ObserveStoreAction implements ActionProvider {
return new DataStoreCallSite<ObservableDataStore>() {
@Override
public ActionProvider.Action createAction(ObservableDataStore store) {
public ActionProvider.Action createAction(DataStoreEntryRef<ObservableDataStore> store) {
return new Action(store);
}
@ -39,13 +40,13 @@ public class ObserveStoreAction implements ActionProvider {
}
@Override
public ObservableValue<String> getName(ObservableDataStore store) {
return store.getObserverState() ? AppI18n.observable("base.stopObserve") : AppI18n.observable("base.observe");
public ObservableValue<String> getName(DataStoreEntryRef<ObservableDataStore> store) {
return store.getStore().getObserverState() ? AppI18n.observable("base.stopObserve") : AppI18n.observable("base.observe");
}
@Override
public String getIcon(ObservableDataStore store) {
return store.getObserverState() ? "mdi2e-eye-off-outline" : "mdi2e-eye-outline";
public String getIcon(DataStoreEntryRef<ObservableDataStore> store) {
return store.getStore().getObserverState() ? "mdi2e-eye-off-outline" : "mdi2e-eye-outline";
}
};
}

View file

@ -4,6 +4,7 @@ import io.xpipe.app.core.AppI18n;
import io.xpipe.app.ext.ActionProvider;
import io.xpipe.app.storage.DataStorage;
import io.xpipe.app.storage.DataStoreEntry;
import io.xpipe.app.storage.DataStoreEntryRef;
import io.xpipe.app.util.FixedHierarchyStore;
import javafx.beans.value.ObservableValue;
import lombok.Value;
@ -31,13 +32,13 @@ public class RefreshStoreAction implements ActionProvider {
return new DefaultDataStoreCallSite<>() {
@Override
public boolean isApplicable(FixedHierarchyStore o) {
return DataStorage.get().getStoreChildren(DataStorage.get().getStoreEntry(o), true).size() == 0;
public boolean isApplicable(DataStoreEntryRef<FixedHierarchyStore> o) {
return DataStorage.get().getStoreChildren(o.get(), true).size() == 0;
}
@Override
public ActionProvider.Action createAction(FixedHierarchyStore store) {
return new Action(DataStorage.get().getStoreEntry(store));
public ActionProvider.Action createAction(DataStoreEntryRef<FixedHierarchyStore> store) {
return new Action(store.get());
}
@Override
@ -52,7 +53,7 @@ public class RefreshStoreAction implements ActionProvider {
return new ActionProvider.DataStoreCallSite<FixedHierarchyStore>() {
@Override
public boolean isMajor(FixedHierarchyStore o) {
public boolean isMajor(DataStoreEntryRef<FixedHierarchyStore> o) {
return true;
}
@ -62,8 +63,8 @@ public class RefreshStoreAction implements ActionProvider {
}
@Override
public ActionProvider.Action createAction(FixedHierarchyStore store) {
return new Action(DataStorage.get().getStoreEntry(store));
public ActionProvider.Action createAction(DataStoreEntryRef<FixedHierarchyStore> store) {
return new Action(store.get());
}
@Override
@ -72,12 +73,12 @@ public class RefreshStoreAction implements ActionProvider {
}
@Override
public ObservableValue<String> getName(FixedHierarchyStore store) {
public ObservableValue<String> getName(DataStoreEntryRef<FixedHierarchyStore> store) {
return AppI18n.observable("base.refresh");
}
@Override
public String getIcon(FixedHierarchyStore store) {
public String getIcon(DataStoreEntryRef<FixedHierarchyStore> store) {
return "mdi2r-refresh";
}
};

View file

@ -2,12 +2,12 @@ package io.xpipe.ext.base.action;
import io.xpipe.app.core.AppI18n;
import io.xpipe.app.ext.ActionProvider;
import io.xpipe.app.storage.DataStorage;
import io.xpipe.app.storage.DataStoreEntry;
import io.xpipe.core.store.LocalStore;
import io.xpipe.app.storage.DataStoreEntryRef;
import io.xpipe.core.process.CommandControl;
import io.xpipe.core.process.ShellControl;
import io.xpipe.core.process.ShellDialects;
import io.xpipe.core.store.LocalStore;
import io.xpipe.core.store.ShellStore;
import javafx.beans.value.ObservableValue;
import lombok.Value;
@ -113,8 +113,8 @@ public class SampleAction implements ActionProvider {
return new DataStoreCallSite<ShellStore>() {
@Override
public Action createAction(ShellStore store) {
return new Action(DataStorage.get().getStoreEntry(store));
public Action createAction(DataStoreEntryRef<ShellStore> store) {
return new Action(store.get());
}
@Override
@ -124,20 +124,20 @@ public class SampleAction implements ActionProvider {
}
@Override
public boolean isApplicable(ShellStore o) {
public boolean isApplicable(DataStoreEntryRef<ShellStore> o) {
// Allows you to individually check whether this action should be available for the specific store.
// In this case it should only be available for remote shell connections, not local ones.
return !ShellStore.isLocal(o);
return !ShellStore.isLocal(o.getStore());
}
@Override
public ObservableValue<String> getName(ShellStore store) {
public ObservableValue<String> getName(DataStoreEntryRef<ShellStore> store) {
// The displayed name of the action, allows you to use translation keys.
return AppI18n.observable("installConnector");
}
@Override
public String getIcon(ShellStore store) {
public String getIcon(DataStoreEntryRef<ShellStore> store) {
// The ikonli icon of the button.
return "mdi2c-code-greater-than";
}

View file

@ -2,9 +2,8 @@ package io.xpipe.ext.base.action;
import io.xpipe.app.core.AppI18n;
import io.xpipe.app.ext.ActionProvider;
import io.xpipe.app.ext.DataStoreProviders;
import io.xpipe.app.storage.DataStorage;
import io.xpipe.app.storage.DataStoreEntry;
import io.xpipe.app.storage.DataStoreEntryRef;
import io.xpipe.app.util.ScanAlert;
import io.xpipe.core.store.ShellStore;
import javafx.beans.value.ObservableValue;
@ -33,23 +32,23 @@ public class ScanAction implements ActionProvider {
return new DataStoreCallSite<ShellStore>() {
@Override
public boolean isMajor(ShellStore o) {
return DataStoreProviders.byStore(o).shouldHaveChildren();
public boolean isMajor(DataStoreEntryRef<ShellStore> o) {
return o.get().getProvider().shouldHaveChildren();
}
@Override
public ObservableValue<String> getName(ShellStore store) {
public ObservableValue<String> getName(DataStoreEntryRef<ShellStore> store) {
return AppI18n.observable("scanConnections");
}
@Override
public String getIcon(ShellStore store) {
public String getIcon(DataStoreEntryRef<ShellStore> store) {
return "mdi2m-magnify-scan";
}
@Override
public ActionProvider.Action createAction(ShellStore store) {
return new Action(DataStorage.get().getStoreEntry(store));
public ActionProvider.Action createAction(DataStoreEntryRef<ShellStore> store) {
return new Action(store.get());
}
@Override

View file

@ -3,7 +3,8 @@ package io.xpipe.ext.base.action;
import io.xpipe.app.core.AppActionLinkDetector;
import io.xpipe.app.core.AppI18n;
import io.xpipe.app.ext.ActionProvider;
import io.xpipe.app.ext.DataStoreProviders;
import io.xpipe.app.storage.DataStoreEntry;
import io.xpipe.app.storage.DataStoreEntryRef;
import io.xpipe.app.util.SecretHelper;
import io.xpipe.core.store.DataStore;
import javafx.beans.value.ObservableValue;
@ -18,7 +19,7 @@ public class ShareStoreAction implements ActionProvider {
@Value
static class Action implements ActionProvider.Action {
DataStore store;
DataStoreEntry store;
@Override
public boolean requiresJavaFXPlatform() {
@ -32,7 +33,7 @@ public class ShareStoreAction implements ActionProvider {
@Override
public void execute() {
var string = create(store);
var string = create(store.getStore());
var selection = new StringSelection(string);
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
AppActionLinkDetector.setLastDetectedAction(string);
@ -45,8 +46,8 @@ public class ShareStoreAction implements ActionProvider {
return new DataStoreCallSite<>() {
@Override
public ActionProvider.Action createAction(DataStore store) {
return new Action(store);
public ActionProvider.Action createAction(DataStoreEntryRef<DataStore> store) {
return new Action(store.get());
}
@Override
@ -55,17 +56,17 @@ public class ShareStoreAction implements ActionProvider {
}
@Override
public boolean isApplicable(DataStore o) {
return DataStoreProviders.byStore(o).isShareable();
public boolean isApplicable(DataStoreEntryRef<DataStore> o) {
return o.get().getProvider().isShareable();
}
@Override
public ObservableValue<String> getName(DataStore store) {
public ObservableValue<String> getName(DataStoreEntryRef<DataStore> store) {
return AppI18n.observable("base.copyShareLink");
}
@Override
public String getIcon(DataStore store) {
public String getIcon(DataStoreEntryRef<DataStore> store) {
return "mdi2c-clipboard-list-outline";
}
};

View file

@ -1,79 +0,0 @@
package io.xpipe.ext.base.action;
import io.xpipe.app.browser.StandaloneFileBrowser;
import io.xpipe.app.core.AppI18n;
import io.xpipe.app.ext.ActionProvider;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.util.ThreadHelper;
import io.xpipe.core.store.FileStore;
import io.xpipe.core.store.StreamDataStore;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.value.ObservableValue;
import lombok.Value;
import java.io.InputStream;
import java.io.OutputStream;
public class StreamExportAction implements ActionProvider {
@Value
static class Action implements ActionProvider.Action {
StreamDataStore store;
@Override
public boolean requiresJavaFXPlatform() {
return true;
}
@Override
public void execute() {
var outputFile = new SimpleObjectProperty<FileStore>();
StandaloneFileBrowser.saveSingleFile(outputFile);
if (outputFile.get() == null) {
return;
}
ThreadHelper.runAsync(() -> {
try (InputStream inputStream = store.openInput()) {
try (OutputStream outputStream = outputFile.get().openOutput()) {
inputStream.transferTo(outputStream);
}
} catch (Exception e) {
ErrorEvent.fromThrowable(e).handle();
}
});
}
}
@Override
public DataStoreCallSite<?> getDataStoreCallSite() {
return new DataStoreCallSite<StreamDataStore>() {
@Override
public Action createAction(StreamDataStore store) {
return new Action(store);
}
@Override
public boolean isApplicable(StreamDataStore o) {
return o.getFlow() != null && o.getFlow().hasInput();
}
@Override
public Class<StreamDataStore> getApplicableClass() {
return StreamDataStore.class;
}
@Override
public ObservableValue<String> getName(StreamDataStore store) {
return AppI18n.observable("base.exportStream");
}
@Override
public String getIcon(StreamDataStore store) {
return "mdi2f-file-export-outline";
}
};
}
}

View file

@ -56,9 +56,7 @@ open module io.xpipe.ext.base {
XPipeUrlAction,
EditStoreAction,
DeleteStoreChildrenAction,
FileBrowseAction,
BrowseStoreAction,
FileEditAction;
BrowseStoreAction;
provides DataStoreProvider with
ScriptGroupStoreProvider,
SimpleScriptStoreProvider,