Skip to content
Open
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
927e975
Updating out deprecated blocks in graddle file
Aug 4, 2025
3cb558a
Updating the publication for 8+ version
Symeon94 Aug 4, 2025
833b137
Including the correct version of JavaFX in the build
Symeon94 Aug 4, 2025
f169edb
Mapped list with index
Symeon94 Aug 4, 2025
f5130a1
Removing item added by mistake
Symeon94 Aug 4, 2025
a927fd6
Adding tests for lazy evaluation and removing getSource() to use the …
Symeon94 Aug 4, 2025
d7d7393
Issue with outdated 'runtime' and missing JavaFX dependencies for rea…
Symeon94 Aug 4, 2025
8ca155a
Issue with outdated 'runtime' and missing JavaFX dependencies for rea…
Symeon94 Aug 4, 2025
6d0bc07
Javadoc fails building due to h2 title being used while parent is h3.…
Symeon94 Aug 4, 2025
120acab
Issue with build due to likely bug in the builder library. Upgrading …
Symeon94 Aug 4, 2025
411f081
merge
Symeon94 Aug 4, 2025
cf251ac
merge
Symeon94 Aug 8, 2025
a756475
merge
Symeon94 Aug 8, 2025
c5ccdad
merge
Symeon94 Aug 8, 2025
810958b
Using a secondary constructor instead of inheritance
Symeon94 Aug 8, 2025
95e7798
Removing generated gradle files
Symeon94 Aug 8, 2025
17e668d
Adding some comments to differentiate between the two methods
Symeon94 Aug 8, 2025
3764deb
Cosmetic cleanup
Symeon94 Aug 8, 2025
01a43d4
fixing issue when you are removing multiple items at the same time
Symeon94 Aug 9, 2025
431275d
Added unit tests
Symeon94 Aug 11, 2025
6fbb8a2
Forgot to remove a print
Symeon94 Aug 11, 2025
9255efa
Reversing to the original method to remove elements
Symeon94 Aug 11, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,8 @@ gradle.properties
.classpath
.project
.settings/
.idea/

gradle/
gradlew
gradle.bat
9 changes: 7 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
plugins {
id 'biz.aQute.bnd.builder' version '6.4.0'
}

subprojects {
version = '2.0-SNAPSHOT'
version = '2.1-SNAPSHOT'

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'osgi'
apply plugin: 'biz.aQute.bnd.builder' // replaces 'osgi'

repositories {
mavenCentral()
gradlePluginPortal()
}

sourceCompatibility = '1.8'
Expand Down
32 changes: 22 additions & 10 deletions reactfx-demos/build.gradle
Original file line number Diff line number Diff line change
@@ -1,21 +1,33 @@
plugins {
id 'org.openjfx.javafxplugin' version '0.1.0'
}

dependencies {
compile project(":reactfx")
implementation project(":reactfx")
}

task fatJar(type: Jar, dependsOn: classes) {
appendix = 'fat'
tasks.register('fatJar', Jar) {
dependsOn tasks.named('classes')
archiveAppendix.set('fat')
from sourceSets.main.output
from { configurations.runtime.collect { it.isDirectory() ? it : zipTree(it) } }
from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } }
}

javafx {
version = "18"
modules = ['javafx.controls', 'javafx.swing', 'javafx.base', 'javafx.web']
}

assemble.dependsOn fatJar

