Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into SearchKeyEvent
Browse files Browse the repository at this point in the history
* upstream/master:
  Fix markdown
  Update gradle from 4.0.1 to 4.0.2
  Fix #3045 Update Transformer plugin
  Reimplement MappedList using a backigList (#3069)

# Conflicts:
#	CHANGELOG.md
  • Loading branch information
Siedlerchr committed Aug 4, 2017
2 parents 976ff48 + ea29f56 commit 671fca0
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 79 deletions.
10 changes: 6 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#
## [Unreleased]

### Changed

If fetched article is already in database the ImportInspectionDialog is started

### Fixed
We fixed an issue where the fetcher for the Astrophysics Data System (ADS) added some non-bibtex data to the entry returned from the search [#3035](https://github.com/JabRef/jabref/issues/3035)
We fixed an issue where assigning an entry via drag and drop to a group caused JabRef to stop/freeze completely [#3036](https://github.com/JabRef/jabref/issues/3036)
We fixed an issue where the preferences could not be imported without a restart of JabRef [#3064](https://github.com/JabRef/jabref/issues/3064)
We fixed an issue where <kbd>DEL</kbd>, <kbd>Ctrl</kbd>+<kbd>C</kbd>, <kbd>Ctrl</kbd>+<kbd>V</kbd> and <kbd>Ctrl</kbd>+<kbd>A</kbd> in the search field triggered corresponding actions in the main table [#3067](https://github.com/JabRef/jabref/issues/3067)

- We fixed an issue where the fetcher for the Astrophysics Data System (ADS) added some non-bibtex data to the entry returned from the search [#3035](https://github.com/JabRef/jabref/issues/3035)
- We fixed an issue where assigning an entry via drag and drop to a group caused JabRef to stop/freeze completely [#3036](https://github.com/JabRef/jabref/issues/3036)
- We fixed an issue where the preferences could not be imported without a restart of JabRef [#3064](https://github.com/JabRef/jabref/issues/3064)
- We fixed an issue where <kbd>DEL</kbd>, <kbd>Ctrl</kbd>+<kbd>C</kbd>, <kbd>Ctrl</kbd>+<kbd>V</kbd> and <kbd>Ctrl</kbd>+<kbd>A</kbd> in the search field triggered corresponding actions in the main table [#3067](https://github.com/JabRef/jabref/issues/3067)
### Removed


Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import org.gradle.internal.os.OperatingSystem

// to update the gradle wrapper, execute ./gradlew wrapper --gradle-version 3.0
// to update the gradle wrapper, execute ./gradlew wrapper --gradle-version 4.0

plugins {
id 'com.gradle.build-scan' version '1.8'
id 'com.install4j.gradle' version '6.1.5'
id 'com.github.johnrengelman.shadow' version '2.0.1'
id "de.sebastianboegl.shadow.transformer.log4j" version "2.1.0"
id "de.sebastianboegl.shadow.transformer.log4j" version "2.1.1"
id "com.simonharrer.modernizer" version '1.5.0-1'
id 'me.champeau.gradle.jmh' version '0.4.3'
id 'net.ltgt.errorprone' version '0.0.11'
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Tue Jul 18 01:58:04 BRT 2017
#Thu Aug 03 11:08:08 CEST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.0.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.0.2-bin.zip
119 changes: 48 additions & 71 deletions src/main/java/org/jabref/gui/util/MappedList.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,91 +9,68 @@
import javafx.collections.transformation.TransformationList;

/**
* MappedList implementation based on https://gist.github.com/TomasMikula/8883719
*
* @author https://github.com/TomasMikula
* MappedList implementation based on https://github.com/corda/corda/blob/master/client/jfx/src/main/kotlin/net/corda/client/jfx/utils/MappedList.kt
*/
public final class MappedList<A, B> extends TransformationList<A, B> {

private final Function<B, A> mapper;
private final List<A> backingList;

public MappedList(ObservableList<? extends B> sourceList, Function<B, A> mapper) {
super(sourceList);
this.mapper = mapper;
this.backingList = new ArrayList<>(sourceList.size());
sourceList.stream().map(mapper::apply).forEach(backingList::add);
}

@Override
protected void sourceChanged(ListChangeListener.Change<? extends B> change) {
fireChange(new ListChangeListener.Change<A>(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<A> getRemoved() {
List<A> result = new ArrayList<>(change.getRemovedSize());
for (B element : change.getRemoved()) {
result.add(mapper.apply(element));
beginChange();
while (change.next()) {
if (change.wasPermutated()) {
int from = change.getFrom();
int to = change.getTo();

// get permutation array
int[] permutation = new int[to - from];
for (int i = 0; i < to - from; i++) {
permutation[i] = change.getPermutation(i);
}
return result;
}

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

@Override
public int getTo() {
return change.getTo();
}

@Override
public boolean next() {
return change.next();
}
// perform permutation
Object[] permutedPart = new Object[to - from];
for (int i = from; i < to; i++) {
permutedPart[permutation[i]] = backingList.get(i);
}

@Override
public void reset() {
change.reset();
// update backingList
for (int i = 0; i < to; i++) {
backingList.set(i + from, (A) permutedPart[i]);
}
nextPermutation(from, to, permutation);
} else if (change.wasUpdated()) {
backingList.set(change.getFrom(), mapper.apply(getSource().get(change.getFrom())));
nextUpdate(change.getFrom());
} else {
if (change.wasRemoved()) {
int removePosition = change.getFrom();
List<A> removed = new ArrayList<>(change.getRemovedSize());
for (int i = 0; i < change.getRemovedSize(); i++) {
removed.add(backingList.remove(removePosition));
}
nextRemove(change.getFrom(), removed);
}
if (change.wasAdded()) {
int addStart = change.getFrom();
int addEnd = change.getTo();
for (int i = addStart; i < addEnd; i++) {
backingList.add(i, mapper.apply(change.getList().get(i)));
}
nextAdd(addStart, addEnd);
}
}
});
}
endChange();
}

@Override
Expand All @@ -103,11 +80,11 @@ public int getSourceIndex(int index) {

@Override
public A get(int index) {
return mapper.apply(super.getSource().get(index));
return backingList.get(index);
}

@Override
public int size() {
return super.getSource().size();
return backingList.size();
}
}

0 comments on commit 671fca0

Please sign in to comment.