From b80806b7d04cad79ca70c1ae6567161fb04d2ff9 Mon Sep 17 00:00:00 2001 From: Joerg Lenhard Date: Wed, 12 Jul 2017 17:33:18 +0200 Subject: [PATCH 1/4] Listen to change events for setting dirty status of database --- src/main/java/org/jabref/gui/BasePanel.java | 2 ++ .../jabref/gui/DatabaseChangeListener.java | 20 +++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 src/main/java/org/jabref/gui/DatabaseChangeListener.java diff --git a/src/main/java/org/jabref/gui/BasePanel.java b/src/main/java/org/jabref/gui/BasePanel.java index f048050424b..f003715dc70 100644 --- a/src/main/java/org/jabref/gui/BasePanel.java +++ b/src/main/java/org/jabref/gui/BasePanel.java @@ -204,6 +204,8 @@ public BasePanel(JabRefFrame frame, BibDatabaseContext bibDatabaseContext) { Objects.requireNonNull(bibDatabaseContext); this.bibDatabaseContext = bibDatabaseContext; + bibDatabaseContext.getDatabase().registerListener(new DatabaseChangeListener(this)); + bibDatabaseContext.getMetaData().registerListener(new DatabaseChangeListener(this)); this.sidePaneManager = frame.getSidePaneManager(); this.frame = frame; diff --git a/src/main/java/org/jabref/gui/DatabaseChangeListener.java b/src/main/java/org/jabref/gui/DatabaseChangeListener.java new file mode 100644 index 00000000000..caec97f847b --- /dev/null +++ b/src/main/java/org/jabref/gui/DatabaseChangeListener.java @@ -0,0 +1,20 @@ +package org.jabref.gui; + + +import com.google.common.eventbus.Subscribe; +import org.jabref.model.database.event.BibDatabaseContextChangedEvent; + +public class DatabaseChangeListener { + + private BasePanel basePanel; + + public DatabaseChangeListener(BasePanel basePanel) { + this.basePanel = basePanel; + } + + @Subscribe + public void listen(BibDatabaseContextChangedEvent event) { + basePanel.markBaseChanged(); + } + +} From 5724a9eef0bee5edd19be047de7ed36c2e67bb2e Mon Sep 17 00:00:00 2001 From: Joerg Lenhard Date: Wed, 12 Jul 2017 17:40:06 +0200 Subject: [PATCH 2/4] Use a single listener instance --- src/main/java/org/jabref/gui/BasePanel.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/jabref/gui/BasePanel.java b/src/main/java/org/jabref/gui/BasePanel.java index f003715dc70..62151ebf6a8 100644 --- a/src/main/java/org/jabref/gui/BasePanel.java +++ b/src/main/java/org/jabref/gui/BasePanel.java @@ -204,8 +204,9 @@ public BasePanel(JabRefFrame frame, BibDatabaseContext bibDatabaseContext) { Objects.requireNonNull(bibDatabaseContext); this.bibDatabaseContext = bibDatabaseContext; - bibDatabaseContext.getDatabase().registerListener(new DatabaseChangeListener(this)); - bibDatabaseContext.getMetaData().registerListener(new DatabaseChangeListener(this)); + DatabaseChangeListener databaseChangeListener = new DatabaseChangeListener(this); + bibDatabaseContext.getDatabase().registerListener(databaseChangeListener); + bibDatabaseContext.getMetaData().registerListener(databaseChangeListener); this.sidePaneManager = frame.getSidePaneManager(); this.frame = frame; From 7694532ba7bbb1bf64ec51d7bd526a301366ea0b Mon Sep 17 00:00:00 2001 From: Joerg Lenhard Date: Thu, 13 Jul 2017 10:22:55 +0200 Subject: [PATCH 3/4] Merge DatabaseChangeListener into BasePanel --- src/main/java/org/jabref/gui/BasePanel.java | 11 +++++++--- .../jabref/gui/DatabaseChangeListener.java | 20 ------------------- 2 files changed, 8 insertions(+), 23 deletions(-) delete mode 100644 src/main/java/org/jabref/gui/DatabaseChangeListener.java diff --git a/src/main/java/org/jabref/gui/BasePanel.java b/src/main/java/org/jabref/gui/BasePanel.java index 62151ebf6a8..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,9 +205,8 @@ public BasePanel(JabRefFrame frame, BibDatabaseContext bibDatabaseContext) { Objects.requireNonNull(bibDatabaseContext); this.bibDatabaseContext = bibDatabaseContext; - DatabaseChangeListener databaseChangeListener = new DatabaseChangeListener(this); - bibDatabaseContext.getDatabase().registerListener(databaseChangeListener); - bibDatabaseContext.getMetaData().registerListener(databaseChangeListener); + bibDatabaseContext.getDatabase().registerListener(this); + bibDatabaseContext.getMetaData().registerListener(this); this.sidePaneManager = frame.getSidePaneManager(); this.frame = frame; @@ -262,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. */ diff --git a/src/main/java/org/jabref/gui/DatabaseChangeListener.java b/src/main/java/org/jabref/gui/DatabaseChangeListener.java deleted file mode 100644 index caec97f847b..00000000000 --- a/src/main/java/org/jabref/gui/DatabaseChangeListener.java +++ /dev/null @@ -1,20 +0,0 @@ -package org.jabref.gui; - - -import com.google.common.eventbus.Subscribe; -import org.jabref.model.database.event.BibDatabaseContextChangedEvent; - -public class DatabaseChangeListener { - - private BasePanel basePanel; - - public DatabaseChangeListener(BasePanel basePanel) { - this.basePanel = basePanel; - } - - @Subscribe - public void listen(BibDatabaseContextChangedEvent event) { - basePanel.markBaseChanged(); - } - -} From 02fe46a890ecf998d3eed8cbd51540bf3d20e77e Mon Sep 17 00:00:00 2001 From: Joerg Lenhard Date: Thu, 13 Jul 2017 10:44:38 +0200 Subject: [PATCH 4/4] Add changelog entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) 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