Skip to content

Commit f5a8f00

Browse files
tobiasdiezSiedlerchr
authored andcommitted
Fix group hit counter when adding entries (#4413)
Fixes #3537 by replacing the EventBus subscription by a JavaFX listener.
1 parent 72a73a6 commit f5a8f00

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#
6161
- 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)
6262
- We fixed an issue where the groups tree of the last database was still shown even after the database was already closed.
6363
- We fixed an issue where the "Open file dialog" may disappear behind other windows. https://github.com/JabRef/jabref/issues/3410
64+
- 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)
6465
- We fixed an issue where the default icon of a group was not colored correctly.
6566
- 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)
6667
- 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

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

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import javafx.beans.property.SimpleBooleanProperty;
1212
import javafx.beans.property.SimpleIntegerProperty;
1313
import javafx.collections.FXCollections;
14+
import javafx.collections.ListChangeListener;
1415
import javafx.collections.ObservableList;
1516
import javafx.scene.input.Dragboard;
1617
import javafx.scene.paint.Color;
@@ -29,15 +30,13 @@
2930
import org.jabref.model.FieldChange;
3031
import org.jabref.model.database.BibDatabaseContext;
3132
import org.jabref.model.entry.BibEntry;
32-
import org.jabref.model.entry.event.EntryEvent;
3333
import org.jabref.model.groups.AbstractGroup;
3434
import org.jabref.model.groups.AutomaticGroup;
3535
import org.jabref.model.groups.GroupEntryChanger;
3636
import org.jabref.model.groups.GroupTreeNode;
3737
import org.jabref.model.strings.StringUtil;
3838

3939
import com.google.common.base.Enums;
40-
import com.google.common.eventbus.Subscribe;
4140
import de.jensd.fx.glyphs.materialdesignicons.MaterialDesignIcon;
4241
import org.fxmisc.easybind.EasyBind;
4342

@@ -85,7 +84,7 @@ public GroupNodeViewModel(BibDatabaseContext databaseContext, StateManager state
8584
expandedProperty.addListener((observable, oldValue, newValue) -> groupNode.getGroup().setExpanded(newValue));
8685

8786
// Register listener
88-
databaseContext.getDatabase().registerListener(this);
87+
databaseContext.getDatabase().getEntries().addListener(this::onDatabaseChanged);
8988

9089
ObservableList<Boolean> selectedEntriesMatchStatus = EasyBind.map(stateManager.getSelectedEntries(), groupNode::matches);
9190
anySelectedEntriesMatched = BindingsHelper.any(selectedEntriesMatchStatus, matched -> matched);
@@ -212,10 +211,9 @@ public GroupTreeNode getGroupNode() {
212211
}
213212

214213
/**
215-
* Gets invoked if an entry in the current database changes.
216-
*/
217-
@Subscribe
218-
public void listen(@SuppressWarnings("unused") EntryEvent entryEvent) {
214+
* Gets invoked if an entry in the current database changes.
215+
*/
216+
private void onDatabaseChanged(ListChangeListener.Change<? extends BibEntry> change) {
219217
calculateNumberOfMatches();
220218
}
221219

0 commit comments

Comments
 (0)