From cd93f934ffad43a35e3e3deceac15f73b9419e49 Mon Sep 17 00:00:00 2001 From: Christopher Schnick Date: Mon, 10 Jan 2022 07:10:44 +0100 Subject: [PATCH] Prepare for publish --- api/build.gradle | 39 ++++------- api/publish.gradle | 35 ++++++++++ beacon/build.gradle | 30 ++++---- {library => beacon}/publish.gradle | 27 ++------ .../java/io/xpipe/beacon/BeaconConfig.java | 11 --- .../java/io/xpipe/beacon/BeaconServer.java | 20 +----- build.gradle | 9 --- core/build.gradle | 43 ++++-------- core/publish.gradle | 31 +++++++++ extension/build.gradle | 19 +++--- extension/publish.gradle | 31 +++++++++ .../xpipe/extension/DataSourceProviders.java | 17 +++++ .../xpipe/extension/comp/CharChoiceComp.java | 39 +++++------ .../io/xpipe/extension/comp/CharComp.java | 22 ++++-- .../extension/comp/CharsetChoiceComp.java | 21 ++++-- .../io/xpipe/extension/comp/ChoiceComp.java | 27 +++----- .../xpipe/extension/comp/ToggleGroupComp.java | 19 +++--- .../io/xpipe/extension/event/TrackEvent.java | 8 +++ library/build.gradle | 68 ------------------- library/module-info.java | 58 ---------------- samples/sample_program/build.gradle | 6 +- settings.gradle | 1 - version | 1 + 23 files changed, 253 insertions(+), 329 deletions(-) create mode 100644 api/publish.gradle rename {library => beacon}/publish.gradle (57%) delete mode 100644 build.gradle create mode 100644 core/publish.gradle create mode 100644 extension/publish.gradle delete mode 100644 library/build.gradle delete mode 100644 library/module-info.java create mode 100644 version diff --git a/api/build.gradle b/api/build.gradle index bfbc12b99..16556726b 100644 --- a/api/build.gradle +++ b/api/build.gradle @@ -1,35 +1,28 @@ plugins { - id 'java' + id 'java-library' + id 'maven-publish' + id 'signing' id "org.moditect.gradleplugin" version "1.0.0-rc3" } -java { - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 -} +apply from: "$rootDir/deps/java.gradle" +apply from: "$rootDir/deps/commons.gradle" +apply from: "$rootDir/deps/jackson.gradle" +apply from: "$rootDir/deps/junit.gradle" +apply from: 'publish.gradle' +apply from: "$rootDir/deps/publish-base.gradle" + +version = file('../version').text +group = 'io.xpipe' +archivesBaseName = 'api' repositories { mavenCentral() - maven { url "https://jitpack.io" } } -plugins.withType(JavaPlugin).configureEach { - java { - modularity.inferModulePath = true - } -} - -apply from: "$rootDir/deps/commons.gradle" -apply from: "$rootDir/deps/jackson.gradle" - dependencies { implementation project(':core') implementation project(':beacon') - - testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2' - //testRuntimeOnly project(':app') - testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.2' - testRuntimeOnly "org.junit.platform:junit-platform-launcher" } test { @@ -39,12 +32,10 @@ test { showStandardStreams = true } - //workingDir = project(":app").projectDir - - systemProperty 'io.xpipe.beacon.startInProcess', 'true' + systemProperty 'io.xpipe.beacon.exec', 'start_test_daemon.bat' systemProperty "io.xpipe.daemon.mode", 'base' systemProperty "io.xpipe.storage.dir", "$projectDir/test_env" systemProperty "io.xpipe.beacon.port", "21722" systemProperty 'io.xpipe.app.writeSysOut', "true" - systemProperty 'io.xpipe.app.logLevel', "debug" + systemProperty 'io.xpipe.app.logLevel', "trace" } diff --git a/api/publish.gradle b/api/publish.gradle new file mode 100644 index 000000000..b26c91691 --- /dev/null +++ b/api/publish.gradle @@ -0,0 +1,35 @@ +publishing { + publications { + mavenJava(MavenPublication) { + from components.java + + pom { + name = 'X-Pipe API' + description = 'Contains everything necessary to use and interact with X-Pipe.' + url = 'https://github.com/xpipe-io/xpipe_java/api' + licenses { + license { + name = 'The MIT License (MIT)' + url = 'https://github.com/xpipe-io/xpipe_java/LICENSE.md' + } + } + developers { + developer { + id = 'crschnick' + name = 'Christopher Schnick' + email = 'crschnick@xpipe.io' + } + } + scm { + connection = 'scm:git:git://github.com/xpipe-io/xpipe_java.git' + developerConnection = 'scm:git:ssh://github.com/xpipe-io/xpipe_java.git' + url = 'https://github.com/xpipe-io/xpipe_java' + } + + withXml { + //asNode().appendNode('dependencies').appendNode('dependency').appendNode('my-property', 'my-value') + } + } + } + } +} \ No newline at end of file diff --git a/beacon/build.gradle b/beacon/build.gradle index 90201e303..3ffbeb788 100644 --- a/beacon/build.gradle +++ b/beacon/build.gradle @@ -1,29 +1,27 @@ plugins { - id 'java' + id 'java-library' + id 'maven-publish' + id 'signing' id "org.moditect.gradleplugin" version "1.0.0-rc3" } -java { - modularity.inferModulePath = true - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 -} +apply from: "$rootDir/deps/java.gradle" +apply from: "$rootDir/deps/commons.gradle" +apply from: "$rootDir/deps/slf4j.gradle" +apply from: "$rootDir/deps/jackson.gradle" +apply from: "$rootDir/deps/lombok.gradle" +apply from: 'publish.gradle' +apply from: "$rootDir/deps/publish-base.gradle" + +version = file('../version').text +group = 'io.xpipe' +archivesBaseName = 'beacon' repositories { mavenCentral() } -apply from: "$rootDir/deps/slf4j.gradle" -apply from: "$rootDir/deps/jackson.gradle" - dependencies { implementation project(':core') implementation project(':extension') - - compileOnly 'org.projectlombok:lombok:1.18.22' - annotationProcessor 'org.projectlombok:lombok:1.18.22' } - -test { - useJUnitPlatform() -} \ No newline at end of file diff --git a/library/publish.gradle b/beacon/publish.gradle similarity index 57% rename from library/publish.gradle rename to beacon/publish.gradle index ae3f0eb1c..6d6246eb0 100644 --- a/library/publish.gradle +++ b/beacon/publish.gradle @@ -1,21 +1,16 @@ -java { - withJavadocJar() - withSourcesJar() -} - publishing { publications { mavenJava(MavenPublication) { from components.java pom { - name = 'XPipe' - description = 'XPipe library.' - url = 'https://github.com/xpipe-io/xpipe_java' + name = 'X-Pipe beacon' + description = 'The socket-based implementation used for the communication with X-Pipe.' + url = 'https://github.com/xpipe-io/xpipe_java/beacon' licenses { license { name = 'The MIT License (MIT)' - url = 'https://github.com/xpipe-io/xpipe_java/LICENSE' + url = 'https://github.com/xpipe-io/xpipe_java/LICENSE.md' } } developers { @@ -33,18 +28,4 @@ publishing { } } } - - repositories { - maven { - url "https://oss.sonatype.org/service/local/staging/deploy/maven2" - credentials { - setUsername "${project.hasProperty('sonatypeUsername') ? project.property('sonatypeUsername') : ''}" - setPassword "${project.hasProperty('sonatypePassword') ? project.property('sonatypePassword') : ''}" - } - } - } } - -signing { - sign publishing.publications.mavenJava -} \ No newline at end of file diff --git a/beacon/src/main/java/io/xpipe/beacon/BeaconConfig.java b/beacon/src/main/java/io/xpipe/beacon/BeaconConfig.java index 207f59ae7..5b870b18b 100644 --- a/beacon/src/main/java/io/xpipe/beacon/BeaconConfig.java +++ b/beacon/src/main/java/io/xpipe/beacon/BeaconConfig.java @@ -29,17 +29,6 @@ public class BeaconConfig { - private static final String IN_PROCESS_PROP = "io.xpipe.beacon.startInProcess"; - - public static boolean shouldStartInProcess() { - if (System.getProperty(IN_PROCESS_PROP) != null) { - return Boolean.parseBoolean(System.getProperty(IN_PROCESS_PROP)); - } - return false; - } - - - private static final String EXEC_PROCESS_PROP = "io.xpipe.beacon.exec"; public static String getCustomExecCommand() { diff --git a/beacon/src/main/java/io/xpipe/beacon/BeaconServer.java b/beacon/src/main/java/io/xpipe/beacon/BeaconServer.java index e603b148c..6db7d930c 100644 --- a/beacon/src/main/java/io/xpipe/beacon/BeaconServer.java +++ b/beacon/src/main/java/io/xpipe/beacon/BeaconServer.java @@ -1,7 +1,6 @@ package io.xpipe.beacon; import java.io.IOException; -import java.lang.reflect.InvocationTargetException; import java.net.DatagramSocket; import java.net.ServerSocket; @@ -21,29 +20,12 @@ public class BeaconServer { } public static boolean tryStart() throws Exception { - if (BeaconConfig.shouldStartInProcess()) { - startInProcess(); - return true; - } - var custom = BeaconConfig.getCustomExecCommand(); if (custom != null) { - var proc = new ProcessBuilder("cmd", "/c", "CALL", "C:\\Projects\\xpipe\\xpipe\\gradlew.bat", ":app:run").inheritIO().start(); + new ProcessBuilder("cmd", "/c", "CALL", custom).inheritIO().start(); return true; } return false; } - - private static void startInProcess() throws Exception { - var mainClass = Class.forName("io.xpipe.app.Main"); - var method = mainClass.getDeclaredMethod("main", String[].class); - new Thread(() -> { - try { - method.invoke(null, (Object) new String[0]); - } catch (IllegalAccessException | InvocationTargetException e) { - e.printStackTrace(); - } - }).start(); - } } diff --git a/build.gradle b/build.gradle deleted file mode 100644 index e12bb1604..000000000 --- a/build.gradle +++ /dev/null @@ -1,9 +0,0 @@ -plugins { - id 'java' -} - -group 'io.xpipe' - -repositories { - mavenCentral() -} diff --git a/core/build.gradle b/core/build.gradle index dd6288d47..27efc2ec7 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -1,38 +1,21 @@ plugins { - id 'java' + id 'java-library' + id 'maven-publish' + id 'signing' id "org.moditect.gradleplugin" version "1.0.0-rc3" } -java { - modularity.inferModulePath = true - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 -} +apply from: "$rootDir/deps/java.gradle" +apply from: "$rootDir/deps/commons.gradle" +apply from: "$rootDir/deps/jackson.gradle" +apply from: "$rootDir/deps/lombok.gradle" +apply from: 'publish.gradle' +apply from: "$rootDir/deps/publish-base.gradle" + +version = file('../version').text +group = 'io.xpipe' +archivesBaseName = 'core' repositories { mavenCentral() } - -apply from: "$rootDir/deps/commons.gradle" -apply from: "$rootDir/deps/jackson.gradle" - -dependencies { - compileOnly 'org.projectlombok:lombok:1.18.22' - annotationProcessor 'org.projectlombok:lombok:1.18.22' - - testCompileOnly 'org.projectlombok:lombok:1.18.22' - testAnnotationProcessor 'org.projectlombok:lombok:1.18.22' - testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2' - testImplementation 'org.junit.jupiter:junit-jupiter-params:5.8.2' - testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.2' - testRuntimeOnly "org.junit.platform:junit-platform-launcher" -} - - -test { - useJUnitPlatform() - testLogging { - exceptionFormat = 'full' - showStandardStreams = true - } -} diff --git a/core/publish.gradle b/core/publish.gradle new file mode 100644 index 000000000..81a3ef588 --- /dev/null +++ b/core/publish.gradle @@ -0,0 +1,31 @@ +publishing { + publications { + mavenJava(MavenPublication) { + from components.java + + pom { + name = 'X-Pipe core' + description = 'Core classes ued by all X-Pipe components.' + url = 'https://github.com/xpipe-io/xpipe_java/core' + licenses { + license { + name = 'The MIT License (MIT)' + url = 'https://github.com/xpipe-io/xpipe_java/LICENSE.md' + } + } + developers { + developer { + id = 'crschnick' + name = 'Christopher Schnick' + email = 'crschnick@xpipe.io' + } + } + scm { + connection = 'scm:git:git://github.com/xpipe-io/xpipe_java.git' + developerConnection = 'scm:git:ssh://github.com/xpipe-io/xpipe_java.git' + url = 'https://github.com/xpipe-io/xpipe_java' + } + } + } + } +} diff --git a/extension/build.gradle b/extension/build.gradle index ef808e799..cf7167b29 100644 --- a/extension/build.gradle +++ b/extension/build.gradle @@ -1,18 +1,21 @@ plugins { - id 'java' + id 'java-library' + id 'maven-publish' + id 'signing' id "org.moditect.gradleplugin" version "1.0.0-rc3" } -java { - modularity.inferModulePath = true - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 -} - +apply from: "$rootDir/deps/java.gradle" apply from: "$rootDir/deps/javafx.gradle" apply from: "$rootDir/deps/jackson.gradle" apply from: "$rootDir/deps/commons.gradle" apply from: "$rootDir/deps/lombok.gradle" +apply from: 'publish.gradle' +apply from: "$rootDir/deps/publish-base.gradle" + +version = file('../version').text +group = 'io.xpipe' +archivesBaseName = 'core' repositories { mavenCentral() @@ -20,5 +23,5 @@ repositories { dependencies { implementation project(':core') - compileOnly project(':fxcomps') + implementation project(':fxcomps') } diff --git a/extension/publish.gradle b/extension/publish.gradle new file mode 100644 index 000000000..b7a353361 --- /dev/null +++ b/extension/publish.gradle @@ -0,0 +1,31 @@ +publishing { + publications { + mavenJava(MavenPublication) { + from components.java + + pom { + name = 'X-Pipe extension base' + description = 'Classes required to create X-Pipe extensions.' + url = 'https://github.com/xpipe-io/xpipe_java/extension' + licenses { + license { + name = 'The MIT License (MIT)' + url = 'https://github.com/xpipe-io/xpipe_java/LICENSE.md' + } + } + developers { + developer { + id = 'crschnick' + name = 'Christopher Schnick' + email = 'crschnick@xpipe.io' + } + } + scm { + connection = 'scm:git:git://github.com/xpipe-io/xpipe_java.git' + developerConnection = 'scm:git:ssh://github.com/xpipe-io/xpipe_java.git' + url = 'https://github.com/xpipe-io/xpipe_java' + } + } + } + } +} diff --git a/extension/src/main/java/io/xpipe/extension/DataSourceProviders.java b/extension/src/main/java/io/xpipe/extension/DataSourceProviders.java index 2c703e0e1..9347c0f6b 100644 --- a/extension/src/main/java/io/xpipe/extension/DataSourceProviders.java +++ b/extension/src/main/java/io/xpipe/extension/DataSourceProviders.java @@ -1,5 +1,10 @@ package io.xpipe.extension; +import io.xpipe.core.data.type.TupleType; +import io.xpipe.core.source.TableDataSourceDescriptor; +import io.xpipe.core.store.LocalFileDataStore; +import io.xpipe.extension.event.ErrorEvent; + import java.net.URISyntaxException; import java.net.URL; import java.nio.file.Path; @@ -19,6 +24,18 @@ public class DataSourceProviders { } } + @SuppressWarnings("unchecked") + public static TableDataSourceDescriptor createLocalTableDescriptor(TupleType type) { + try { + return (TableDataSourceDescriptor) + DataSourceProviders.byId("xpbt").orElseThrow().getType() + .getDeclaredConstructors()[0].newInstance(type); + } catch (Exception ex) { + ErrorEvent.fromThrowable(ex).terminal(true).build().handle(); + return null; + } + } + public static Optional byDataSourceClass(Class clazz) { if (ALL == null) { throw new IllegalStateException("Not initialized"); diff --git a/extension/src/main/java/io/xpipe/extension/comp/CharChoiceComp.java b/extension/src/main/java/io/xpipe/extension/comp/CharChoiceComp.java index c2f26c531..31d217b92 100644 --- a/extension/src/main/java/io/xpipe/extension/comp/CharChoiceComp.java +++ b/extension/src/main/java/io/xpipe/extension/comp/CharChoiceComp.java @@ -1,8 +1,9 @@ package io.xpipe.extension.comp; +import io.xpipe.fxcomps.Comp; import io.xpipe.fxcomps.CompStructure; -import io.xpipe.fxcomps.store.DefaultValueStoreComp; -import io.xpipe.fxcomps.util.StrongBindings; +import javafx.beans.property.Property; +import javafx.beans.property.SimpleObjectProperty; import javafx.geometry.Pos; import javafx.scene.layout.HBox; import org.apache.commons.collections4.BidiMap; @@ -10,37 +11,33 @@ import org.apache.commons.collections4.bidimap.DualLinkedHashBidiMap; import java.util.function.Supplier; -public class CharChoiceComp extends DefaultValueStoreComp, Character> { +public class CharChoiceComp extends Comp> { + private final Property value; + private final Property charChoiceValue; private final BidiMap> range; private final Supplier customName; - public CharChoiceComp(Character defaultVal, BidiMap> range, Supplier customName) { - super(defaultVal); + public CharChoiceComp(Property value, BidiMap> range, Supplier customName) { + this.value = value; this.range = range; this.customName = customName; + this.charChoiceValue = new SimpleObjectProperty<>(range.containsKey(value.getValue()) ? value.getValue() : null); + value.addListener((c, o, n) -> { + if (!range.containsKey(n)) { + charChoiceValue.setValue(null); + } else { + charChoiceValue.setValue(n); + } + }); } @Override public CompStructure createBase() { - var charChoice = new CharComp(); - StrongBindings.bind(charChoice.valueProperty(), valueProperty()); - + var charChoice = new CharComp(value); var rangeCopy = new DualLinkedHashBidiMap<>(range); rangeCopy.put(null, customName); - var choice = new ChoiceComp(value.getValue(), rangeCopy); - choice.set(getValue()); - choice.valueProperty().addListener((c, o, n) -> { - set(n); - }); - valueProperty().addListener((c, o, n) -> { - if (n != null && !range.containsKey(n)) { - choice.set(null); - } else { - choice.set(n); - } - }); - + var choice = new ChoiceComp(charChoiceValue, rangeCopy); var charChoiceR = charChoice.createRegion(); var choiceR = choice.createRegion(); var box = new HBox(charChoiceR, choiceR); diff --git a/extension/src/main/java/io/xpipe/extension/comp/CharComp.java b/extension/src/main/java/io/xpipe/extension/comp/CharComp.java index c99d04ddc..4247be901 100644 --- a/extension/src/main/java/io/xpipe/extension/comp/CharComp.java +++ b/extension/src/main/java/io/xpipe/extension/comp/CharComp.java @@ -1,22 +1,32 @@ package io.xpipe.extension.comp; +import io.xpipe.fxcomps.Comp; import io.xpipe.fxcomps.CompStructure; -import io.xpipe.fxcomps.store.ValueStoreComp; +import io.xpipe.fxcomps.util.PlatformUtil; +import javafx.beans.property.Property; import javafx.scene.control.TextField; -public class CharComp extends ValueStoreComp, Character> { +public class CharComp extends Comp> { + + private final Property value; + + public CharComp(Property value) { + this.value = value; + } @Override public CompStructure createBase() { - var text = new TextField(getValue() != null ? getValue().toString() : null); + var text = new TextField(value.getValue() != null ? value.getValue().toString() : null); text.setOnKeyTyped(e -> { text.setText(e.getCharacter()); }); text.textProperty().addListener((c, o, n) -> { - this.set(n != null && n.length() > 0 ? n.charAt(0) : null); + value.setValue(n != null && n.length() > 0 ? n.charAt(0) : null); }); - valueProperty().addListener((c, o, n) -> { - text.setText(n != null ? n.toString() : null); + value.addListener((c, o, n) -> { + PlatformUtil.runLaterIfNeeded(() -> { + text.setText(n != null ? n.toString() : null); + }); }); return new CompStructure<>(text); } 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 b5235b1fd..ed0de26cb 100644 --- a/extension/src/main/java/io/xpipe/extension/comp/CharsetChoiceComp.java +++ b/extension/src/main/java/io/xpipe/extension/comp/CharsetChoiceComp.java @@ -1,19 +1,30 @@ package io.xpipe.extension.comp; +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 org.apache.commons.collections4.bidimap.DualLinkedHashBidiMap; import java.nio.charset.Charset; -import java.nio.charset.StandardCharsets; import java.util.LinkedHashMap; import java.util.function.Supplier; -public class CharsetChoiceComp { +public class CharsetChoiceComp extends ReplacementComp>> { - public static ChoiceComp create() { + private final Property charset; + + public CharsetChoiceComp(Property charset) { + this.charset = charset; + } + + @Override + protected Comp>> createComp() { var map = new LinkedHashMap>(); for (var e : Charset.availableCharsets().entrySet()) { - map.put(e.getValue(), () -> e.getKey()); + map.put(e.getValue(), e::getKey); } - return new ChoiceComp<>(StandardCharsets.UTF_8, new DualLinkedHashBidiMap<>(map)); + return new ChoiceComp<>(charset, new DualLinkedHashBidiMap<>(map)); } } 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 de0042e3c..3f46ecbdc 100644 --- a/extension/src/main/java/io/xpipe/extension/comp/ChoiceComp.java +++ b/extension/src/main/java/io/xpipe/extension/comp/ChoiceComp.java @@ -1,7 +1,9 @@ package io.xpipe.extension.comp; +import io.xpipe.fxcomps.Comp; import io.xpipe.fxcomps.CompStructure; -import io.xpipe.fxcomps.store.DefaultValueStoreComp; +import io.xpipe.fxcomps.util.PlatformUtil; +import javafx.beans.property.Property; import javafx.collections.FXCollections; import javafx.scene.control.ChoiceBox; import javafx.util.StringConverter; @@ -9,33 +11,24 @@ import org.apache.commons.collections4.BidiMap; import java.util.function.Supplier; -public class ChoiceComp extends DefaultValueStoreComp>, T> { +public class ChoiceComp extends Comp>> { + private final Property value; private final BidiMap> range; - public ChoiceComp(T defaultVal, BidiMap> range) { - super(defaultVal); + public ChoiceComp(Property value, BidiMap> range) { + this.value = value; this.range = range; } - @Override - protected boolean isValid(T newValue) { - return range.containsKey(newValue); - } - - public BidiMap> getRange() { - return range; - } - @Override public CompStructure> createBase() { - var comp = this; - var list = FXCollections.observableArrayList(comp.getRange().keySet()); + var list = FXCollections.observableArrayList(range.keySet()); var cb = new ChoiceBox<>(list); cb.setConverter(new StringConverter<>() { @Override public String toString(T object) { - return comp.getRange().get(object).get(); + return range.get(object).get(); } @Override @@ -43,7 +36,7 @@ public class ChoiceComp extends DefaultValueStoreComp(cb); } diff --git a/extension/src/main/java/io/xpipe/extension/comp/ToggleGroupComp.java b/extension/src/main/java/io/xpipe/extension/comp/ToggleGroupComp.java index f3136e6dd..d7c987a61 100644 --- a/extension/src/main/java/io/xpipe/extension/comp/ToggleGroupComp.java +++ b/extension/src/main/java/io/xpipe/extension/comp/ToggleGroupComp.java @@ -1,7 +1,9 @@ package io.xpipe.extension.comp; +import io.xpipe.fxcomps.Comp; import io.xpipe.fxcomps.CompStructure; -import io.xpipe.fxcomps.store.DefaultValueStoreComp; +import io.xpipe.fxcomps.util.PlatformUtil; +import javafx.beans.property.Property; import javafx.scene.control.ToggleButton; import javafx.scene.control.ToggleGroup; import javafx.scene.layout.HBox; @@ -9,12 +11,13 @@ import org.apache.commons.collections4.BidiMap; import java.util.function.Supplier; -public class ToggleGroupComp extends DefaultValueStoreComp, T> { +public class ToggleGroupComp extends Comp> { + private final Property value; private final BidiMap> range; - public ToggleGroupComp(T defaultVal, BidiMap> range) { - super(defaultVal); + public ToggleGroupComp(Property value, BidiMap> range) { + this.value = value; this.range = range; } @@ -30,15 +33,15 @@ public class ToggleGroupComp extends DefaultValueStoreComp { - set(entry.getKey()); + value.setValue(entry.getKey()); e.consume(); }); box.getChildren().add(b); b.setToggleGroup(group); - valueProperty().addListener((c, o, n) -> { - b.setSelected(entry.equals(n)); + value.addListener((c, o, n) -> { + PlatformUtil.runLaterIfNeeded(() -> b.setSelected(entry.equals(n))); }); - if (entry.getKey().equals(getValue())) { + if (entry.getKey().equals(value.getValue())) { b.setSelected(true); } } diff --git a/extension/src/main/java/io/xpipe/extension/event/TrackEvent.java b/extension/src/main/java/io/xpipe/extension/event/TrackEvent.java index 5bf59a82c..48d37c49c 100644 --- a/extension/src/main/java/io/xpipe/extension/event/TrackEvent.java +++ b/extension/src/main/java/io/xpipe/extension/event/TrackEvent.java @@ -17,6 +17,10 @@ public class TrackEvent { this.category("window"); return this; } + + public void handle() { + build().handle(); + } } public static TrackEventBuilder fromMessage(String type, String message) { @@ -35,6 +39,10 @@ public class TrackEvent { return builder().type("trace").message(message); } + public static TrackEventBuilder withTrace(String cat, String message) { + return builder().category(cat).type("trace").message(message); + } + public static void info(String message) { builder().type("info").message(message).build().handle(); } diff --git a/library/build.gradle b/library/build.gradle deleted file mode 100644 index d7b31f17f..000000000 --- a/library/build.gradle +++ /dev/null @@ -1,68 +0,0 @@ -plugins { - id 'java-library' - id 'maven-publish' - id 'signing' - id "org.moditect.gradleplugin" version "1.0.0-rc3" -} - -apply from: 'publish.gradle' -apply from: "$rootDir/deps/jackson.gradle" -apply from: "$rootDir/deps/slf4j.gradle" -apply from: "$rootDir/deps/lombok.gradle" -apply from: "$rootDir/deps/commons.gradle" -apply from: "$rootDir/deps/javafx.gradle" -apply from: "$rootDir/deps/javafx-static.gradle" - -version '0.1' -group 'io.xpipe' -archivesBaseName = 'xpipe' - -java { - modularity.inferModulePath = true - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 -} - -dependencies { - compileOnly project(':fxcomps') -} - -repositories { - mavenCentral() -} - -javadoc{ - source = sourceSets.main.allJava - options { - addStringOption('-release', '17') - addStringOption('link', 'https://docs.oracle.com/en/java/javase/17/docs/api/') - } -} - -sourceSets { - main { - java { - srcDir(projectDir) - - srcDir("../api/src/main/java") - exclude { - return it.getFile() == file("../api/src/main/java/module-info.java") - } - - srcDir("../core/src/main/java") - exclude { - return it.getFile() == file("../core/src/main/java/module-info.java") - } - - srcDir("../beacon/src/main/java") - exclude { - return it.getFile() == file("../beacon/src/main/java/module-info.java") - } - - srcDir("../extension/src/main/java") - exclude { - return it.getFile() == file("../extension/src/main/java/module-info.java") - } - } - } -} diff --git a/library/module-info.java b/library/module-info.java deleted file mode 100644 index 769d949c8..000000000 --- a/library/module-info.java +++ /dev/null @@ -1,58 +0,0 @@ -module io.xpipe { - // api - exports io.xpipe.api; - - // beacon - exports io.xpipe.beacon; - exports io.xpipe.beacon.exchange; - exports io.xpipe.beacon.message; - opens io.xpipe.beacon; - opens io.xpipe.beacon.exchange; - opens io.xpipe.beacon.message; - uses io.xpipe.beacon.exchange.MessageExchange; - provides io.xpipe.beacon.exchange.MessageExchange with - io.xpipe.beacon.exchange.ListCollectionsExchange, - io.xpipe.beacon.exchange.ListEntriesExchange, - io.xpipe.beacon.exchange.ReadTableDataExchange, - io.xpipe.beacon.exchange.ReadInfoExchange, - io.xpipe.beacon.exchange.StatusExchange, - io.xpipe.beacon.exchange.StopExchange, - io.xpipe.beacon.exchange.StoreResourceExchange, - io.xpipe.beacon.exchange.VersionExchange; - - // core - exports io.xpipe.core.store; - exports io.xpipe.core.source; - exports io.xpipe.core.data.generic; - exports io.xpipe.core.data.type; - exports io.xpipe.core.data.node; - exports io.xpipe.core.util; - exports io.xpipe.core.data.typed; - opens io.xpipe.core.store; - opens io.xpipe.core.source; - opens io.xpipe.core.data.typed; - opens io.xpipe.core.data.type; - - // core services - uses com.fasterxml.jackson.databind.Module; - provides com.fasterxml.jackson.databind.Module with io.xpipe.core.util.CoreJacksonModule; - - // extension - requires static io.xpipe.fxcomps; - requires static javafx.base; - requires static javafx.graphics; - requires static javafx.controls; - requires static org.apache.commons.collections4; - exports io.xpipe.extension; - exports io.xpipe.extension.comp; - uses io.xpipe.extension.DataSourceProvider; - uses io.xpipe.extension.DataSourceGuiProvider; - uses io.xpipe.extension.SupportedApplicationProvider; - uses io.xpipe.extension.I18n; - - requires com.fasterxml.jackson.core; - requires com.fasterxml.jackson.databind; - requires com.fasterxml.jackson.module.paramnames; - requires org.slf4j; - requires static lombok; -} \ No newline at end of file diff --git a/samples/sample_program/build.gradle b/samples/sample_program/build.gradle index 6b200fc7a..910b67c2f 100644 --- a/samples/sample_program/build.gradle +++ b/samples/sample_program/build.gradle @@ -12,15 +12,11 @@ repositories { mavenCentral() } apply from: "$rootDir/deps/jackson.gradle" -apply from: "$rootDir/deps/slf4j.gradle" dependencies { - implementation files(project(':library').jar.archivePath) - implementation group: 'org.slf4j', name: 'slf4j-simple', version: '2.0.0-alpha1' + implementation project(':api') } -compileJava.dependsOn(project(':library').jar) - application { mainModule = 'io.xpipe.sample' mainClass = 'io.xpipe.sample.HomePricesSample' diff --git a/settings.gradle b/settings.gradle index f309654c6..df119b379 100644 --- a/settings.gradle +++ b/settings.gradle @@ -4,7 +4,6 @@ include 'core' include 'beacon' include 'api' include 'extension' -include 'library' include 'sample_extension' project(":sample_extension").projectDir = file("samples/sample_extension") diff --git a/version b/version new file mode 100644 index 000000000..ceab6e11e --- /dev/null +++ b/version @@ -0,0 +1 @@ +0.1 \ No newline at end of file