mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-11-25 00:50:31 +00:00
Various small fixes
This commit is contained in:
parent
a9ee9c1bdc
commit
bcc581c0bd
10 changed files with 74 additions and 22 deletions
|
@ -17,6 +17,22 @@ import java.util.Map;
|
||||||
*/
|
*/
|
||||||
public interface DataSource {
|
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)}.
|
* Wrapper for {@link #get(DataSourceId)}.
|
||||||
*
|
*
|
||||||
|
|
|
@ -9,6 +9,13 @@ import java.util.stream.Stream;
|
||||||
|
|
||||||
public interface DataTable extends Iterable<TupleNode>, DataSource {
|
public interface DataTable extends Iterable<TupleNode>, DataSource {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see DataSource#supplySource()
|
||||||
|
*/
|
||||||
|
static DataTable supplySource() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
Stream<TupleNode> stream();
|
Stream<TupleNode> stream();
|
||||||
|
|
||||||
int getRowCount();
|
int getRowCount();
|
||||||
|
|
|
@ -89,6 +89,6 @@ public class DataSourceId {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return collectionName.toLowerCase() + SEPARATOR + (entryName != null ? entryName.toLowerCase() : "");
|
return (collectionName != null ? collectionName.toLowerCase() : "") + SEPARATOR + entryName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
package io.xpipe.extension;
|
package io.xpipe.extension;
|
||||||
|
|
||||||
import io.xpipe.core.source.DataSourceConfig;
|
import io.xpipe.core.source.*;
|
||||||
import io.xpipe.core.source.DataSourceDescriptor;
|
|
||||||
import io.xpipe.core.source.DataSourceInfo;
|
|
||||||
import io.xpipe.core.source.TableReadConnection;
|
|
||||||
import io.xpipe.core.store.DataStore;
|
import io.xpipe.core.store.DataStore;
|
||||||
import io.xpipe.core.store.StreamDataStore;
|
import io.xpipe.core.store.StreamDataStore;
|
||||||
import javafx.beans.property.Property;
|
import javafx.beans.property.Property;
|
||||||
|
@ -77,6 +74,8 @@ public interface DataSourceProvider {
|
||||||
List<String> getPossibleNames();
|
List<String> getPossibleNames();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DataSourceType getType();
|
||||||
|
|
||||||
boolean supportsStore(DataStore store);
|
boolean supportsStore(DataStore store);
|
||||||
|
|
||||||
FileProvider getFileProvider();
|
FileProvider getFileProvider();
|
||||||
|
|
|
@ -4,14 +4,14 @@ import io.xpipe.fxcomps.Comp;
|
||||||
import io.xpipe.fxcomps.CompStructure;
|
import io.xpipe.fxcomps.CompStructure;
|
||||||
import io.xpipe.fxcomps.comp.ReplacementComp;
|
import io.xpipe.fxcomps.comp.ReplacementComp;
|
||||||
import javafx.beans.property.Property;
|
import javafx.beans.property.Property;
|
||||||
import javafx.scene.control.ChoiceBox;
|
import javafx.scene.control.ComboBox;
|
||||||
import org.apache.commons.collections4.bidimap.DualLinkedHashBidiMap;
|
import org.apache.commons.collections4.bidimap.DualLinkedHashBidiMap;
|
||||||
|
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
public class CharsetChoiceComp extends ReplacementComp<CompStructure<ChoiceBox<Charset>>> {
|
public class CharsetChoiceComp extends ReplacementComp<CompStructure<ComboBox<Charset>>> {
|
||||||
|
|
||||||
private final Property<Charset> charset;
|
private final Property<Charset> charset;
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ public class CharsetChoiceComp extends ReplacementComp<CompStructure<ChoiceBox<C
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Comp<CompStructure<ChoiceBox<Charset>>> createComp() {
|
protected Comp<CompStructure<ComboBox<Charset>>> createComp() {
|
||||||
var map = new LinkedHashMap<Charset, Supplier<String>>();
|
var map = new LinkedHashMap<Charset, Supplier<String>>();
|
||||||
for (var e : Charset.availableCharsets().entrySet()) {
|
for (var e : Charset.availableCharsets().entrySet()) {
|
||||||
map.put(e.getValue(), e::getKey);
|
map.put(e.getValue(), e::getKey);
|
||||||
|
|
|
@ -5,13 +5,13 @@ import io.xpipe.fxcomps.CompStructure;
|
||||||
import io.xpipe.fxcomps.util.PlatformUtil;
|
import io.xpipe.fxcomps.util.PlatformUtil;
|
||||||
import javafx.beans.property.Property;
|
import javafx.beans.property.Property;
|
||||||
import javafx.collections.FXCollections;
|
import javafx.collections.FXCollections;
|
||||||
import javafx.scene.control.ChoiceBox;
|
import javafx.scene.control.ComboBox;
|
||||||
import javafx.util.StringConverter;
|
import javafx.util.StringConverter;
|
||||||
import org.apache.commons.collections4.BidiMap;
|
import org.apache.commons.collections4.BidiMap;
|
||||||
|
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
public class ChoiceComp<T> extends Comp<CompStructure<ChoiceBox<T>>> {
|
public class ChoiceComp<T> extends Comp<CompStructure<ComboBox<T>>> {
|
||||||
|
|
||||||
private final Property<T> value;
|
private final Property<T> value;
|
||||||
private final BidiMap<T, Supplier<String>> range;
|
private final BidiMap<T, Supplier<String>> range;
|
||||||
|
@ -22,9 +22,9 @@ public class ChoiceComp<T> extends Comp<CompStructure<ChoiceBox<T>>> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompStructure<ChoiceBox<T>> createBase() {
|
public CompStructure<ComboBox<T>> createBase() {
|
||||||
var list = FXCollections.observableArrayList(range.keySet());
|
var list = FXCollections.observableArrayList(range.keySet());
|
||||||
var cb = new ChoiceBox<>(list);
|
var cb = new ComboBox<>(list);
|
||||||
cb.setConverter(new StringConverter<>() {
|
cb.setConverter(new StringConverter<>() {
|
||||||
@Override
|
@Override
|
||||||
public String toString(T object) {
|
public String toString(T object) {
|
||||||
|
|
|
@ -20,9 +20,11 @@ import java.awt.datatransfer.StringSelection;
|
||||||
|
|
||||||
public class CodeSnippetComp extends Comp<CompStructure<StackPane>> {
|
public class CodeSnippetComp extends Comp<CompStructure<StackPane>> {
|
||||||
|
|
||||||
|
private final ObservableValue<Boolean> showLineNumbers;
|
||||||
private final ObservableValue<CodeSnippet> value;
|
private final ObservableValue<CodeSnippet> value;
|
||||||
|
|
||||||
public CodeSnippetComp(ObservableValue<CodeSnippet> value) {
|
public CodeSnippetComp(ObservableValue<Boolean> showLineNumbers, ObservableValue<CodeSnippet> value) {
|
||||||
|
this.showLineNumbers = showLineNumbers;
|
||||||
this.value = PlatformUtil.wrap(value);
|
this.value = PlatformUtil.wrap(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,22 +90,40 @@ public class CodeSnippetComp extends Comp<CompStructure<StackPane>> {
|
||||||
value.addListener((c,o,n) -> {
|
value.addListener((c,o,n) -> {
|
||||||
PlatformUtil.runLaterIfNeeded(() -> {
|
PlatformUtil.runLaterIfNeeded(() -> {
|
||||||
fillArea(lineNumbers, s);
|
fillArea(lineNumbers, s);
|
||||||
|
s.setMaxHeight(5);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
var spacer = new Region();
|
var spacer = new Region();
|
||||||
spacer.getStyleClass().add("spacer");
|
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);
|
HBox.setHgrow(s, Priority.ALWAYS);
|
||||||
var container = new ScrollPane(content);
|
var container = new ScrollPane(content);
|
||||||
container.setFitToWidth(true);
|
container.setFitToWidth(true);
|
||||||
|
container.setFitToHeight(true);
|
||||||
|
|
||||||
var c = new StackPane(container);
|
var c = new StackPane(container);
|
||||||
|
container.prefHeightProperty().bind(c.heightProperty());
|
||||||
c.getStyleClass().add("code-snippet-container");
|
c.getStyleClass().add("code-snippet-container");
|
||||||
|
|
||||||
var copyButton = createCopyButton(c);
|
var copyButton = createCopyButton(c);
|
||||||
var pane = new AnchorPane(copyButton);
|
var pane = new AnchorPane(copyButton);
|
||||||
|
pane.setPickOnBounds(false);
|
||||||
AnchorPane.setTopAnchor(copyButton, 10.0);
|
AnchorPane.setTopAnchor(copyButton, 10.0);
|
||||||
AnchorPane.setRightAnchor(copyButton, 10.0);
|
AnchorPane.setRightAnchor(copyButton, 10.0);
|
||||||
c.getChildren().add(pane);
|
c.getChildren().add(pane);
|
||||||
|
|
|
@ -11,6 +11,17 @@ import java.util.List;
|
||||||
@Getter
|
@Getter
|
||||||
public class ErrorEvent {
|
public class ErrorEvent {
|
||||||
|
|
||||||
|
public static class ErrorEventBuilder {
|
||||||
|
|
||||||
|
public ErrorEventBuilder omit() {
|
||||||
|
return omitted(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void handle() {
|
||||||
|
build().handle();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static ErrorEventBuilder fromThrowable(Throwable t) {
|
public static ErrorEventBuilder fromThrowable(Throwable t) {
|
||||||
return builder().throwable(t)
|
return builder().throwable(t)
|
||||||
.description(ExceptionConverter.convertMessage(t));
|
.description(ExceptionConverter.convertMessage(t));
|
||||||
|
|
|
@ -12,6 +12,10 @@ public class ExceptionConverter {
|
||||||
return I18n.get("fileNotFound", msg);
|
return I18n.get("fileNotFound", msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ex instanceof ClassNotFoundException) {
|
||||||
|
return I18n.get("classNotFound", msg);
|
||||||
|
}
|
||||||
|
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
.code-snippet {
|
.code-snippet {
|
||||||
-fx-padding: 0.3em 0.5em 0.3em 0.5em;
|
-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-border-color: -xp-border;
|
||||||
-fx-spacing: 0;
|
-fx-spacing: 0;
|
||||||
-fx-font-family: Monospace;
|
-fx-font-family: Monospace;
|
||||||
|
@ -30,12 +30,7 @@
|
||||||
-fx-background-color: #073B4C11;
|
-fx-background-color: #073B4C11;
|
||||||
}
|
}
|
||||||
|
|
||||||
.code-snippet .line {
|
.code-snippet-container .spacer {
|
||||||
-fx-padding: 0.1em 0 0 0;
|
|
||||||
-fx-background-color: transparent;
|
|
||||||
}
|
|
||||||
|
|
||||||
.code-snippet .spacer {
|
|
||||||
-fx-pref-width: 1px;
|
-fx-pref-width: 1px;
|
||||||
-fx-background-color: #073B4C43;
|
-fx-background-color: -xp-border;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue