Small fixes

This commit is contained in:
Christopher Schnick committed 2022-10-19 05:20:17 +02:00
1 parent a2238be4cd
commit d6cccd1d5a
5 files changed
+42 -16

No files matched your search

@@ -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();
}