Skip to content

Commit 01e8548

Browse files
committed
Fix #2852: Improve performance of group filtering.
1 parent 624c4ac commit 01e8548

File tree

7 files changed

+27
-126
lines changed

7 files changed

+27
-126
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#
1313
### Changed
1414
- We continued to improve the new groups interface:
1515
- You can now again select multiple groups (and a few related settings were added to the preferences) [#2786](https://github.com/JabRef/jabref/issues/2786).
16+
- We further improved performance of group operations, especially of the new filter feature [#2852](https://github.com/JabRef/jabref/issues/2852).
1617
- The entry editor got a fresh coat of paint:
1718
- Homogenize the size of text fields.
1819
- The buttons were changed to icons.

build.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ dependencies {
114114
compile 'de.codecentric.centerdevice:javafxsvg:1.2.1'
115115
compile 'org.controlsfx:controlsfx:8.40.12'
116116
compile 'org.fxmisc.easybind:easybind:1.0.3'
117+
compile 'net.corda:jfx:0.11.0'
117118
compile 'org.fxmisc.flowless:flowless:0.5.2'
118119
compile 'de.jensd:fontawesomefx-materialdesignfont:1.7.22-4'
119120

external-libraries.txt

+8-3
Original file line numberDiff line numberDiff line change
@@ -131,17 +131,22 @@ URL: http://fxexperience.com/controlsfx/
131131
License: BSD-3-Clause
132132

133133
Id: org.fx.misc.easybin:easybind
134-
Projekt: EasyBind
134+
Project: EasyBind
135135
URL: https://github.com/TomasMikula/EasyBind
136136
License: BSD-2-Clause
137137

138+
Id: net.corda:jfx
139+
Project: Corda
140+
URL: https://github.com/corda/corda/tree/master/client/jfx
141+
License: Apache-2.0
142+
138143
Id: org.fxmisc.flowless:flowless
139-
Projekt: Flowless
144+
Project: Flowless
140145
URL: https://github.com/TomasMikula/Flowless
141146
License: BSD-2-Clause
142147

143148
Id: de.jensd:fontawesomefx-materialdesignfont
144-
Projekt: FontAwesomeFX
149+
Project: FontAwesomeFX
145150
URL: https://bitbucket.org/Jerady/fontawesomefx
146151
License: Apache-2.0
147152

src/main/java/org/jabref/gui/MappedList.java

-120
This file was deleted.

src/main/java/org/jabref/gui/errorconsole/ErrorConsoleViewModel.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import org.jabref.gui.AbstractViewModel;
1717
import org.jabref.gui.ClipBoardManager;
1818
import org.jabref.gui.DialogService;
19-
import org.jabref.gui.MappedList;
2019
import org.jabref.gui.desktop.JabRefDesktop;
2120
import org.jabref.logic.l10n.Localization;
2221
import org.jabref.logic.logging.LogMessages;
@@ -27,6 +26,7 @@
2726
import org.apache.commons.logging.LogFactory;
2827
import org.apache.http.client.utils.URIBuilder;
2928
import org.apache.logging.log4j.core.LogEvent;
29+
import org.fxmisc.easybind.EasyBind;
3030

3131
public class ErrorConsoleViewModel extends AbstractViewModel {
3232
private static final Log LOGGER = LogFactory.getLog(ErrorConsoleViewModel.class);
@@ -42,7 +42,7 @@ public ErrorConsoleViewModel(DialogService dialogService, ClipBoardManager clipB
4242
this.dialogService = Objects.requireNonNull(dialogService);
4343
this.clipBoardManager = Objects.requireNonNull(clipBoardManager);
4444
this.buildInfo = Objects.requireNonNull(buildInfo);
45-
ObservableList<LogEventViewModel> eventViewModels = new MappedList<>(LogMessages.getInstance().getMessages(), LogEventViewModel::new);
45+
ObservableList<LogEventViewModel> eventViewModels = EasyBind.map(LogMessages.getInstance().getMessages(), LogEventViewModel::new);
4646
allMessagesData = new ReadOnlyListWrapper<>(eventViewModels);
4747
}
4848

src/main/java/org/jabref/gui/groups/GroupNodeViewModel.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public GroupNodeViewModel(BibDatabaseContext databaseContext, StateManager state
6767
.sorted((group1, group2) -> group1.getDisplayName().compareToIgnoreCase(group2.getDisplayName()))
6868
.collect(Collectors.toCollection(FXCollections::observableArrayList));
6969
} else {
70-
children = EasyBind.map(groupNode.getChildren(), this::toViewModel);
70+
children = BindingsHelper.mapBacked(groupNode.getChildren(), this::toViewModel);
7171
}
7272
hasChildren = new SimpleBooleanProperty();
7373
hasChildren.bind(Bindings.isNotEmpty(children));

src/main/java/org/jabref/gui/util/BindingsHelper.java

+14
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
import javafx.css.PseudoClass;
1919
import javafx.scene.Node;
2020

21+
import net.corda.client.jfx.utils.MappedList;
22+
2123

2224
/**
2325
* Helper methods for javafx binding.
@@ -57,6 +59,18 @@ public String getName() {
5759
pseudoClassState.bind(condition);
5860
}
5961

62+
/**
63+
* Creates a new list in which each element is converted using the provided mapping.
64+
* All changes to the underlying list are propagated to the converted list.
65+
*
66+
* In contrast to {@link org.fxmisc.easybind.EasyBind#map(ObservableList, Function)},
67+
* the items are converted when the are inserted (and at the initialization) instead of when they are accessed.
68+
* Thus the initial CPU overhead and memory consumption is higher but the access to list items is quicker.
69+
*/
70+
public static <A, B> ObservableList<B> mapBacked(ObservableList<A> source, Function<A, B> mapper) {
71+
return new MappedList<>(source, mapper::apply);
72+
}
73+
6074
/**
6175
* Binds propertA bidirectional to propertyB using the provided map functions to convert between them.
6276
*/

0 commit comments

Comments
 (0)