Skip to content

Commit

Permalink
fix ignore version (JabRef#2055)
Browse files Browse the repository at this point in the history
  • Loading branch information
chriba authored and zesaro committed Oct 27, 2016
1 parent 25f657c commit c5d6b32
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#
- Prohibit more than one connections to the same shared database.

### Fixed
- Fixed [#2054](https://github.com/JabRef/jabref/issues/2054): Ignoring a new version now works as expected
- Fixed selecting an entry out of multiple duplicates
- Fixed [#617](https://github.com/JabRef/jabref/issues/617): `Enter` in global search opens the selected entry & `Enter` in search dialog window opens the selected entry
- Entries in the SearchResultPanel will be shown correctly (Latex to Unicode)
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/net/sf/jabref/JabRefGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import net.sf.jabref.logic.util.Version;
import net.sf.jabref.migrations.PreferencesMigrations;
import net.sf.jabref.preferences.JabRefPreferences;
import net.sf.jabref.preferences.VersionPreferences;
import net.sf.jabref.shared.exception.DatabaseNotSupportedException;

import com.jgoodies.looks.plastic.Plastic3DLookAndFeel;
Expand Down Expand Up @@ -69,7 +68,7 @@ public JabRefGUI(List<ParserResult> argsDatabases, boolean isBlank) {
}

public static void checkForNewVersion(boolean manualExecution) {
Version toBeIgnored = new VersionPreferences(Globals.prefs).getIgnoredVersion();
Version toBeIgnored = Globals.prefs.getVersionPreferences().getIgnoredVersion();
Version currentVersion = Globals.BUILD_INFO.getVersion();
new VersionWorker(JabRefGUI.getMainFrame(), manualExecution, currentVersion, toBeIgnored).execute();
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/net/sf/jabref/gui/help/NewVersionDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

public class NewVersionDialog extends JDialog {

public NewVersionDialog(JFrame frame, Version currentVersion, Version latestVersion, Version toBeIgnored) {
public NewVersionDialog(JFrame frame, Version currentVersion, Version latestVersion) {
super(frame);
setTitle(Localization.lang("New version available"));

Expand All @@ -41,7 +41,7 @@ public void mouseClicked(MouseEvent e) {

JButton btnIgnoreUpdate = new JButton(Localization.lang("Ignore this update"));
btnIgnoreUpdate.addActionListener(e -> {
new VersionPreferences(Globals.prefs).setAsIgnoredVersion(toBeIgnored);
Globals.prefs.storeVersionPreferences(new VersionPreferences(latestVersion));
dispose();
});

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/sf/jabref/gui/worker/VersionWorker.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public void done(){

boolean newer = latestVersion.isNewerThan(installedVersion);
if (newer){
new NewVersionDialog(this.mainFrame, installedVersion, latestVersion, toBeIgnored);
new NewVersionDialog(this.mainFrame, installedVersion, latestVersion);
return;
}

Expand Down
11 changes: 11 additions & 0 deletions src/main/java/net/sf/jabref/preferences/JabRefPreferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
import net.sf.jabref.logic.remote.RemotePreferences;
import net.sf.jabref.logic.util.OS;
import net.sf.jabref.logic.util.UpdateFieldPreferences;
import net.sf.jabref.logic.util.Version;
import net.sf.jabref.logic.util.io.FileHistory;
import net.sf.jabref.logic.xmp.XMPPreferences;
import net.sf.jabref.model.bibtexkeypattern.AbstractBibtexKeyPattern;
Expand Down Expand Up @@ -1452,6 +1453,16 @@ public FileLinkPreferences getFileLinkPreferences() {
fileDirForDatabase);
}

public JabRefPreferences storeVersionPreferences(VersionPreferences versionPreferences) {
put(VERSION_IGNORED_UPDATE, versionPreferences.getIgnoredVersion().toString());
return this;
}

public VersionPreferences getVersionPreferences() {
Version ignoredVersion = new Version(get(VERSION_IGNORED_UPDATE));
return new VersionPreferences(ignoredVersion);
}

public JabRefPreferences storePreviewPreferences(PreviewPreferences previewPreferences) {
putInt(CYCLE_PREVIEW_POS, previewPreferences.getPreviewCyclePosition());
putStringList(CYCLE_PREVIEW, previewPreferences.getPreviewCycle());
Expand Down
13 changes: 4 additions & 9 deletions src/main/java/net/sf/jabref/preferences/VersionPreferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,17 @@

import net.sf.jabref.logic.util.Version;


public class VersionPreferences {

private final JabRefPreferences preferences;

private final Version ignoredVersion;

public VersionPreferences(JabRefPreferences preferences) {
this.preferences = preferences;
}

public void setAsIgnoredVersion(Version version) {
preferences.put(JabRefPreferences.VERSION_IGNORED_UPDATE, version.toString());
public VersionPreferences(Version ignoredVersion) {
this.ignoredVersion = ignoredVersion;
}

public Version getIgnoredVersion() {
return new Version(preferences.get(JabRefPreferences.VERSION_IGNORED_UPDATE));
return ignoredVersion;
}

}

0 comments on commit c5d6b32

Please sign in to comment.