Skip to content

Commit

Permalink
Item Count in a group updated correctly (#4807)
Browse files Browse the repository at this point in the history
* Item Count in a group updated correctly

* Added comments

* changes
  • Loading branch information
samiyac authored and tobiasdiez committed Mar 27, 2019
1 parent ef5710c commit ce7293d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/main/java/org/jabref/gui/groups/GroupNodeViewModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public class GroupNodeViewModel {
private final BooleanBinding allSelectedEntriesMatched;
private final TaskExecutor taskExecutor;
private final CustomLocalDragboard localDragBoard;
private final ObservableList<BibEntry> entriesList;

public GroupNodeViewModel(BibDatabaseContext databaseContext, StateManager stateManager, TaskExecutor taskExecutor, GroupTreeNode groupNode, CustomLocalDragboard localDragBoard) {
this.databaseContext = Objects.requireNonNull(databaseContext);
Expand Down Expand Up @@ -84,7 +85,9 @@ public GroupNodeViewModel(BibDatabaseContext databaseContext, StateManager state
expandedProperty.addListener((observable, oldValue, newValue) -> groupNode.getGroup().setExpanded(newValue));

// Register listener
databaseContext.getDatabase().getEntries().addListener(this::onDatabaseChanged);
// The wrapper created by the FXCollections will set a weak listener on the wrapped list. This weak listener gets garbage collected. Hence, we need to maintain a reference to this list.
entriesList = databaseContext.getDatabase().getEntries();
entriesList.addListener(this::onDatabaseChanged);

ObservableList<Boolean> selectedEntriesMatchStatus = EasyBind.map(stateManager.getSelectedEntries(), groupNode::matches);
anySelectedEntriesMatched = BindingsHelper.any(selectedEntriesMatchStatus, matched -> matched);
Expand Down

0 comments on commit ce7293d

Please sign in to comment.