diff --git a/core/src/main/java/io/xpipe/core/util/JacksonizedValue.java b/core/src/main/java/io/xpipe/core/util/JacksonizedValue.java index 8217420c2..d0c62b707 100644 --- a/core/src/main/java/io/xpipe/core/util/JacksonizedValue.java +++ b/core/src/main/java/io/xpipe/core/util/JacksonizedValue.java @@ -4,7 +4,7 @@ import com.fasterxml.jackson.annotation.JsonTypeInfo; import lombok.SneakyThrows; import lombok.experimental.SuperBuilder; -@SuperBuilder +@SuperBuilder(toBuilder = true) @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type") public class JacksonizedValue { diff --git a/ext/base/src/main/java/io/xpipe/ext/base/script/ScriptStore.java b/ext/base/src/main/java/io/xpipe/ext/base/script/ScriptStore.java index 41e3b8fff..904c3945c 100644 --- a/ext/base/src/main/java/io/xpipe/ext/base/script/ScriptStore.java +++ b/ext/base/src/main/java/io/xpipe/ext/base/script/ScriptStore.java @@ -21,7 +21,7 @@ import lombok.experimental.SuperBuilder; import java.util.*; -@SuperBuilder +@SuperBuilder(toBuilder = true) @Getter @AllArgsConstructor public abstract class ScriptStore extends JacksonizedValue implements DataStore, StatefulDataStore { diff --git a/ext/base/src/main/java/io/xpipe/ext/base/script/SimpleScriptQuickEditAction.java b/ext/base/src/main/java/io/xpipe/ext/base/script/SimpleScriptQuickEditAction.java new file mode 100644 index 000000000..a23d8065b --- /dev/null +++ b/ext/base/src/main/java/io/xpipe/ext/base/script/SimpleScriptQuickEditAction.java @@ -0,0 +1,45 @@ +package io.xpipe.ext.base.script; + +import io.xpipe.app.ext.ActionProvider; +import io.xpipe.app.storage.DataStoreEntryRef; +import io.xpipe.app.util.FileOpener; +import io.xpipe.core.process.OsType; +import lombok.Value; + +public class SimpleScriptQuickEditAction implements ActionProvider { + @Override + public DefaultDataStoreCallSite getDefaultDataStoreCallSite() { + return new DefaultDataStoreCallSite() { + @Override + public ActionProvider.Action createAction(DataStoreEntryRef store) { + return new Action(store); + } + + @Override + public Class getApplicableClass() { + return SimpleScriptStore.class; + } + }; + } + + @Value + static class Action implements ActionProvider.Action { + + DataStoreEntryRef ref; + + @Override + public void execute() { + var script = ref.getStore(); + var dialect = script.getMinimumDialect(); + var ext = dialect.getScriptFileEnding(); + var name = OsType.getLocal().makeFileSystemCompatible(ref.get().getName()); + FileOpener.openString( + name + "." + ext, + this, + script.getCommands(), + (s) -> { + ref.get().setStoreInternal(script.toBuilder().commands(s).build(), true); + }); + } + } +} diff --git a/ext/base/src/main/java/io/xpipe/ext/base/script/SimpleScriptStore.java b/ext/base/src/main/java/io/xpipe/ext/base/script/SimpleScriptStore.java index 5f63b046d..85ed87dfc 100644 --- a/ext/base/src/main/java/io/xpipe/ext/base/script/SimpleScriptStore.java +++ b/ext/base/src/main/java/io/xpipe/ext/base/script/SimpleScriptStore.java @@ -21,7 +21,7 @@ import java.util.Objects; import java.util.Optional; import java.util.stream.Collectors; -@SuperBuilder +@SuperBuilder(toBuilder = true) @Getter @Jacksonized @JsonTypeName("script") diff --git a/ext/base/src/main/java/module-info.java b/ext/base/src/main/java/module-info.java index 8e93f8cf2..43142af89 100644 --- a/ext/base/src/main/java/module-info.java +++ b/ext/base/src/main/java/module-info.java @@ -7,10 +7,7 @@ import io.xpipe.ext.base.browser.*; import io.xpipe.ext.base.desktop.DesktopApplicationStoreProvider; import io.xpipe.ext.base.desktop.DesktopCommandStoreProvider; import io.xpipe.ext.base.desktop.DesktopEnvironmentStoreProvider; -import io.xpipe.ext.base.script.RunScriptAction; -import io.xpipe.ext.base.script.ScriptDataStorageProvider; -import io.xpipe.ext.base.script.ScriptGroupStoreProvider; -import io.xpipe.ext.base.script.SimpleScriptStoreProvider; +import io.xpipe.ext.base.script.*; import io.xpipe.ext.base.service.*; import io.xpipe.ext.base.store.StorePauseAction; import io.xpipe.ext.base.store.StoreStartAction; @@ -65,6 +62,7 @@ open module io.xpipe.ext.base { JavapAction, JarAction; provides ActionProvider with + SimpleScriptQuickEditAction, StoreStopAction, StoreStartAction, StorePauseAction,