From f5a8f00a892f46ee6f3c8e5cbccdec9d1f36dba7 Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Sat, 27 Oct 2018 15:36:07 +0200 Subject: [PATCH] Fix group hit counter when adding entries (#4413) Fixes #3537 by replacing the EventBus subscription by a JavaFX listener. --- CHANGELOG.md | 1 + .../org/jabref/gui/groups/GroupNodeViewModel.java | 12 +++++------- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 91a47bb024c..9848a45705f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -61,6 +61,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `# - We fixed an issue where the order of fields in customized entry types was not saved correctly. [#4033](http://github.com/JabRef/jabref/issues/4033) - We fixed an issue where the groups tree of the last database was still shown even after the database was already closed. - We fixed an issue where the "Open file dialog" may disappear behind other windows. https://github.com/JabRef/jabref/issues/3410 +- We fixed an issue where the number of entries matched was not updated correctly upon adding or removing an entry. [#3537](https://github.com/JabRef/jabref/issues/3537) - We fixed an issue where the default icon of a group was not colored correctly. - We fixed an issue where the first field in entry editor was not focused when adding a new entry. [#4024](https://github.com/JabRef/jabref/issues/4024) - We reworked the "Edit file" dialog to make it resizeable and improved the workflow for adding and editing files https://github.com/JabRef/jabref/issues/2970 diff --git a/src/main/java/org/jabref/gui/groups/GroupNodeViewModel.java b/src/main/java/org/jabref/gui/groups/GroupNodeViewModel.java index 2699df22cb6..12abad57d6c 100644 --- a/src/main/java/org/jabref/gui/groups/GroupNodeViewModel.java +++ b/src/main/java/org/jabref/gui/groups/GroupNodeViewModel.java @@ -11,6 +11,7 @@ import javafx.beans.property.SimpleBooleanProperty; import javafx.beans.property.SimpleIntegerProperty; import javafx.collections.FXCollections; +import javafx.collections.ListChangeListener; import javafx.collections.ObservableList; import javafx.scene.input.Dragboard; import javafx.scene.paint.Color; @@ -29,7 +30,6 @@ import org.jabref.model.FieldChange; import org.jabref.model.database.BibDatabaseContext; import org.jabref.model.entry.BibEntry; -import org.jabref.model.entry.event.EntryEvent; import org.jabref.model.groups.AbstractGroup; import org.jabref.model.groups.AutomaticGroup; import org.jabref.model.groups.GroupEntryChanger; @@ -37,7 +37,6 @@ import org.jabref.model.strings.StringUtil; import com.google.common.base.Enums; -import com.google.common.eventbus.Subscribe; import de.jensd.fx.glyphs.materialdesignicons.MaterialDesignIcon; import org.fxmisc.easybind.EasyBind; @@ -85,7 +84,7 @@ public GroupNodeViewModel(BibDatabaseContext databaseContext, StateManager state expandedProperty.addListener((observable, oldValue, newValue) -> groupNode.getGroup().setExpanded(newValue)); // Register listener - databaseContext.getDatabase().registerListener(this); + databaseContext.getDatabase().getEntries().addListener(this::onDatabaseChanged); ObservableList selectedEntriesMatchStatus = EasyBind.map(stateManager.getSelectedEntries(), groupNode::matches); anySelectedEntriesMatched = BindingsHelper.any(selectedEntriesMatchStatus, matched -> matched); @@ -212,10 +211,9 @@ public GroupTreeNode getGroupNode() { } /** - * Gets invoked if an entry in the current database changes. - */ - @Subscribe - public void listen(@SuppressWarnings("unused") EntryEvent entryEvent) { + * Gets invoked if an entry in the current database changes. + */ + private void onDatabaseChanged(ListChangeListener.Change change) { calculateNumberOfMatches(); }