- * The actual data is only queried when required and is not cached.
- * Therefore, the queried data is always up-to-date at the point of calling a method that queries the data.
- *
- * As soon a data source reference is created, the data source is locked
- * within XPipe to prevent concurrent modification and the problems that can arise from it.
- * By default, the lock is held until the calling program terminates and prevents
- * other applications from modifying the data source in any way.
- * To unlock the data source earlier, you can make use the {@link #unlock()} method.
- */
-public interface DataSource {
-
- /**
- * NOT YET IMPLEMENTED!
- *
- * Creates a new supplier data source that will be interpreted as the generated data source.
- * In case this program should be a data source generator, this method has to be called at
- * least once to register that it actually generates a data source.
- *
- * All content that is written to this data source until the generator program terminates is
- * will be available later on when the data source is used as a supplier later on.
- *
- * In case this method is called multiple times, the same data source is returned.
- *
- * @return the generator data source
- */
- static DataSource drain() {
- return null;
- }
-
- /**
- * NOT YET IMPLEMENTED!
- *
- * Creates a data source sink that will block with any read operations
- * until an external data producer routes the output into this sink.
- */
- static DataSource sink() {
- return null;
- }
-
- /**
- * Wrapper for {@link #get(DataSourceReference)}.
- *
- * @throws IllegalArgumentException if {@code id} is not a valid data source id
- */
- static DataSource getById(String id) {
- return get(DataSourceReference.id(id));
- }
-
- /**
- * Wrapper for {@link #get(DataSourceReference)} using the latest reference.
- */
- static DataSource getLatest() {
- return get(DataSourceReference.latest());
- }
-
- /**
- * Wrapper for {@link #get(DataSourceReference)} using a name reference.
- */
- static DataSource getByName(String name) {
- return get(DataSourceReference.name(name));
- }
-
- /**
- * Retrieves the data source for a given reference.
- *
- * @param ref the data source reference
- */
- static DataSource get(DataSourceReference ref) {
- return DataSourceImpl.get(ref);
- }
-
- /**
- * Releases the lock held by this program for this data source such
- * that other applications can modify the data source again.
- */
- static void unlock() {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Wrapper for {@link #create(DataStoreId, String, InputStream)} that creates an anonymous data source.
- */
- static DataSource createAnonymous(String type, Path path) {
- return create(null, type, path);
- }
-
- /**
- * Wrapper for {@link #create(DataStoreId, String, InputStream)}.
- */
- static DataSource create(DataStoreId id, String type, Path path) {
- try (var in = Files.newInputStream(path)) {
- return create(id, type, in);
- } catch (IOException e) {
- throw new UncheckedIOException(e);
- }
- }
-
- /**
- * Wrapper for {@link #create(DataStoreId, String, InputStream)} that creates an anonymous data source.
- */
- static DataSource createAnonymous(String type, URL url) {
- return create(null, type, url);
- }
-
- /**
- * Wrapper for {@link #create(DataStoreId, String, InputStream)}.
- */
- static DataSource create(DataStoreId id, String type, URL url) {
- try (var in = url.openStream()) {
- return create(id, type, in);
- } catch (IOException e) {
- throw new UncheckedIOException(e);
- }
- }
-
- /**
- * Wrapper for {@link #create(DataStoreId, String, InputStream)} that creates an anonymous data source.
- */
- static DataSource createAnonymous(String type, InputStream in) {
- return create(null, type, in);
- }
-
- /**
- * Creates a new data source from an input stream.
- *
- * @param id the data source id
- * @param type the data source type
- * @param in the input stream to read
- * @return a {@link DataSource} instances that can be used to access the underlying data
- */
- static DataSource create(DataStoreId id, String type, InputStream in) {
- return DataSourceImpl.create(id, type, in);
- }
-
- /**
- * Creates a new data source from an input stream.
- *
- * @param id the data source id
- * @return a {@link DataSource} instances that can be used to access the underlying data
- */
- static DataSource create(DataStoreId id, io.xpipe.core.source.DataSource> source) {
- return DataSourceImpl.create(id, source);
- }
-
- /**
- * Creates a new data source from an input stream.
- * 1
- *
- * @param id the data source id
- * @param type the data source type
- * @param in the data store to add
- * @return a {@link DataSource} instances that can be used to access the underlying data
- */
- static DataSource create(DataStoreId id, String type, DataStore in) {
- return DataSourceImpl.create(id, type, in);
- }
-
- void forwardTo(DataSource target);
-
- void appendTo(DataSource target);
-
- io.xpipe.core.source.DataSource> getInternalSource();
-
- /**
- * Returns the id of this data source.
- */
- DataStoreId getId();
-
- /**
- * Returns the type of this data source.
- */
- DataSourceType getType();
-
- DataSourceConfig getConfig();
-
- /**
- * Attempts to cast this object to a {@link DataTable}.
- *
- * @throws UnsupportedOperationException if the data source is not a table
- */
- default DataTable asTable() {
- throw new UnsupportedOperationException("Data source is not a table");
- }
-
- /**
- * Attempts to cast this object to a {@link DataStructure}.
- *
- * @throws UnsupportedOperationException if the data source is not a structure
- */
- default DataStructure asStructure() {
- throw new UnsupportedOperationException("Data source is not a structure");
- }
-
- /**
- * Attempts to cast this object to a {@link DataText}.
- *
- * @throws UnsupportedOperationException if the data source is not a text
- */
- default DataText asText() {
- throw new UnsupportedOperationException("Data source is not a text");
- }
-
- /**
- * Attempts to cast this object to a {@link DataRaw}.
- *
- * @throws UnsupportedOperationException if the data source is not raw
- */
- default DataRaw asRaw() {
- throw new UnsupportedOperationException("Data source is not raw");
- }
-}
diff --git a/api/src/main/java/io/xpipe/api/DataSourceConfig.java b/api/src/main/java/io/xpipe/api/DataSourceConfig.java
deleted file mode 100644
index 921488039..000000000
--- a/api/src/main/java/io/xpipe/api/DataSourceConfig.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package io.xpipe.api;
-
-import java.util.Map;
-
-/**
- * Represents the current configuration of a data source.
- */
-public final class DataSourceConfig {
-
- /**
- * The data source provider id.
- */
- private final String provider;
-
- /**
- * The set configuration parameters.
- */
- private final Map configInstance;
-
- public DataSourceConfig(String provider, Map configInstance) {
- this.provider = provider;
- this.configInstance = configInstance;
- }
-
- public String getProvider() {
- return provider;
- }
-
- public Map getConfig() {
- return configInstance;
- }
-}
diff --git a/api/src/main/java/io/xpipe/api/DataStructure.java b/api/src/main/java/io/xpipe/api/DataStructure.java
deleted file mode 100644
index 6f43874d3..000000000
--- a/api/src/main/java/io/xpipe/api/DataStructure.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package io.xpipe.api;
-
-import io.xpipe.core.data.node.DataStructureNode;
-
-public interface DataStructure extends DataSource {
- DataStructureNode read();
-}
diff --git a/api/src/main/java/io/xpipe/api/DataTable.java b/api/src/main/java/io/xpipe/api/DataTable.java
deleted file mode 100644
index 1fa4a761e..000000000
--- a/api/src/main/java/io/xpipe/api/DataTable.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package io.xpipe.api;
-
-import io.xpipe.core.data.node.ArrayNode;
-import io.xpipe.core.data.node.TupleNode;
-
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.stream.Stream;
-
-public interface DataTable extends Iterable, DataSource {
-
- Stream stream();
-
- ArrayNode readAll();
-
- ArrayNode read(int maxRows);
-
- default int countAndDiscard() {
- AtomicInteger count = new AtomicInteger();
- try (var stream = stream()) {
- stream.forEach(dataStructureNodes -> {
- count.getAndIncrement();
- });
- }
- return count.get();
- }
-}
diff --git a/api/src/main/java/io/xpipe/api/DataTableAccumulator.java b/api/src/main/java/io/xpipe/api/DataTableAccumulator.java
deleted file mode 100644
index 768037193..000000000
--- a/api/src/main/java/io/xpipe/api/DataTableAccumulator.java
+++ /dev/null
@@ -1,52 +0,0 @@
-package io.xpipe.api;
-
-import io.xpipe.api.impl.DataTableAccumulatorImpl;
-import io.xpipe.core.data.node.DataStructureNode;
-import io.xpipe.core.data.node.DataStructureNodeAcceptor;
-import io.xpipe.core.data.type.TupleType;
-import io.xpipe.core.source.DataStoreId;
-
-/**
- * An accumulator for table data.
- *
- * This class can be used to construct new table data sources by
- * accumulating the rows using {@link #add(DataStructureNode)} or {@link #acceptor()} and then calling
- * {@link #finish(DataStoreId)} to complete the construction process and create a new data source.
- */
-public interface DataTableAccumulator {
-
- static DataTableAccumulator create(TupleType type) {
- return new DataTableAccumulatorImpl(type);
- }
-
- /**
- * Wrapper for {@link #finish(DataStoreId)}.
- */
- default DataTable finish(String id) {
- return finish(DataStoreId.fromString(id));
- }
-
- /**
- * Finishes the construction process and returns the data source reference.
- *
- * @param id the data source id to assign
- */
- DataTable finish(DataStoreId id);
-
- /**
- * Adds a row to the table.
- *
- * @param row the row to add
- */
- void add(DataStructureNode row);
-
- /**
- * Creates a tuple acceptor that adds all accepted tuples to the table.
- */
- DataStructureNodeAcceptor acceptor();
-
- /**
- * Returns the current amount of rows added to the table.
- */
- int getCurrentRows();
-}
diff --git a/api/src/main/java/io/xpipe/api/DataText.java b/api/src/main/java/io/xpipe/api/DataText.java
deleted file mode 100644
index 864a34d97..000000000
--- a/api/src/main/java/io/xpipe/api/DataText.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package io.xpipe.api;
-
-import java.util.List;
-import java.util.stream.Stream;
-
-public interface DataText extends DataSource {
-
- List readAllLines();
-
- List readLines(int maxLines);
-
- Stream lines();
-
- String readAll();
-
- String read(int maxCharacters);
-}
diff --git a/api/src/main/java/io/xpipe/api/impl/DataRawImpl.java b/api/src/main/java/io/xpipe/api/impl/DataRawImpl.java
deleted file mode 100644
index 4f63432f1..000000000
--- a/api/src/main/java/io/xpipe/api/impl/DataRawImpl.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package io.xpipe.api.impl;
-
-import io.xpipe.api.DataRaw;
-import io.xpipe.api.DataSourceConfig;
-import io.xpipe.core.source.DataStoreId;
-import io.xpipe.core.source.DataSourceType;
-
-import java.io.InputStream;
-
-public class DataRawImpl extends DataSourceImpl implements DataRaw {
-
- public DataRawImpl(
- DataStoreId sourceId, DataSourceConfig sourceConfig, io.xpipe.core.source.DataSource> internalSource) {
- super(sourceId, sourceConfig, internalSource);
- }
-
- @Override
- public InputStream open() {
- return null;
- }
-
- @Override
- public byte[] readAll() {
- return new byte[0];
- }
-
- @Override
- public byte[] read(int maxBytes) {
- return new byte[0];
- }
-
- @Override
- public DataSourceType getType() {
- return DataSourceType.RAW;
- }
-
- @Override
- public DataRaw asRaw() {
- return this;
- }
-}
diff --git a/api/src/main/java/io/xpipe/api/impl/DataSourceImpl.java b/api/src/main/java/io/xpipe/api/impl/DataSourceImpl.java
deleted file mode 100644
index 82e4251a5..000000000
--- a/api/src/main/java/io/xpipe/api/impl/DataSourceImpl.java
+++ /dev/null
@@ -1,161 +0,0 @@
-package io.xpipe.api.impl;
-
-import io.xpipe.api.DataSource;
-import io.xpipe.api.DataSourceConfig;
-import io.xpipe.api.connector.XPipeApiConnection;
-import io.xpipe.beacon.exchange.*;
-import io.xpipe.core.source.DataStoreId;
-import io.xpipe.core.source.DataSourceReference;
-import io.xpipe.core.store.DataStore;
-import io.xpipe.core.store.StreamDataStore;
-
-import java.io.InputStream;
-
-public abstract class DataSourceImpl implements DataSource {
-
- private final DataStoreId sourceId;
- private final DataSourceConfig config;
- private final io.xpipe.core.source.DataSource> internalSource;
-
- public DataSourceImpl(
- DataStoreId sourceId, DataSourceConfig config, io.xpipe.core.source.DataSource> internalSource) {
- this.sourceId = sourceId;
- this.config = config;
- this.internalSource = internalSource;
- }
-
- public static DataSource get(DataSourceReference ds) {
- return XPipeApiConnection.execute(con -> {
- var req = QueryDataSourceExchange.Request.builder().ref(ds).build();
- QueryDataSourceExchange.Response res = con.performSimpleExchange(req);
- var config = new DataSourceConfig(res.getProvider(), res.getConfig());
- return switch (res.getType()) {
- case TABLE -> {
- yield new DataTableImpl(res.getId(), config, res.getInternalSource());
- }
- case STRUCTURE -> {
- yield new DataStructureImpl(res.getId(), config, res.getInternalSource());
- }
- case TEXT -> {
- yield new DataTextImpl(res.getId(), config, res.getInternalSource());
- }
- case RAW -> {
- yield new DataRawImpl(res.getId(), config, res.getInternalSource());
- }
- case COLLECTION -> throw new UnsupportedOperationException("Unimplemented case: " + res.getType());
- default -> throw new IllegalArgumentException("Unexpected value: " + res.getType());
- };
- });
- }
-
- public static DataSource create(DataStoreId id, io.xpipe.core.source.DataSource> source) {
- var startReq =
- AddSourceExchange.Request.builder().source(source).target(id).build();
- var returnedId = XPipeApiConnection.execute(con -> {
- AddSourceExchange.Response r = con.performSimpleExchange(startReq);
- return r.getId();
- });
-
- var ref = DataSourceReference.id(returnedId);
- return get(ref);
- }
-
- public static DataSource create(DataStoreId id, String type, DataStore store) {
- if (store instanceof StreamDataStore s && s.isContentExclusivelyAccessible()) {
- store = XPipeApiConnection.execute(con -> {
- var internal = con.createInternalStreamStore();
- var req = WriteStreamExchange.Request.builder()
- .name(internal.getUuid().toString())
- .build();
- con.performOutputExchange(req, out -> {
- try (InputStream inputStream = s.openInput()) {
- inputStream.transferTo(out);
- }
- });
- return internal;
- });
- }
-
- var startReq = ReadExchange.Request.builder()
- .provider(type)
- .store(store)
- .target(id)
- .configureAll(false)
- .build();
- var startRes = XPipeApiConnection.execute(con -> {
- return con.performSimpleExchange(startReq);
- });
-
- var configInstance = startRes.getConfig();
- XPipeApiConnection.finishDialog(configInstance);
-
- var ref = id != null ? DataSourceReference.id(id) : DataSourceReference.latest();
- return get(ref);
- }
-
- public static DataSource create(DataStoreId id, String type, InputStream in) {
- var store = XPipeApiConnection.execute(con -> {
- var internal = con.createInternalStreamStore();
- var req = WriteStreamExchange.Request.builder()
- .name(internal.getUuid().toString())
- .build();
- con.performOutputExchange(req, out -> {
- in.transferTo(out);
- });
- return internal;
- });
-
- var startReq = ReadExchange.Request.builder()
- .provider(type)
- .store(store)
- .target(id)
- .configureAll(false)
- .build();
- var startRes = XPipeApiConnection.execute(con -> {
- return con.performSimpleExchange(startReq);
- });
-
- var configInstance = startRes.getConfig();
- XPipeApiConnection.finishDialog(configInstance);
-
- var ref = id != null ? DataSourceReference.id(id) : DataSourceReference.latest();
- return get(ref);
- }
-
- @Override
- public void forwardTo(DataSource target) {
- XPipeApiConnection.execute(con -> {
- var req = ForwardExchange.Request.builder()
- .source(DataSourceReference.id(sourceId))
- .target(DataSourceReference.id(target.getId()))
- .build();
- ForwardExchange.Response res = con.performSimpleExchange(req);
- });
- }
-
- @Override
- public void appendTo(DataSource target) {
- XPipeApiConnection.execute(con -> {
- var req = ForwardExchange.Request.builder()
- .source(DataSourceReference.id(sourceId))
- .target(DataSourceReference.id(target.getId()))
- .append(true)
- .build();
- ForwardExchange.Response res = con.performSimpleExchange(req);
- });
- }
-
- public io.xpipe.core.source.DataSource> getInternalSource() {
- return internalSource;
- }
-
- @Override
- public DataStoreId getId() {
- return sourceId;
- }
-
- @Override
- public DataSourceConfig getConfig() {
- return config;
- }
-}
diff --git a/api/src/main/java/io/xpipe/api/impl/DataStructureImpl.java b/api/src/main/java/io/xpipe/api/impl/DataStructureImpl.java
deleted file mode 100644
index f1e2f8ca1..000000000
--- a/api/src/main/java/io/xpipe/api/impl/DataStructureImpl.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package io.xpipe.api.impl;
-
-import io.xpipe.api.DataSourceConfig;
-import io.xpipe.api.DataStructure;
-import io.xpipe.core.data.node.DataStructureNode;
-import io.xpipe.core.source.DataStoreId;
-import io.xpipe.core.source.DataSourceType;
-
-public class DataStructureImpl extends DataSourceImpl implements DataStructure {
-
- DataStructureImpl(
- DataStoreId sourceId, DataSourceConfig sourceConfig, io.xpipe.core.source.DataSource> internalSource) {
- super(sourceId, sourceConfig, internalSource);
- }
-
- @Override
- public DataSourceType getType() {
- return DataSourceType.STRUCTURE;
- }
-
- @Override
- public DataStructure asStructure() {
- return this;
- }
-
- @Override
- public DataStructureNode read() {
- return null;
- }
-}
diff --git a/api/src/main/java/io/xpipe/api/impl/DataTableAccumulatorImpl.java b/api/src/main/java/io/xpipe/api/impl/DataTableAccumulatorImpl.java
deleted file mode 100644
index cf89065d9..000000000
--- a/api/src/main/java/io/xpipe/api/impl/DataTableAccumulatorImpl.java
+++ /dev/null
@@ -1,115 +0,0 @@
-package io.xpipe.api.impl;
-
-import io.xpipe.api.DataSource;
-import io.xpipe.api.DataTable;
-import io.xpipe.api.DataTableAccumulator;
-import io.xpipe.api.connector.XPipeApiConnection;
-import io.xpipe.api.util.TypeDescriptor;
-import io.xpipe.beacon.BeaconException;
-import io.xpipe.beacon.exchange.ReadExchange;
-import io.xpipe.beacon.exchange.WriteStreamExchange;
-import io.xpipe.beacon.exchange.cli.StoreAddExchange;
-import io.xpipe.beacon.util.QuietDialogHandler;
-import io.xpipe.core.data.node.DataStructureNode;
-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.impl.InternalStreamStore;
-import io.xpipe.core.source.DataStoreId;
-import io.xpipe.core.source.DataSourceReference;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.nio.charset.StandardCharsets;
-
-public class DataTableAccumulatorImpl implements DataTableAccumulator {
-
- private final XPipeApiConnection connection;
- private final TupleType type;
- private int rows;
- private final InternalStreamStore store;
- private TupleType writtenDescriptor;
- private final OutputStream bodyOutput;
-
- public DataTableAccumulatorImpl(TupleType type) {
- this.type = type;
- connection = XPipeApiConnection.open();
-
- store = new InternalStreamStore();
- var addReq = StoreAddExchange.Request.builder()
- .storeInput(store)
- .name(store.getUuid().toString())
- .build();
- StoreAddExchange.Response addRes = connection.performSimpleExchange(addReq);
- QuietDialogHandler.handle(addRes.getConfig(), connection);
-
- connection.sendRequest(WriteStreamExchange.Request.builder()
- .name(store.getUuid().toString())
- .build());
- bodyOutput = connection.sendBody();
- }
-
- @Override
- public synchronized DataTable finish(DataStoreId id) {
- try {
- bodyOutput.close();
- } catch (IOException e) {
- throw new BeaconException(e);
- }
-
- WriteStreamExchange.Response res = connection.receiveResponse();
- connection.close();
-
- var req = ReadExchange.Request.builder()
- .target(id)
- .store(store)
- .provider("xpbt")
- .configureAll(false)
- .build();
- ReadExchange.Response response = XPipeApiConnection.execute(con -> {
- return con.performSimpleExchange(req);
- });
-
- var configInstance = response.getConfig();
- XPipeApiConnection.finishDialog(configInstance);
-
- return DataSource.get(DataSourceReference.id(id)).asTable();
- }
-
- private void writeDescriptor() {
- if (writtenDescriptor != null) {
- return;
- }
- writtenDescriptor = TupleType.tableType(type.getNames());
-
- connection.withOutputStream(out -> {
- out.write((TypeDescriptor.create(type.getNames())).getBytes(StandardCharsets.UTF_8));
- });
- }
-
- @Override
- public synchronized void add(DataStructureNode row) {
- TupleNode toUse = type.matches(row)
- ? row.asTuple()
- : type.convert(row).orElseThrow().asTuple();
- connection.withOutputStream(out -> {
- writeDescriptor();
- TypedDataStreamWriter.writeStructure(out, toUse, writtenDescriptor);
- rows++;
- });
- }
-
- @Override
- public synchronized DataStructureNodeAcceptor acceptor() {
- return node -> {
- add(node);
- return true;
- };
- }
-
- @Override
- public synchronized int getCurrentRows() {
- return rows;
- }
-}
diff --git a/api/src/main/java/io/xpipe/api/impl/DataTableImpl.java b/api/src/main/java/io/xpipe/api/impl/DataTableImpl.java
deleted file mode 100644
index 7b06e22f6..000000000
--- a/api/src/main/java/io/xpipe/api/impl/DataTableImpl.java
+++ /dev/null
@@ -1,61 +0,0 @@
-package io.xpipe.api.impl;
-
-import io.xpipe.api.DataSourceConfig;
-import io.xpipe.api.DataTable;
-import io.xpipe.core.data.node.ArrayNode;
-import io.xpipe.core.data.node.DataStructureNode;
-import io.xpipe.core.data.node.TupleNode;
-import io.xpipe.core.source.DataStoreId;
-import io.xpipe.core.source.DataSourceType;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.stream.Stream;
-
-public class DataTableImpl extends DataSourceImpl implements DataTable {
-
- DataTableImpl(DataStoreId id, DataSourceConfig sourceConfig, io.xpipe.core.source.DataSource> internalSource) {
- super(id, sourceConfig, internalSource);
- }
-
- @Override
- public DataTable asTable() {
- return this;
- }
-
- public Stream stream() {
- return Stream.of();
- }
-
- @Override
- public DataSourceType getType() {
- return DataSourceType.TABLE;
- }
-
- @Override
- public ArrayNode readAll() {
- return read(Integer.MAX_VALUE);
- }
-
- @Override
- public ArrayNode read(int maxRows) {
- List nodes = new ArrayList<>();
- return ArrayNode.of(nodes);
- }
-
- @Override
- public Iterator iterator() {
- return new Iterator<>() {
- @Override
- public boolean hasNext() {
- return false;
- }
-
- @Override
- public TupleNode next() {
- return null;
- }
- };
- }
-}
diff --git a/api/src/main/java/io/xpipe/api/impl/DataTextImpl.java b/api/src/main/java/io/xpipe/api/impl/DataTextImpl.java
deleted file mode 100644
index 19658e9ce..000000000
--- a/api/src/main/java/io/xpipe/api/impl/DataTextImpl.java
+++ /dev/null
@@ -1,66 +0,0 @@
-package io.xpipe.api.impl;
-
-import io.xpipe.api.DataSourceConfig;
-import io.xpipe.api.DataText;
-import io.xpipe.core.source.DataStoreId;
-import io.xpipe.core.source.DataSourceType;
-
-import java.util.List;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
-public class DataTextImpl extends DataSourceImpl implements DataText {
-
- DataTextImpl(
- DataStoreId sourceId, DataSourceConfig sourceConfig, io.xpipe.core.source.DataSource> internalSource) {
- super(sourceId, sourceConfig, internalSource);
- }
-
- @Override
- public DataSourceType getType() {
- return DataSourceType.TEXT;
- }
-
- @Override
- public DataText asText() {
- return this;
- }
-
- @Override
- public List readAllLines() {
- return readLines(Integer.MAX_VALUE);
- }
-
- @Override
- public List readLines(int maxLines) {
- try (Stream lines = lines()) {
- return lines.limit(maxLines).toList();
- }
- }
-
- @Override
- public Stream lines() {
- return Stream.of();
- }
-
- @Override
- public String readAll() {
- try (Stream lines = lines()) {
- return lines.collect(Collectors.joining("\n"));
- }
- }
-
- @Override
- public String read(int maxCharacters) {
- StringBuilder builder = new StringBuilder();
- lines().takeWhile(s -> {
- if (builder.length() > maxCharacters) {
- return false;
- }
-
- builder.append(s);
- return true;
- });
- return builder.toString();
- }
-}
diff --git a/api/src/test/java/io/xpipe/api/test/DataTableTest.java b/api/src/test/java/io/xpipe/api/test/DataTableTest.java
index 95ef63d3b..272c7b252 100644
--- a/api/src/test/java/io/xpipe/api/test/DataTableTest.java
+++ b/api/src/test/java/io/xpipe/api/test/DataTableTest.java
@@ -1,7 +1,7 @@
package io.xpipe.api.test;
import io.xpipe.api.DataSource;
-import io.xpipe.core.source.DataStoreId;
+import io.xpipe.core.store.DataStoreId;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
diff --git a/app/build.gradle b/app/build.gradle
index 9abeddd96..a979e3337 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -138,7 +138,7 @@ application {
run {
systemProperty 'io.xpipe.app.useVirtualThreads', 'false'
systemProperty 'io.xpipe.app.mode', 'gui'
- systemProperty 'io.xpipe.app.dataDir', "$projectDir/local_git2/"
+ systemProperty 'io.xpipe.app.dataDir', "$projectDir/local_git3/"
systemProperty 'io.xpipe.app.writeLogs', "true"
systemProperty 'io.xpipe.app.writeSysOut', "true"
systemProperty 'io.xpipe.app.developerMode', "true"
diff --git a/app/src/main/java/io/xpipe/app/browser/BrowserBookmarkList.java b/app/src/main/java/io/xpipe/app/browser/BrowserBookmarkList.java
index 2f3a20d6d..788fa2e81 100644
--- a/app/src/main/java/io/xpipe/app/browser/BrowserBookmarkList.java
+++ b/app/src/main/java/io/xpipe/app/browser/BrowserBookmarkList.java
@@ -12,11 +12,10 @@ import io.xpipe.app.fxcomps.impl.HorizontalComp;
import io.xpipe.app.fxcomps.util.PlatformThread;
import io.xpipe.app.util.BooleanScope;
import io.xpipe.app.util.DataStoreCategoryChoiceComp;
+import io.xpipe.app.util.FixedHierarchyStore;
import io.xpipe.app.util.ThreadHelper;
import io.xpipe.core.store.DataStore;
-import io.xpipe.core.store.FixedHierarchyStore;
import io.xpipe.core.store.ShellStore;
-import javafx.application.Platform;
import javafx.beans.binding.Bindings;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.SimpleBooleanProperty;
@@ -53,7 +52,7 @@ final class BrowserBookmarkList extends SimpleComp {
Predicate applicable = storeEntryWrapper -> {
return (storeEntryWrapper.getEntry().getStore() instanceof ShellStore
|| storeEntryWrapper.getEntry().getStore() instanceof FixedHierarchyStore)
- && storeEntryWrapper.getEntry().getState().isUsable();
+ && storeEntryWrapper.getEntry().getValidity().isUsable();
};
var section = StoreSectionMiniComp.createList(
StoreSection.createTopLevel(
@@ -68,7 +67,7 @@ final class BrowserBookmarkList extends SimpleComp {
.pseudoClassStateChanged(
SELECTED,
newValue != null
- && newValue.getStore()
+ && newValue.getEntry()
.equals(s.getWrapper()
.getEntry()
.getStore()));
@@ -77,13 +76,10 @@ final class BrowserBookmarkList extends SimpleComp {
ThreadHelper.runFailableAsync(() -> {
var entry = s.getWrapper().getEntry();
if (entry.getStore() instanceof ShellStore fileSystem) {
- BooleanScope.execute(busy, () -> {
- s.getWrapper().refreshIfNeeded();
- });
- model.openFileSystemAsync(null, fileSystem, null, busy);
+ model.openFileSystemAsync(entry.ref(), null, busy);
} else if (entry.getStore() instanceof FixedHierarchyStore) {
BooleanScope.execute(busy, () -> {
- s.getWrapper().refreshWithChildren();
+ s.getWrapper().refreshChildren();
});
}
});
@@ -125,7 +121,7 @@ final class BrowserBookmarkList extends SimpleComp {
return;
}
- Platform.runLater(() -> model.openExistingFileSystemIfPresent(null, store.asNeeded()));
+ // Platform.runLater(() -> model.openExistingFileSystemIfPresent(store.asNeeded()));
}
};
DROP_TIMER.schedule(activeTask, 500);
diff --git a/app/src/main/java/io/xpipe/app/browser/BrowserBreadcrumbBar.java b/app/src/main/java/io/xpipe/app/browser/BrowserBreadcrumbBar.java
index 8afc08ecc..5acbcc856 100644
--- a/app/src/main/java/io/xpipe/app/browser/BrowserBreadcrumbBar.java
+++ b/app/src/main/java/io/xpipe/app/browser/BrowserBreadcrumbBar.java
@@ -4,7 +4,7 @@ import atlantafx.base.controls.Breadcrumbs;
import io.xpipe.app.fxcomps.SimpleComp;
import io.xpipe.app.fxcomps.util.PlatformThread;
import io.xpipe.app.fxcomps.util.SimpleChangeListener;
-import io.xpipe.core.impl.FileNames;
+import io.xpipe.core.store.FileNames;
import javafx.scene.Node;
import javafx.scene.control.Button;
import javafx.scene.control.ButtonBase;
diff --git a/app/src/main/java/io/xpipe/app/browser/BrowserComp.java b/app/src/main/java/io/xpipe/app/browser/BrowserComp.java
index d940b836e..0cb75c85a 100644
--- a/app/src/main/java/io/xpipe/app/browser/BrowserComp.java
+++ b/app/src/main/java/io/xpipe/app/browser/BrowserComp.java
@@ -7,7 +7,6 @@ import io.xpipe.app.browser.icon.DirectoryType;
import io.xpipe.app.browser.icon.FileIconManager;
import io.xpipe.app.browser.icon.FileType;
import io.xpipe.app.comp.base.MultiContentComp;
-import io.xpipe.app.ext.DataStoreProviders;
import io.xpipe.app.fxcomps.Comp;
import io.xpipe.app.fxcomps.SimpleComp;
import io.xpipe.app.fxcomps.impl.FancyTooltipAugment;
@@ -252,7 +251,7 @@ public class BrowserComp extends SimpleComp {
.bind(Bindings.createDoubleBinding(
() -> model.getBusy().get() ? -1d : 0, PlatformThread.sync(model.getBusy())));
- var image = DataStoreProviders.byStore(model.getStore()).getDisplayIconFileName(model.getStore());
+ var image = model.getEntry().get().getProvider().getDisplayIconFileName(model.getEntry().getStore());
var logo = PrettyImageHelper.ofFixedSquare(image, 16).createRegion();
tab.graphicProperty()
diff --git a/app/src/main/java/io/xpipe/app/browser/BrowserEntry.java b/app/src/main/java/io/xpipe/app/browser/BrowserEntry.java
index 1d718a726..381eff69d 100644
--- a/app/src/main/java/io/xpipe/app/browser/BrowserEntry.java
+++ b/app/src/main/java/io/xpipe/app/browser/BrowserEntry.java
@@ -2,7 +2,7 @@ package io.xpipe.app.browser;
import io.xpipe.app.browser.icon.DirectoryType;
import io.xpipe.app.browser.icon.FileType;
-import io.xpipe.core.impl.FileNames;
+import io.xpipe.core.store.FileNames;
import io.xpipe.core.store.FileKind;
import io.xpipe.core.store.FileSystem;
import lombok.Getter;
diff --git a/app/src/main/java/io/xpipe/app/browser/BrowserFileListComp.java b/app/src/main/java/io/xpipe/app/browser/BrowserFileListComp.java
index 6f995e40e..d058ce311 100644
--- a/app/src/main/java/io/xpipe/app/browser/BrowserFileListComp.java
+++ b/app/src/main/java/io/xpipe/app/browser/BrowserFileListComp.java
@@ -12,7 +12,7 @@ import io.xpipe.app.fxcomps.util.PlatformThread;
import io.xpipe.app.util.BooleanScope;
import io.xpipe.app.util.HumanReadableFormat;
import io.xpipe.app.util.ThreadHelper;
-import io.xpipe.core.impl.FileNames;
+import io.xpipe.core.store.FileNames;
import io.xpipe.core.process.OsType;
import io.xpipe.core.store.FileKind;
import io.xpipe.core.store.FileSystem;
diff --git a/app/src/main/java/io/xpipe/app/browser/BrowserFileListModel.java b/app/src/main/java/io/xpipe/app/browser/BrowserFileListModel.java
index bce6612e1..f82d27414 100644
--- a/app/src/main/java/io/xpipe/app/browser/BrowserFileListModel.java
+++ b/app/src/main/java/io/xpipe/app/browser/BrowserFileListModel.java
@@ -2,7 +2,7 @@ package io.xpipe.app.browser;
import io.xpipe.app.fxcomps.util.BindingsHelper;
import io.xpipe.app.issue.ErrorEvent;
-import io.xpipe.core.impl.FileNames;
+import io.xpipe.core.store.FileNames;
import io.xpipe.core.store.FileKind;
import io.xpipe.core.store.FileSystem;
import javafx.beans.property.Property;
diff --git a/app/src/main/java/io/xpipe/app/browser/BrowserModel.java b/app/src/main/java/io/xpipe/app/browser/BrowserModel.java
index e876e07e1..b0fc483ab 100644
--- a/app/src/main/java/io/xpipe/app/browser/BrowserModel.java
+++ b/app/src/main/java/io/xpipe/app/browser/BrowserModel.java
@@ -2,10 +2,11 @@ package io.xpipe.app.browser;
import io.xpipe.app.fxcomps.util.BindingsHelper;
import io.xpipe.app.storage.DataStorage;
+import io.xpipe.app.storage.DataStoreEntryRef;
import io.xpipe.app.util.BooleanScope;
import io.xpipe.app.util.ThreadHelper;
-import io.xpipe.core.impl.FileStore;
-import io.xpipe.core.store.ShellStore;
+import io.xpipe.core.store.FileStore;
+import io.xpipe.core.store.FileSystemStore;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.Property;
import javafx.beans.property.SimpleBooleanProperty;
@@ -76,18 +77,19 @@ public class BrowserModel {
}
public void restoreState(BrowserSavedState.Entry e, BooleanProperty busy) {
- var storageEntry = DataStorage.get().getStoreEntry(e.getUuid());
+ var storageEntry = DataStorage.get().getStoreEntryIfPresent(e.getUuid());
storageEntry.ifPresent(entry -> {
- openFileSystemAsync(null, entry.getStore().asNeeded(), e.getPath(), busy);
+ openFileSystemAsync(entry.ref(), e.getPath(), busy);
});
}
public void reset() {
var list = new ArrayList();
openFileSystems.forEach(model -> {
- var storageEntry = DataStorage.get().getStoreEntryIfPresent(model.getStore());
- storageEntry.ifPresent(entry -> list.add(new BrowserSavedState.Entry(
- entry.getUuid(), model.getCurrentPath().get())));
+ if (DataStorage.get().getStoreEntries().contains(model.getEntry().get())) {
+ list.add(new BrowserSavedState.Entry(
+ model.getEntry().get().getUuid(), model.getCurrentPath().get()));
+ }
});
// Don't override state if it is empty
@@ -138,18 +140,18 @@ public class BrowserModel {
});
}
- public void openExistingFileSystemIfPresent(String name, ShellStore store) {
+ public void openExistingFileSystemIfPresent(DataStoreEntryRef extends FileSystemStore> store) {
var found = openFileSystems.stream()
- .filter(model -> Objects.equals(model.getStore(), store))
+ .filter(model -> Objects.equals(model.getEntry(), store))
.findFirst();
if (found.isPresent()) {
selected.setValue(found.get());
} else {
- openFileSystemAsync(name, store, null, null);
+ openFileSystemAsync(store, null, null);
}
}
- public void openFileSystemAsync(String name, ShellStore store, String path, BooleanProperty externalBusy) {
+ public void openFileSystemAsync(DataStoreEntryRef extends FileSystemStore> store, String path, BooleanProperty externalBusy) {
// // Prevent multiple tabs in non browser modes
// if (!mode.equals(Mode.BROWSER)) {
// ThreadHelper.runFailableAsync(() -> {
@@ -177,7 +179,7 @@ public class BrowserModel {
// Prevent multiple calls from interfering with each other
synchronized (BrowserModel.this) {
try (var b = new BooleanScope(externalBusy != null ? externalBusy : new SimpleBooleanProperty()).start()) {
- model = new OpenFileSystemModel(name, this, store);
+ model = new OpenFileSystemModel(this, store);
model.initFileSystem();
model.initSavedState();
}
diff --git a/app/src/main/java/io/xpipe/app/browser/BrowserSelectionListComp.java b/app/src/main/java/io/xpipe/app/browser/BrowserSelectionListComp.java
index ab5f45cec..55f242b94 100644
--- a/app/src/main/java/io/xpipe/app/browser/BrowserSelectionListComp.java
+++ b/app/src/main/java/io/xpipe/app/browser/BrowserSelectionListComp.java
@@ -8,7 +8,7 @@ import io.xpipe.app.fxcomps.Comp;
import io.xpipe.app.fxcomps.SimpleComp;
import io.xpipe.app.fxcomps.impl.PrettyImageHelper;
import io.xpipe.app.fxcomps.util.PlatformThread;
-import io.xpipe.core.impl.FileNames;
+import io.xpipe.core.store.FileNames;
import io.xpipe.core.store.FileSystem;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.value.ObservableValue;
diff --git a/app/src/main/java/io/xpipe/app/browser/BrowserTransferComp.java b/app/src/main/java/io/xpipe/app/browser/BrowserTransferComp.java
index 11a2f0f50..cf12eaae7 100644
--- a/app/src/main/java/io/xpipe/app/browser/BrowserTransferComp.java
+++ b/app/src/main/java/io/xpipe/app/browser/BrowserTransferComp.java
@@ -9,7 +9,7 @@ import io.xpipe.app.fxcomps.impl.*;
import io.xpipe.app.fxcomps.util.BindingsHelper;
import io.xpipe.app.fxcomps.util.PlatformThread;
import io.xpipe.app.storage.DataStorage;
-import io.xpipe.core.impl.FileNames;
+import io.xpipe.core.store.FileNames;
import javafx.beans.binding.Bindings;
import javafx.collections.FXCollections;
import javafx.geometry.Insets;
diff --git a/app/src/main/java/io/xpipe/app/browser/BrowserTransferModel.java b/app/src/main/java/io/xpipe/app/browser/BrowserTransferModel.java
index df32461ae..0204c9fef 100644
--- a/app/src/main/java/io/xpipe/app/browser/BrowserTransferModel.java
+++ b/app/src/main/java/io/xpipe/app/browser/BrowserTransferModel.java
@@ -2,7 +2,7 @@ package io.xpipe.app.browser;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.util.BooleanScope;
-import io.xpipe.core.impl.FileNames;
+import io.xpipe.core.store.FileNames;
import io.xpipe.core.store.FileSystem;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.SimpleBooleanProperty;
diff --git a/app/src/main/java/io/xpipe/app/browser/BrowserWelcomeComp.java b/app/src/main/java/io/xpipe/app/browser/BrowserWelcomeComp.java
index 1167800ff..48c6ef9e2 100644
--- a/app/src/main/java/io/xpipe/app/browser/BrowserWelcomeComp.java
+++ b/app/src/main/java/io/xpipe/app/browser/BrowserWelcomeComp.java
@@ -54,12 +54,12 @@ public class BrowserWelcomeComp extends SimpleComp {
var storeList = new VBox();
storeList.setSpacing(8);
state.getLastSystems().forEach(e -> {
- var entry = DataStorage.get().getStoreEntry(e.getUuid());
+ var entry = DataStorage.get().getStoreEntryIfPresent(e.getUuid());
if (entry.isEmpty()) {
return;
}
- if (!entry.get().getState().isUsable()) {
+ if (!entry.get().getValidity().isUsable()) {
return;
}
@@ -68,7 +68,7 @@ public class BrowserWelcomeComp extends SimpleComp {
var view = PrettyImageHelper.ofFixedSquare(graphic, 45);
view.padding(new Insets(2, 8, 2, 8));
var tile = new Tile(
- DataStorage.get().getStoreBrowserDisplayName(entry.get().getStore()),
+ DataStorage.get().getStoreBrowserDisplayName(entry.get()),
e.getPath(),
view.createRegion());
tile.setActionHandler(() -> {
diff --git a/app/src/main/java/io/xpipe/app/browser/FileSystemHelper.java b/app/src/main/java/io/xpipe/app/browser/FileSystemHelper.java
index 2432bef7c..ac39454c3 100644
--- a/app/src/main/java/io/xpipe/app/browser/FileSystemHelper.java
+++ b/app/src/main/java/io/xpipe/app/browser/FileSystemHelper.java
@@ -1,8 +1,8 @@
package io.xpipe.app.browser;
import io.xpipe.app.issue.ErrorEvent;
-import io.xpipe.core.impl.FileNames;
-import io.xpipe.core.impl.LocalStore;
+import io.xpipe.core.store.FileNames;
+import io.xpipe.core.store.LocalStore;
import io.xpipe.core.process.OsType;
import io.xpipe.core.store.ConnectionFileSystem;
import io.xpipe.core.store.FileKind;
diff --git a/app/src/main/java/io/xpipe/app/browser/OpenFileSystemModel.java b/app/src/main/java/io/xpipe/app/browser/OpenFileSystemModel.java
index e87a779fa..e3e1779cb 100644
--- a/app/src/main/java/io/xpipe/app/browser/OpenFileSystemModel.java
+++ b/app/src/main/java/io/xpipe/app/browser/OpenFileSystemModel.java
@@ -3,10 +3,11 @@ package io.xpipe.app.browser;
import io.xpipe.app.comp.base.ModalOverlayComp;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.storage.DataStorage;
+import io.xpipe.app.storage.DataStoreEntryRef;
import io.xpipe.app.util.BooleanScope;
import io.xpipe.app.util.TerminalHelper;
import io.xpipe.app.util.ThreadHelper;
-import io.xpipe.core.impl.FileNames;
+import io.xpipe.core.store.FileNames;
import io.xpipe.core.process.ShellControl;
import io.xpipe.core.process.ShellDialects;
import io.xpipe.core.store.*;
@@ -26,7 +27,7 @@ import java.util.stream.Stream;
@Getter
public final class OpenFileSystemModel {
- private final FileSystemStore store;
+ private final DataStoreEntryRef extends FileSystemStore> entry;
private FileSystem fileSystem;
private final Property filter = new SimpleStringProperty();
private final BrowserFileListModel fileList;
@@ -42,12 +43,11 @@ public final class OpenFileSystemModel {
private final String tooltip;
private boolean local;
- public OpenFileSystemModel(String name, BrowserModel browserModel, FileSystemStore store) {
+ public OpenFileSystemModel(BrowserModel browserModel, DataStoreEntryRef extends FileSystemStore> entry) {
this.browserModel = browserModel;
- this.store = store;
- var e = DataStorage.get().getStoreEntryIfPresent(store);
- this.name = name != null ? name : e.isPresent() ? DataStorage.get().getStoreBrowserDisplayName(store) : "?";
- this.tooltip = e.isPresent() ? DataStorage.get().getId(e.get()).toString() : name;
+ this.entry = entry;
+ this.name = entry.get().getName();
+ this.tooltip = DataStorage.get().getId(entry.getEntry()).toString();
this.inOverview.bind(Bindings.createBooleanBinding(
() -> {
return currentPath.get() == null;
@@ -63,7 +63,7 @@ public final class OpenFileSystemModel {
}
BooleanScope.execute(busy, () -> {
- if (store instanceof ShellStore s) {
+ if (entry.getStore() instanceof ShellStore s) {
c.accept(fileSystem.getShell().orElseThrow());
if (refresh) {
refreshSync();
@@ -150,8 +150,7 @@ public final class OpenFileSystemModel {
if (allowCommands && evaluatedPath != null && !FileNames.isAbsolute(evaluatedPath)
&& fileSystem.getShell().isPresent()) {
var directory = currentPath.get();
- var name = adjustedPath + " - "
- + DataStorage.get().getStoreDisplayName(store).orElse("?");
+ var name = adjustedPath + " - " + entry.get().getName();
ThreadHelper.runFailableAsync(() -> {
if (ShellDialects.ALL.stream()
.anyMatch(dialect -> adjustedPath.startsWith(dialect.getOpenCommand()))) {
@@ -205,7 +204,7 @@ public final class OpenFileSystemModel {
private void cdSyncWithoutCheck(String path) throws Exception {
if (fileSystem == null) {
- var fs = store.createFileSystem();
+ var fs = entry.getStore().createFileSystem();
fs.open();
this.fileSystem = fs;
}
@@ -364,7 +363,7 @@ public final class OpenFileSystemModel {
public void initFileSystem() throws Exception {
BooleanScope.execute(busy, () -> {
- var fs = store.createFileSystem();
+ var fs = entry.getStore().createFileSystem();
fs.open();
this.fileSystem = fs;
this.local =
@@ -393,23 +392,17 @@ public final class OpenFileSystemModel {
}
BooleanScope.execute(busy, () -> {
- if (store instanceof ShellStore s) {
+ if (entry.getStore() instanceof ShellStore s) {
var connection = ((ConnectionFileSystem) fileSystem).getShellControl();
var command = s.control()
.initWith(connection.getShellDialect().getCdCommand(directory))
- .prepareTerminalOpen(directory + " - "
- + DataStorage.get().getStoreDisplayName(store)
- .orElse("?"));
+ .prepareTerminalOpen(directory + " - " + entry.get().getName());
TerminalHelper.open(directory, command);
}
});
});
}
- public OpenFileSystemHistory getHistory() {
- return history;
- }
-
public void backSync() throws Exception {
cdSyncWithoutCheck(history.back());
}
diff --git a/app/src/main/java/io/xpipe/app/browser/OpenFileSystemSavedState.java b/app/src/main/java/io/xpipe/app/browser/OpenFileSystemSavedState.java
index b495552c8..1cae5619c 100644
--- a/app/src/main/java/io/xpipe/app/browser/OpenFileSystemSavedState.java
+++ b/app/src/main/java/io/xpipe/app/browser/OpenFileSystemSavedState.java
@@ -12,8 +12,7 @@ import com.fasterxml.jackson.databind.node.JsonNodeFactory;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
import io.xpipe.app.core.AppCache;
-import io.xpipe.app.storage.DataStorage;
-import io.xpipe.core.impl.FileNames;
+import io.xpipe.core.store.FileNames;
import io.xpipe.core.util.JacksonMapper;
import javafx.application.Platform;
import javafx.collections.FXCollections;
@@ -81,11 +80,7 @@ public class OpenFileSystemSavedState {
}
static OpenFileSystemSavedState loadForStore(OpenFileSystemModel model) {
- var storageEntry = DataStorage.get()
- .getStoreEntryIfPresent(model.getStore())
- .map(entry -> entry.getUuid())
- .orElse(UUID.randomUUID());
- var state = AppCache.get("fs-state-" + storageEntry, OpenFileSystemSavedState.class, () -> {
+ var state = AppCache.get("fs-state-" + model.getEntry().get().getUuid(), OpenFileSystemSavedState.class, () -> {
return new OpenFileSystemSavedState();
});
state.setModel(model);
@@ -127,8 +122,7 @@ public class OpenFileSystemSavedState {
return;
}
- var storageEntry = DataStorage.get().getStoreEntryIfPresent(model.getStore());
- storageEntry.ifPresent(entry -> AppCache.update("fs-state-" + entry.getUuid(), this));
+ AppCache.update("fs-state-" + model.getEntry().get().getUuid(), this);
}
public void cd(String dir) {
diff --git a/app/src/main/java/io/xpipe/app/browser/StandaloneFileBrowser.java b/app/src/main/java/io/xpipe/app/browser/StandaloneFileBrowser.java
index 844508d82..0e040144e 100644
--- a/app/src/main/java/io/xpipe/app/browser/StandaloneFileBrowser.java
+++ b/app/src/main/java/io/xpipe/app/browser/StandaloneFileBrowser.java
@@ -4,8 +4,9 @@ import io.xpipe.app.core.AppFont;
import io.xpipe.app.core.AppI18n;
import io.xpipe.app.core.AppWindowHelper;
import io.xpipe.app.fxcomps.util.PlatformThread;
-import io.xpipe.core.impl.FileStore;
-import io.xpipe.core.store.ShellStore;
+import io.xpipe.app.storage.DataStoreEntryRef;
+import io.xpipe.core.store.FileStore;
+import io.xpipe.core.store.FileSystemStore;
import javafx.beans.property.Property;
import javafx.stage.FileChooser;
import javafx.stage.Window;
@@ -38,7 +39,7 @@ public class StandaloneFileBrowser {
});
}
- public static void openSingleFile(Supplier store, Consumer file) {
+ public static void openSingleFile(Supplier> store, Consumer file) {
PlatformThread.runLaterIfNeeded(() -> {
var model = new BrowserModel(BrowserModel.Mode.SINGLE_FILE_CHOOSER);
var comp = new BrowserComp(model)
@@ -50,7 +51,7 @@ public class StandaloneFileBrowser {
window.close();
});
window.show();
- model.openFileSystemAsync(null, store.get(), null, null);
+ model.openFileSystemAsync(store.get(), null, null);
});
}
diff --git a/app/src/main/java/io/xpipe/app/browser/action/MultiExecuteAction.java b/app/src/main/java/io/xpipe/app/browser/action/MultiExecuteAction.java
index 81b522daa..049eaf310 100644
--- a/app/src/main/java/io/xpipe/app/browser/action/MultiExecuteAction.java
+++ b/app/src/main/java/io/xpipe/app/browser/action/MultiExecuteAction.java
@@ -5,7 +5,7 @@ import io.xpipe.app.browser.OpenFileSystemModel;
import io.xpipe.app.prefs.AppPrefs;
import io.xpipe.app.util.ScriptHelper;
import io.xpipe.app.util.TerminalHelper;
-import io.xpipe.core.impl.FileNames;
+import io.xpipe.core.store.FileNames;
import io.xpipe.core.process.ShellControl;
import org.apache.commons.io.FilenameUtils;
diff --git a/app/src/main/java/io/xpipe/app/browser/icon/DirectoryType.java b/app/src/main/java/io/xpipe/app/browser/icon/DirectoryType.java
index 0b91da25d..cfc1d9036 100644
--- a/app/src/main/java/io/xpipe/app/browser/icon/DirectoryType.java
+++ b/app/src/main/java/io/xpipe/app/browser/icon/DirectoryType.java
@@ -1,7 +1,7 @@
package io.xpipe.app.browser.icon;
import io.xpipe.app.core.AppResources;
-import io.xpipe.core.impl.FileNames;
+import io.xpipe.core.store.FileNames;
import io.xpipe.core.store.FileKind;
import io.xpipe.core.store.FileSystem;
import lombok.Getter;
diff --git a/app/src/main/java/io/xpipe/app/comp/base/DropdownComp.java b/app/src/main/java/io/xpipe/app/comp/base/DropdownComp.java
index 5431a87e1..6dd2cd2b2 100644
--- a/app/src/main/java/io/xpipe/app/comp/base/DropdownComp.java
+++ b/app/src/main/java/io/xpipe/app/comp/base/DropdownComp.java
@@ -3,66 +3,53 @@ package io.xpipe.app.comp.base;
import io.xpipe.app.fxcomps.Comp;
import io.xpipe.app.fxcomps.CompStructure;
import io.xpipe.app.fxcomps.SimpleCompStructure;
+import io.xpipe.app.fxcomps.augment.ContextMenuAugment;
+import io.xpipe.app.fxcomps.util.BindingsHelper;
import io.xpipe.app.fxcomps.util.SimpleChangeListener;
-import javafx.beans.property.ObjectProperty;
-import javafx.beans.property.SimpleObjectProperty;
-import javafx.beans.value.ObservableValue;
import javafx.css.Size;
import javafx.css.SizeUnits;
-import javafx.scene.Node;
-import javafx.scene.control.MenuButton;
+import javafx.scene.control.Button;
+import javafx.scene.control.ContextMenu;
import javafx.scene.control.MenuItem;
import org.kordamp.ikonli.javafx.FontIcon;
import java.util.List;
-public class DropdownComp extends Comp >{
+public class DropdownComp extends Comp> {
- private final ObservableValue name;
- private final ObjectProperty graphic;
private final List> items;
- public DropdownComp(ObservableValue name, List> items) {
- this.name = name;
- this.graphic = new SimpleObjectProperty<>(null);
+ public DropdownComp(List> items) {
this.items = items;
}
- public DropdownComp(ObservableValue name, Node graphic, List> items) {
- this.name = name;
- this.graphic = new SimpleObjectProperty<>(graphic);
- this.items = items;
- }
-
- public Node getGraphic() {
- return graphic.get();
- }
-
- public ObjectProperty graphicProperty() {
- return graphic;
- }
-
@Override
- public CompStructure createBase() {
- var button = new MenuButton(null);
- if (name != null) {
- button.textProperty().bind(name);
- }
- var graphic = getGraphic();
- if (graphic instanceof FontIcon f) {
- SimpleChangeListener.apply(button.fontProperty(), c -> {
- f.setIconSize((int) new Size(c.getSize(), SizeUnits.PT).pixels());
- });
- }
+ public CompStructure