mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-11-22 07:30:24 +00:00
Fixes
This commit is contained in:
parent
bae68e7ea8
commit
e5c1ebed1d
7 changed files with 38 additions and 24 deletions
|
@ -155,7 +155,7 @@ public interface ExternalTerminalType extends PrefsChoiceValue {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FailableFunction<LaunchConfiguration, String, Exception> remoteLaunchCommand() {
|
public FailableFunction<LaunchConfiguration, String, Exception> remoteLaunchCommand(ShellDialect systemDialect) {
|
||||||
return launchConfiguration -> {
|
return launchConfiguration -> {
|
||||||
var toExecute = CommandBuilder.of()
|
var toExecute = CommandBuilder.of()
|
||||||
.add(executable, "-v", "--title")
|
.add(executable, "-v", "--title")
|
||||||
|
@ -566,7 +566,7 @@ public interface ExternalTerminalType extends PrefsChoiceValue {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FailableFunction<LaunchConfiguration, String, Exception> remoteLaunchCommand() {
|
public FailableFunction<LaunchConfiguration, String, Exception> remoteLaunchCommand(ShellDialect systemDialect) {
|
||||||
return launchConfiguration -> {
|
return launchConfiguration -> {
|
||||||
var toExecute = CommandBuilder.of()
|
var toExecute = CommandBuilder.of()
|
||||||
.add("open", "-a")
|
.add("open", "-a")
|
||||||
|
@ -628,7 +628,7 @@ public interface ExternalTerminalType extends PrefsChoiceValue {
|
||||||
all.addAll(MACOS_TERMINALS);
|
all.addAll(MACOS_TERMINALS);
|
||||||
}
|
}
|
||||||
if (remote) {
|
if (remote) {
|
||||||
all.removeIf(externalTerminalType -> externalTerminalType.remoteLaunchCommand() == null);
|
all.removeIf(externalTerminalType -> externalTerminalType.remoteLaunchCommand(null) == null);
|
||||||
}
|
}
|
||||||
// Prefer recommended
|
// Prefer recommended
|
||||||
all.sort(Comparator.comparingInt(o -> (o.isRecommended() ? -1 : 0)));
|
all.sort(Comparator.comparingInt(o -> (o.isRecommended() ? -1 : 0)));
|
||||||
|
@ -672,7 +672,7 @@ public interface ExternalTerminalType extends PrefsChoiceValue {
|
||||||
|
|
||||||
default void launch(LaunchConfiguration configuration) throws Exception {}
|
default void launch(LaunchConfiguration configuration) throws Exception {}
|
||||||
|
|
||||||
default FailableFunction<LaunchConfiguration, String, Exception> remoteLaunchCommand() {
|
default FailableFunction<LaunchConfiguration, String, Exception> remoteLaunchCommand(ShellDialect systemDialect) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -714,12 +714,6 @@ public interface ExternalTerminalType extends PrefsChoiceValue {
|
||||||
var open = scriptDialect.getOpenScriptCommand(scriptFile.toString());
|
var open = scriptDialect.getOpenScriptCommand(scriptFile.toString());
|
||||||
return open;
|
return open;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CommandBuilder appendDialectLaunchCommand(CommandBuilder b) {
|
|
||||||
var open = getDialectLaunchCommand();
|
|
||||||
b.add(open);
|
|
||||||
return b;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class MacOsType extends ExternalApplicationType.MacApplication implements ExternalTerminalType {
|
abstract class MacOsType extends ExternalApplicationType.MacApplication implements ExternalTerminalType {
|
||||||
|
@ -751,12 +745,12 @@ public interface ExternalTerminalType extends PrefsChoiceValue {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FailableFunction<LaunchConfiguration, String, Exception> remoteLaunchCommand() {
|
public FailableFunction<LaunchConfiguration, String, Exception> remoteLaunchCommand(ShellDialect systemDialect) {
|
||||||
return launchConfiguration -> {
|
return launchConfiguration -> {
|
||||||
var args = toCommand(launchConfiguration);
|
var args = toCommand(launchConfiguration);
|
||||||
args.add(0, executable);
|
args.add(0, executable);
|
||||||
if (explicityAsync) {
|
if (explicityAsync) {
|
||||||
args = launchConfiguration.getScriptDialect().launchAsnyc(args);
|
args = systemDialect.launchAsnyc(args);
|
||||||
}
|
}
|
||||||
return args.buildSimple();
|
return args.buildSimple();
|
||||||
};
|
};
|
||||||
|
|
|
@ -37,7 +37,7 @@ public class DataStoreFormatter {
|
||||||
return formattedOsName(s.getOsName());
|
return formattedOsName(s.getOsName());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s.getShellDialect().equals(ShellDialects.UNSUPPORTED)) {
|
if (s.getShellDialect().equals(ShellDialects.NO_INTERACTION)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ public class ShellDialects {
|
||||||
public static ShellDialect CSH;
|
public static ShellDialect CSH;
|
||||||
public static ShellDialect FISH;
|
public static ShellDialect FISH;
|
||||||
|
|
||||||
public static ShellDialect UNSUPPORTED;
|
public static ShellDialect NO_INTERACTION;
|
||||||
public static ShellDialect CISCO;
|
public static ShellDialect CISCO;
|
||||||
public static ShellDialect MIKROTIK;
|
public static ShellDialect MIKROTIK;
|
||||||
public static ShellDialect RBASH;
|
public static ShellDialect RBASH;
|
||||||
|
@ -74,7 +74,7 @@ public class ShellDialects {
|
||||||
CSH = byId("csh");
|
CSH = byId("csh");
|
||||||
ASH = byId("ash");
|
ASH = byId("ash");
|
||||||
SH = byId("sh");
|
SH = byId("sh");
|
||||||
UNSUPPORTED = byId("unsupported");
|
NO_INTERACTION = byId("unsupported");
|
||||||
CISCO = byId("cisco");
|
CISCO = byId("cisco");
|
||||||
MIKROTIK = byId("mikrotik");
|
MIKROTIK = byId("mikrotik");
|
||||||
RBASH = byId("rbash");
|
RBASH = byId("rbash");
|
||||||
|
|
|
@ -96,7 +96,7 @@ public class CoreJacksonModule extends SimpleModule {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ShellDialect deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
|
public ShellDialect deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
|
||||||
var tree = JacksonMapper.getDefault().readTree(p);
|
JsonNode tree = JacksonMapper.getDefault().readTree(p);
|
||||||
if (tree.isObject()) {
|
if (tree.isObject()) {
|
||||||
var t = (JsonNode) tree.get("type");
|
var t = (JsonNode) tree.get("type");
|
||||||
if (t == null) {
|
if (t == null) {
|
||||||
|
@ -105,7 +105,7 @@ public class CoreJacksonModule extends SimpleModule {
|
||||||
return ShellDialects.byNameIfPresent(t.asText()).orElse(null);
|
return ShellDialects.byNameIfPresent(t.asText()).orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ShellDialects.byNameIfPresent(p.getValueAsString()).orElse(null);
|
return ShellDialects.byNameIfPresent(tree.asText()).orElse(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,11 +6,11 @@ import io.xpipe.app.core.AppLayoutModel;
|
||||||
import io.xpipe.app.ext.ActionProvider;
|
import io.xpipe.app.ext.ActionProvider;
|
||||||
import io.xpipe.app.storage.DataStoreEntry;
|
import io.xpipe.app.storage.DataStoreEntry;
|
||||||
import io.xpipe.app.storage.DataStoreEntryRef;
|
import io.xpipe.app.storage.DataStoreEntryRef;
|
||||||
|
import io.xpipe.core.process.ShellDialects;
|
||||||
|
import io.xpipe.core.process.ShellStoreState;
|
||||||
import io.xpipe.core.store.ShellStore;
|
import io.xpipe.core.store.ShellStore;
|
||||||
|
|
||||||
import javafx.beans.property.SimpleBooleanProperty;
|
import javafx.beans.property.SimpleBooleanProperty;
|
||||||
import javafx.beans.value.ObservableValue;
|
import javafx.beans.value.ObservableValue;
|
||||||
|
|
||||||
import lombok.Value;
|
import lombok.Value;
|
||||||
|
|
||||||
public class BrowseStoreAction implements ActionProvider {
|
public class BrowseStoreAction implements ActionProvider {
|
||||||
|
@ -19,6 +19,16 @@ public class BrowseStoreAction implements ActionProvider {
|
||||||
public DataStoreCallSite<?> getDataStoreCallSite() {
|
public DataStoreCallSite<?> getDataStoreCallSite() {
|
||||||
return new DataStoreCallSite<ShellStore>() {
|
return new DataStoreCallSite<ShellStore>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isApplicable(DataStoreEntryRef<ShellStore> o) {
|
||||||
|
var state = o.get().getStorePersistentState();
|
||||||
|
if (state instanceof ShellStoreState shellStoreState) {
|
||||||
|
return shellStoreState.getShellDialect() != ShellDialects.NO_INTERACTION;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ActionProvider.Action createAction(DataStoreEntryRef<ShellStore> store) {
|
public ActionProvider.Action createAction(DataStoreEntryRef<ShellStore> store) {
|
||||||
return new Action(store.get());
|
return new Action(store.get());
|
||||||
|
|
|
@ -5,6 +5,8 @@ import io.xpipe.app.ext.ActionProvider;
|
||||||
import io.xpipe.app.storage.DataStoreEntry;
|
import io.xpipe.app.storage.DataStoreEntry;
|
||||||
import io.xpipe.app.storage.DataStoreEntryRef;
|
import io.xpipe.app.storage.DataStoreEntryRef;
|
||||||
import io.xpipe.app.util.ScanAlert;
|
import io.xpipe.app.util.ScanAlert;
|
||||||
|
import io.xpipe.core.process.ShellDialects;
|
||||||
|
import io.xpipe.core.process.ShellStoreState;
|
||||||
import io.xpipe.core.store.ShellStore;
|
import io.xpipe.core.store.ShellStore;
|
||||||
|
|
||||||
import javafx.beans.value.ObservableValue;
|
import javafx.beans.value.ObservableValue;
|
||||||
|
@ -34,7 +36,16 @@ public class ScanAction implements ActionProvider {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isApplicable(DataStoreEntryRef<ShellStore> o) {
|
public boolean isApplicable(DataStoreEntryRef<ShellStore> o) {
|
||||||
return o.get().getProvider().canHaveSubShells();
|
if (!o.get().getProvider().canHaveSubShells()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var state = o.get().getStorePersistentState();
|
||||||
|
if (state instanceof ShellStoreState shellStoreState) {
|
||||||
|
return shellStoreState.getShellDialect() != ShellDialects.NO_INTERACTION;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -89,17 +89,16 @@ public class DesktopEnvironmentStore extends JacksonizedValue
|
||||||
}
|
}
|
||||||
|
|
||||||
public void runDesktopTerminal(String name, String script) throws Exception {
|
public void runDesktopTerminal(String name, String script) throws Exception {
|
||||||
var launchCommand = terminal.remoteLaunchCommand();
|
var launchCommand = terminal.remoteLaunchCommand(base.getStore().getUsedDialect());
|
||||||
var toExecute = (script != null
|
var toExecute = (script != null
|
||||||
? getMergedInitCommands(
|
? getMergedInitCommands(
|
||||||
script + "\n" + dialect.getPauseCommand() + "\n" + dialect.getNormalExitCommand())
|
script + "\n" + dialect.getPauseCommand() + "\n" + dialect.getNormalExitCommand())
|
||||||
: getMergedInitCommands(null));
|
: getMergedInitCommands(null));
|
||||||
var scriptFile = base.getStore().createScript(dialect, toExecute);
|
var scriptFile = base.getStore().createScript(dialect, toExecute);
|
||||||
var launchScriptFile = base.getStore()
|
var launchScriptFile = base.getStore()
|
||||||
.createScript(
|
.createScript(dialect, dialect.prepareTerminalInitFileOpenCommand(dialect, null, scriptFile.toString()));
|
||||||
dialect, dialect.prepareTerminalInitFileOpenCommand(dialect, null, scriptFile.toString()));
|
|
||||||
var launchConfig =
|
var launchConfig =
|
||||||
new ExternalTerminalType.LaunchConfiguration(null, name, name, launchScriptFile, getUsedDialect());
|
new ExternalTerminalType.LaunchConfiguration(null, name, name, launchScriptFile, dialect);
|
||||||
base.getStore().runDesktopScript(name, launchCommand.apply(launchConfig));
|
base.getStore().runDesktopScript(name, launchCommand.apply(launchConfig));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue