From 59b979484828b72536400b4be7f9234c0ab03d4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Lenhard?= Date: Thu, 13 Jul 2017 11:32:14 +0200 Subject: [PATCH] Listen to change events for setting dirty status of database (#3001) * Listen to change events for setting dirty status of database * Use a single listener instance * Merge DatabaseChangeListener into BasePanel * Add changelog entry --- CHANGELOG.md | 1 + src/main/java/org/jabref/gui/BasePanel.java | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 192b1595e42..6e3c2cb2e5a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/main/java/org/jabref/gui/BasePanel.java b/src/main/java/org/jabref/gui/BasePanel.java index f048050424b..3a244151a89 100644 --- a/src/main/java/org/jabref/gui/BasePanel.java +++ b/src/main/java/org/jabref/gui/BasePanel.java @@ -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; @@ -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; @@ -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. */