From 3d980ef00a3186cf2b965ebeb72378beaa85bd76 Mon Sep 17 00:00:00 2001 From: Qing Date: Sun, 31 May 2020 11:22:40 +0800 Subject: [PATCH 1/4] fix-6351 --- build.gradle | 2 +- gradle/wrapper/gradle-wrapper.properties | 3 +- .../preferences/EntryEditorTabViewModel.java | 13 ++++++-- .../gui/preference/SaveAutoCompleteTest.java | 31 +++++++++++++++++++ 4 files changed, 44 insertions(+), 5 deletions(-) create mode 100644 src/test/java/org/jabref/gui/preference/SaveAutoCompleteTest.java diff --git a/build.gradle b/build.gradle index 48be26438d8..0230c8dbe60 100644 --- a/build.gradle +++ b/build.gradle @@ -214,7 +214,7 @@ dependencies { checkstyle 'com.puppycrawl.tools:checkstyle:8.32' xjc group: 'org.glassfish.jaxb', name: 'jaxb-xjc', version: '2.3.3' - jython 'org.python:jython-standalone:2.7.2' + jython 'org.python:jython-standalone:2.7.2'q } dependencyUpdates { diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index a4b4429748d..c105523a468 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-bin.zip -zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME diff --git a/src/main/java/org/jabref/gui/preferences/EntryEditorTabViewModel.java b/src/main/java/org/jabref/gui/preferences/EntryEditorTabViewModel.java index eee3f3e4daf..59cfc847a0d 100644 --- a/src/main/java/org/jabref/gui/preferences/EntryEditorTabViewModel.java +++ b/src/main/java/org/jabref/gui/preferences/EntryEditorTabViewModel.java @@ -12,6 +12,7 @@ import org.jabref.gui.autocompleter.AutoCompleteFirstNameMode; import org.jabref.gui.autocompleter.AutoCompletePreferences; import org.jabref.gui.entryeditor.EntryEditorPreferences; +import org.jabref.logic.l10n.Localization; import org.jabref.model.entry.field.FieldFactory; import org.jabref.preferences.PreferencesService; @@ -37,6 +38,8 @@ public class EntryEditorTabViewModel implements PreferenceTabViewModel { private final EntryEditorPreferences initialEntryEditorPreferences; private final AutoCompletePreferences initialAutoCompletePreferences; + private List restartWarnings = new ArrayList<>(); + public EntryEditorTabViewModel(DialogService dialogService, PreferencesService preferencesService) { this.dialogService = dialogService; this.preferencesService = preferencesService; @@ -106,7 +109,13 @@ public void storeSettings() { } else if (firstNameModeFullProperty.getValue()) { firstNameMode = AutoCompleteFirstNameMode.ONLY_FULL; } - + if(initialAutoCompletePreferences.shouldAutoComplete()!=enableAutoCompleteProperty.getValue()){ + if(enableAutoCompleteProperty.getValue()){ + restartWarnings.add(Localization.lang("Auto complete enable.")); + }else{ + restartWarnings.add(Localization.lang("Auto complete disable.")); + } + } preferencesService.storeAutoCompletePreferences(new AutoCompletePreferences( enableAutoCompleteProperty.getValue(), firstNameMode, @@ -122,7 +131,7 @@ public boolean validateSettings() { @Override public List getRestartWarnings() { - return new ArrayList<>(); + return restartWarnings; } public BooleanProperty openOnNewEntryProperty() { diff --git a/src/test/java/org/jabref/gui/preference/SaveAutoCompleteTest.java b/src/test/java/org/jabref/gui/preference/SaveAutoCompleteTest.java new file mode 100644 index 00000000000..4b4ef06c7e0 --- /dev/null +++ b/src/test/java/org/jabref/gui/preference/SaveAutoCompleteTest.java @@ -0,0 +1,31 @@ +package org.jabref.gui.preference; + + +import org.jabref.gui.autocompleter.AutoCompleteFirstNameMode; +import org.jabref.gui.autocompleter.AutoCompletePreferences; +import org.jabref.model.entry.field.FieldFactory; +import org.jabref.preferences.JabRefPreferences; +import org.junit.Test; + +import java.lang.reflect.Field; + +import static org.junit.Assert.assertEquals; + + +public class SaveAutoCompleteTest { + + @Test + public void storeAutoCompletePreferencesTest() throws NoSuchFieldException, IllegalAccessException { + JabRefPreferences preferencesService = JabRefPreferences.getInstance(); + preferencesService.storeAutoCompletePreferences(new AutoCompletePreferences( + true, + AutoCompleteFirstNameMode.BOTH, + AutoCompletePreferences.NameFormat.BOTH, + FieldFactory.parseFieldList(""), + preferencesService.getJournalAbbreviationPreferences())); + + Field field = preferencesService.getClass().getDeclaredField("AUTO_COMPLETE"); + field.setAccessible(true); + assertEquals(preferencesService.getBoolean((String) field.get(preferencesService)), true); + } +} From c725ef0c06c7307923d02b8a99c99c1ae0535b9f Mon Sep 17 00:00:00 2001 From: Qing Date: Sun, 31 May 2020 11:25:50 +0800 Subject: [PATCH 2/4] update --- build.gradle | 2 +- gradle/wrapper/gradle-wrapper.properties | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 0230c8dbe60..48be26438d8 100644 --- a/build.gradle +++ b/build.gradle @@ -214,7 +214,7 @@ dependencies { checkstyle 'com.puppycrawl.tools:checkstyle:8.32' xjc group: 'org.glassfish.jaxb', name: 'jaxb-xjc', version: '2.3.3' - jython 'org.python:jython-standalone:2.7.2'q + jython 'org.python:jython-standalone:2.7.2' } dependencyUpdates { diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index c105523a468..a4b4429748d 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,4 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-bin.zip zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists From f3c3a00b287b525b131200f582f07f5ae7605293 Mon Sep 17 00:00:00 2001 From: ShiqingLiu <32733577+ShiqingLiu@users.noreply.github.com> Date: Mon, 1 Jun 2020 17:56:09 +0800 Subject: [PATCH 3/4] Apply suggestions from code review Correct typos. Co-authored-by: Carl Christian Snethlage <50491877+calixtus@users.noreply.github.com> --- .../org/jabref/gui/preferences/EntryEditorTabViewModel.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/jabref/gui/preferences/EntryEditorTabViewModel.java b/src/main/java/org/jabref/gui/preferences/EntryEditorTabViewModel.java index 59cfc847a0d..05f9e3e4786 100644 --- a/src/main/java/org/jabref/gui/preferences/EntryEditorTabViewModel.java +++ b/src/main/java/org/jabref/gui/preferences/EntryEditorTabViewModel.java @@ -111,9 +111,9 @@ public void storeSettings() { } if(initialAutoCompletePreferences.shouldAutoComplete()!=enableAutoCompleteProperty.getValue()){ if(enableAutoCompleteProperty.getValue()){ - restartWarnings.add(Localization.lang("Auto complete enable.")); + restartWarnings.add(Localization.lang("Auto complete enabled.")); }else{ - restartWarnings.add(Localization.lang("Auto complete disable.")); + restartWarnings.add(Localization.lang("Auto complete disabled.")); } } preferencesService.storeAutoCompletePreferences(new AutoCompletePreferences( From 8864bd3e8ca1f4e7a0f58b2d56d9c8a03be08855 Mon Sep 17 00:00:00 2001 From: Qing Date: Thu, 4 Jun 2020 00:25:58 +0800 Subject: [PATCH 4/4] change request --- .../preferences/EntryEditorTabViewModel.java | 7 +++-- .../gui/preference/SaveAutoCompleteTest.java | 31 ------------------- 2 files changed, 4 insertions(+), 34 deletions(-) delete mode 100644 src/test/java/org/jabref/gui/preference/SaveAutoCompleteTest.java diff --git a/src/main/java/org/jabref/gui/preferences/EntryEditorTabViewModel.java b/src/main/java/org/jabref/gui/preferences/EntryEditorTabViewModel.java index 59cfc847a0d..816e43bf580 100644 --- a/src/main/java/org/jabref/gui/preferences/EntryEditorTabViewModel.java +++ b/src/main/java/org/jabref/gui/preferences/EntryEditorTabViewModel.java @@ -109,10 +109,11 @@ public void storeSettings() { } else if (firstNameModeFullProperty.getValue()) { firstNameMode = AutoCompleteFirstNameMode.ONLY_FULL; } - if(initialAutoCompletePreferences.shouldAutoComplete()!=enableAutoCompleteProperty.getValue()){ - if(enableAutoCompleteProperty.getValue()){ + + if (initialAutoCompletePreferences.shouldAutoComplete() != enableAutoCompleteProperty.getValue()) { + if (enableAutoCompleteProperty.getValue()) { restartWarnings.add(Localization.lang("Auto complete enable.")); - }else{ + } else { restartWarnings.add(Localization.lang("Auto complete disable.")); } } diff --git a/src/test/java/org/jabref/gui/preference/SaveAutoCompleteTest.java b/src/test/java/org/jabref/gui/preference/SaveAutoCompleteTest.java deleted file mode 100644 index 4b4ef06c7e0..00000000000 --- a/src/test/java/org/jabref/gui/preference/SaveAutoCompleteTest.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.jabref.gui.preference; - - -import org.jabref.gui.autocompleter.AutoCompleteFirstNameMode; -import org.jabref.gui.autocompleter.AutoCompletePreferences; -import org.jabref.model.entry.field.FieldFactory; -import org.jabref.preferences.JabRefPreferences; -import org.junit.Test; - -import java.lang.reflect.Field; - -import static org.junit.Assert.assertEquals; - - -public class SaveAutoCompleteTest { - - @Test - public void storeAutoCompletePreferencesTest() throws NoSuchFieldException, IllegalAccessException { - JabRefPreferences preferencesService = JabRefPreferences.getInstance(); - preferencesService.storeAutoCompletePreferences(new AutoCompletePreferences( - true, - AutoCompleteFirstNameMode.BOTH, - AutoCompletePreferences.NameFormat.BOTH, - FieldFactory.parseFieldList(""), - preferencesService.getJournalAbbreviationPreferences())); - - Field field = preferencesService.getClass().getDeclaredField("AUTO_COMPLETE"); - field.setAccessible(true); - assertEquals(preferencesService.getBoolean((String) field.get(preferencesService)), true); - } -}