This commit is contained in:
Christopher Schnick 2022-12-19 00:31:50 +01:00
parent 6f912798af
commit 7be90d0666
15 changed files with 81 additions and 42 deletions

View file

@ -20,7 +20,6 @@ public class StoreAddExchange implements MessageExchange {
@Builder
@Value
public static class Request implements RequestMessage {
String input;
DataStore storeInput;
String type;

View file

@ -59,7 +59,7 @@ public class FileStore extends JacksonizedValue implements FilenameStore, Stream
@Override
public void checkComplete() throws Exception {
if (fileSystem == null) {
throw new IllegalStateException("Machine is missing");
throw new IllegalStateException("File system is missing");
}
if (file == null) {
throw new IllegalStateException("File is missing");

View file

@ -0,0 +1,66 @@
package io.xpipe.core.impl;
import io.xpipe.core.charsetter.StreamCharset;
import io.xpipe.core.data.node.DataStructureNodeAcceptor;
import io.xpipe.core.data.node.TupleNode;
import io.xpipe.core.data.type.TupleType;
import io.xpipe.core.source.TableReadConnection;
import io.xpipe.core.store.StreamDataStore;
import java.util.concurrent.atomic.AtomicReference;
public abstract class PeekTableStreamReadConnection extends StreamReadConnection implements TableReadConnection {
private TupleNode first;
private TupleType type;
public PeekTableStreamReadConnection(StreamDataStore store, StreamCharset charset) {
super(store, charset);
}
@Override
public void init() throws Exception {
super.init();
AtomicReference<TupleNode> read = new AtomicReference<>();
withRowsInternal(node -> {
read.set(node);
return false;
});
if (read.get() == null) {
return;
}
first = read.get().asTuple();
type = convertType(first);
}
protected TupleType convertType(TupleNode n) {
return n.determineDataType().asTuple();
}
@Override
public void close() throws Exception {
if (inputStream == null) {
throw new IllegalStateException("Not initialized");
}
inputStream.close();
}
@Override
public TupleType getDataType() {
return type;
}
@Override
public final void withRows(DataStructureNodeAcceptor<TupleNode> lineAcceptor) throws Exception {
if (first != null) {
lineAcceptor.accept(first);
first = null;
}
withRowsInternal(lineAcceptor);
}
protected abstract void withRowsInternal(DataStructureNodeAcceptor<TupleNode> lineAcceptor) throws Exception;
}

View file

@ -1,7 +1,8 @@
package io.xpipe.core.source;
package io.xpipe.core.impl;
import io.xpipe.core.charsetter.Charsetter;
import io.xpipe.core.charsetter.StreamCharset;
import io.xpipe.core.source.DataSourceReadConnection;
import io.xpipe.core.store.StreamDataStore;
import java.io.InputStream;

View file

@ -1,6 +1,7 @@
package io.xpipe.core.source;
package io.xpipe.core.impl;
import io.xpipe.core.charsetter.StreamCharset;
import io.xpipe.core.source.DataSourceConnection;
import io.xpipe.core.store.StreamDataStore;
import java.io.OutputStream;

View file

@ -1,7 +1,5 @@
package io.xpipe.core.impl;
import io.xpipe.core.source.StreamReadConnection;
import java.io.BufferedReader;
import java.util.stream.Stream;

View file

@ -1,7 +1,5 @@
package io.xpipe.core.impl;
import io.xpipe.core.source.StreamWriteConnection;
public class TextWriteConnection extends StreamWriteConnection implements io.xpipe.core.source.TextWriteConnection {
private final TextSource source;

View file

@ -2,7 +2,6 @@ package io.xpipe.core.impl;
import io.xpipe.core.data.generic.GenericDataStreamParser;
import io.xpipe.core.data.node.DataStructureNode;
import io.xpipe.core.source.StreamReadConnection;
import io.xpipe.core.source.StructureReadConnection;
public class XpbsReadConnection extends StreamReadConnection implements StructureReadConnection {

View file

@ -2,7 +2,6 @@ package io.xpipe.core.impl;
import io.xpipe.core.data.generic.GenericDataStreamWriter;
import io.xpipe.core.data.node.DataStructureNode;
import io.xpipe.core.source.StreamWriteConnection;
import io.xpipe.core.source.StructureWriteConnection;
public class XpbsWriteConnection extends StreamWriteConnection implements StructureWriteConnection {

View file

@ -7,7 +7,6 @@ import io.xpipe.core.data.node.TupleNode;
import io.xpipe.core.data.type.TupleType;
import io.xpipe.core.data.typed.TypedDataStreamParser;
import io.xpipe.core.data.typed.TypedDataStructureNodeReader;
import io.xpipe.core.source.StreamReadConnection;
import io.xpipe.core.source.TableReadConnection;
import io.xpipe.core.store.StreamDataStore;
import io.xpipe.core.util.JacksonMapper;

View file

@ -7,7 +7,6 @@ import io.xpipe.core.data.node.DataStructureNodeAcceptor;
import io.xpipe.core.data.node.TupleNode;
import io.xpipe.core.data.type.TupleType;
import io.xpipe.core.data.typed.TypedDataStreamWriter;
import io.xpipe.core.source.StreamWriteConnection;
import io.xpipe.core.source.TableMapping;
import io.xpipe.core.util.JacksonMapper;
import lombok.Getter;

View file

@ -76,8 +76,6 @@ public interface DataStoreProvider {
return getModuleName() + ":" + getId() + "_icon.png";
}
DataStore storeForString(String s);
default Dialog dialogForStore(DataStore store) {
return null;
}

View file

@ -1,10 +1,12 @@
package io.xpipe.extension;
import io.xpipe.core.dialog.Dialog;
import io.xpipe.core.store.DataStore;
import io.xpipe.extension.event.ErrorEvent;
import java.util.*;
import java.util.Comparator;
import java.util.List;
import java.util.Optional;
import java.util.ServiceLoader;
import java.util.stream.Collectors;
public class DataStoreProviders {
@ -53,24 +55,6 @@ public class DataStoreProviders {
.collect(Collectors.joining()));
}
public static Optional<Dialog> byString(String s) {
if (ALL == null) {
throw new IllegalStateException("Not initialized");
}
return ALL.stream()
.map(d -> {
var store = d.storeForString(s);
if (store != null) {
return d.dialogForStore(store);
} else {
return null;
}
})
.filter(Objects::nonNull)
.findAny();
}
@SuppressWarnings("unchecked")
public static <T extends DataStoreProvider> T byStore(DataStore store) {
return (T) byStoreClass(store.getClass()).orElseThrow();

View file

@ -1,6 +1,5 @@
package io.xpipe.extension.fxcomps.impl;
import io.xpipe.core.impl.LocalStore;
import io.xpipe.core.store.ShellStore;
import io.xpipe.extension.DataStoreProviders;
import io.xpipe.extension.I18n;
@ -17,7 +16,6 @@ import javafx.scene.layout.Region;
import lombok.AllArgsConstructor;
import java.util.function.Predicate;
import java.util.stream.Stream;
/*
TODO: Integrate store validation more into this comp.
@ -39,7 +37,7 @@ public class ShellStoreChoiceComp<T extends ShellStore> extends SimpleComp {
.filter(e -> e.equals(s))
.findAny()
.flatMap(store -> XPipeDaemon.getInstance().getStoreName(store))
.orElse(I18n.get("localMachine"));
.orElse("?");
return new Label(name, imgView);
}
@ -57,7 +55,7 @@ public class ShellStoreChoiceComp<T extends ShellStore> extends SimpleComp {
.filter(e -> e.equals(n))
.findAny()
.flatMap(store -> XPipeDaemon.getInstance().getStoreName(store))
.orElse(I18n.get("localMachine"));
.orElse("?");
ErrorEvent.fromMessage(I18n.get("extension.namedHostNotActive", name))
.reportable(false)
.handle();
@ -77,12 +75,10 @@ public class ShellStoreChoiceComp<T extends ShellStore> extends SimpleComp {
return true;
});
var available = Stream.concat(
Stream.of(new LocalStore()),
XPipeDaemon.getInstance().getNamedStores().stream()
var available = XPipeDaemon.getInstance().getNamedStores().stream()
.filter(s -> s != self)
.filter(s -> storeClass.isAssignableFrom(s.getClass()) && applicableCheck.test((T) s))
.map(s -> (ShellStore) s))
.map(s -> (ShellStore) s)
.toList();
available.forEach(s -> comboBox.add((T) s));
ComboBox<Node> cb = comboBox.build();

View file

@ -5,6 +5,8 @@ tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8'
options.compilerArgs << "-Xlint:unchecked"
options.compilerArgs << "--enable-preview"
// These settings are explicitly specified as they can cause problems with annotation processors
options.compilerArgs << "-implicit:none"
options.incremental = false
}