From 3ec708ef37386cbc57697d3a99a758e8a33d3e7a Mon Sep 17 00:00:00 2001 From: crschnick Date: Mon, 6 Mar 2023 19:42:26 +0000 Subject: [PATCH] Various small fixes [release] --- app/build.gradle | 2 +- .../source/store/DataStoreSelectorComp.java | 2 +- .../source/store/DsLocalFileBrowseComp.java | 4 +- .../source/store/DsRemoteFileChoiceComp.java | 2 +- .../comp/source/store/GuiDsStoreCreator.java | 6 ++ .../comp/storage/store/StoreEntryComp.java | 2 +- .../comp/storage/store/StoreEntryWrapper.java | 23 +++--- .../java/io/xpipe/app/ext/ActionProvider.java | 19 ++++- .../app/fxcomps/impl/FileStoreChoiceComp.java | 4 +- .../impl/FileSystemStoreChoiceComp.java | 4 +- .../io/xpipe/app/issue/ErrorHandlerComp.java | 78 ++++++++++++++----- .../io/xpipe/app/storage/DataStorage.java | 29 +++---- .../java/io/xpipe/core/impl/FileStore.java | 22 +++--- .../io/xpipe/ext/base/FileStoreProvider.java | 8 +- .../ext/base/actions/AddStoreAction.java | 4 +- .../ext/base/actions/EditStoreAction.java | 21 +++++ .../ext/base/actions/FileBrowseAction.java | 4 +- .../ext/base/actions/FileEditAction.java | 2 +- .../ext/base/actions/ShareStoreAction.java | 2 +- version | 2 +- 20 files changed, 159 insertions(+), 81 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index ed3fc133..f475d74a 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -136,7 +136,7 @@ run { systemProperty 'io.xpipe.app.writeLogs', "true" systemProperty 'io.xpipe.app.writeSysOut', "true" systemProperty 'io.xpipe.app.developerMode', "true" - systemProperty 'io.xpipe.app.logLevel', "trace" + systemProperty 'io.xpipe.app.logLevel', "debug" systemProperty 'io.xpipe.app.fullVersion', rootProject.fullVersion // systemProperty "io.xpipe.beacon.port", "21724" // systemProperty "io.xpipe.beacon.printMessages", "true" diff --git a/app/src/main/java/io/xpipe/app/comp/source/store/DataStoreSelectorComp.java b/app/src/main/java/io/xpipe/app/comp/source/store/DataStoreSelectorComp.java index da8d55c0..af4f27dd 100644 --- a/app/src/main/java/io/xpipe/app/comp/source/store/DataStoreSelectorComp.java +++ b/app/src/main/java/io/xpipe/app/comp/source/store/DataStoreSelectorComp.java @@ -62,7 +62,7 @@ public class DataStoreSelectorComp extends Comp> { AppI18n.get("selectStreamStore"), AppI18n.get("openStreamStoreWizard"), graphic); } else { return JfxHelper.createNamedEntry( - f.getFileName().toString(), f.getFile().toString(), graphic); + f.getFileName().toString(), f.getPath().toString(), graphic); } } } diff --git a/app/src/main/java/io/xpipe/app/comp/source/store/DsLocalFileBrowseComp.java b/app/src/main/java/io/xpipe/app/comp/source/store/DsLocalFileBrowseComp.java index 4f3854e4..fc0b8656 100644 --- a/app/src/main/java/io/xpipe/app/comp/source/store/DsLocalFileBrowseComp.java +++ b/app/src/main/java/io/xpipe/app/comp/source/store/DsLocalFileBrowseComp.java @@ -65,11 +65,11 @@ public class DsLocalFileBrowseComp extends Comp> { private Region getGraphic() { var graphic = hasProvider() ? provider.getValue().getDisplayIconFileName() : "file_icon.png"; - if (chosenFile.getValue() == null || !(chosenFile.getValue() instanceof FileStore f) || f.getFile() == null) { + if (chosenFile.getValue() == null || !(chosenFile.getValue() instanceof FileStore f) || f.getPath() == null) { return JfxHelper.createNamedEntry(AppI18n.get("browse"), AppI18n.get("selectFileFromComputer"), graphic); } else { return JfxHelper.createNamedEntry( - f.getFileName().toString(), f.getFile().toString(), graphic); + f.getFileName().toString(), f.getPath().toString(), graphic); } } } diff --git a/app/src/main/java/io/xpipe/app/comp/source/store/DsRemoteFileChoiceComp.java b/app/src/main/java/io/xpipe/app/comp/source/store/DsRemoteFileChoiceComp.java index bb2c7075..10480fa5 100644 --- a/app/src/main/java/io/xpipe/app/comp/source/store/DsRemoteFileChoiceComp.java +++ b/app/src/main/java/io/xpipe/app/comp/source/store/DsRemoteFileChoiceComp.java @@ -33,7 +33,7 @@ public class DsRemoteFileChoiceComp extends SimpleComp { return FileStore.builder() .fileSystem(machine.get()) - .file(fileName.get()) + .path(fileName.get()) .build(); }, store) diff --git a/app/src/main/java/io/xpipe/app/comp/source/store/GuiDsStoreCreator.java b/app/src/main/java/io/xpipe/app/comp/source/store/GuiDsStoreCreator.java index a2f909c2..98b9840e 100644 --- a/app/src/main/java/io/xpipe/app/comp/source/store/GuiDsStoreCreator.java +++ b/app/src/main/java/io/xpipe/app/comp/source/store/GuiDsStoreCreator.java @@ -85,6 +85,12 @@ public class GuiDsStoreCreator extends MultiStepComp.Step> { r.get().setPrefWidth(AppFont.em(36)); r.get().setPrefHeight(AppFont.em(42)); }); + + this.validator.addListener((observable, oldValue, newValue) -> { + Platform.runLater(() -> { + newValue.validate(); + }); + }); } public static void showEdit(DataStoreEntry e) { diff --git a/app/src/main/java/io/xpipe/app/comp/storage/store/StoreEntryComp.java b/app/src/main/java/io/xpipe/app/comp/storage/store/StoreEntryComp.java index 596fba1c..1a54cdce 100644 --- a/app/src/main/java/io/xpipe/app/comp/storage/store/StoreEntryComp.java +++ b/app/src/main/java/io/xpipe/app/comp/storage/store/StoreEntryComp.java @@ -155,7 +155,7 @@ public class StoreEntryComp extends SimpleComp { ThreadHelper.runFailableAsync(() -> { var found = entry.getDefaultActionProvider().getValue(); if (found != null) { - found.getDataStoreCallSite() + found .createAction(entry.getEntry().getStore().asNeeded()) .execute(); } diff --git a/app/src/main/java/io/xpipe/app/comp/storage/store/StoreEntryWrapper.java b/app/src/main/java/io/xpipe/app/comp/storage/store/StoreEntryWrapper.java index 0e2ceef9..c0574171 100644 --- a/app/src/main/java/io/xpipe/app/comp/storage/store/StoreEntryWrapper.java +++ b/app/src/main/java/io/xpipe/app/comp/storage/store/StoreEntryWrapper.java @@ -8,10 +8,7 @@ import io.xpipe.app.issue.ErrorEvent; import io.xpipe.app.prefs.AppPrefs; import io.xpipe.app.storage.DataStorage; import io.xpipe.app.storage.DataStoreEntry; -import javafx.beans.Observable; -import javafx.beans.binding.Bindings; import javafx.beans.property.*; -import javafx.beans.value.ObservableValue; import lombok.Getter; import java.time.Duration; @@ -31,7 +28,7 @@ public class StoreEntryWrapper implements StorageFilter.Filterable { private final StringProperty information = new SimpleStringProperty(); private final StringProperty summary = new SimpleStringProperty(); private final Map actionProviders; - private final ObservableValue defaultActionProvider; + private final Property> defaultActionProvider; private final BooleanProperty editable = new SimpleBooleanProperty(); private final BooleanProperty renamable = new SimpleBooleanProperty(); private final BooleanProperty refreshable = new SimpleBooleanProperty(); @@ -54,16 +51,7 @@ public class StoreEntryWrapper implements StorageFilter.Filterable { .forEach(dataStoreActionProvider -> { actionProviders.put(dataStoreActionProvider, new SimpleBooleanProperty(true)); }); - this.defaultActionProvider = Bindings.createObjectBinding( - () -> { - var found = actionProviders.entrySet().stream() - .filter(e -> e.getValue().get()) - .filter(e -> e.getKey().getDataStoreCallSite() != null - && e.getKey().getDataStoreCallSite().isDefault()) - .findFirst(); - return found.map(p -> p.getKey()).orElse(null); - }, - actionProviders.values().toArray(Observable[]::new)); + this.defaultActionProvider = new SimpleObjectProperty<>(); setupListeners(); update(); } @@ -126,6 +114,7 @@ public class StoreEntryWrapper implements StorageFilter.Filterable { actionProviders.keySet().forEach(dataStoreActionProvider -> { if (!isInStorage()) { actionProviders.get(dataStoreActionProvider).set(false); + defaultActionProvider.setValue(null); return; } @@ -138,6 +127,12 @@ public class StoreEntryWrapper implements StorageFilter.Filterable { return; } + var defaultProvider = ActionProvider.ALL.stream() + .filter(e -> e.getDefaultDataStoreCallSite() != null + && e.getDefaultDataStoreCallSite().isApplicable(entry.getStore().asNeeded())) + .findFirst().map(ActionProvider::getDefaultDataStoreCallSite).orElse(null); + this.defaultActionProvider.setValue(defaultProvider); + try { actionProviders .get(dataStoreActionProvider) diff --git a/app/src/main/java/io/xpipe/app/ext/ActionProvider.java b/app/src/main/java/io/xpipe/app/ext/ActionProvider.java index e84949fa..c20f79a2 100644 --- a/app/src/main/java/io/xpipe/app/ext/ActionProvider.java +++ b/app/src/main/java/io/xpipe/app/ext/ActionProvider.java @@ -68,11 +68,26 @@ public interface ActionProvider { default DataStoreCallSite getDataStoreCallSite() { return null; } + default DefaultDataStoreCallSite getDefaultDataStoreCallSite() { + return null; + } default DataSourceCallSite getDataSourceCallSite() { return null; } + + public static interface DefaultDataStoreCallSite { + + Action createAction(T store); + + Class getApplicableClass(); + + default boolean isApplicable(T o) { + return true; + } + } + public static interface DataStoreCallSite { enum ActiveType { @@ -85,10 +100,6 @@ public interface ActionProvider { Class getApplicableClass(); - default boolean isDefault() { - return false; - } - default boolean isMajor() { return false; } diff --git a/app/src/main/java/io/xpipe/app/fxcomps/impl/FileStoreChoiceComp.java b/app/src/main/java/io/xpipe/app/fxcomps/impl/FileStoreChoiceComp.java index 89679aa7..4a2bc3cc 100644 --- a/app/src/main/java/io/xpipe/app/fxcomps/impl/FileStoreChoiceComp.java +++ b/app/src/main/java/io/xpipe/app/fxcomps/impl/FileStoreChoiceComp.java @@ -33,12 +33,12 @@ public class FileStoreChoiceComp extends SimpleComp { @Override protected Region createSimple() { var fileProperty = new SimpleStringProperty( - selected.getValue() != null ? selected.getValue().getFile() : null); + selected.getValue() != null ? selected.getValue().getPath() : null); fileProperty.addListener((observable, oldValue, newValue) -> { setSelected(selected.getValue().getFileSystem(), newValue); }); selected.addListener((observable, oldValue, newValue) -> { - fileProperty.setValue(newValue.getFile()); + fileProperty.setValue(newValue.getPath()); }); var fileSystemChoiceComp = new FileSystemStoreChoiceComp(selected).grow(false, true).styleClass(Styles.LEFT_PILL); diff --git a/app/src/main/java/io/xpipe/app/fxcomps/impl/FileSystemStoreChoiceComp.java b/app/src/main/java/io/xpipe/app/fxcomps/impl/FileSystemStoreChoiceComp.java index e28f5d14..7a86644a 100644 --- a/app/src/main/java/io/xpipe/app/fxcomps/impl/FileSystemStoreChoiceComp.java +++ b/app/src/main/java/io/xpipe/app/fxcomps/impl/FileSystemStoreChoiceComp.java @@ -51,12 +51,12 @@ public class FileSystemStoreChoiceComp extends SimpleComp { fileSystemProperty.addListener((observable, oldValue, newValue) -> { selected.setValue(FileStore.builder() .fileSystem(newValue) - .file(selected.getValue() != null ? selected.getValue().getFile() : null) + .path(selected.getValue() != null ? selected.getValue().getPath() : null) .build()); }); selected.addListener((observable, oldValue, newValue) -> { - fileSystemProperty.setValue(newValue.getFileSystem()); + fileSystemProperty.setValue(newValue != null?newValue.getFileSystem():null); }); var comboBox = diff --git a/app/src/main/java/io/xpipe/app/issue/ErrorHandlerComp.java b/app/src/main/java/io/xpipe/app/issue/ErrorHandlerComp.java index 1bb0621e..7e00e0d4 100644 --- a/app/src/main/java/io/xpipe/app/issue/ErrorHandlerComp.java +++ b/app/src/main/java/io/xpipe/app/issue/ErrorHandlerComp.java @@ -7,8 +7,8 @@ import io.xpipe.app.core.AppI18n; import io.xpipe.app.core.AppWindowHelper; import io.xpipe.app.fxcomps.SimpleComp; import io.xpipe.app.fxcomps.augment.GrowAugment; -import io.xpipe.app.fxcomps.util.PlatformThread; import io.xpipe.app.util.JfxHelper; +import javafx.application.Platform; import javafx.geometry.Orientation; import javafx.scene.control.Label; import javafx.scene.control.Separator; @@ -20,6 +20,8 @@ import javafx.stage.Stage; import org.kordamp.ikonli.javafx.FontIcon; import java.util.List; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; import static atlantafx.base.theme.Styles.ACCENT; @@ -37,27 +39,67 @@ public class ErrorHandlerComp extends SimpleComp { } public static void showAndWait(ErrorEvent event) { - PlatformThread.runLaterIfNeededBlocking(() -> { - synchronized (showing) { - if (!showing.get()) { - showing.set(true); - var window = AppWindowHelper.sideWindow( - AppI18n.get("errorHandler"), w -> new ErrorHandlerComp(event, w), true, null); - window.setOnHidden(e -> { - showing.set(false); - }); + if (Platform.isFxApplicationThread()) { + showAndWaitWithPlatformThread(event); + } else { + showAndWaitWithOtherThread(event); + } + } - // An exception is thrown when show and wait is called - // within an animation or layout processing task - try { - window.showAndWait(); - } catch (Throwable t) { - window.show(); - t.printStackTrace(); - } + public static void showAndWaitWithPlatformThread(ErrorEvent event) { + var finishLatch = new CountDownLatch(1); + if (!showing.get()) { + showing.set(true); + var window = AppWindowHelper.sideWindow( + AppI18n.get("errorHandler"), w -> new ErrorHandlerComp(event, w), true, null); + window.setOnHidden(e -> { + showing.set(false); + finishLatch.countDown(); + }); + + // An exception is thrown when show and wait is called + // within an animation or layout processing task, so use show + try { + window.show(); + } catch (Throwable t) { + t.printStackTrace(); + } + } + } + + public static void showAndWaitWithOtherThread(ErrorEvent event) { + var showLatch = new CountDownLatch(1); + var finishLatch = new CountDownLatch(1); + Platform.runLater(() -> { + if (!showing.get()) { + showing.set(true); + var window = AppWindowHelper.sideWindow( + AppI18n.get("errorHandler"), w -> new ErrorHandlerComp(event, w), true, null); + window.setOnHidden(e -> { + showing.set(false); + finishLatch.countDown(); + }); + + // An exception is thrown when show and wait is called + // within an animation or layout processing task, so use show + try { + showLatch.countDown(); + window.show(); + } catch (Throwable t) { + t.printStackTrace(); } } }); + + try { + // Only wait for a certain time in case we somehow deadlocked the platform thread + if (showLatch.await(5, TimeUnit.SECONDS)) { + finishLatch.await(); + } else { + TrackEvent.error("Platform thread in error handler was timed out"); + } + } catch (InterruptedException ignored) { + } } private Region createActionComp(ErrorAction a) { diff --git a/app/src/main/java/io/xpipe/app/storage/DataStorage.java b/app/src/main/java/io/xpipe/app/storage/DataStorage.java index 5f1f4ea2..84d3184e 100644 --- a/app/src/main/java/io/xpipe/app/storage/DataStorage.java +++ b/app/src/main/java/io/xpipe/app/storage/DataStorage.java @@ -367,30 +367,32 @@ public abstract class DataStorage { }); } - private synchronized void propagateUpdate() { + private void propagateUpdate() { for (DataStoreEntry dataStoreEntry : getStoreEntries()) { dataStoreEntry.simpleRefresh(); } - for (var e : sourceEntries) { + for (var e : getSourceEntries()) { e.simpleRefresh(); } } - public synchronized void addStoreEntry(@NonNull DataStoreEntry e) { + public void addStoreEntry(@NonNull DataStoreEntry e) { if (getStoreEntryIfPresent(e.getName()).isPresent()) { throw new IllegalArgumentException("Store with name " + e.getName() + " already exists"); } - e.setDirectory(getStoresDir().resolve(e.getUuid().toString())); - this.storeEntries.add(e); + synchronized (this) { + e.setDirectory(getStoresDir().resolve(e.getUuid().toString())); + this.storeEntries.add(e); + } propagateUpdate(); save(); this.listeners.forEach(l -> l.onStoreAdd(e)); } - public synchronized void addStoreEntryIfNotPresent(@NonNull String name, DataStore store) { + public void addStoreEntryIfNotPresent(@NonNull String name, DataStore store) { if (getStoreEntryIfPresent(store).isPresent()) { return; } @@ -399,21 +401,22 @@ public abstract class DataStorage { addStoreEntry(e); } - public synchronized DataStoreEntry addStoreEntry(@NonNull String name, DataStore store) { + public DataStoreEntry addStoreEntry(@NonNull String name, DataStore store) { var e = DataStoreEntry.createNew(UUID.randomUUID(), createUniqueStoreEntryName(name), store); addStoreEntry(e); return e; } - public synchronized void deleteStoreEntry(@NonNull DataStoreEntry store) { + public void deleteStoreEntry(@NonNull DataStoreEntry store) { if (!store.getConfiguration().isDeletable()) { throw new UnsupportedOperationException(); } - this.storeEntries.remove(store); + synchronized (this) { + this.storeEntries.remove(store); + } propagateUpdate(); save(); - this.listeners.forEach(l -> l.onStoreRemove(store)); } @@ -421,7 +424,7 @@ public abstract class DataStorage { this.listeners.add(l); } - public synchronized DataSourceCollection createOrGetCollection(String name) { + public DataSourceCollection createOrGetCollection(String name) { return getCollectionForName(name).orElseGet(() -> { var col = DataSourceCollection.createNew(name); addCollection(col); @@ -460,8 +463,8 @@ public abstract class DataStorage { public abstract void load(); - public synchronized void refresh() { - storeEntries.forEach(entry -> { + public void refresh() { + getStoreEntries().forEach(entry -> { entry.simpleRefresh(); }); save(); diff --git a/core/src/main/java/io/xpipe/core/impl/FileStore.java b/core/src/main/java/io/xpipe/core/impl/FileStore.java index 6da25776..774e160b 100644 --- a/core/src/main/java/io/xpipe/core/impl/FileStore.java +++ b/core/src/main/java/io/xpipe/core/impl/FileStore.java @@ -26,11 +26,11 @@ import java.util.regex.Pattern; public class FileStore extends JacksonizedValue implements FilenameStore, StreamDataStore { FileSystemStore fileSystem; - String file; + String path; - public FileStore(FileSystemStore fileSystem, String file) { + public FileStore(FileSystemStore fileSystem, String path) { this.fileSystem = fileSystem; - this.file = file; + this.path = path; } public static FileStore local(Path p) { @@ -45,9 +45,9 @@ public class FileStore extends JacksonizedValue implements FilenameStore, Stream } public String getParent() { - var matcher = Pattern.compile("^(.+?)[^\\\\/]+$").matcher(file); + var matcher = Pattern.compile("^(.+?)[^\\\\/]+$").matcher(path); if (!matcher.matches()) { - throw new IllegalArgumentException("Unable to determine parent of " + file); + throw new IllegalArgumentException("Unable to determine parent of " + path); } return matcher.group(1); @@ -62,17 +62,17 @@ public class FileStore extends JacksonizedValue implements FilenameStore, Stream if (fileSystem == null) { throw new ValidationException("File system is missing"); } - if (file == null) { + if (path == null) { throw new ValidationException("File is missing"); } - if (!FileNames.isAbsolute(file)) { + if (!FileNames.isAbsolute(path)) { throw new ValidationException("File path is not absolute"); } } @Override public InputStream openInput() throws Exception { - return fileSystem.createFileSystem().open().openInput(file); + return fileSystem.createFileSystem().open().openInput(path); } @Override @@ -81,17 +81,17 @@ public class FileStore extends JacksonizedValue implements FilenameStore, Stream throw new IOException("Unable to create directory: " + getParent()); } - return fileSystem.createFileSystem().open().openOutput(file); + return fileSystem.createFileSystem().open().openOutput(path); } @Override public boolean canOpen() throws Exception { - return fileSystem.createFileSystem().open().exists(file); + return fileSystem.createFileSystem().open().exists(path); } @Override public String getFileName() { - var split = file.split("[\\\\/]"); + var split = path.split("[\\\\/]"); if (split.length == 0) { return ""; } diff --git a/ext/base/src/main/java/io/xpipe/ext/base/FileStoreProvider.java b/ext/base/src/main/java/io/xpipe/ext/base/FileStoreProvider.java index 29114468..f1cb0a38 100644 --- a/ext/base/src/main/java/io/xpipe/ext/base/FileStoreProvider.java +++ b/ext/base/src/main/java/io/xpipe/ext/base/FileStoreProvider.java @@ -39,10 +39,10 @@ public class FileStoreProvider implements DataStoreProvider { FileStore s = store.asNeeded(); var local = s.getFileSystem() instanceof LocalStore; if (local) { - return fileNameString(s.getFile(), length); + return fileNameString(s.getPath(), length); } else { var machineString = DataStoreFormatter.toName(s.getFileSystem(), length / 2); - var fileString = fileNameString(s.getFile(), length - machineString.length() - 3); + var fileString = fileNameString(s.getPath(), length - machineString.length() - 3); return String.format("%s @ %s", fileString, machineString); } } @@ -70,10 +70,10 @@ public class FileStoreProvider implements DataStoreProvider { public Dialog dialogForStore(DataStore store) { FileStore fileStore = store.asNeeded(); var machineQuery = DialogHelper.machineQuery(fileStore.getFileSystem()); - var fileQuery = DialogHelper.fileQuery(fileStore.getFile()); + var fileQuery = DialogHelper.fileQuery(fileStore.getPath()); return Dialog.chain(machineQuery, fileQuery).evaluateTo(() -> FileStore.builder() .fileSystem(machineQuery.getResult()) - .file(fileQuery.getResult()) + .path(fileQuery.getResult()) .build()); } diff --git a/ext/base/src/main/java/io/xpipe/ext/base/actions/AddStoreAction.java b/ext/base/src/main/java/io/xpipe/ext/base/actions/AddStoreAction.java index 2993731a..4441d837 100644 --- a/ext/base/src/main/java/io/xpipe/ext/base/actions/AddStoreAction.java +++ b/ext/base/src/main/java/io/xpipe/ext/base/actions/AddStoreAction.java @@ -38,12 +38,12 @@ public class AddStoreAction implements ActionProvider { return new LauncherCallSite() { @Override public String getId() { - return "add"; + return "addStore"; } @Override public Action createAction(List args) throws Exception { - var storeString = SecretValue.ofSecret(args.get(1)); + var storeString = SecretValue.ofSecret(args.get(0)); var store = JacksonMapper.parse(storeString.getSecretValue(), DataStore.class); return new Action(store); } diff --git a/ext/base/src/main/java/io/xpipe/ext/base/actions/EditStoreAction.java b/ext/base/src/main/java/io/xpipe/ext/base/actions/EditStoreAction.java index 45e55ddb..9423cfb0 100644 --- a/ext/base/src/main/java/io/xpipe/ext/base/actions/EditStoreAction.java +++ b/ext/base/src/main/java/io/xpipe/ext/base/actions/EditStoreAction.java @@ -27,6 +27,27 @@ public class EditStoreAction implements ActionProvider { } } + + @Override + public DefaultDataStoreCallSite getDefaultDataStoreCallSite() { + return new DefaultDataStoreCallSite() { + @Override + public boolean isApplicable(DataStore o) { + return DataStorage.get().getStoreEntryIfPresent(o).orElseThrow().getState().equals(DataStoreEntry.State.INCOMPLETE); + } + + @Override + public ActionProvider.Action createAction(DataStore store) { + return new Action(DataStorage.get().getStoreEntryIfPresent(store).orElseThrow()); + } + + @Override + public Class getApplicableClass() { + return DataStore.class; + } + }; + } + @Override public DataStoreCallSite getDataStoreCallSite() { return new DataStoreCallSite() { diff --git a/ext/base/src/main/java/io/xpipe/ext/base/actions/FileBrowseAction.java b/ext/base/src/main/java/io/xpipe/ext/base/actions/FileBrowseAction.java index ad627ab3..8ef10a43 100644 --- a/ext/base/src/main/java/io/xpipe/ext/base/actions/FileBrowseAction.java +++ b/ext/base/src/main/java/io/xpipe/ext/base/actions/FileBrowseAction.java @@ -25,7 +25,7 @@ public class FileBrowseAction implements ActionProvider { @Override public void execute() throws Exception { - DesktopHelper.browseFileInDirectory(Path.of(store.getFile())); + DesktopHelper.browseFileInDirectory(Path.of(store.getPath())); } } @@ -45,7 +45,7 @@ public class FileBrowseAction implements ActionProvider { @Override public boolean isApplicable(FileStore o) throws Exception { - return o.getFileSystem().equals(new LocalStore()) && Files.exists(Path.of(o.getFile())); + return o.getFileSystem().equals(new LocalStore()) && Files.exists(Path.of(o.getPath())); } @Override diff --git a/ext/base/src/main/java/io/xpipe/ext/base/actions/FileEditAction.java b/ext/base/src/main/java/io/xpipe/ext/base/actions/FileEditAction.java index f287d53e..2195a837 100644 --- a/ext/base/src/main/java/io/xpipe/ext/base/actions/FileEditAction.java +++ b/ext/base/src/main/java/io/xpipe/ext/base/actions/FileEditAction.java @@ -24,7 +24,7 @@ public class FileEditAction implements ActionProvider { @Override public void execute() throws Exception { if (store.getFileSystem().equals(new LocalStore())) { - FileOpener.openInTextEditor(store.getFile()); + FileOpener.openInTextEditor(store.getPath()); } } } diff --git a/ext/base/src/main/java/io/xpipe/ext/base/actions/ShareStoreAction.java b/ext/base/src/main/java/io/xpipe/ext/base/actions/ShareStoreAction.java index c134329b..cf220acb 100644 --- a/ext/base/src/main/java/io/xpipe/ext/base/actions/ShareStoreAction.java +++ b/ext/base/src/main/java/io/xpipe/ext/base/actions/ShareStoreAction.java @@ -26,7 +26,7 @@ public class ShareStoreAction implements ActionProvider { } public static String create(DataStore store) { - return "xpipe://add/store/" + SecretValue.encrypt(store.toString()).getEncryptedValue(); + return "xpipe://addStore/" + SecretValue.encrypt(store.toString()).getEncryptedValue(); } @Override diff --git a/version b/version index ad83b1b0..dc2b74e6 100644 --- a/version +++ b/version @@ -1 +1 @@ -0.5.6 \ No newline at end of file +0.5.7 \ No newline at end of file