mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-09-03 11:11:38 +12:00
More cleanup
This commit is contained in:
parent
990bea4f59
commit
b0e9a96fc6
37 changed files with 291 additions and 202 deletions
|
@ -16,16 +16,16 @@ public interface DataSourceActionProvider<T extends DataSource<?>> {
|
||||||
public static void init(ModuleLayer layer) {
|
public static void init(ModuleLayer layer) {
|
||||||
if (ALL.size() == 0) {
|
if (ALL.size() == 0) {
|
||||||
ALL.addAll(ServiceLoader.load(layer, DataSourceActionProvider.class).stream()
|
ALL.addAll(ServiceLoader.load(layer, DataSourceActionProvider.class).stream()
|
||||||
.map(p -> (DataSourceActionProvider<?>) p.get())
|
.map(p -> (DataSourceActionProvider<?>) p.get())
|
||||||
.filter(provider -> {
|
.filter(provider -> {
|
||||||
try {
|
try {
|
||||||
return provider.isActive();
|
return provider.isActive();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
ErrorEvent.fromThrowable(e).handle();
|
ErrorEvent.fromThrowable(e).handle();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.toList());
|
.toList());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,11 +39,13 @@ public interface DataSourceActionProvider<T extends DataSource<?>> {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
default void applyToRegion(T store, Region region) {}
|
default void applyToRegion(T store, Region region) {
|
||||||
|
}
|
||||||
|
|
||||||
ObservableValue<String> getName(T store);
|
ObservableValue<String> getName(T store);
|
||||||
|
|
||||||
String getIcon(T store);
|
String getIcon(T store);
|
||||||
|
|
||||||
default void execute(T store) throws Exception {}
|
default void execute(T store) throws Exception {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,8 @@ public interface DataSourceProvider<T extends DataSource<?>> {
|
||||||
throw new ExtensionException();
|
throw new ExtensionException();
|
||||||
}
|
}
|
||||||
|
|
||||||
default void init() throws Exception {}
|
default void init() throws Exception {
|
||||||
|
}
|
||||||
|
|
||||||
default String i18n(String key) {
|
default String i18n(String key) {
|
||||||
return I18n.get(i18nKey(key));
|
return I18n.get(i18nKey(key));
|
||||||
|
@ -64,6 +65,7 @@ public interface DataSourceProvider<T extends DataSource<?>> {
|
||||||
default String queryInformationString(DataStore store, int length) throws Exception {
|
default String queryInformationString(DataStore store, int length) throws Exception {
|
||||||
return getDisplayName();
|
return getDisplayName();
|
||||||
}
|
}
|
||||||
|
|
||||||
default String getDisplayIconFileName() {
|
default String getDisplayIconFileName() {
|
||||||
return getModuleName() + ":" + getId() + "_icon.png";
|
return getModuleName() + ":" + getId() + "_icon.png";
|
||||||
}
|
}
|
||||||
|
@ -86,14 +88,14 @@ public interface DataSourceProvider<T extends DataSource<?>> {
|
||||||
* Checks whether this provider supports the store in principle.
|
* Checks whether this provider supports the store in principle.
|
||||||
* This method should not perform any further checks,
|
* This method should not perform any further checks,
|
||||||
* just check whether it may be possible that the store is supported.
|
* just check whether it may be possible that the store is supported.
|
||||||
*
|
* <p>
|
||||||
* This method will be called for validation purposes.
|
* This method will be called for validation purposes.
|
||||||
*/
|
*/
|
||||||
boolean couldSupportStore(DataStore store);
|
boolean couldSupportStore(DataStore store);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Performs a deep inspection to check whether this provider supports a given store.
|
* Performs a deep inspection to check whether this provider supports a given store.
|
||||||
*
|
* <p>
|
||||||
* This functionality will be used in case no preferred provider has been found.
|
* This functionality will be used in case no preferred provider has been found.
|
||||||
*/
|
*/
|
||||||
default boolean supportsStore(DataStore store) {
|
default boolean supportsStore(DataStore store) {
|
||||||
|
|
|
@ -42,7 +42,7 @@ public class DataSourceProviders {
|
||||||
case STRUCTURE -> DataSourceProviders.byId("xpbs");
|
case STRUCTURE -> DataSourceProviders.byId("xpbs");
|
||||||
case TEXT -> DataSourceProviders.byId("text");
|
case TEXT -> DataSourceProviders.byId("text");
|
||||||
case RAW -> DataSourceProviders.byId("binary");
|
case RAW -> DataSourceProviders.byId("binary");
|
||||||
// TODO
|
// TODO
|
||||||
case COLLECTION -> null;
|
case COLLECTION -> null;
|
||||||
};
|
};
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
|
@ -126,7 +126,7 @@ public class DataSourceProviders {
|
||||||
|
|
||||||
return ALL.stream()
|
return ALL.stream()
|
||||||
.filter(d -> d.getPossibleNames().stream()
|
.filter(d -> d.getPossibleNames().stream()
|
||||||
.anyMatch(s -> nameAlternatives(s).stream().anyMatch(s1 -> s1.equalsIgnoreCase(name)))
|
.anyMatch(s -> nameAlternatives(s).stream().anyMatch(s1 -> s1.equalsIgnoreCase(name)))
|
||||||
|| d.getId().equalsIgnoreCase(name))
|
|| d.getId().equalsIgnoreCase(name))
|
||||||
.findAny();
|
.findAny();
|
||||||
}
|
}
|
||||||
|
@ -139,7 +139,8 @@ public class DataSourceProviders {
|
||||||
String.join("-", split),
|
String.join("-", split),
|
||||||
split.stream()
|
split.stream()
|
||||||
.map(s -> s.equals(split.get(0)) ? s : s.substring(0, 1).toUpperCase() + s.substring(1))
|
.map(s -> s.equals(split.get(0)) ? s : s.substring(0, 1).toUpperCase() + s.substring(1))
|
||||||
.collect(Collectors.joining()));
|
.collect(Collectors.joining())
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Optional<DataSourceProvider<?>> byPreferredStore(DataStore store, DataSourceType type) {
|
public static Optional<DataSourceProvider<?>> byPreferredStore(DataStore store, DataSourceType type) {
|
||||||
|
|
|
@ -16,16 +16,16 @@ public interface DataStoreActionProvider<T extends DataStore> {
|
||||||
public static void init(ModuleLayer layer) {
|
public static void init(ModuleLayer layer) {
|
||||||
if (ALL.size() == 0) {
|
if (ALL.size() == 0) {
|
||||||
ALL.addAll(ServiceLoader.load(layer, DataStoreActionProvider.class).stream()
|
ALL.addAll(ServiceLoader.load(layer, DataStoreActionProvider.class).stream()
|
||||||
.map(p -> (DataStoreActionProvider<?>) p.get())
|
.map(p -> (DataStoreActionProvider<?>) p.get())
|
||||||
.filter(provider -> {
|
.filter(provider -> {
|
||||||
try {
|
try {
|
||||||
return provider.isActive();
|
return provider.isActive();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
ErrorEvent.fromThrowable(e).handle();
|
ErrorEvent.fromThrowable(e).handle();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.toList());
|
.toList());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,11 +43,13 @@ public interface DataStoreActionProvider<T extends DataStore> {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
default void applyToRegion(T store, Region region) {}
|
default void applyToRegion(T store, Region region) {
|
||||||
|
}
|
||||||
|
|
||||||
ObservableValue<String> getName(T store);
|
ObservableValue<String> getName(T store);
|
||||||
|
|
||||||
String getIcon(T store);
|
String getIcon(T store);
|
||||||
|
|
||||||
default void execute(T store) throws Exception {}
|
default void execute(T store) throws Exception {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,8 @@ public class DataStoreProviders {
|
||||||
String.join("-", split),
|
String.join("-", split),
|
||||||
split.stream()
|
split.stream()
|
||||||
.map(s -> s.equals(split.get(0)) ? s : s.substring(0, 1).toUpperCase() + s.substring(1))
|
.map(s -> s.equals(split.get(0)) ? s : s.substring(0, 1).toUpperCase() + s.substring(1))
|
||||||
.collect(Collectors.joining()));
|
.collect(Collectors.joining())
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
|
|
@ -2,7 +2,8 @@ package io.xpipe.extension;
|
||||||
|
|
||||||
public class ExtensionException extends RuntimeException {
|
public class ExtensionException extends RuntimeException {
|
||||||
|
|
||||||
public ExtensionException() {}
|
public ExtensionException() {
|
||||||
|
}
|
||||||
|
|
||||||
public ExtensionException(String message) {
|
public ExtensionException(String message) {
|
||||||
super(message);
|
super(message);
|
||||||
|
|
|
@ -23,8 +23,12 @@ public abstract class EventHandler {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle(ErrorEvent ee) {
|
public void handle(ErrorEvent ee) {
|
||||||
if (ee.getDescription() != null) System.err.println(ee.getDescription());
|
if (ee.getDescription() != null) {
|
||||||
if (ee.getThrowable() != null) ee.getThrowable().printStackTrace();
|
System.err.println(ee.getDescription());
|
||||||
|
}
|
||||||
|
if (ee.getThrowable() != null) {
|
||||||
|
ee.getThrowable().printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -42,13 +46,12 @@ public abstract class EventHandler {
|
||||||
public void handle(ErrorEvent ee) {
|
public void handle(ErrorEvent ee) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
private static EventHandler INSTANCE;
|
||||||
|
|
||||||
public static void set(EventHandler handler) {
|
public static void set(EventHandler handler) {
|
||||||
INSTANCE = handler;
|
INSTANCE = handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static EventHandler INSTANCE;
|
|
||||||
|
|
||||||
private static void init() {
|
private static void init() {
|
||||||
if (INSTANCE == null) {
|
if (INSTANCE == null) {
|
||||||
INSTANCE = ServiceLoader.load(EventHandler.class).findFirst().orElse(DEFAULT);
|
INSTANCE = ServiceLoader.load(EventHandler.class).findFirst().orElse(DEFAULT);
|
||||||
|
|
|
@ -14,22 +14,20 @@ import java.util.stream.Collectors;
|
||||||
@Getter
|
@Getter
|
||||||
public class TrackEvent {
|
public class TrackEvent {
|
||||||
|
|
||||||
public static TrackEventBuilder storage() {
|
|
||||||
return TrackEvent.builder().category("storage");
|
|
||||||
}
|
|
||||||
|
|
||||||
private final Thread thread = Thread.currentThread();
|
private final Thread thread = Thread.currentThread();
|
||||||
private final Instant instant = Instant.now();
|
private final Instant instant = Instant.now();
|
||||||
private String type;
|
private String type;
|
||||||
private String message;
|
private String message;
|
||||||
private String category;
|
private String category;
|
||||||
|
|
||||||
@Singular
|
@Singular
|
||||||
private Map<String, Object> tags;
|
private Map<String, Object> tags;
|
||||||
|
|
||||||
@Singular
|
@Singular
|
||||||
private List<Object> elements;
|
private List<Object> elements;
|
||||||
|
|
||||||
|
public static TrackEventBuilder storage() {
|
||||||
|
return TrackEvent.builder().category("storage");
|
||||||
|
}
|
||||||
|
|
||||||
public static TrackEventBuilder fromMessage(String type, String message) {
|
public static TrackEventBuilder fromMessage(String type, String message) {
|
||||||
return builder().type(type).message(message);
|
return builder().type(type).message(message);
|
||||||
}
|
}
|
||||||
|
@ -115,10 +113,10 @@ public class TrackEvent {
|
||||||
var valueString = e.getValue() != null ? e.getValue().toString() : "null";
|
var valueString = e.getValue() != null ? e.getValue().toString() : "null";
|
||||||
var value = valueString.contains("\n")
|
var value = valueString.contains("\n")
|
||||||
? "\n"
|
? "\n"
|
||||||
+ (valueString.toString()
|
+ (valueString.toString()
|
||||||
.lines()
|
.lines()
|
||||||
.map(line -> " | " + line)
|
.map(line -> " | " + line)
|
||||||
.collect(Collectors.joining("\n")))
|
.collect(Collectors.joining("\n")))
|
||||||
: valueString;
|
: valueString;
|
||||||
s.append(" ")
|
s.append(" ")
|
||||||
.append(e.getKey())
|
.append(e.getKey())
|
||||||
|
|
|
@ -20,7 +20,8 @@ public class CharChoiceComp extends Comp<CompStructure<HBox>> {
|
||||||
public CharChoiceComp(
|
public CharChoiceComp(
|
||||||
Property<Character> value,
|
Property<Character> value,
|
||||||
Map<Character, ObservableValue<String>> range,
|
Map<Character, ObservableValue<String>> range,
|
||||||
ObservableValue<String> customName) {
|
ObservableValue<String> customName
|
||||||
|
) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
this.range = range;
|
this.range = range;
|
||||||
this.customName = customName;
|
this.customName = customName;
|
||||||
|
|
|
@ -22,10 +22,11 @@ public class CharsetChoiceComp extends SimpleComp {
|
||||||
charset,
|
charset,
|
||||||
streamCharset -> {
|
streamCharset -> {
|
||||||
return new Label(streamCharset.getCharset().displayName()
|
return new Label(streamCharset.getCharset().displayName()
|
||||||
+ (streamCharset.hasByteOrderMark() ? " (BOM)" : ""));
|
+ (streamCharset.hasByteOrderMark() ? " (BOM)" : ""));
|
||||||
},
|
},
|
||||||
new Label(I18n.get("extension.none")),
|
new Label(I18n.get("extension.none")),
|
||||||
null);
|
null
|
||||||
|
);
|
||||||
builder.addFilter((charset, filter) -> {
|
builder.addFilter((charset, filter) -> {
|
||||||
return charset.getCharset().displayName().contains(filter);
|
return charset.getCharset().displayName().contains(filter);
|
||||||
});
|
});
|
||||||
|
@ -38,7 +39,7 @@ public class CharsetChoiceComp extends SimpleComp {
|
||||||
for (var e : StreamCharset.RARE) {
|
for (var e : StreamCharset.RARE) {
|
||||||
builder.add(e);
|
builder.add(e);
|
||||||
}
|
}
|
||||||
var comboBox = builder.build();
|
var comboBox = builder.build();
|
||||||
comboBox.setVisibleRowCount(16);
|
comboBox.setVisibleRowCount(16);
|
||||||
return comboBox;
|
return comboBox;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,10 @@ import lombok.experimental.FieldDefaults;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE)
|
@FieldDefaults(
|
||||||
|
makeFinal = true,
|
||||||
|
level = AccessLevel.PRIVATE
|
||||||
|
)
|
||||||
public class ChoiceComp<T> extends Comp<CompStructure<ComboBox<T>>> {
|
public class ChoiceComp<T> extends Comp<CompStructure<ComboBox<T>>> {
|
||||||
|
|
||||||
Property<T> value;
|
Property<T> value;
|
||||||
|
|
|
@ -20,7 +20,10 @@ import lombok.experimental.FieldDefaults;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
@FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE)
|
@FieldDefaults(
|
||||||
|
makeFinal = true,
|
||||||
|
level = AccessLevel.PRIVATE
|
||||||
|
)
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class ChoicePaneComp extends Comp<CompStructure<VBox>> {
|
public class ChoicePaneComp extends Comp<CompStructure<VBox>> {
|
||||||
|
|
||||||
|
@ -75,5 +78,6 @@ public class ChoicePaneComp extends Comp<CompStructure<VBox>> {
|
||||||
return new SimpleCompStructure<>(vbox);
|
return new SimpleCompStructure<>(vbox);
|
||||||
}
|
}
|
||||||
|
|
||||||
public record Entry(ObservableValue<String> name, Comp<?> comp) {}
|
public record Entry(ObservableValue<String> name, Comp<?> comp) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -120,7 +120,9 @@ public record CodeSnippet(List<CodeSnippet.Line> lines) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public record Line(List<CodeSnippet.Element> elements) {}
|
public record Line(List<CodeSnippet.Element> elements) {
|
||||||
|
}
|
||||||
|
|
||||||
public record ColorScheme(Color keyword, Color identifier, Color type, Color string) {}
|
public record ColorScheme(Color keyword, Color identifier, Color type, Color string) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,7 +104,8 @@ public class DynamicOptionsComp extends Comp<CompStructure<Pane>> {
|
||||||
.orElse(0.0);
|
.orElse(0.0);
|
||||||
return m;
|
return m;
|
||||||
},
|
},
|
||||||
compRegions.stream().map(Region::widthProperty).toList().toArray(new Observable[0]));
|
compRegions.stream().map(Region::widthProperty).toList().toArray(new Observable[0])
|
||||||
|
);
|
||||||
compRegions.forEach(r -> r.prefWidthProperty().bind(compWidthBinding));
|
compRegions.forEach(r -> r.prefWidthProperty().bind(compWidthBinding));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,7 +122,8 @@ public class DynamicOptionsComp extends Comp<CompStructure<Pane>> {
|
||||||
.orElse(0.0);
|
.orElse(0.0);
|
||||||
return m;
|
return m;
|
||||||
},
|
},
|
||||||
nameRegions.stream().map(Region::widthProperty).toList().toArray(new Observable[0]));
|
nameRegions.stream().map(Region::widthProperty).toList().toArray(new Observable[0])
|
||||||
|
);
|
||||||
nameRegions.forEach(r -> r.prefWidthProperty().bind(nameWidthBinding));
|
nameRegions.forEach(r -> r.prefWidthProperty().bind(nameWidthBinding));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,5 +134,6 @@ public class DynamicOptionsComp extends Comp<CompStructure<Pane>> {
|
||||||
return entries;
|
return entries;
|
||||||
}
|
}
|
||||||
|
|
||||||
public record Entry(String key, ObservableValue<String> name, Comp<?> comp) {}
|
public record Entry(String key, ObservableValue<String> name, Comp<?> comp) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,36 @@ import javafx.util.Duration;
|
||||||
public class FancyTooltipAugment<S extends CompStructure<?>> implements Augment<S> {
|
public class FancyTooltipAugment<S extends CompStructure<?>> implements Augment<S> {
|
||||||
|
|
||||||
private static final TooltipBehavior BEHAVIOR = new TooltipBehavior(Duration.millis(400), Duration.INDEFINITE, Duration.millis(100));
|
private static final TooltipBehavior BEHAVIOR = new TooltipBehavior(Duration.millis(400), Duration.INDEFINITE, Duration.millis(100));
|
||||||
|
private final ObservableValue<String> text;
|
||||||
|
|
||||||
|
public FancyTooltipAugment(ObservableValue<String> text) {
|
||||||
|
this.text = PlatformThread.sync(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
public FancyTooltipAugment(String key) {
|
||||||
|
this.text = I18n.observable(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void augment(S struc) {
|
||||||
|
augment(struc.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void augment(Node region) {
|
||||||
|
var tt = new JFXTooltip();
|
||||||
|
var toDisplay = text.getValue();
|
||||||
|
if (Shortcuts.getShortcut((Region) region) != null) {
|
||||||
|
toDisplay =
|
||||||
|
toDisplay + " (" + Shortcuts.getShortcut((Region) region).getDisplayText() + ")";
|
||||||
|
}
|
||||||
|
tt.textProperty().setValue(toDisplay);
|
||||||
|
tt.setStyle("-fx-font-size: 11pt;");
|
||||||
|
tt.setWrapText(true);
|
||||||
|
tt.setMaxWidth(400);
|
||||||
|
tt.getStyleClass().add("fancy-tooltip");
|
||||||
|
|
||||||
|
BEHAVIOR.install(region, tt);
|
||||||
|
}
|
||||||
|
|
||||||
private static class TooltipBehavior {
|
private static class TooltipBehavior {
|
||||||
|
|
||||||
|
@ -37,10 +67,40 @@ public class FancyTooltipAugment<S extends CompStructure<?>> implements Augment<
|
||||||
* the next tooltip to be shown
|
* the next tooltip to be shown
|
||||||
*/
|
*/
|
||||||
private JFXTooltip nextTooltip;
|
private JFXTooltip nextTooltip;
|
||||||
|
private final EventHandler<MouseEvent> exitHandler = (MouseEvent event) -> {
|
||||||
|
// stop running hover timer as the mouse exited the node
|
||||||
|
if (hoverTimer.getStatus() == Timeline.Status.RUNNING) {
|
||||||
|
hoverTimer.stop();
|
||||||
|
} else if (visibleTimer.getStatus() == Timeline.Status.RUNNING) {
|
||||||
|
// if tool tip was already showing, stop the visible timer
|
||||||
|
// and start the left timer to hide the current tooltip
|
||||||
|
visibleTimer.stop();
|
||||||
|
leftTimer.playFromStart();
|
||||||
|
}
|
||||||
|
hoveredNode = null;
|
||||||
|
nextTooltip = null;
|
||||||
|
};
|
||||||
|
private final WeakEventHandler<MouseEvent> weakExitHandler = new WeakEventHandler<>(exitHandler);
|
||||||
/**
|
/**
|
||||||
* the current showing tooltip
|
* the current showing tooltip
|
||||||
*/
|
*/
|
||||||
private JFXTooltip currentTooltip;
|
private JFXTooltip currentTooltip;
|
||||||
|
// if mouse is pressed then stop all timers / clear all fields
|
||||||
|
private final EventHandler<MouseEvent> pressedHandler = (MouseEvent event) -> {
|
||||||
|
// stop timers
|
||||||
|
hoverTimer.stop();
|
||||||
|
visibleTimer.stop();
|
||||||
|
leftTimer.stop();
|
||||||
|
// hide current tooltip
|
||||||
|
if (currentTooltip != null) {
|
||||||
|
currentTooltip.hide();
|
||||||
|
}
|
||||||
|
// clear fields
|
||||||
|
hoveredNode = null;
|
||||||
|
currentTooltip = null;
|
||||||
|
nextTooltip = null;
|
||||||
|
};
|
||||||
|
private final WeakEventHandler<MouseEvent> weakPressedHandler = new WeakEventHandler<>(pressedHandler);
|
||||||
|
|
||||||
private TooltipBehavior(Duration hoverDelay, Duration visibleDuration, Duration leftDelay) {
|
private TooltipBehavior(Duration hoverDelay, Duration visibleDuration, Duration leftDelay) {
|
||||||
setHoverDelay(hoverDelay);
|
setHoverDelay(hoverDelay);
|
||||||
|
@ -71,24 +131,7 @@ public class FancyTooltipAugment<S extends CompStructure<?>> implements Augment<
|
||||||
|
|
||||||
private void setVisibleDuration(Duration duration) {
|
private void setVisibleDuration(Duration duration) {
|
||||||
visibleTimer.getKeyFrames().setAll(new KeyFrame(duration));
|
visibleTimer.getKeyFrames().setAll(new KeyFrame(duration));
|
||||||
}
|
} private final EventHandler<MouseEvent> moveHandler = (MouseEvent event) -> {
|
||||||
|
|
||||||
private void setLeftDelay(Duration duration) {
|
|
||||||
leftTimer.getKeyFrames().setAll(new KeyFrame(duration));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void hideCurrentTooltip() {
|
|
||||||
currentTooltip.hide();
|
|
||||||
currentTooltip = null;
|
|
||||||
hoveredNode = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void showTooltip(JFXTooltip tooltip) {
|
|
||||||
// anchors are computed differently for each tooltip
|
|
||||||
tooltip.show(hoveredNode, -1, -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
private final EventHandler<MouseEvent> moveHandler = (MouseEvent event) -> {
|
|
||||||
// if tool tip is already showing, do nothing
|
// if tool tip is already showing, do nothing
|
||||||
if (visibleTimer.getStatus() == Timeline.Status.RUNNING) {
|
if (visibleTimer.getStatus() == Timeline.Status.RUNNING) {
|
||||||
return;
|
return;
|
||||||
|
@ -123,39 +166,21 @@ public class FancyTooltipAugment<S extends CompStructure<?>> implements Augment<
|
||||||
uninstall(hoveredNode);
|
uninstall(hoveredNode);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
private final WeakEventHandler<MouseEvent> weakMoveHandler = new WeakEventHandler<>(moveHandler);
|
|
||||||
|
|
||||||
private final EventHandler<MouseEvent> exitHandler = (MouseEvent event) -> {
|
private void setLeftDelay(Duration duration) {
|
||||||
// stop running hover timer as the mouse exited the node
|
leftTimer.getKeyFrames().setAll(new KeyFrame(duration));
|
||||||
if (hoverTimer.getStatus() == Timeline.Status.RUNNING) {
|
} private final WeakEventHandler<MouseEvent> weakMoveHandler = new WeakEventHandler<>(moveHandler);
|
||||||
hoverTimer.stop();
|
|
||||||
} else if (visibleTimer.getStatus() == Timeline.Status.RUNNING) {
|
|
||||||
// if tool tip was already showing, stop the visible timer
|
|
||||||
// and start the left timer to hide the current tooltip
|
|
||||||
visibleTimer.stop();
|
|
||||||
leftTimer.playFromStart();
|
|
||||||
}
|
|
||||||
hoveredNode = null;
|
|
||||||
nextTooltip = null;
|
|
||||||
};
|
|
||||||
private final WeakEventHandler<MouseEvent> weakExitHandler = new WeakEventHandler<>(exitHandler);
|
|
||||||
|
|
||||||
// if mouse is pressed then stop all timers / clear all fields
|
private void hideCurrentTooltip() {
|
||||||
private final EventHandler<MouseEvent> pressedHandler = (MouseEvent event) -> {
|
currentTooltip.hide();
|
||||||
// stop timers
|
|
||||||
hoverTimer.stop();
|
|
||||||
visibleTimer.stop();
|
|
||||||
leftTimer.stop();
|
|
||||||
// hide current tooltip
|
|
||||||
if (currentTooltip != null) {
|
|
||||||
currentTooltip.hide();
|
|
||||||
}
|
|
||||||
// clear fields
|
|
||||||
hoveredNode = null;
|
|
||||||
currentTooltip = null;
|
currentTooltip = null;
|
||||||
nextTooltip = null;
|
hoveredNode = null;
|
||||||
};
|
}
|
||||||
private final WeakEventHandler<MouseEvent> weakPressedHandler = new WeakEventHandler<>(pressedHandler);
|
|
||||||
|
private void showTooltip(JFXTooltip tooltip) {
|
||||||
|
// anchors are computed differently for each tooltip
|
||||||
|
tooltip.show(hoveredNode, -1, -1);
|
||||||
|
}
|
||||||
|
|
||||||
private void install(Node node, JFXTooltip tooltip) {
|
private void install(Node node, JFXTooltip tooltip) {
|
||||||
if (node == null) {
|
if (node == null) {
|
||||||
|
@ -204,36 +229,9 @@ public class FancyTooltipAugment<S extends CompStructure<?>> implements Augment<
|
||||||
final Scene scene = node == null ? null : node.getScene();
|
final Scene scene = node == null ? null : node.getScene();
|
||||||
return scene == null ? null : scene.getWindow();
|
return scene == null ? null : scene.getWindow();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private final ObservableValue<String> text;
|
|
||||||
|
|
||||||
public FancyTooltipAugment(ObservableValue<String> text) {
|
|
||||||
this.text = PlatformThread.sync(text);
|
|
||||||
}
|
|
||||||
|
|
||||||
public FancyTooltipAugment(String key) {
|
|
||||||
this.text = I18n.observable(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void augment(S struc) {
|
|
||||||
augment(struc.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void augment(Node region) {
|
|
||||||
var tt = new JFXTooltip();
|
|
||||||
var toDisplay = text.getValue();
|
|
||||||
if (Shortcuts.getShortcut((Region) region) != null) {
|
|
||||||
toDisplay =
|
|
||||||
toDisplay + " (" + Shortcuts.getShortcut((Region) region).getDisplayText() + ")";
|
|
||||||
}
|
|
||||||
tt.textProperty().setValue(toDisplay);
|
|
||||||
tt.setStyle("-fx-font-size: 11pt;");
|
|
||||||
tt.setWrapText(true);
|
|
||||||
tt.setMaxWidth(400);
|
|
||||||
tt.getStyleClass().add("fancy-tooltip");
|
|
||||||
|
|
||||||
BEHAVIOR.install(region, tt);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,10 @@ import javafx.scene.input.KeyEvent;
|
||||||
import lombok.AccessLevel;
|
import lombok.AccessLevel;
|
||||||
import lombok.experimental.FieldDefaults;
|
import lombok.experimental.FieldDefaults;
|
||||||
|
|
||||||
@FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE)
|
@FieldDefaults(
|
||||||
|
makeFinal = true,
|
||||||
|
level = AccessLevel.PRIVATE
|
||||||
|
)
|
||||||
public class IntFieldComp extends Comp<CompStructure<TextField>> {
|
public class IntFieldComp extends Comp<CompStructure<TextField>> {
|
||||||
|
|
||||||
Property<Integer> value;
|
Property<Integer> value;
|
||||||
|
|
|
@ -37,7 +37,8 @@ public class PrettyImageComp extends SimpleComp {
|
||||||
return height * aspectRatioProperty.doubleValue();
|
return height * aspectRatioProperty.doubleValue();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
aspectRatioProperty);
|
aspectRatioProperty
|
||||||
|
);
|
||||||
var heightProperty = Bindings.createDoubleBinding(
|
var heightProperty = Bindings.createDoubleBinding(
|
||||||
() -> {
|
() -> {
|
||||||
boolean widthLimited = width / height < aspectRatioProperty.doubleValue();
|
boolean widthLimited = width / height < aspectRatioProperty.doubleValue();
|
||||||
|
@ -47,7 +48,8 @@ public class PrettyImageComp extends SimpleComp {
|
||||||
return height;
|
return height;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
aspectRatioProperty);
|
aspectRatioProperty
|
||||||
|
);
|
||||||
|
|
||||||
Node node;
|
Node node;
|
||||||
|
|
||||||
|
@ -60,7 +62,8 @@ public class PrettyImageComp extends SimpleComp {
|
||||||
/ storeIcon.getHeight().getValue().doubleValue();
|
/ storeIcon.getHeight().getValue().doubleValue();
|
||||||
},
|
},
|
||||||
storeIcon.getWidth(),
|
storeIcon.getWidth(),
|
||||||
storeIcon.getHeight()));
|
storeIcon.getHeight()
|
||||||
|
));
|
||||||
node = storeIcon.createWebview();
|
node = storeIcon.createWebview();
|
||||||
((WebView) node).prefWidthProperty().bind(widthProperty);
|
((WebView) node).prefWidthProperty().bind(widthProperty);
|
||||||
((WebView) node).maxWidthProperty().bind(widthProperty);
|
((WebView) node).maxWidthProperty().bind(widthProperty);
|
||||||
|
@ -78,7 +81,8 @@ public class PrettyImageComp extends SimpleComp {
|
||||||
aspectRatioProperty.set(image.getWidth() / image.getHeight());
|
aspectRatioProperty.set(image.getWidth() / image.getHeight());
|
||||||
return image;
|
return image;
|
||||||
},
|
},
|
||||||
PlatformThread.sync(value)));
|
PlatformThread.sync(value)
|
||||||
|
));
|
||||||
storeIcon.fitWidthProperty().bind(widthProperty);
|
storeIcon.fitWidthProperty().bind(widthProperty);
|
||||||
storeIcon.fitHeightProperty().bind(heightProperty);
|
storeIcon.fitHeightProperty().bind(heightProperty);
|
||||||
storeIcon.setSmooth(true);
|
storeIcon.setSmooth(true);
|
||||||
|
|
|
@ -76,9 +76,9 @@ public class ShellStoreChoiceComp<T extends ShellStore> extends SimpleComp {
|
||||||
});
|
});
|
||||||
|
|
||||||
var available = XPipeDaemon.getInstance().getNamedStores().stream()
|
var available = XPipeDaemon.getInstance().getNamedStores().stream()
|
||||||
.filter(s -> s != self)
|
.filter(s -> s != self)
|
||||||
.filter(s -> storeClass.isAssignableFrom(s.getClass()) && applicableCheck.test((T) s))
|
.filter(s -> storeClass.isAssignableFrom(s.getClass()) && applicableCheck.test((T) s))
|
||||||
.map(s -> (ShellStore) s)
|
.map(s -> (ShellStore) s)
|
||||||
.toList();
|
.toList();
|
||||||
available.forEach(s -> comboBox.add((T) s));
|
available.forEach(s -> comboBox.add((T) s));
|
||||||
ComboBox<Node> cb = comboBox.build();
|
ComboBox<Node> cb = comboBox.build();
|
||||||
|
|
|
@ -40,7 +40,8 @@ public class SvgComp {
|
||||||
return new Size(
|
return new Size(
|
||||||
Double.parseDouble(string.substring(
|
Double.parseDouble(string.substring(
|
||||||
0, string.length() - unit.toString().length())),
|
0, string.length() - unit.toString().length())),
|
||||||
unit);
|
unit
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new Size(Double.parseDouble(string), SizeUnits.PX);
|
return new Size(Double.parseDouble(string), SizeUnits.PX);
|
||||||
|
@ -96,7 +97,8 @@ public class SvgComp {
|
||||||
return wv.getWidth() / width.getValue().doubleValue();
|
return wv.getWidth() / width.getValue().doubleValue();
|
||||||
},
|
},
|
||||||
wv.widthProperty(),
|
wv.widthProperty(),
|
||||||
width));
|
width
|
||||||
|
));
|
||||||
|
|
||||||
wv.maxWidthProperty().bind(wv.prefWidthProperty());
|
wv.maxWidthProperty().bind(wv.prefWidthProperty());
|
||||||
wv.maxHeightProperty().bind(wv.prefHeightProperty());
|
wv.maxHeightProperty().bind(wv.prefHeightProperty());
|
||||||
|
|
|
@ -20,6 +20,7 @@ public class TabPaneComp extends Comp<CompStructure<JFXTabPane>> {
|
||||||
|
|
||||||
private final Property<Entry> selected;
|
private final Property<Entry> selected;
|
||||||
private final List<Entry> entries;
|
private final List<Entry> entries;
|
||||||
|
|
||||||
public TabPaneComp(Property<Entry> selected, List<Entry> entries) {
|
public TabPaneComp(Property<Entry> selected, List<Entry> entries) {
|
||||||
this.selected = selected;
|
this.selected = selected;
|
||||||
this.entries = entries;
|
this.entries = entries;
|
||||||
|
@ -59,5 +60,6 @@ public class TabPaneComp extends Comp<CompStructure<JFXTabPane>> {
|
||||||
return new SimpleCompStructure<>(tabPane);
|
return new SimpleCompStructure<>(tabPane);
|
||||||
}
|
}
|
||||||
|
|
||||||
public record Entry(ObservableValue<String> name, String graphic, Comp<?> comp) {}
|
public record Entry(ObservableValue<String> name, String graphic, Comp<?> comp) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,7 @@ public class TextAreaComp extends SimpleComp {
|
||||||
var isEqual = Bindings.createBooleanBinding(() -> Objects.equals(lazyValue.getValue(), value.getValue()), value, lazyValue);
|
var isEqual = Bindings.createBooleanBinding(() -> Objects.equals(lazyValue.getValue(), value.getValue()), value, lazyValue);
|
||||||
var button = new IconButtonComp("mdi2c-checkbox-marked-outline").hide(isEqual).createRegion();
|
var button = new IconButtonComp("mdi2c-checkbox-marked-outline").hide(isEqual).createRegion();
|
||||||
var anchorPane = new AnchorPane(text, button);
|
var anchorPane = new AnchorPane(text, button);
|
||||||
AnchorPane.setBottomAnchor(button, 5.0 );
|
AnchorPane.setBottomAnchor(button, 5.0);
|
||||||
AnchorPane.setRightAnchor(button, 5.0);
|
AnchorPane.setRightAnchor(button, 5.0);
|
||||||
|
|
||||||
text.prefWidthProperty().bind(anchorPane.widthProperty());
|
text.prefWidthProperty().bind(anchorPane.widthProperty());
|
||||||
|
|
|
@ -64,7 +64,9 @@ public class ToggleGroupComp<T> extends Comp<CompStructure<HBox>> {
|
||||||
});
|
});
|
||||||
|
|
||||||
group.selectedToggleProperty().addListener((obsVal, oldVal, newVal) -> {
|
group.selectedToggleProperty().addListener((obsVal, oldVal, newVal) -> {
|
||||||
if (newVal == null) oldVal.setSelected(true);
|
if (newVal == null) {
|
||||||
|
oldVal.setSelected(true);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return new SimpleCompStructure<>(box);
|
return new SimpleCompStructure<>(box);
|
||||||
|
|
|
@ -43,13 +43,13 @@ public class WriteModeChoiceComp extends SimpleComp implements Validatable {
|
||||||
var a = available;
|
var a = available;
|
||||||
Property<Map<WriteMode, ObservableValue<String>>> map = new SimpleObjectProperty<>(new LinkedHashMap<WriteMode, ObservableValue<String>>());
|
Property<Map<WriteMode, ObservableValue<String>>> map = new SimpleObjectProperty<>(new LinkedHashMap<WriteMode, ObservableValue<String>>());
|
||||||
for (WriteMode writeMode : a) {
|
for (WriteMode writeMode : a) {
|
||||||
map.getValue().put(writeMode,I18n.observable(writeMode.getId()));
|
map.getValue().put(writeMode, I18n.observable(writeMode.getId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
PlatformThread.sync(available).addListener((ListChangeListener<? super WriteMode>) c -> {
|
PlatformThread.sync(available).addListener((ListChangeListener<? super WriteMode>) c -> {
|
||||||
var newMap = new LinkedHashMap<WriteMode, ObservableValue<String>>();
|
var newMap = new LinkedHashMap<WriteMode, ObservableValue<String>>();
|
||||||
for (WriteMode writeMode : c.getList()) {
|
for (WriteMode writeMode : c.getList()) {
|
||||||
newMap.put(writeMode,I18n.observable(writeMode.getId()));
|
newMap.put(writeMode, I18n.observable(writeMode.getId()));
|
||||||
}
|
}
|
||||||
map.setValue(newMap);
|
map.setValue(newMap);
|
||||||
|
|
||||||
|
|
|
@ -20,8 +20,9 @@ public class BindingsHelper {
|
||||||
public static <T extends Binding<?>> T persist(T binding) {
|
public static <T extends Binding<?>> T persist(T binding) {
|
||||||
var dependencies = new HashSet<ObservableValue<?>>();
|
var dependencies = new HashSet<ObservableValue<?>>();
|
||||||
while (dependencies.addAll(binding.getDependencies().stream()
|
while (dependencies.addAll(binding.getDependencies().stream()
|
||||||
.map(o -> (ObservableValue<?>) o)
|
.map(o -> (ObservableValue<?>) o)
|
||||||
.toList())) {}
|
.toList())) {
|
||||||
|
}
|
||||||
dependencies.add(binding);
|
dependencies.add(binding);
|
||||||
BINDINGS.put(new WeakReference<>(binding), dependencies);
|
BINDINGS.put(new WeakReference<>(binding), dependencies);
|
||||||
return binding;
|
return binding;
|
||||||
|
|
|
@ -39,7 +39,7 @@ public interface PrefsChoiceValue extends Translatable {
|
||||||
throw new AssertionError();
|
throw new AssertionError();
|
||||||
}
|
}
|
||||||
|
|
||||||
return all.stream().filter(t -> ((PrefsChoiceValue)t).isSupported()).toList();
|
return all.stream().filter(t -> ((PrefsChoiceValue) t).isSupported()).toList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,5 +6,5 @@ import java.util.List;
|
||||||
|
|
||||||
public interface PrefsHandler {
|
public interface PrefsHandler {
|
||||||
|
|
||||||
void addSetting(List<String> category, String group, Setting<?,?> setting, Class<?> c);
|
void addSetting(List<String> category, String group, Setting<?, ?> setting, Class<?> c);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,11 +9,6 @@ import java.util.stream.Collectors;
|
||||||
|
|
||||||
public abstract class PrefsProvider {
|
public abstract class PrefsProvider {
|
||||||
|
|
||||||
protected <T extends Field<?>> T editable(T o, ObservableBooleanValue v) {
|
|
||||||
o.editableProperty().bind(v);
|
|
||||||
return o;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Set<PrefsProvider> ALL;
|
private static Set<PrefsProvider> ALL;
|
||||||
|
|
||||||
public static void init(ModuleLayer layer) {
|
public static void init(ModuleLayer layer) {
|
||||||
|
@ -33,5 +28,10 @@ public abstract class PrefsProvider {
|
||||||
return (T) ALL.stream().filter(prefsProvider -> prefsProvider.getClass().equals(c)).findAny().orElseThrow();
|
return (T) ALL.stream().filter(prefsProvider -> prefsProvider.getClass().equals(c)).findAny().orElseThrow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected <T extends Field<?>> T editable(T o, ObservableBooleanValue v) {
|
||||||
|
o.editableProperty().bind(v);
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
|
||||||
public abstract void addPrefs(PrefsHandler handler);
|
public abstract void addPrefs(PrefsHandler handler);
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,6 +104,7 @@ public class ChainedValidator implements Validator {
|
||||||
.map(v -> v.createStringBinding(prefix, separator).get())
|
.map(v -> v.createStringBinding(prefix, separator).get())
|
||||||
.collect(Collectors.joining("\n"));
|
.collect(Collectors.joining("\n"));
|
||||||
},
|
},
|
||||||
observables);
|
observables
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,8 @@ public class CustomComboBoxBuilder<T> {
|
||||||
private Node filterNode;
|
private Node filterNode;
|
||||||
|
|
||||||
public CustomComboBoxBuilder(
|
public CustomComboBoxBuilder(
|
||||||
Property<T> selected, Function<T, Node> nodeFunction, Node emptyNode, Predicate<T> veto) {
|
Property<T> selected, Function<T, Node> nodeFunction, Node emptyNode, Predicate<T> veto
|
||||||
|
) {
|
||||||
this.selected = selected;
|
this.selected = selected;
|
||||||
this.nodeFunction = nodeFunction;
|
this.nodeFunction = nodeFunction;
|
||||||
this.emptyNode = emptyNode;
|
this.emptyNode = emptyNode;
|
||||||
|
@ -122,9 +123,9 @@ public class CustomComboBoxBuilder<T> {
|
||||||
var filteredNodes = nodes.stream()
|
var filteredNodes = nodes.stream()
|
||||||
.filter(e -> e.equals(cb.getValue())
|
.filter(e -> e.equals(cb.getValue())
|
||||||
|| !(nodeMap.get(e) != null
|
|| !(nodeMap.get(e) != null
|
||||||
&& (filterable.contains(nodeMap.get(e))
|
&& (filterable.contains(nodeMap.get(e))
|
||||||
&& filterString.getValue() != null
|
&& filterString.getValue() != null
|
||||||
&& !filterPredicate.test(nodeMap.get(e), c))))
|
&& !filterPredicate.test(nodeMap.get(e), c))))
|
||||||
.toList();
|
.toList();
|
||||||
cb.setItems(FXCollections.observableList(filteredNodes));
|
cb.setItems(FXCollections.observableList(filteredNodes));
|
||||||
});
|
});
|
||||||
|
|
|
@ -92,7 +92,8 @@ public class DataStoreFormatter {
|
||||||
var lengthShare = (length - 3) / 2;
|
var lengthShare = (length - 3) / 2;
|
||||||
return String.format(
|
return String.format(
|
||||||
"%s.%s",
|
"%s.%s",
|
||||||
DataStoreFormatter.cut(name, lengthShare), DataStoreFormatter.cut(region, length - lengthShare));
|
DataStoreFormatter.cut(name, lengthShare), DataStoreFormatter.cut(region, length - lengthShare)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return cut(input, length);
|
return cut(input, length);
|
||||||
|
|
|
@ -76,7 +76,8 @@ public class DynamicOptionsBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
public DynamicOptionsBuilder addCharacter(
|
public DynamicOptionsBuilder addCharacter(
|
||||||
Property<Character> prop, ObservableValue<String> name, Map<Character, ObservableValue<String>> names) {
|
Property<Character> prop, ObservableValue<String> name, Map<Character, ObservableValue<String>> names
|
||||||
|
) {
|
||||||
var comp = new CharChoiceComp(prop, names, null);
|
var comp = new CharChoiceComp(prop, names, null);
|
||||||
entries.add(new DynamicOptionsComp.Entry(null, name, comp));
|
entries.add(new DynamicOptionsComp.Entry(null, name, comp));
|
||||||
props.add(prop);
|
props.add(prop);
|
||||||
|
@ -87,23 +88,28 @@ public class DynamicOptionsBuilder {
|
||||||
Property<Character> prop,
|
Property<Character> prop,
|
||||||
ObservableValue<String> name,
|
ObservableValue<String> name,
|
||||||
Map<Character, ObservableValue<String>> names,
|
Map<Character, ObservableValue<String>> names,
|
||||||
ObservableValue<String> customName) {
|
ObservableValue<String> customName
|
||||||
|
) {
|
||||||
var comp = new CharChoiceComp(prop, names, customName);
|
var comp = new CharChoiceComp(prop, names, customName);
|
||||||
entries.add(new DynamicOptionsComp.Entry(null, name, comp));
|
entries.add(new DynamicOptionsComp.Entry(null, name, comp));
|
||||||
props.add(prop);
|
props.add(prop);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DynamicOptionsBuilder addToggle(String nameKey,
|
public DynamicOptionsBuilder addToggle(
|
||||||
Property<Boolean> prop) {
|
String nameKey,
|
||||||
var comp = new ToggleGroupComp<>(prop, new SimpleObjectProperty<>(Map.of(Boolean.TRUE, I18n.observable("extension.yes"), Boolean.FALSE, I18n.observable("extension.no"))));
|
Property<Boolean> prop
|
||||||
|
) {
|
||||||
|
var comp = new ToggleGroupComp<>(prop, new SimpleObjectProperty<>(
|
||||||
|
Map.of(Boolean.TRUE, I18n.observable("extension.yes"), Boolean.FALSE, I18n.observable("extension.no"))));
|
||||||
entries.add(new DynamicOptionsComp.Entry(nameKey, I18n.observable(nameKey), comp));
|
entries.add(new DynamicOptionsComp.Entry(nameKey, I18n.observable(nameKey), comp));
|
||||||
props.add(prop);
|
props.add(prop);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public <V> DynamicOptionsBuilder addToggle(
|
public <V> DynamicOptionsBuilder addToggle(
|
||||||
Property<V> prop, ObservableValue<String> name, Map<V, ObservableValue<String>> names) {
|
Property<V> prop, ObservableValue<String> name, Map<V, ObservableValue<String>> names
|
||||||
|
) {
|
||||||
var comp = new ToggleGroupComp<>(prop, new SimpleObjectProperty<>(names));
|
var comp = new ToggleGroupComp<>(prop, new SimpleObjectProperty<>(names));
|
||||||
entries.add(new DynamicOptionsComp.Entry(null, name, comp));
|
entries.add(new DynamicOptionsComp.Entry(null, name, comp));
|
||||||
props.add(prop);
|
props.add(prop);
|
||||||
|
@ -180,13 +186,17 @@ public class DynamicOptionsBuilder {
|
||||||
|
|
||||||
public DynamicOptionsBuilder addComp(String nameKey, Comp<?> comp, Property<?> prop) {
|
public DynamicOptionsBuilder addComp(String nameKey, Comp<?> comp, Property<?> prop) {
|
||||||
entries.add(new DynamicOptionsComp.Entry(nameKey, I18n.observable(nameKey), comp));
|
entries.add(new DynamicOptionsComp.Entry(nameKey, I18n.observable(nameKey), comp));
|
||||||
if (prop != null) props.add(prop);
|
if (prop != null) {
|
||||||
|
props.add(prop);
|
||||||
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DynamicOptionsBuilder addComp(ObservableValue<String> name, Comp<?> comp, Property<?> prop) {
|
public DynamicOptionsBuilder addComp(ObservableValue<String> name, Comp<?> comp, Property<?> prop) {
|
||||||
entries.add(new DynamicOptionsComp.Entry(null, name, comp));
|
entries.add(new DynamicOptionsComp.Entry(null, name, comp));
|
||||||
if (prop != null) props.add(prop);
|
if (prop != null) {
|
||||||
|
props.add(prop);
|
||||||
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,7 +241,8 @@ public class DynamicOptionsBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
public final <T, V extends T> DynamicOptionsBuilder bindChoice(
|
public final <T, V extends T> DynamicOptionsBuilder bindChoice(
|
||||||
Supplier<Property<? extends V>> creator, Property<T> toSet) {
|
Supplier<Property<? extends V>> creator, Property<T> toSet
|
||||||
|
) {
|
||||||
props.forEach(prop -> {
|
props.forEach(prop -> {
|
||||||
prop.addListener((c, o, n) -> {
|
prop.addListener((c, o, n) -> {
|
||||||
toSet.unbind();
|
toSet.unbind();
|
||||||
|
@ -247,7 +258,8 @@ public class DynamicOptionsBuilder {
|
||||||
entries.add(
|
entries.add(
|
||||||
0,
|
0,
|
||||||
new DynamicOptionsComp.Entry(
|
new DynamicOptionsComp.Entry(
|
||||||
null, null, Comp.of(() -> new Label(title.getValue())).styleClass("title-header")));
|
null, null, Comp.of(() -> new Label(title.getValue())).styleClass("title-header"))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return new DynamicOptionsComp(entries, wrap);
|
return new DynamicOptionsComp(entries, wrap);
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,6 +81,7 @@ public final class ExclusiveValidator<T> implements Validator {
|
||||||
() -> {
|
() -> {
|
||||||
return get().createStringBinding(prefix, separator).get();
|
return get().createStringBinding(prefix, separator).get();
|
||||||
},
|
},
|
||||||
observables);
|
observables
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ public class ExecScriptHelper {
|
||||||
return createExecScript(l, content);
|
return createExecScript(l, content);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
public static String createExecScript(ShellProcessControl processControl, String content) {
|
public static String createExecScript(ShellProcessControl processControl, String content) {
|
||||||
var fileName = "exec-" + getConnectionHash(content);
|
var fileName = "exec-" + getConnectionHash(content);
|
||||||
|
@ -35,7 +36,8 @@ public class ExecScriptHelper {
|
||||||
try (var c = processControl.command(processControl.getShellType()
|
try (var c = processControl.command(processControl.getShellType()
|
||||||
.joinCommands(
|
.joinCommands(
|
||||||
processControl.getShellType().createFileWriteCommand(file),
|
processControl.getShellType().createFileWriteCommand(file),
|
||||||
processControl.getShellType().getMakeExecutableCommand(file)))
|
processControl.getShellType().getMakeExecutableCommand(file)
|
||||||
|
))
|
||||||
.start()) {
|
.start()) {
|
||||||
c.discardOut();
|
c.discardOut();
|
||||||
c.discardErr();
|
c.discardErr();
|
||||||
|
|
|
@ -15,6 +15,7 @@ public class PrettyListView<T> extends ListView<T> {
|
||||||
|
|
||||||
private final ScrollBar vBar = new ScrollBar();
|
private final ScrollBar vBar = new ScrollBar();
|
||||||
private final ScrollBar hBar = new ScrollBar();
|
private final ScrollBar hBar = new ScrollBar();
|
||||||
|
|
||||||
public PrettyListView() {
|
public PrettyListView() {
|
||||||
super();
|
super();
|
||||||
skinProperty().addListener(it -> {
|
skinProperty().addListener(it -> {
|
||||||
|
@ -78,14 +79,16 @@ public class PrettyListView<T> extends ListView<T> {
|
||||||
w - prefWidth - insets.getRight(),
|
w - prefWidth - insets.getRight(),
|
||||||
insets.getTop(),
|
insets.getTop(),
|
||||||
prefWidth,
|
prefWidth,
|
||||||
h - insets.getTop() - insets.getBottom());
|
h - insets.getTop() - insets.getBottom()
|
||||||
|
);
|
||||||
|
|
||||||
final double prefHeight = hBar.prefHeight(-1);
|
final double prefHeight = hBar.prefHeight(-1);
|
||||||
hBar.resizeRelocate(
|
hBar.resizeRelocate(
|
||||||
insets.getLeft(),
|
insets.getLeft(),
|
||||||
h - prefHeight - insets.getBottom(),
|
h - prefHeight - insets.getBottom(),
|
||||||
w - insets.getLeft() - insets.getRight(),
|
w - insets.getLeft() - insets.getRight(),
|
||||||
prefHeight);
|
prefHeight
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class NoSelectionModel<T> extends MultipleSelectionModel<T> {
|
public static class NoSelectionModel<T> extends MultipleSelectionModel<T> {
|
||||||
|
@ -101,31 +104,40 @@ public class PrettyListView<T> extends ListView<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void selectIndices(int index, int... indices) {}
|
public void selectIndices(int index, int... indices) {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void selectAll() {}
|
public void selectAll() {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void selectFirst() {}
|
public void selectFirst() {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void selectLast() {}
|
public void selectLast() {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void clearAndSelect(int index) {}
|
public void clearAndSelect(int index) {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void select(int index) {}
|
public void select(int index) {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void select(T obj) {}
|
public void select(T obj) {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void clearSelection(int index) {}
|
public void clearSelection(int index) {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void clearSelection() {}
|
public void clearSelection() {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isSelected(int index) {
|
public boolean isSelected(int index) {
|
||||||
|
@ -138,9 +150,11 @@ public class PrettyListView<T> extends ListView<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void selectPrevious() {}
|
public void selectPrevious() {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void selectNext() {}
|
public void selectNext() {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -22,7 +22,9 @@ public class SimpleValidator implements Validator {
|
||||||
new ReadOnlyObjectWrapper<>(new ValidationResult());
|
new ReadOnlyObjectWrapper<>(new ValidationResult());
|
||||||
private final ReadOnlyBooleanWrapper containsErrorsProperty = new ReadOnlyBooleanWrapper();
|
private final ReadOnlyBooleanWrapper containsErrorsProperty = new ReadOnlyBooleanWrapper();
|
||||||
|
|
||||||
/** Create a check that lives within this checker's domain.
|
/**
|
||||||
|
* Create a check that lives within this checker's domain.
|
||||||
|
*
|
||||||
* @return A check object whose dependsOn, decorates, etc. methods can be called
|
* @return A check object whose dependsOn, decorates, etc. methods can be called
|
||||||
*/
|
*/
|
||||||
public Check createCheck() {
|
public Check createCheck() {
|
||||||
|
@ -31,7 +33,9 @@ public class SimpleValidator implements Validator {
|
||||||
return check;
|
return check;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Add another check to the checker. Changes in the check's validationResultProperty will be reflected in the checker.
|
/**
|
||||||
|
* Add another check to the checker. Changes in the check's validationResultProperty will be reflected in the checker.
|
||||||
|
*
|
||||||
* @param check The check to add.
|
* @param check The check to add.
|
||||||
*/
|
*/
|
||||||
public void add(Check check) {
|
public void add(Check check) {
|
||||||
|
@ -40,7 +44,9 @@ public class SimpleValidator implements Validator {
|
||||||
check.validationResultProperty().addListener(listener);
|
check.validationResultProperty().addListener(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Removes a check from this validator.
|
/**
|
||||||
|
* Removes a check from this validator.
|
||||||
|
*
|
||||||
* @param check The check to remove from this validator.
|
* @param check The check to remove from this validator.
|
||||||
*/
|
*/
|
||||||
public void remove(Check check) {
|
public void remove(Check check) {
|
||||||
|
@ -51,21 +57,27 @@ public class SimpleValidator implements Validator {
|
||||||
refreshProperties();
|
refreshProperties();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Retrieves current validation result
|
/**
|
||||||
|
* Retrieves current validation result
|
||||||
|
*
|
||||||
* @return validation result
|
* @return validation result
|
||||||
*/
|
*/
|
||||||
public ValidationResult getValidationResult() {
|
public ValidationResult getValidationResult() {
|
||||||
return validationResultProperty.get();
|
return validationResultProperty.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Can be used to track validation result changes
|
/**
|
||||||
|
* Can be used to track validation result changes
|
||||||
|
*
|
||||||
* @return The Validation result property.
|
* @return The Validation result property.
|
||||||
*/
|
*/
|
||||||
public ReadOnlyObjectProperty<ValidationResult> validationResultProperty() {
|
public ReadOnlyObjectProperty<ValidationResult> validationResultProperty() {
|
||||||
return validationResultProperty.getReadOnlyProperty();
|
return validationResultProperty.getReadOnlyProperty();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** A read-only boolean property indicating whether any of the checks of this validator emitted an error. */
|
/**
|
||||||
|
* A read-only boolean property indicating whether any of the checks of this validator emitted an error.
|
||||||
|
*/
|
||||||
public ReadOnlyBooleanProperty containsErrorsProperty() {
|
public ReadOnlyBooleanProperty containsErrorsProperty() {
|
||||||
return containsErrorsProperty.getReadOnlyProperty();
|
return containsErrorsProperty.getReadOnlyProperty();
|
||||||
}
|
}
|
||||||
|
@ -74,7 +86,9 @@ public class SimpleValidator implements Validator {
|
||||||
return containsErrorsProperty().get();
|
return containsErrorsProperty().get();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Run all checks (decorating nodes if appropriate)
|
/**
|
||||||
|
* Run all checks (decorating nodes if appropriate)
|
||||||
|
*
|
||||||
* @return true if no errors were found, false otherwise
|
* @return true if no errors were found, false otherwise
|
||||||
*/
|
*/
|
||||||
public boolean validate() {
|
public boolean validate() {
|
||||||
|
@ -97,7 +111,8 @@ public class SimpleValidator implements Validator {
|
||||||
containsErrorsProperty.set(hasErrors);
|
containsErrorsProperty.set(hasErrors);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Create a string property that depends on the validation result.
|
/**
|
||||||
|
* Create a string property that depends on the validation result.
|
||||||
* Each error message will be displayed on a separate line prefixed with a bullet.
|
* Each error message will be displayed on a separate line prefixed with a bullet.
|
||||||
*/
|
*/
|
||||||
public StringBinding createStringBinding() {
|
public StringBinding createStringBinding() {
|
||||||
|
@ -117,6 +132,7 @@ public class SimpleValidator implements Validator {
|
||||||
}
|
}
|
||||||
return str.toString();
|
return str.toString();
|
||||||
},
|
},
|
||||||
validationResultProperty);
|
validationResultProperty
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ public class WindowsRegistry {
|
||||||
public static final int HKEY_LOCAL_MACHINE = 0x80000002;
|
public static final int HKEY_LOCAL_MACHINE = 0x80000002;
|
||||||
|
|
||||||
public static Optional<String> readString(int hkey, String key) {
|
public static Optional<String> readString(int hkey, String key) {
|
||||||
return readString(hkey,key, null);
|
return readString(hkey, key, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Optional<String> readString(int hkey, String key, String valueName) {
|
public static Optional<String> readString(int hkey, String key, String valueName) {
|
||||||
|
|
|
@ -29,6 +29,7 @@ public interface XPipeDaemon {
|
||||||
}
|
}
|
||||||
|
|
||||||
void withResource(String module, String file, Charsetter.FailableConsumer<Path, IOException> con);
|
void withResource(String module, String file, Charsetter.FailableConsumer<Path, IOException> con);
|
||||||
|
|
||||||
List<DataStore> getNamedStores();
|
List<DataStore> getNamedStores();
|
||||||
|
|
||||||
String getVersion();
|
String getVersion();
|
||||||
|
@ -41,20 +42,24 @@ public interface XPipeDaemon {
|
||||||
Property<DataStore> storeProperty,
|
Property<DataStore> storeProperty,
|
||||||
Property<DataSourceProvider<?>> provider,
|
Property<DataSourceProvider<?>> provider,
|
||||||
boolean showAnonymous,
|
boolean showAnonymous,
|
||||||
boolean showSaved);
|
boolean showSaved
|
||||||
|
);
|
||||||
|
|
||||||
<T extends Comp<?> & Validatable> T namedStoreChooser(
|
<T extends Comp<?> & Validatable> T namedStoreChooser(
|
||||||
ObservableValue<Predicate<DataStore>> filter,
|
ObservableValue<Predicate<DataStore>> filter,
|
||||||
Property<? extends DataStore> selected,
|
Property<? extends DataStore> selected,
|
||||||
DataStoreProvider.Category category);
|
DataStoreProvider.Category category
|
||||||
|
);
|
||||||
|
|
||||||
<T extends Comp<?> & Validatable> T namedSourceChooser(
|
<T extends Comp<?> & Validatable> T namedSourceChooser(
|
||||||
ObservableValue<Predicate<DataSource<?>>> filter,
|
ObservableValue<Predicate<DataSource<?>>> filter,
|
||||||
Property<? extends DataSource<?>> selected,
|
Property<? extends DataSource<?>> selected,
|
||||||
DataSourceProvider.Category category);
|
DataSourceProvider.Category category
|
||||||
|
);
|
||||||
|
|
||||||
<T extends Comp<?> & Validatable> T sourceProviderChooser(
|
<T extends Comp<?> & Validatable> T sourceProviderChooser(
|
||||||
Property<DataSourceProvider<?>> provider, DataSourceProvider.Category category, DataSourceType filter);
|
Property<DataSourceProvider<?>> provider, DataSourceProvider.Category category, DataSourceType filter
|
||||||
|
);
|
||||||
|
|
||||||
Optional<DataStore> getNamedStore(String name);
|
Optional<DataStore> getNamedStore(String name);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue