diff --git a/build.gradle b/build.gradle index f34f2e28e6a..945071766cf 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ import org.gradle.internal.os.OperatingSystem buildscript { repositories { maven { - url 'http://maven.ej-technologies.com/repository' + url 'https://maven.ej-technologies.com/repository' } } dependencies { @@ -113,10 +113,8 @@ dependencies { compile 'de.codecentric.centerdevice:javafxsvg:1.2.1' compile 'org.controlsfx:controlsfx:8.40.12' compile 'org.fxmisc.easybind:easybind:1.0.3' - compile('net.corda:jfx:0.12.1') { - transitive = false - } - compile 'org.jetbrains.kotlin:kotlin-stdlib:1.1.3' // required by net.corda:jfxc + + compile 'org.fxmisc.flowless:flowless:0.5.2' compile 'de.jensd:fontawesomefx-materialdesignfont:1.7.22-4' compile 'org.fxmisc.richtext:richtextfx:0.7-M5' diff --git a/external-libraries.txt b/external-libraries.txt index 1bf47425154..02e257a40bc 100644 --- a/external-libraries.txt +++ b/external-libraries.txt @@ -138,11 +138,6 @@ Project: EasyBind URL: https://github.com/TomasMikula/EasyBind License: BSD-2-Clause -Id: net.corda:jfx -Project: Corda -URL: https://github.com/corda/corda/tree/master/client/jfx -License: Apache-2.0 - Id: org.fxmisc.flowless:flowless Project: Flowless URL: https://github.com/TomasMikula/Flowless diff --git a/src/main/java/org/jabref/gui/util/BindingsHelper.java b/src/main/java/org/jabref/gui/util/BindingsHelper.java index 88ca45210af..246ad43ff50 100644 --- a/src/main/java/org/jabref/gui/util/BindingsHelper.java +++ b/src/main/java/org/jabref/gui/util/BindingsHelper.java @@ -18,8 +18,6 @@ import javafx.css.PseudoClass; import javafx.scene.Node; -import net.corda.client.jfx.utils.MappedList; - /** * Helper methods for javafx binding. @@ -67,8 +65,8 @@ public String getName() { * the items are converted when the are inserted (and at the initialization) instead of when they are accessed. * Thus the initial CPU overhead and memory consumption is higher but the access to list items is quicker. */ - public static ObservableList mapBacked(ObservableList source, Function mapper) { - return new MappedList<>(source, mapper::apply); + public static MappedList mapBacked(ObservableList source, Function mapper) { + return new MappedList<>(source, mapper); } /** @@ -154,7 +152,7 @@ public ChangeListener getChangeListenerB() { public void changedA(ObservableValue observable, A oldValue, A newValue) { updateLocked(updateB, oldValue, newValue); } - + public void changedB(ObservableValue observable, B oldValue, B newValue) { updateLocked(updateA, oldValue, newValue); } diff --git a/src/main/java/org/jabref/gui/util/MappedList.java b/src/main/java/org/jabref/gui/util/MappedList.java new file mode 100644 index 00000000000..8e2c64b0cb8 --- /dev/null +++ b/src/main/java/org/jabref/gui/util/MappedList.java @@ -0,0 +1,113 @@ +package org.jabref.gui.util; + +import java.util.ArrayList; +import java.util.List; +import java.util.function.Function; + +import javafx.collections.ListChangeListener; +import javafx.collections.ObservableList; +import javafx.collections.transformation.TransformationList; + +/** + * MappedList implementation based on https://gist.github.com/TomasMikula/8883719 + * + * @author https://github.com/TomasMikula + */ +public final class MappedList extends TransformationList { + + private final Function mapper; + + public MappedList(ObservableList sourceList, Function mapper) { + super(sourceList); + this.mapper = mapper; + } + + @Override + protected void sourceChanged(ListChangeListener.Change change) { + fireChange(new ListChangeListener.Change(this) { + + @Override + public boolean wasAdded() { + return change.wasAdded(); + } + + @Override + public boolean wasRemoved() { + return change.wasRemoved(); + } + + @Override + public boolean wasReplaced() { + return change.wasReplaced(); + } + + @Override + public boolean wasUpdated() { + return change.wasUpdated(); + } + + @Override + public boolean wasPermutated() { + return change.wasPermutated(); + } + + @Override + public int getPermutation(int index) { + return change.getPermutation(index); + } + + @Override + protected int[] getPermutation() { + // This method is only called by the superclass methods + // wasPermutated() and getPermutation(int), which are + // both overridden by this class. There is no other way + // this method can be called. + throw new AssertionError("Unreachable code"); + } + + @Override + public List getRemoved() { + List result = new ArrayList<>(change.getRemovedSize()); + for (B element : change.getRemoved()) { + result.add(mapper.apply(element)); + } + return result; + } + + @Override + public int getFrom() { + return change.getFrom(); + } + + @Override + public int getTo() { + return change.getTo(); + } + + @Override + public boolean next() { + return change.next(); + } + + @Override + public void reset() { + change.reset(); + } + }); + } + + @Override + public int getSourceIndex(int index) { + return index; + } + + @Override + public A get(int index) { + return mapper.apply(super.getSource().get(index)); + } + + @Override + public int size() { + return super.getSource().size(); + } +}