task AndGateDemo(type: JavaExec, dependsOn: classes) {
main = 'org.reactfx.inhibeans.demo.AndGateDemo'
classpath = files(sourceSets.main.output, configurations.runtime)
tasks.register('AndGateDemo', JavaExec) {
dependsOn tasks.named('classes')
mainClass.set('org.reactfx.inhibeans.demo.AndGateDemo')
classpath = files(sourceSets.main.output, configurations.runtimeClasspath)
}

task FibTest(type: JavaExec, dependsOn: classes) {
main = 'org.reactfx.inhibeans.demo.FibTest'
classpath = files(sourceSets.main.output, configurations.runtime)
tasks.register('FibTest', JavaExec) {
dependsOn tasks.named('classes')
mainClass.set('org.reactfx.inhibeans.demo.FibTest')
classpath = files(sourceSets.main.output, configurations.runtimeClasspath)
}
115 changes: 69 additions & 46 deletions reactfx/build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
apply plugin: 'maven'
plugins {
id 'org.openjfx.javafxplugin' version '0.1.0'
}

apply plugin: 'maven-publish'
apply plugin: 'signing'

group = 'org.reactfx'

dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
testCompile group: 'org.hamcrest', name: 'hamcrest-library', version: '1.3'
testCompile group: 'org.junit.contrib', name: 'junit-theories', version: '4.12'
testCompile group: 'com.pholser', name: 'junit-quickcheck-core', version: '0.4'
testCompile group: 'com.pholser', name: 'junit-quickcheck-generators', version: '0.4'
// Test dependencies
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '5.13.4'
testImplementation group: 'org.hamcrest', name: 'hamcrest-library', version: '1.3'
testImplementation group: 'org.junit.contrib', name: 'junit-theories', version: '4.12'
testImplementation group: 'com.pholser', name: 'junit-quickcheck-core', version: '0.4'
testImplementation group: 'com.pholser', name: 'junit-quickcheck-generators', version: '0.4'
}

javafx {
version = "18"
modules = ['javafx.controls', 'javafx.swing']
}

javadoc {
Expand All @@ -22,73 +32,86 @@ javadoc {
]
}

task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
tasks.register('javadocJar', Jar) {
dependsOn tasks.named('javadoc')
archiveClassifier.set('javadoc')
from 'build/docs/javadoc'
}

task sourcesJar(type: Jar) {
tasks.register('sourcesJar', Jar) {
archiveClassifier.set('sources')
from sourceSets.main.allSource
classifier = 'sources'
}

artifacts {
archives jar

archives javadocJar
archives sourcesJar
}

signing {
sign configurations.archives
}

signArchives.onlyIf {
project.hasProperty('signing.keyId') && project.hasProperty('signing.password') && project.hasProperty('signing.secretKeyRingFile')
}

def doUploadArchives = project.hasProperty('sonatypeUsername') && project.hasProperty('sonatypePassword')
if(doUploadArchives) {
uploadArchives {
repositories.mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
publishing {
publications {
ReactFX(MavenPublication) {
from components.java

repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication(userName: sonatypeUsername, password: sonatypePassword)
}
groupId = 'org.reactfx'
artifactId = 'reactfx'
version = '2.0'

snapshotRepository(url: 'https://oss.sonatype.org/content/repositories/snapshots') {
authentication(userName: sonatypeUsername, password: sonatypePassword)
pom.withXml {
asNode().appendNode('packaging', 'jar')
}

pom.project {
name 'ReactFX'
pom {
name = 'ReactFX'
description = 'Reactive event streams for JavaFX'
url = 'http://www.reactfx.org/'
packaging 'jar'
description 'Reactive event streams for JavaFX'
url 'http://www.reactfx.org/'

scm {
url 'scm:[email protected]:TomasMikula/ReactFX.git'
connection 'scm:[email protected]:TomasMikula/ReactFX.git'
developerConnection 'scm:[email protected]:TomasMikula/ReactFX.git'
}

licenses {
license {
name 'The BSD 2-Clause License'
url 'http://opensource.org/licenses/BSD-2-Clause'
distribution 'repo'
name = 'The BSD 2-Clause License'
url = 'http://opensource.org/licenses/BSD-2-Clause'
distribution = 'repo'
}
}

scm {
url = 'scm:[email protected]:TomasMikula/ReactFX.git'
connection = 'scm:[email protected]:TomasMikula/ReactFX.git'
developerConnection = 'scm:[email protected]:TomasMikula/ReactFX.git'
}
developers {
developer {
name 'Tomas Mikula'
name = 'Tomas Mikula'
}
}
}
}
}
}

uploadArchives.onlyIf { doUploadArchives }
def isSnapshot = version.endsWith("-SNAPSHOT")
repositories {
maven {
name = "ReactFX"
url = uri(isSnapshot ? "https://oss.sonatype.org/content/repositories/snapshots"
: "https://oss.sonatype.org/service/local/staging/deploy/maven2/")
credentials {
username = project.findProperty('sonatypeUsername')
password = project.findProperty('sonatypePassword')
}
}
}

def doUploadArchives = project.hasProperty('sonatypeUsername') && project.hasProperty('sonatypePassword')
tasks.withType(PublishToMavenRepository).configureEach {
onlyIf { doUploadArchives }
}

signing {
sign configurations.archives
sign publishing.publications.ReactFX
}

signArchives.onlyIf {
project.hasProperty('signing.keyId') && project.hasProperty('signing.password') && project.hasProperty('signing.secretKeyRingFile')
}
8 changes: 4 additions & 4 deletions reactfx/src/main/java/org/reactfx/EventStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ default EventStream<List<T>> latestN(int n) {
* C :----a------------c-----------d----&gt;
* </pre>
*
* <h2>Relationship to other EventStreams:</h2>
* <h4>Relationship to other EventStreams:</h4>
* <ul>
* <li>
* This stream does NOT emit A's most recent event multiple
Expand Down Expand Up @@ -514,7 +514,7 @@ default EventStream<T> emitOn(EventStream<?> impulse) {
* C :----a------------c--c--c-----d----&gt;
* </pre>
*
* <h2>Relationship to other EventStreams:</h2>
* <h4>Relationship to other EventStreams:</h4>
* <ul>
* <li>
* This stream DOES emit A's most recent event multiple
Expand Down Expand Up @@ -553,7 +553,7 @@ default EventStream<T> emitOnEach(EventStream<?> impulse) {
* C :---[a,1]------[c,2]-----------[d,4]-----&gt;
* </pre>
*
* <h2>Relationship to other EventStreams:</h2>
* <h4>Relationship to other EventStreams:</h4>
* <ul>
* <li>
* This stream emits both A and B's events whereas {@link #emitOn(EventStream)},
Expand Down Expand Up @@ -586,7 +586,7 @@ default <I> EventStream<Tuple2<T, I>> emitBothOnEach(EventStream<I> impulse) {
* C :-a--a----b---c--c-----c-----c---d-------&gt;
* </pre>
*
* <h2>Relationship to other EventStreams:</h2>
* <h4>Relationship to other EventStreams:</h4>
* <ul>
* <li>
* This stream emits A's events when A emits an event and
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package org.reactfx.collection;

import javafx.collections.ObservableList;
import org.reactfx.Subscription;
import org.reactfx.util.Lists;

import java.util.List;

abstract class AbstractMappedList<E, F> extends LiveListBase<F> implements UnmodifiableByDefaultLiveList<F> {
private final ObservableList<? extends E> source;

public AbstractMappedList(ObservableList<? extends E> source) {
this.source = source;
}

@Override
public F get(int index) {
return apply(index, source.get(index));
}

abstract protected F apply(int index, E elem);

@Override
public int size() {
return source.size();
}

@Override
protected Subscription observeInputs() {
return LiveList.<E>observeQuasiChanges(source, this::sourceChanged);
}

abstract protected void sourceChanged(QuasiListChange<? extends E> change);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package org.reactfx.collection;

import javafx.collections.ObservableList;
import org.reactfx.util.Lists;

import java.util.List;
import java.util.function.BiFunction;

/**
* The index mapped list is applying a {@link BiFunction} taking as input the index of the element and the source element
* itself and return a mapping used for the mapped list content
* @param <E> the type of elements from the source
* @param <F> the output type of the {@link BiFunction} mapping the elements
*/
class IndexedMappedList<E, F> extends AbstractMappedList<E, F> {
private final BiFunction<Integer, ? super E, ? extends F> mapper;

public IndexedMappedList(ObservableList<? extends E> source,
BiFunction<Integer, ? super E, ? extends F> mapper) {
super(source);
this.mapper = mapper;
}

@Override
protected F apply(int index, E elem) {
return mapper.apply(index, elem);
}

@Override
protected void sourceChanged(QuasiListChange<? extends E> change) {
notifyObservers(mappedChangeView(change));
}

private QuasiListChange<F> mappedChangeView(QuasiListChange<? extends E> change) {
return () -> {
List<? extends QuasiListModification<? extends E>> mods = change.getModifications();
return Lists.<QuasiListModification<? extends E>, QuasiListModification<F>>mappedView(mods, mod -> new QuasiListModification<F>() {

@Override
public int getFrom() {
return mod.getFrom();
}

@Override
public int getAddedSize() {
return mod.getAddedSize();
}

@Override
public List<? extends F> getRemoved() {
return Lists.mappedView(mod.getRemoved(), elem -> mapper.apply(mod.getFrom(), elem));
}
});
};
}
}
Loading