Skip to content

Commit

Permalink
Listen to change events for setting dirty status of database (#3001)
Browse files Browse the repository at this point in the history
* Listen to change events for setting dirty status of database

* Use a single listener instance

* Merge DatabaseChangeListener into BasePanel

* Add changelog entry
  • Loading branch information
lenhard authored and Siedlerchr committed Jul 13, 2017
1 parent 55a6857 commit 59b9794
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#
- We fixed a bug where recursive RegExpBased search found a file in a subdirectory multiple times and non-recursive RegExpBased search erroneously found files in subdirectories.
- We fixed a bug where new groups information was not stored on save [#2932](https://github.com/JabRef/jabref/issues/2932)
- We fixed a bug where the language files for Brazilian Portugese could not be loaded and the GUI localization remained in English [#1128](https://github.com/JabRef/jabref/issues/1182)
- We fixed a bug where the database was not marked as dirty when entries or groups were changed [#2787](https://github.com/JabRef/jabref/issues/2787)

### Removed

Expand Down
8 changes: 8 additions & 0 deletions src/main/java/org/jabref/gui/BasePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.model.database.DatabaseLocation;
import org.jabref.model.database.KeyCollisionException;
import org.jabref.model.database.event.BibDatabaseContextChangedEvent;
import org.jabref.model.database.event.EntryAddedEvent;
import org.jabref.model.database.event.EntryRemovedEvent;
import org.jabref.model.entry.BibEntry;
Expand Down Expand Up @@ -204,6 +205,8 @@ public BasePanel(JabRefFrame frame, BibDatabaseContext bibDatabaseContext) {
Objects.requireNonNull(bibDatabaseContext);

this.bibDatabaseContext = bibDatabaseContext;
bibDatabaseContext.getDatabase().registerListener(this);
bibDatabaseContext.getMetaData().registerListener(this);

this.sidePaneManager = frame.getSidePaneManager();
this.frame = frame;
Expand Down Expand Up @@ -259,6 +262,11 @@ public static void runWorker(AbstractWorker worker) throws Exception {
clb.update(); // Runs the update() method on the EDT.
}

@Subscribe
public void listen(BibDatabaseContextChangedEvent event) {
this.markBaseChanged();
}

/**
* Returns a collection of suggestion providers, which are populated from the current library.
*/
Expand Down

0 comments on commit 59b9794

Please sign in to comment.