mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-11-21 15:10:23 +00:00
Add script quick edit action
This commit is contained in:
parent
ba9ead724f
commit
474606bcb3
5 changed files with 50 additions and 7 deletions
|
@ -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 {
|
||||
|
||||
|
|
|
@ -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<EnabledStoreState> {
|
||||
|
|
|
@ -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<SimpleScriptStore>() {
|
||||
@Override
|
||||
public ActionProvider.Action createAction(DataStoreEntryRef<SimpleScriptStore> store) {
|
||||
return new Action(store);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<SimpleScriptStore> getApplicableClass() {
|
||||
return SimpleScriptStore.class;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Value
|
||||
static class Action implements ActionProvider.Action {
|
||||
|
||||
DataStoreEntryRef<SimpleScriptStore> 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);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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")
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue