mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-11-22 07:30:24 +00:00
Small fixes
This commit is contained in:
parent
a2238be4cd
commit
d6cccd1d5a
5 changed files with 42 additions and 16 deletions
|
@ -4,13 +4,19 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
|||
|
||||
public enum DataFlow {
|
||||
@JsonProperty("input")
|
||||
INPUT,
|
||||
INPUT("Input"),
|
||||
@JsonProperty("output")
|
||||
OUTPUT,
|
||||
OUTPUT("Output"),
|
||||
@JsonProperty("inputOutput")
|
||||
INPUT_OUTPUT,
|
||||
INPUT_OUTPUT("Input/Output"),
|
||||
@JsonProperty("transformer")
|
||||
TRANSFORMER;
|
||||
TRANSFORMER("Transformer");
|
||||
|
||||
private final String displayName;
|
||||
|
||||
DataFlow(String displayName) {
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
public boolean hasInput() {
|
||||
return this == INPUT || this == INPUT_OUTPUT;
|
||||
|
@ -19,4 +25,8 @@ public enum DataFlow {
|
|||
public boolean hasOutput() {
|
||||
return this == OUTPUT || this == INPUT_OUTPUT;
|
||||
}
|
||||
|
||||
public String getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ public class ShellTypes {
|
|||
public static StandardShellStore.ShellType[] getAvailable(ShellStore store) throws Exception {
|
||||
var o = store.prepareCommand(List.of(), List.of("echo", "$0"), null, StandardCharsets.US_ASCII)
|
||||
.executeAndReadStdoutOrThrow();
|
||||
if (!o.trim().equals("$0")) {
|
||||
if (o.trim().length() > 0 && !o.trim().equals("$0")) {
|
||||
return getLinuxShells();
|
||||
} else {
|
||||
return getWindowsShells();
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
package io.xpipe.extension;
|
||||
|
||||
import io.xpipe.core.dialog.Dialog;
|
||||
import io.xpipe.core.store.*;
|
||||
import io.xpipe.core.store.DataStore;
|
||||
import io.xpipe.core.store.MachineFileStore;
|
||||
import io.xpipe.core.store.ShellStore;
|
||||
import io.xpipe.core.store.StreamDataStore;
|
||||
import io.xpipe.core.util.JacksonizedValue;
|
||||
import javafx.beans.property.Property;
|
||||
|
||||
|
@ -90,8 +93,8 @@ public interface DataStoreProvider {
|
|||
|
||||
List<Class<?>> getStoreClasses();
|
||||
|
||||
default DataFlow[] getPossibleFlows() {
|
||||
return new DataFlow[] {DataFlow.INPUT};
|
||||
default boolean shouldShow() {
|
||||
return true;
|
||||
}
|
||||
|
||||
enum Category {
|
||||
|
|
|
@ -36,10 +36,23 @@ public class DataStoreProviders {
|
|||
}
|
||||
|
||||
return ALL.stream()
|
||||
.filter(d -> d.getPossibleNames().stream().anyMatch(s -> s.equalsIgnoreCase(name)))
|
||||
.filter(d -> d.getPossibleNames().stream()
|
||||
.anyMatch(s -> nameAlternatives(s).stream().anyMatch(s1 -> s1.equalsIgnoreCase(name)))
|
||||
|| d.getId().equalsIgnoreCase(name))
|
||||
.findAny();
|
||||
}
|
||||
|
||||
private static List<String> nameAlternatives(String name) {
|
||||
var split = List.of(name.split("_"));
|
||||
return List.of(
|
||||
String.join(" ", split),
|
||||
String.join("_", split),
|
||||
String.join("-", split),
|
||||
split.stream()
|
||||
.map(s -> s.equals(split.get(0)) ? s : s.substring(0, 1).toUpperCase() + s.substring(1))
|
||||
.collect(Collectors.joining()));
|
||||
}
|
||||
|
||||
public static Optional<Dialog> byString(String s) {
|
||||
if (ALL == null) {
|
||||
throw new IllegalStateException("Not initialized");
|
||||
|
|
|
@ -21,10 +21,10 @@ public class DialogHelper {
|
|||
}
|
||||
|
||||
public static Dialog machineQuery(DataStore store) {
|
||||
var storeName = XPipeDaemon.getInstance().getStoreName(store).orElse("local");
|
||||
var storeName = XPipeDaemon.getInstance().getStoreName(store).orElse("localhost");
|
||||
return Dialog.query("Machine", false, true, false, storeName, QueryConverter.STRING)
|
||||
.map((String name) -> {
|
||||
if (name.equals("local")) {
|
||||
if (name.equals("local") || name.equals("localhost")) {
|
||||
return new LocalStore();
|
||||
}
|
||||
|
||||
|
@ -42,14 +42,14 @@ public class DialogHelper {
|
|||
}
|
||||
|
||||
public static Dialog dataStoreFlowQuery(DataFlow flow, DataFlow[] available) {
|
||||
return Dialog.choice("flow", o -> o.toString(), true, flow, available);
|
||||
return Dialog.choice("Flow", (DataFlow o) -> o.getDisplayName(), true, flow, available);
|
||||
}
|
||||
|
||||
public static Dialog shellQuery(DataStore store) {
|
||||
var storeName = XPipeDaemon.getInstance().getStoreName(store).orElse("local");
|
||||
return Dialog.query("Shell", false, true, false, storeName, QueryConverter.STRING)
|
||||
public static Dialog shellQuery(String displayName, DataStore store) {
|
||||
var storeName = XPipeDaemon.getInstance().getStoreName(store).orElse("localhost");
|
||||
return Dialog.query(displayName, false, true, false, storeName, QueryConverter.STRING)
|
||||
.map((String name) -> {
|
||||
if (name.equals("local")) {
|
||||
if (name.equals("local") || name.equals("localhost")) {
|
||||
return new LocalStore();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue