Skip to content

Commit

Permalink
Fix #2852: Improve performance of group filtering.
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasdiez committed May 20, 2017
1 parent 624c4ac commit 01e8548
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 126 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#
### Changed
- We continued to improve the new groups interface:
- 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).
- We further improved performance of group operations, especially of the new filter feature [#2852](https://github.com/JabRef/jabref/issues/2852).
- The entry editor got a fresh coat of paint:
- Homogenize the size of text fields.
- The buttons were changed to icons.
Expand Down
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ 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.11.0'
compile 'org.fxmisc.flowless:flowless:0.5.2'
compile 'de.jensd:fontawesomefx-materialdesignfont:1.7.22-4'

Expand Down
11 changes: 8 additions & 3 deletions external-libraries.txt
Original file line number Diff line number Diff line change
Expand Up @@ -131,17 +131,22 @@ URL: http://fxexperience.com/controlsfx/
License: BSD-3-Clause

Id: org.fx.misc.easybin:easybind
Projekt: EasyBind
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
Projekt: Flowless
Project: Flowless
URL: https://github.com/TomasMikula/Flowless
License: BSD-2-Clause

Id: de.jensd:fontawesomefx-materialdesignfont
Projekt: FontAwesomeFX
Project: FontAwesomeFX
URL: https://bitbucket.org/Jerady/fontawesomefx
License: Apache-2.0

Expand Down
120 changes: 0 additions & 120 deletions src/main/java/org/jabref/gui/MappedList.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import org.jabref.gui.AbstractViewModel;
import org.jabref.gui.ClipBoardManager;
import org.jabref.gui.DialogService;
import org.jabref.gui.MappedList;
import org.jabref.gui.desktop.JabRefDesktop;
import org.jabref.logic.l10n.Localization;
import org.jabref.logic.logging.LogMessages;
Expand All @@ -27,6 +26,7 @@
import org.apache.commons.logging.LogFactory;
import org.apache.http.client.utils.URIBuilder;
import org.apache.logging.log4j.core.LogEvent;
import org.fxmisc.easybind.EasyBind;

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public GroupNodeViewModel(BibDatabaseContext databaseContext, StateManager state
.sorted((group1, group2) -> group1.getDisplayName().compareToIgnoreCase(group2.getDisplayName()))
.collect(Collectors.toCollection(FXCollections::observableArrayList));
} else {
children = EasyBind.map(groupNode.getChildren(), this::toViewModel);
children = BindingsHelper.mapBacked(groupNode.getChildren(), this::toViewModel);
}
hasChildren = new SimpleBooleanProperty();
hasChildren.bind(Bindings.isNotEmpty(children));
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/org/jabref/gui/util/BindingsHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import javafx.css.PseudoClass;
import javafx.scene.Node;

import net.corda.client.jfx.utils.MappedList;


/**
* Helper methods for javafx binding.
Expand Down Expand Up @@ -57,6 +59,18 @@ public String getName() {
pseudoClassState.bind(condition);
}

/**
* Creates a new list in which each element is converted using the provided mapping.
* All changes to the underlying list are propagated to the converted list.
*
* In contrast to {@link org.fxmisc.easybind.EasyBind#map(ObservableList, Function)},
* 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 <A, B> ObservableList<B> mapBacked(ObservableList<A> source, Function<A, B> mapper) {
return new MappedList<>(source, mapper::apply);
}

/**
* Binds propertA bidirectional to propertyB using the provided map functions to convert between them.
*/
Expand Down

0 comments on commit 01e8548

Please sign in to comment.