mirror of
https://github.com/xpipe-io/xpipe.git
synced 2026-08-24 10:16:40 +00:00
Rework launchable stores
This commit is contained in:
@@ -2,19 +2,10 @@ 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.TerminalLauncher;
|
||||
import io.xpipe.core.store.DataStore;
|
||||
import io.xpipe.core.store.LaunchableStore;
|
||||
import io.xpipe.core.store.ShellStore;
|
||||
import io.xpipe.ext.base.script.ScriptStore;
|
||||
|
||||
import javafx.beans.value.ObservableValue;
|
||||
|
||||
import lombok.Value;
|
||||
|
||||
public class LaunchStoreAction implements ActionProvider {
|
||||
|
||||
@Override
|
||||
@@ -33,7 +24,7 @@ public class LaunchStoreAction implements ActionProvider {
|
||||
|
||||
@Override
|
||||
public ActionProvider.Action createAction(DataStoreEntryRef<DataStore> store) {
|
||||
return new Action(store.get());
|
||||
return store.get().getProvider().launchAction(store.get());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -44,8 +35,7 @@ public class LaunchStoreAction implements ActionProvider {
|
||||
@Override
|
||||
public boolean isApplicable(DataStoreEntryRef<DataStore> o) {
|
||||
return o.get().getValidity().isUsable()
|
||||
&& (o.getStore() instanceof LaunchableStore
|
||||
|| o.get().getProvider().launchAction(o.get()) != null);
|
||||
&& (o.get().getProvider().launchAction(o.get()) != null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -66,7 +56,7 @@ public class LaunchStoreAction implements ActionProvider {
|
||||
|
||||
@Override
|
||||
public ActionProvider.Action createAction(DataStoreEntryRef<DataStore> store) {
|
||||
return new Action(store.get());
|
||||
return store.get().getProvider().launchAction(store.get());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -77,33 +67,8 @@ public class LaunchStoreAction implements ActionProvider {
|
||||
@Override
|
||||
public boolean isApplicable(DataStoreEntryRef<DataStore> o) {
|
||||
return o.get().getValidity().isUsable()
|
||||
&& (o.getStore() instanceof LaunchableStore
|
||||
|| o.get().getProvider().launchAction(o.get()) != null);
|
||||
&& (o.get().getProvider().launchAction(o.get()) != null);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Value
|
||||
static class Action implements ActionProvider.Action {
|
||||
|
||||
DataStoreEntry entry;
|
||||
|
||||
@Override
|
||||
public void execute() throws Exception {
|
||||
var storeName = DataStorage.get().getStoreEntryDisplayName(entry);
|
||||
if (entry.getStore() instanceof ShellStore s) {
|
||||
TerminalLauncher.open(entry, storeName, null, ScriptStore.controlWithDefaultScripts(s.control()));
|
||||
return;
|
||||
}
|
||||
|
||||
if (entry.getStore() instanceof LaunchableStore s) {
|
||||
s.launch();
|
||||
return;
|
||||
}
|
||||
|
||||
if (entry.getProvider().launchAction(entry) != null) {
|
||||
entry.getProvider().launchAction(entry).execute();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +43,8 @@ public class XPipeUrlAction implements ActionProvider {
|
||||
if (!entry.getValidity().isUsable()) {
|
||||
return null;
|
||||
}
|
||||
return new LaunchStoreAction.Action(entry);
|
||||
var p = entry.getProvider();
|
||||
return p.launchAction(entry);
|
||||
}
|
||||
case "action" -> {
|
||||
var id = args.get(1);
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
package io.xpipe.ext.base.store;
|
||||
|
||||
import io.xpipe.app.util.TerminalLauncher;
|
||||
import io.xpipe.core.process.ProcessControl;
|
||||
import io.xpipe.core.store.LaunchableStore;
|
||||
import io.xpipe.ext.base.SelfReferentialStore;
|
||||
|
||||
public interface LaunchableTerminalStore extends SelfReferentialStore, LaunchableStore {
|
||||
|
||||
@Override
|
||||
default void launch() throws Exception {
|
||||
TerminalLauncher.open(getSelfEntry(), getSelfEntry().getName(), null, prepareLaunchCommand());
|
||||
}
|
||||
|
||||
ProcessControl prepareLaunchCommand() throws Exception;
|
||||
}
|
||||
Reference in New Issue
Block a user