diff --git a/api/src/main/java/io/xpipe/api/DataSource.java b/api/src/main/java/io/xpipe/api/DataSource.java index 4f230a20a..7c2271897 100644 --- a/api/src/main/java/io/xpipe/api/DataSource.java +++ b/api/src/main/java/io/xpipe/api/DataSource.java @@ -17,6 +17,22 @@ import java.util.Map; */ public interface DataSource { + /** + * 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 supplySource() { + return null; + } + /** * Wrapper for {@link #get(DataSourceId)}. * diff --git a/api/src/main/java/io/xpipe/api/DataTable.java b/api/src/main/java/io/xpipe/api/DataTable.java index 1522e50e5..33af114a8 100644 --- a/api/src/main/java/io/xpipe/api/DataTable.java +++ b/api/src/main/java/io/xpipe/api/DataTable.java @@ -9,6 +9,13 @@ import java.util.stream.Stream; public interface DataTable extends Iterable, DataSource { + /** + * @see DataSource#supplySource() + */ + static DataTable supplySource() { + return null; + } + Stream stream(); int getRowCount(); diff --git a/core/src/main/java/io/xpipe/core/source/DataSourceId.java b/core/src/main/java/io/xpipe/core/source/DataSourceId.java index 0453aeb21..9f9707d26 100644 --- a/core/src/main/java/io/xpipe/core/source/DataSourceId.java +++ b/core/src/main/java/io/xpipe/core/source/DataSourceId.java @@ -89,6 +89,6 @@ public class DataSourceId { @Override public String toString() { - return collectionName.toLowerCase() + SEPARATOR + (entryName != null ? entryName.toLowerCase() : ""); + return (collectionName != null ? collectionName.toLowerCase() : "") + SEPARATOR + entryName; } } diff --git a/extension/src/main/java/io/xpipe/extension/DataSourceProvider.java b/extension/src/main/java/io/xpipe/extension/DataSourceProvider.java index 339da00bc..d312612f6 100644 --- a/extension/src/main/java/io/xpipe/extension/DataSourceProvider.java +++ b/extension/src/main/java/io/xpipe/extension/DataSourceProvider.java @@ -1,9 +1,6 @@ package io.xpipe.extension; -import io.xpipe.core.source.DataSourceConfig; -import io.xpipe.core.source.DataSourceDescriptor; -import io.xpipe.core.source.DataSourceInfo; -import io.xpipe.core.source.TableReadConnection; +import io.xpipe.core.source.*; import io.xpipe.core.store.DataStore; import io.xpipe.core.store.StreamDataStore; import javafx.beans.property.Property; @@ -77,6 +74,8 @@ public interface DataSourceProvider { List getPossibleNames(); } + DataSourceType getType(); + boolean supportsStore(DataStore store); FileProvider getFileProvider(); diff --git a/extension/src/main/java/io/xpipe/extension/comp/CharsetChoiceComp.java b/extension/src/main/java/io/xpipe/extension/comp/CharsetChoiceComp.java index ed0de26cb..4f9417e4a 100644 --- a/extension/src/main/java/io/xpipe/extension/comp/CharsetChoiceComp.java +++ b/extension/src/main/java/io/xpipe/extension/comp/CharsetChoiceComp.java @@ -4,14 +4,14 @@ import io.xpipe.fxcomps.Comp; import io.xpipe.fxcomps.CompStructure; import io.xpipe.fxcomps.comp.ReplacementComp; import javafx.beans.property.Property; -import javafx.scene.control.ChoiceBox; +import javafx.scene.control.ComboBox; import org.apache.commons.collections4.bidimap.DualLinkedHashBidiMap; import java.nio.charset.Charset; import java.util.LinkedHashMap; import java.util.function.Supplier; -public class CharsetChoiceComp extends ReplacementComp>> { +public class CharsetChoiceComp extends ReplacementComp>> { private final Property charset; @@ -20,7 +20,7 @@ public class CharsetChoiceComp extends ReplacementComp>> createComp() { + protected Comp>> createComp() { var map = new LinkedHashMap>(); for (var e : Charset.availableCharsets().entrySet()) { map.put(e.getValue(), e::getKey); diff --git a/extension/src/main/java/io/xpipe/extension/comp/ChoiceComp.java b/extension/src/main/java/io/xpipe/extension/comp/ChoiceComp.java index 3f46ecbdc..60b4bfbf2 100644 --- a/extension/src/main/java/io/xpipe/extension/comp/ChoiceComp.java +++ b/extension/src/main/java/io/xpipe/extension/comp/ChoiceComp.java @@ -5,13 +5,13 @@ import io.xpipe.fxcomps.CompStructure; import io.xpipe.fxcomps.util.PlatformUtil; import javafx.beans.property.Property; import javafx.collections.FXCollections; -import javafx.scene.control.ChoiceBox; +import javafx.scene.control.ComboBox; import javafx.util.StringConverter; import org.apache.commons.collections4.BidiMap; import java.util.function.Supplier; -public class ChoiceComp extends Comp>> { +public class ChoiceComp extends Comp>> { private final Property value; private final BidiMap> range; @@ -22,9 +22,9 @@ public class ChoiceComp extends Comp>> { } @Override - public CompStructure> createBase() { + public CompStructure> createBase() { var list = FXCollections.observableArrayList(range.keySet()); - var cb = new ChoiceBox<>(list); + var cb = new ComboBox<>(list); cb.setConverter(new StringConverter<>() { @Override public String toString(T object) { diff --git a/extension/src/main/java/io/xpipe/extension/comp/CodeSnippetComp.java b/extension/src/main/java/io/xpipe/extension/comp/CodeSnippetComp.java index fa7a8af11..1379f019e 100644 --- a/extension/src/main/java/io/xpipe/extension/comp/CodeSnippetComp.java +++ b/extension/src/main/java/io/xpipe/extension/comp/CodeSnippetComp.java @@ -20,9 +20,11 @@ import java.awt.datatransfer.StringSelection; public class CodeSnippetComp extends Comp> { + private final ObservableValue showLineNumbers; private final ObservableValue value; - public CodeSnippetComp(ObservableValue value) { + public CodeSnippetComp(ObservableValue showLineNumbers, ObservableValue value) { + this.showLineNumbers = showLineNumbers; this.value = PlatformUtil.wrap(value); } @@ -88,22 +90,40 @@ public class CodeSnippetComp extends Comp> { value.addListener((c,o,n) -> { PlatformUtil.runLaterIfNeeded(() -> { fillArea(lineNumbers, s); + s.setMaxHeight(5); }); }); var spacer = new Region(); spacer.getStyleClass().add("spacer"); - var content = new HBox(lineNumbers, spacer, s); + var content = new HBox(s); + spacer.prefHeightProperty().bind(content.heightProperty()); + if (showLineNumbers.getValue()) { + content.getChildren().add(0, lineNumbers); + content.getChildren().add(1, spacer); + } + PlatformUtil.wrap(showLineNumbers).addListener((c,o,n) -> { + if (n) { + content.getChildren().add(0, lineNumbers); + content.getChildren().add(1, spacer); + } else { + content.getChildren().remove(lineNumbers); + content.getChildren().remove(spacer); + } + }); HBox.setHgrow(s, Priority.ALWAYS); var container = new ScrollPane(content); container.setFitToWidth(true); + container.setFitToHeight(true); var c = new StackPane(container); + container.prefHeightProperty().bind(c.heightProperty()); c.getStyleClass().add("code-snippet-container"); var copyButton = createCopyButton(c); var pane = new AnchorPane(copyButton); + pane.setPickOnBounds(false); AnchorPane.setTopAnchor(copyButton, 10.0); AnchorPane.setRightAnchor(copyButton, 10.0); c.getChildren().add(pane); diff --git a/extension/src/main/java/io/xpipe/extension/event/ErrorEvent.java b/extension/src/main/java/io/xpipe/extension/event/ErrorEvent.java index c47192528..c99befa91 100644 --- a/extension/src/main/java/io/xpipe/extension/event/ErrorEvent.java +++ b/extension/src/main/java/io/xpipe/extension/event/ErrorEvent.java @@ -11,6 +11,17 @@ import java.util.List; @Getter public class ErrorEvent { + public static class ErrorEventBuilder { + + public ErrorEventBuilder omit() { + return omitted(true); + } + + public void handle() { + build().handle(); + } + } + public static ErrorEventBuilder fromThrowable(Throwable t) { return builder().throwable(t) .description(ExceptionConverter.convertMessage(t)); diff --git a/extension/src/main/java/io/xpipe/extension/event/ExceptionConverter.java b/extension/src/main/java/io/xpipe/extension/event/ExceptionConverter.java index f13a0deb8..6c8897a2c 100644 --- a/extension/src/main/java/io/xpipe/extension/event/ExceptionConverter.java +++ b/extension/src/main/java/io/xpipe/extension/event/ExceptionConverter.java @@ -12,6 +12,10 @@ public class ExceptionConverter { return I18n.get("fileNotFound", msg); } + if (ex instanceof ClassNotFoundException) { + return I18n.get("classNotFound", msg); + } + return msg; } } diff --git a/extension/src/main/resources/io/xpipe/extension/resources/style/code-snippet.css b/extension/src/main/resources/io/xpipe/extension/resources/style/code-snippet.css index d2fad34e4..af5798a4d 100644 --- a/extension/src/main/resources/io/xpipe/extension/resources/style/code-snippet.css +++ b/extension/src/main/resources/io/xpipe/extension/resources/style/code-snippet.css @@ -1,6 +1,6 @@ .code-snippet { -fx-padding: 0.3em 0.5em 0.3em 0.5em; --fx-border-width: 0 0 0 1px; +-fx-border-width: 0; -fx-border-color: -xp-border; -fx-spacing: 0; -fx-font-family: Monospace; @@ -30,12 +30,7 @@ -fx-background-color: #073B4C11; } -.code-snippet .line { --fx-padding: 0.1em 0 0 0; --fx-background-color: transparent; -} - -.code-snippet .spacer { +.code-snippet-container .spacer { -fx-pref-width: 1px; --fx-background-color: #073B4C43; +-fx-background-color: -xp-border; }