-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
129 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 12 additions & 12 deletions
24
src/main/java/org/jabref/gui/UpdateTimestampListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,32 @@ | ||
package org.jabref.gui; | ||
|
||
import java.util.function.Supplier; | ||
|
||
import org.jabref.logic.preferences.TimestampPreferences; | ||
import org.jabref.model.entry.event.EntryChangedEvent; | ||
import org.jabref.preferences.JabRefPreferences; | ||
|
||
import com.google.common.eventbus.Subscribe; | ||
|
||
/** | ||
* Updates the timestamp of changed entries if the feature is enabled | ||
*/ | ||
class UpdateTimestampListener { | ||
private final JabRefPreferences jabRefPreferences; | ||
private final Supplier<TimestampPreferences> timestampPreferencesSupplier; | ||
|
||
/** | ||
* The jabRefPreferences are required, because they are queried at each call. The user can change the preferences | ||
* and this listener behaves differently. This implementation seems to be less complex then re-registering this | ||
* listener or reconfiguring this listener if the preferences changed. | ||
* | ||
* @param jabRefPreferences the global JabRef preferences. | ||
* The timestampPreferencesSupplier is required, because timestampPreferences are queried at each call. The user can | ||
* change the preferences and this listener behaves differently. This implementation seems to be less complex then | ||
* re-registering this listener or reconfiguring this listener if the preferences changed. | ||
*/ | ||
UpdateTimestampListener(JabRefPreferences jabRefPreferences) { | ||
this.jabRefPreferences = jabRefPreferences; | ||
UpdateTimestampListener(Supplier<TimestampPreferences> timestampPreferencesSupplier) { | ||
this.timestampPreferencesSupplier = timestampPreferencesSupplier; | ||
} | ||
|
||
@Subscribe | ||
public void listen(EntryChangedEvent event) { | ||
if (jabRefPreferences.getTimestampPreferences().includeTimestamps()) { | ||
event.getBibEntry().setField(jabRefPreferences.getTimestampPreferences().getTimestampField(), | ||
jabRefPreferences.getTimestampPreferences().now()); | ||
TimestampPreferences timestampPreferences = timestampPreferencesSupplier.get(); | ||
if (timestampPreferences.includeTimestamps()) { | ||
event.getBibEntry().setField(timestampPreferences.getTimestampField(), timestampPreferences.now()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.