Skip to content

Commit

Permalink
Trigger group display update when grouping changes (#3111)
Browse files Browse the repository at this point in the history
  • Loading branch information
lenhard authored and LinusDietz committed Aug 16, 2017
1 parent 870b86d commit b8485f7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#
- We fixed an issue where the other tab was not updated when fields where changed in the source tab. [#3063](https://github.com/JabRef/jabref/issues/3063)
- We fixed an issue where the source tab was not updated after fetching data by DOI. [#3103](https://github.com/JabRef/jabref/issues/3103)
- We fixed an issue where the move to group operation did not remove the entry from other groups [#3101](https://github.com/JabRef/jabref/issues/3101)
- We fixed an issue where the main table was not updated when grouping changes [#1903](https://github.com/JabRef/jabref/issues/1903)

### Removed

Expand Down
20 changes: 20 additions & 0 deletions src/main/java/org/jabref/gui/groups/GroupSidePane.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,15 @@
import org.jabref.gui.keyboard.KeyBinding;
import org.jabref.gui.maintable.MainTableDataModel;
import org.jabref.logic.l10n.Localization;
import org.jabref.model.entry.FieldName;
import org.jabref.model.entry.event.FieldChangedEvent;
import org.jabref.model.groups.GroupTreeNode;
import org.jabref.model.search.matchers.MatcherSet;
import org.jabref.model.search.matchers.MatcherSets;
import org.jabref.preferences.JabRefPreferences;

import com.google.common.eventbus.Subscribe;

/**
* The groups side pane.
* This class is just a Swing wrapper around the JavaFX implementation {@link GroupTreeView}.
Expand All @@ -40,6 +44,15 @@ public GroupSidePane(JabRefFrame frame, SidePaneManager manager) {
Globals.stateManager.activeGroupProperty()
.addListener((observable, oldValue, newValue) -> updateShownEntriesAccordingToSelectedGroups(newValue));

// register the panel the current active context
Globals.stateManager.activeDatabaseProperty()
.addListener((observable, oldValue, newValue) -> {
newValue.ifPresent(databaseContext ->
databaseContext.getDatabase().registerListener(this));
oldValue.ifPresent(databaseContext ->
databaseContext.getDatabase().unregisterListener(this));
});

toggleAction = new ToggleAction(Localization.menuTitle("Toggle groups interface"),
Localization.lang("Toggle groups interface"),
Globals.getKeyPrefs().getKey(KeyBinding.TOGGLE_GROUPS_INTERFACE),
Expand All @@ -60,6 +73,13 @@ public GroupSidePane(JabRefFrame frame, SidePaneManager manager) {
});
}

@Subscribe
public synchronized void listen(FieldChangedEvent event) {
if (FieldName.GROUPS.equals(event.getFieldName())) {
updateShownEntriesAccordingToSelectedGroups(Globals.stateManager.activeGroupProperty());
}
}

private void updateShownEntriesAccordingToSelectedGroups(List<GroupTreeNode> selectedGroups) {
if (selectedGroups == null || selectedGroups.isEmpty()) {
// No selected group, nothing to do
Expand Down

0 comments on commit b8485f7

Please sign in to comment.