From 46cd633735bd673e333825d1598b1c048d1b4e9c Mon Sep 17 00:00:00 2001 From: jacobtr Date: Wed, 1 Mar 2023 14:27:27 +0100 Subject: [PATCH 01/77] (feat) Makes sure password is never stored in preferences Instead asks user for the password at the start of the program if they have enabled proxy with password. --- src/main/java/org/jabref/gui/JabRefGUI.java | 10 ++++++++++ .../jabref/gui/preferences/PreferencesDialogView.java | 2 ++ .../java/org/jabref/preferences/JabRefPreferences.java | 3 +-- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/jabref/gui/JabRefGUI.java b/src/main/java/org/jabref/gui/JabRefGUI.java index 4f5963945ea..57cdf7f8307 100644 --- a/src/main/java/org/jabref/gui/JabRefGUI.java +++ b/src/main/java/org/jabref/gui/JabRefGUI.java @@ -6,6 +6,7 @@ import java.util.List; import java.util.stream.Collectors; +import com.airhacks.afterburner.injection.Injector; import javafx.application.Platform; import javafx.scene.Scene; import javafx.scene.input.KeyEvent; @@ -17,6 +18,7 @@ import org.jabref.gui.importer.ParserResultWarningDialog; import org.jabref.gui.importer.actions.OpenDatabaseAction; import org.jabref.gui.keyboard.TextInputKeyBindings; +import org.jabref.gui.preferences.PreferencesDialogView; import org.jabref.gui.shared.SharedDatabaseUIManager; import org.jabref.logic.importer.ParserResult; import org.jabref.logic.l10n.Localization; @@ -26,6 +28,7 @@ import org.jabref.logic.util.WebViewStore; import org.jabref.preferences.GuiPreferences; import org.jabref.preferences.PreferencesService; +import org.jabref.preferences.JabRefPreferences; import impl.org.controlsfx.skin.DecorationPane; import org.slf4j.Logger; @@ -61,6 +64,13 @@ public JabRefGUI(Stage mainStage, List databases, boolean isBlank, Globals.TASK_EXECUTOR, preferencesService.getInternalPreferences()) .checkForNewVersionDelayed(); + + if (JabRefPreferences.getInstance().getProxyPreferences().shouldUseAuthentication()){ + DialogService dialogService = Injector.instantiateModelOrService(DialogService.class); + PreferencesDialogView preferencesDialogView = new PreferencesDialogView(this.mainFrame); + preferencesDialogView.getPreferenceTabList().getSelectionModel().select(20); + dialogService.showCustomDialog(preferencesDialogView); + } } private void openWindow(Stage mainStage) { diff --git a/src/main/java/org/jabref/gui/preferences/PreferencesDialogView.java b/src/main/java/org/jabref/gui/preferences/PreferencesDialogView.java index f3a5c245913..089b09f693a 100644 --- a/src/main/java/org/jabref/gui/preferences/PreferencesDialogView.java +++ b/src/main/java/org/jabref/gui/preferences/PreferencesDialogView.java @@ -67,6 +67,8 @@ public PreferencesDialogViewModel getViewModel() { return viewModel; } + public ListView getPreferenceTabList() {return preferenceTabList;} + @FXML private void initialize() { viewModel = new PreferencesDialogViewModel(dialogService, preferencesService, frame); diff --git a/src/main/java/org/jabref/preferences/JabRefPreferences.java b/src/main/java/org/jabref/preferences/JabRefPreferences.java index 3ea8f83a45b..c5104e3ad41 100644 --- a/src/main/java/org/jabref/preferences/JabRefPreferences.java +++ b/src/main/java/org/jabref/preferences/JabRefPreferences.java @@ -1552,14 +1552,13 @@ public ProxyPreferences getProxyPreferences() { get(PROXY_PORT), getBoolean(PROXY_USE_AUTHENTICATION), get(PROXY_USERNAME), - get(PROXY_PASSWORD)); + (String) defaults.get(PROXY_PASSWORD)); EasyBind.listen(proxyPreferences.useProxyProperty(), (obs, oldValue, newValue) -> putBoolean(PROXY_USE, newValue)); EasyBind.listen(proxyPreferences.hostnameProperty(), (obs, oldValue, newValue) -> put(PROXY_HOSTNAME, newValue)); EasyBind.listen(proxyPreferences.portProperty(), (obs, oldValue, newValue) -> put(PROXY_PORT, newValue)); EasyBind.listen(proxyPreferences.useAuthenticationProperty(), (obs, oldValue, newValue) -> putBoolean(PROXY_USE_AUTHENTICATION, newValue)); EasyBind.listen(proxyPreferences.usernameProperty(), (obs, oldValue, newValue) -> put(PROXY_USERNAME, newValue)); - EasyBind.listen(proxyPreferences.passwordProperty(), (obs, oldValue, newValue) -> put(PROXY_PASSWORD, newValue)); return proxyPreferences; } From bd1446be7dc81ed014b90ad0da835bf6d6828efe Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 1 Mar 2023 16:24:29 +0100 Subject: [PATCH 02/77] (Feat): #1 Added test for storage of proxy preferences Don't accept the pull request and start the testing when password changes have been implemented. --- .../java/org/jabref/logic/net/ProxyTest.java | 93 +++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 src/test/java/org/jabref/logic/net/ProxyTest.java diff --git a/src/test/java/org/jabref/logic/net/ProxyTest.java b/src/test/java/org/jabref/logic/net/ProxyTest.java new file mode 100644 index 00000000000..d7e51df526c --- /dev/null +++ b/src/test/java/org/jabref/logic/net/ProxyTest.java @@ -0,0 +1,93 @@ +package org.jabref.logic.net; + +import org.jabref.gui.Globals; +import org.jabref.migrations.PreferencesMigrations; +import org.jabref.preferences.JabRefPreferences; +import org.junit.jupiter.api.Test; + +import java.io.IOException; +import java.util.prefs.BackingStoreException; + +import static org.junit.jupiter.api.Assertions.*; +public class ProxyTest { + /** + + A Javadoc for the testProxyNotStoredInRegisterHttp() method which tests the ProxyRegisterer class + for HTTP protocol. This method checks if the proxy host, port, username are stored and password aren't stored in + the system register after registering the new proxy preference for HTTP protocol. + + @throws IOException if an I/O error occurs. + */ + @Test + public void testProxyCredentialsMotStoredInRegisterHttp() throws IOException, BackingStoreException { + /* + Boolean useProxy = true; + String hostname = "testName"; + String port = "8080"; + Boolean useAuthentication = true; + String username = "testUserName"; + String password = "testPassword"; + + + ProxyPreferences proxyPref = new ProxyPreferences(useProxy, hostname,port,useAuthentication,username,password); + */ + + //Get stored proxy preferences + final JabRefPreferences preferences = JabRefPreferences.getInstance(); + //Globals.prefs = preferences; + PreferencesMigrations.runMigrations(preferences); + ProxyPreferences prox = preferences.getProxyPreferences(); + if(prox.shouldUseAuthentication() && prox.shouldUseProxy()){ + assertNotEquals(prox.getHostname(),""); + assertNotEquals(prox.getPort(),""); + } + if(prox.shouldUseProxy()){ + assertNotEquals(prox.getUsername(),""); + assertEquals(prox.getPassword(), ""); + } + //Run the test 2 times if test don't work to hopefully flush everything from older version and then connect again + preferences.clear(); + } + /** + + A Javadoc for the testProxyNotStoredInRegisterHttps() method which tests the ProxyRegisterer class + for HTTPS protocol. This method checks if the proxy host, port, username are stored and password aren't stored in + the system register after registering the new proxy preference for HTTPS protocol. + + @throws IOException if an I/O error occurs. + + @Test + public void testProxyCredentialsMotStoredInRegisterHttps() throws IOException { + String oldhost = System.getProperty("http" + ".proxyHost", ""); + String oldport = System.getProperty("http" + ".proxyPort", ""); + String olduser = System.getProperty("http" + ".proxyUser", ""); + String oldpassword = System.getProperty("http" + ".proxyPassword", ""); + + Boolean useProxy = true; + String hostname = "testName"; + String port = "8080"; + Boolean useAuthentication = true; + String username = "testUserName"; + String password = "testPassword"; + + ProxyPreferences proxyPref = new ProxyPreferences(useProxy, hostname,port,useAuthentication,username,password); + ProxyPreferences oldProxyPref = new ProxyPreferences(useProxy, oldhost,oldport,useAuthentication,olduser,oldpassword); + + assertNotEquals(hostname , oldhost); + assertNotEquals(port , oldport); + assertNotEquals(username, olduser); + assertNotEquals(password, oldpassword); + + ProxyRegisterer.register(proxyPref); + + assertEquals(hostname , System.getProperty("https" + ".proxyHost", "") ); + assertEquals(port , System.getProperty("https" + ".proxyPort", "") ); + assertEquals(username, System.getProperty("https" + ".proxyUser", "") ); + //assertNotEquals(password, System.getProperty("http" + ".proxyPassword", "") ); + // Last line shoud be incommented when password not stored in register anymore. + + //reset to what it was before + ProxyRegisterer.register(oldProxyPref); + } + */ +} From 1cb1363462c7c423eaed93d0e3f5b02035fbd537 Mon Sep 17 00:00:00 2001 From: Michael Morales Date: Thu, 2 Mar 2023 09:36:49 +0100 Subject: [PATCH 03/77] (Fix) #4 Change to if statements --- src/test/java/org/jabref/logic/net/ProxyTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/org/jabref/logic/net/ProxyTest.java b/src/test/java/org/jabref/logic/net/ProxyTest.java index d7e51df526c..cfb8105875b 100644 --- a/src/test/java/org/jabref/logic/net/ProxyTest.java +++ b/src/test/java/org/jabref/logic/net/ProxyTest.java @@ -37,11 +37,11 @@ public void testProxyCredentialsMotStoredInRegisterHttp() throws IOException, Ba //Globals.prefs = preferences; PreferencesMigrations.runMigrations(preferences); ProxyPreferences prox = preferences.getProxyPreferences(); - if(prox.shouldUseAuthentication() && prox.shouldUseProxy()){ + if(prox.shouldUseProxy()){ assertNotEquals(prox.getHostname(),""); assertNotEquals(prox.getPort(),""); } - if(prox.shouldUseProxy()){ + if(prox.shouldUseAuthentication()){ assertNotEquals(prox.getUsername(),""); assertEquals(prox.getPassword(), ""); } From 63c49e9b2096b1670a5ac584149c2fe174ea2968 Mon Sep 17 00:00:00 2001 From: Michael Morales Date: Thu, 2 Mar 2023 09:43:51 +0100 Subject: [PATCH 04/77] (Fix) #4 removed clear for testing purposes --- src/test/java/org/jabref/logic/net/ProxyTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/org/jabref/logic/net/ProxyTest.java b/src/test/java/org/jabref/logic/net/ProxyTest.java index cfb8105875b..3e4e1515526 100644 --- a/src/test/java/org/jabref/logic/net/ProxyTest.java +++ b/src/test/java/org/jabref/logic/net/ProxyTest.java @@ -46,7 +46,7 @@ public void testProxyCredentialsMotStoredInRegisterHttp() throws IOException, Ba assertEquals(prox.getPassword(), ""); } //Run the test 2 times if test don't work to hopefully flush everything from older version and then connect again - preferences.clear(); + //preferences.clear(); } /** From bc1181e83ea8883f56c6ad29d33072c0b2ef3685 Mon Sep 17 00:00:00 2001 From: jacobtr Date: Wed, 1 Mar 2023 14:27:27 +0100 Subject: [PATCH 05/77] (feat) #6 Makes sure the password is not saved in registry No ui changes in this commit, leaves password field empty on launch --- src/main/java/org/jabref/preferences/JabRefPreferences.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/org/jabref/preferences/JabRefPreferences.java b/src/main/java/org/jabref/preferences/JabRefPreferences.java index 3ea8f83a45b..b0a712eab29 100644 --- a/src/main/java/org/jabref/preferences/JabRefPreferences.java +++ b/src/main/java/org/jabref/preferences/JabRefPreferences.java @@ -1545,21 +1545,19 @@ public ProxyPreferences getProxyPreferences() { if (Objects.nonNull(proxyPreferences)) { return proxyPreferences; } - proxyPreferences = new ProxyPreferences( getBoolean(PROXY_USE), get(PROXY_HOSTNAME), get(PROXY_PORT), getBoolean(PROXY_USE_AUTHENTICATION), get(PROXY_USERNAME), - get(PROXY_PASSWORD)); + (String) defaults.get(PROXY_PASSWORD)); EasyBind.listen(proxyPreferences.useProxyProperty(), (obs, oldValue, newValue) -> putBoolean(PROXY_USE, newValue)); EasyBind.listen(proxyPreferences.hostnameProperty(), (obs, oldValue, newValue) -> put(PROXY_HOSTNAME, newValue)); EasyBind.listen(proxyPreferences.portProperty(), (obs, oldValue, newValue) -> put(PROXY_PORT, newValue)); EasyBind.listen(proxyPreferences.useAuthenticationProperty(), (obs, oldValue, newValue) -> putBoolean(PROXY_USE_AUTHENTICATION, newValue)); EasyBind.listen(proxyPreferences.usernameProperty(), (obs, oldValue, newValue) -> put(PROXY_USERNAME, newValue)); - EasyBind.listen(proxyPreferences.passwordProperty(), (obs, oldValue, newValue) -> put(PROXY_PASSWORD, newValue)); return proxyPreferences; } From 329f3d40c88650c86971fe6bed2482490afb38cf Mon Sep 17 00:00:00 2001 From: Michael Morales Date: Thu, 2 Mar 2023 10:52:40 +0100 Subject: [PATCH 06/77] (Fix) #1 Added further testing with mock data --- .../java/org/jabref/logic/net/ProxyTest.java | 61 ++++++++++++++----- 1 file changed, 47 insertions(+), 14 deletions(-) diff --git a/src/test/java/org/jabref/logic/net/ProxyTest.java b/src/test/java/org/jabref/logic/net/ProxyTest.java index 3e4e1515526..b863fd78af1 100644 --- a/src/test/java/org/jabref/logic/net/ProxyTest.java +++ b/src/test/java/org/jabref/logic/net/ProxyTest.java @@ -20,33 +20,66 @@ A Javadoc for the testProxyNotStoredInRegisterHttp() method which tests the Prox */ @Test public void testProxyCredentialsMotStoredInRegisterHttp() throws IOException, BackingStoreException { - /* - Boolean useProxy = true; - String hostname = "testName"; - String port = "8080"; - Boolean useAuthentication = true; - String username = "testUserName"; - String password = "testPassword"; - - - ProxyPreferences proxyPref = new ProxyPreferences(useProxy, hostname,port,useAuthentication,username,password); - */ - //Get stored proxy preferences final JabRefPreferences preferences = JabRefPreferences.getInstance(); //Globals.prefs = preferences; PreferencesMigrations.runMigrations(preferences); ProxyPreferences prox = preferences.getProxyPreferences(); + + String oldUseProxy = prox.shouldUseProxy().toString(); + String oldHostname = prox.getHostname(); + String oldPort = prox.getPort(); + String oldUseAuthentication = prox.shouldUseAuthentication().toString(); + String oldUsername = prox.getUsername(); + String oldPassword = prox.getPassword(); + if(prox.shouldUseProxy()){ assertNotEquals(prox.getHostname(),""); assertNotEquals(prox.getPort(),""); + System.out.println(); } if(prox.shouldUseAuthentication()){ assertNotEquals(prox.getUsername(),""); assertEquals(prox.getPassword(), ""); } - //Run the test 2 times if test don't work to hopefully flush everything from older version and then connect again - //preferences.clear(); + //Part 2 of test + String useProxy = "true"; + String hostname = "testName"; + String port = "8080"; + String useAuthentication = "true"; + String username = "testUserName"; + String password = "testPassword"; + + String PROXY_USE = "useProxy"; + String PROXY_PORT = "proxyPort"; + String PROXY_HOSTNAME = "proxyHostname"; + String PROXY_USERNAME = "proxyUsername"; + String PROXY_PASSWORD = "proxyPassword"; + String PROXY_USE_AUTHENTICATION = "useProxyAuthentication"; + + preferences.put(PROXY_USE, useProxy); + preferences.put(PROXY_HOSTNAME, hostname); + preferences.put(PROXY_PORT, port); + preferences.put(PROXY_USE_AUTHENTICATION, useAuthentication); + preferences.put(PROXY_USERNAME, username); + preferences.put(PROXY_PASSWORD, password); + + if(prox.shouldUseProxy()){ + assertEquals(prox.getHostname(),"testName"); + assertEquals(prox.getPort(),"8080"); + System.out.println(); + } + if(prox.shouldUseAuthentication()){ + assertEquals(prox.getUsername(),"testUserName"); + assertNotEquals(prox.getPassword(), "testPassword"); + } + + preferences.put(PROXY_USE, oldUseProxy); + preferences.put(PROXY_HOSTNAME, oldHostname); + preferences.put(PROXY_PORT, oldPort); + preferences.put(PROXY_USE_AUTHENTICATION, oldUseAuthentication); + preferences.put(PROXY_USERNAME, oldUsername); + preferences.put(PROXY_PASSWORD, oldPassword); } /** From af71f88da86085fa0d30c6db8d0e98ea1f665002 Mon Sep 17 00:00:00 2001 From: Michael Morales Date: Thu, 2 Mar 2023 11:07:12 +0100 Subject: [PATCH 07/77] (Fix) #1 Cleaned code and added description --- .../java/org/jabref/logic/net/ProxyTest.java | 62 ++----------------- 1 file changed, 6 insertions(+), 56 deletions(-) diff --git a/src/test/java/org/jabref/logic/net/ProxyTest.java b/src/test/java/org/jabref/logic/net/ProxyTest.java index b863fd78af1..9e9b92e2999 100644 --- a/src/test/java/org/jabref/logic/net/ProxyTest.java +++ b/src/test/java/org/jabref/logic/net/ProxyTest.java @@ -11,15 +11,13 @@ import static org.junit.jupiter.api.Assertions.*; public class ProxyTest { /** - - A Javadoc for the testProxyNotStoredInRegisterHttp() method which tests the ProxyRegisterer class - for HTTP protocol. This method checks if the proxy host, port, username are stored and password aren't stored in - the system register after registering the new proxy preference for HTTP protocol. - - @throws IOException if an I/O error occurs. + * The method test if by storing a mock data of proxy information it get's stored as intented, where + * proxy host, port, username are stored and password aren't stored in + * the system register. It also ensures that the previous stored information isn't lost through extracting the + * information first and then restores it. */ @Test - public void testProxyCredentialsMotStoredInRegisterHttp() throws IOException, BackingStoreException { + public void testProxyPasswordNotStoredInRegister(){ //Get stored proxy preferences final JabRefPreferences preferences = JabRefPreferences.getInstance(); //Globals.prefs = preferences; @@ -33,15 +31,6 @@ public void testProxyCredentialsMotStoredInRegisterHttp() throws IOException, Ba String oldUsername = prox.getUsername(); String oldPassword = prox.getPassword(); - if(prox.shouldUseProxy()){ - assertNotEquals(prox.getHostname(),""); - assertNotEquals(prox.getPort(),""); - System.out.println(); - } - if(prox.shouldUseAuthentication()){ - assertNotEquals(prox.getUsername(),""); - assertEquals(prox.getPassword(), ""); - } //Part 2 of test String useProxy = "true"; String hostname = "testName"; @@ -82,45 +71,6 @@ public void testProxyCredentialsMotStoredInRegisterHttp() throws IOException, Ba preferences.put(PROXY_PASSWORD, oldPassword); } /** - - A Javadoc for the testProxyNotStoredInRegisterHttps() method which tests the ProxyRegisterer class - for HTTPS protocol. This method checks if the proxy host, port, username are stored and password aren't stored in - the system register after registering the new proxy preference for HTTPS protocol. - - @throws IOException if an I/O error occurs. - - @Test - public void testProxyCredentialsMotStoredInRegisterHttps() throws IOException { - String oldhost = System.getProperty("http" + ".proxyHost", ""); - String oldport = System.getProperty("http" + ".proxyPort", ""); - String olduser = System.getProperty("http" + ".proxyUser", ""); - String oldpassword = System.getProperty("http" + ".proxyPassword", ""); - - Boolean useProxy = true; - String hostname = "testName"; - String port = "8080"; - Boolean useAuthentication = true; - String username = "testUserName"; - String password = "testPassword"; - - ProxyPreferences proxyPref = new ProxyPreferences(useProxy, hostname,port,useAuthentication,username,password); - ProxyPreferences oldProxyPref = new ProxyPreferences(useProxy, oldhost,oldport,useAuthentication,olduser,oldpassword); - - assertNotEquals(hostname , oldhost); - assertNotEquals(port , oldport); - assertNotEquals(username, olduser); - assertNotEquals(password, oldpassword); - - ProxyRegisterer.register(proxyPref); - - assertEquals(hostname , System.getProperty("https" + ".proxyHost", "") ); - assertEquals(port , System.getProperty("https" + ".proxyPort", "") ); - assertEquals(username, System.getProperty("https" + ".proxyUser", "") ); - //assertNotEquals(password, System.getProperty("http" + ".proxyPassword", "") ); - // Last line shoud be incommented when password not stored in register anymore. - - //reset to what it was before - ProxyRegisterer.register(oldProxyPref); - } + * Add an additional test for testing that password get's stored somehow! */ } From 2e5b5c798f9c9eadf8d5c0b665e8df1b266d2437 Mon Sep 17 00:00:00 2001 From: Michael Morales Date: Thu, 2 Mar 2023 11:18:53 +0100 Subject: [PATCH 08/77] (Fix) fixed spelling and further explained the code through comments --- .../java/org/jabref/logic/net/ProxyTest.java | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/test/java/org/jabref/logic/net/ProxyTest.java b/src/test/java/org/jabref/logic/net/ProxyTest.java index 9e9b92e2999..0c9da5f0d6a 100644 --- a/src/test/java/org/jabref/logic/net/ProxyTest.java +++ b/src/test/java/org/jabref/logic/net/ProxyTest.java @@ -11,48 +11,46 @@ import static org.junit.jupiter.api.Assertions.*; public class ProxyTest { /** - * The method test if by storing a mock data of proxy information it get's stored as intented, where - * proxy host, port, username are stored and password aren't stored in - * the system register. It also ensures that the previous stored information isn't lost through extracting the + * The method test wheter storing a mock data of proxy information gets stored as intented, where + * proxy host, port, username should be stored in the system register and not password. The test also + * ensures that the previous stored information isn't lost through extracting the * information first and then restores it. */ @Test public void testProxyPasswordNotStoredInRegister(){ - //Get stored proxy preferences + //Get stored proxy preferences from registers final JabRefPreferences preferences = JabRefPreferences.getInstance(); - //Globals.prefs = preferences; PreferencesMigrations.runMigrations(preferences); ProxyPreferences prox = preferences.getProxyPreferences(); - + //Save old registers String oldUseProxy = prox.shouldUseProxy().toString(); String oldHostname = prox.getHostname(); String oldPort = prox.getPort(); String oldUseAuthentication = prox.shouldUseAuthentication().toString(); String oldUsername = prox.getUsername(); String oldPassword = prox.getPassword(); - - //Part 2 of test + //mock data String useProxy = "true"; String hostname = "testName"; String port = "8080"; String useAuthentication = "true"; String username = "testUserName"; String password = "testPassword"; - + //String used for enabling usage of preference.put() for each proxy register String PROXY_USE = "useProxy"; String PROXY_PORT = "proxyPort"; String PROXY_HOSTNAME = "proxyHostname"; String PROXY_USERNAME = "proxyUsername"; String PROXY_PASSWORD = "proxyPassword"; String PROXY_USE_AUTHENTICATION = "useProxyAuthentication"; - + //Writing to register with mock data preferences.put(PROXY_USE, useProxy); preferences.put(PROXY_HOSTNAME, hostname); preferences.put(PROXY_PORT, port); preferences.put(PROXY_USE_AUTHENTICATION, useAuthentication); preferences.put(PROXY_USERNAME, username); preferences.put(PROXY_PASSWORD, password); - + //Actual test being conducted if(prox.shouldUseProxy()){ assertEquals(prox.getHostname(),"testName"); assertEquals(prox.getPort(),"8080"); @@ -62,7 +60,7 @@ public void testProxyPasswordNotStoredInRegister(){ assertEquals(prox.getUsername(),"testUserName"); assertNotEquals(prox.getPassword(), "testPassword"); } - + //Restores registers to previous state preferences.put(PROXY_USE, oldUseProxy); preferences.put(PROXY_HOSTNAME, oldHostname); preferences.put(PROXY_PORT, oldPort); From 3587914b1fa9e0fd77fc7bc042ae6c911ed75523 Mon Sep 17 00:00:00 2001 From: Michael Morales Date: Thu, 2 Mar 2023 12:04:44 +0100 Subject: [PATCH 09/77] Added second test for requirment R2 with appropriate comments. --- .../java/org/jabref/logic/net/ProxyTest.java | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/src/test/java/org/jabref/logic/net/ProxyTest.java b/src/test/java/org/jabref/logic/net/ProxyTest.java index 0c9da5f0d6a..d29983ce63b 100644 --- a/src/test/java/org/jabref/logic/net/ProxyTest.java +++ b/src/test/java/org/jabref/logic/net/ProxyTest.java @@ -68,7 +68,34 @@ public void testProxyPasswordNotStoredInRegister(){ preferences.put(PROXY_USERNAME, oldUsername); preferences.put(PROXY_PASSWORD, oldPassword); } + /** - * Add an additional test for testing that password get's stored somehow! + * The test checks if ProxyPreference class is still able to store password and use it from memory, + * even though it's no longer stored in register. */ + @Test + public void testProxyPreferencesStorePassword() { + //mock data + Boolean useProxy = true; + String hostname = "testName"; + String port = "8080"; + Boolean useAuthentication = true; + String username = "testUserName"; + String password = "testPassword"; + //Creates proxy preference + ProxyPreferences proxyPref = new ProxyPreferences( + useProxy, + hostname, + port, + useAuthentication, + username, + password); + //Check if mock data is stored in object memory and can be extracted + assertEquals(proxyPref.shouldUseProxy(), true); + assertEquals(proxyPref.getHostname(), "testName"); + assertEquals(proxyPref.getPort(), port); + assertEquals(proxyPref.shouldUseAuthentication(), true); + assertEquals(proxyPref.getUsername(), username); + assertEquals(proxyPref.getPassword(), password); + } } From c0c5c376c50ec331f282f8fb817740a539461189 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 2 Mar 2023 14:04:12 +0100 Subject: [PATCH 10/77] (Refactor): #1 changed "testName" string to hostname => not hardcode closes #1 --- src/test/java/org/jabref/logic/net/ProxyTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/org/jabref/logic/net/ProxyTest.java b/src/test/java/org/jabref/logic/net/ProxyTest.java index d29983ce63b..414feeef194 100644 --- a/src/test/java/org/jabref/logic/net/ProxyTest.java +++ b/src/test/java/org/jabref/logic/net/ProxyTest.java @@ -92,7 +92,7 @@ public void testProxyPreferencesStorePassword() { password); //Check if mock data is stored in object memory and can be extracted assertEquals(proxyPref.shouldUseProxy(), true); - assertEquals(proxyPref.getHostname(), "testName"); + assertEquals(proxyPref.getHostname(), hostname); assertEquals(proxyPref.getPort(), port); assertEquals(proxyPref.shouldUseAuthentication(), true); assertEquals(proxyPref.getUsername(), username); From 01c529c3593ed80ab8b44b19b125458ae56ee255 Mon Sep 17 00:00:00 2001 From: Jakob Ewaldsson Date: Fri, 3 Mar 2023 12:54:45 +0100 Subject: [PATCH 11/77] (feat) #2 Added password dialog --- .../java/org/jabref/gui/DialogService.java | 9 +++++++ .../org/jabref/gui/JabRefDialogService.java | 26 +++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/src/main/java/org/jabref/gui/DialogService.java b/src/main/java/org/jabref/gui/DialogService.java index 26cf46c00a1..3be1432d54e 100644 --- a/src/main/java/org/jabref/gui/DialogService.java +++ b/src/main/java/org/jabref/gui/DialogService.java @@ -14,6 +14,7 @@ import javafx.scene.control.ChoiceDialog; import javafx.scene.control.DialogPane; import javafx.scene.control.TextInputDialog; +import org.controlsfx.control.textfield.CustomPasswordField; import org.jabref.gui.util.BaseDialog; import org.jabref.gui.util.DirectoryDialogConfiguration; @@ -161,6 +162,14 @@ boolean showConfirmationDialogWithOptOutAndWait(String title, String content, String okButtonLabel, String cancelButtonLabel, String optOutMessage, Consumer optOutAction); + /** + * This will create and display new {@link CustomPasswordField} that doesn't show the text, and two buttons + * one cancel and one ok. + * + * @return the entered password if pressed "OK", null otherwise + */ + Optional showPasswordDialogAndWait(String title, String header, String content); + /** * Shows a custom dialog without returning any results. * diff --git a/src/main/java/org/jabref/gui/JabRefDialogService.java b/src/main/java/org/jabref/gui/JabRefDialogService.java index d21e0b3b9d9..9709223cc2b 100644 --- a/src/main/java/org/jabref/gui/JabRefDialogService.java +++ b/src/main/java/org/jabref/gui/JabRefDialogService.java @@ -26,6 +26,7 @@ import javafx.scene.control.DialogPane; import javafx.scene.control.Label; import javafx.scene.control.TextInputDialog; +import javafx.scene.layout.HBox; import javafx.scene.layout.Pane; import javafx.scene.layout.Region; import javafx.scene.layout.VBox; @@ -49,6 +50,7 @@ import com.tobiasdiez.easybind.EasyBind; import org.controlsfx.control.Notifications; import org.controlsfx.control.TaskProgressView; +import org.controlsfx.control.textfield.CustomPasswordField; import org.controlsfx.dialog.ExceptionDialog; import org.controlsfx.dialog.ProgressDialog; import org.slf4j.Logger; @@ -270,6 +272,30 @@ public Optional showCustomDialogAndWait(javafx.scene.control.Dialog di return dialog.showAndWait(); } + @Override + public Optional showPasswordDialogAndWait(String title, String header, String content) { + javafx.scene.control.Dialog dialog = new javafx.scene.control.Dialog<>(); + dialog.setTitle(title); + dialog.setHeaderText(header); + + CustomPasswordField passwordField = new CustomPasswordField(); + + HBox box = new HBox(); + box.setSpacing(10); + box.getChildren().addAll(new Label(content), passwordField); + dialog.setTitle(title); + dialog.getDialogPane().setContent(box); + + dialog.getDialogPane().getButtonTypes().addAll(ButtonType.CANCEL, ButtonType.OK); + dialog.setResultConverter(dialogButton -> { + if (dialogButton == ButtonType.OK) { + return passwordField.getText(); + } + return null; + }); + return dialog.showAndWait(); + } + @Override public void showProgressDialog(String title, String content, Task task) { ProgressDialog progressDialog = new ProgressDialog(task); From 828110f3d3ff71e438bc7023aa52c84c3b7c6d0b Mon Sep 17 00:00:00 2001 From: Jakob Ewaldsson Date: Fri, 3 Mar 2023 14:09:15 +0100 Subject: [PATCH 12/77] (feat) #2 Added functionality for password dialog pop up. It is triggered from JabRefGUI if proxy requires password --- src/main/java/org/jabref/gui/JabRefGUI.java | 13 +++++++------ .../gui/preferences/PreferencesDialogView.java | 2 -- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/jabref/gui/JabRefGUI.java b/src/main/java/org/jabref/gui/JabRefGUI.java index 57cdf7f8307..1ee881737c9 100644 --- a/src/main/java/org/jabref/gui/JabRefGUI.java +++ b/src/main/java/org/jabref/gui/JabRefGUI.java @@ -18,17 +18,16 @@ import org.jabref.gui.importer.ParserResultWarningDialog; import org.jabref.gui.importer.actions.OpenDatabaseAction; import org.jabref.gui.keyboard.TextInputKeyBindings; -import org.jabref.gui.preferences.PreferencesDialogView; import org.jabref.gui.shared.SharedDatabaseUIManager; import org.jabref.logic.importer.ParserResult; import org.jabref.logic.l10n.Localization; +import org.jabref.logic.net.ProxyRegisterer; import org.jabref.logic.shared.DatabaseNotSupportedException; import org.jabref.logic.shared.exception.InvalidDBMSConnectionPropertiesException; import org.jabref.logic.shared.exception.NotASharedDatabaseException; import org.jabref.logic.util.WebViewStore; import org.jabref.preferences.GuiPreferences; import org.jabref.preferences.PreferencesService; -import org.jabref.preferences.JabRefPreferences; import impl.org.controlsfx.skin.DecorationPane; import org.slf4j.Logger; @@ -65,11 +64,13 @@ public JabRefGUI(Stage mainStage, List databases, boolean isBlank, preferencesService.getInternalPreferences()) .checkForNewVersionDelayed(); - if (JabRefPreferences.getInstance().getProxyPreferences().shouldUseAuthentication()){ + if (preferencesService.getProxyPreferences().shouldUseAuthentication()){ DialogService dialogService = Injector.instantiateModelOrService(DialogService.class); - PreferencesDialogView preferencesDialogView = new PreferencesDialogView(this.mainFrame); - preferencesDialogView.getPreferenceTabList().getSelectionModel().select(20); - dialogService.showCustomDialog(preferencesDialogView); + dialogService.showPasswordDialogAndWait("Proxy configuration", "Proxy requires password","Password") + .ifPresent(newPassword -> { + preferencesService.getProxyPreferences().setPassword(newPassword); + ProxyRegisterer.register(preferencesService.getProxyPreferences()); + }); } } diff --git a/src/main/java/org/jabref/gui/preferences/PreferencesDialogView.java b/src/main/java/org/jabref/gui/preferences/PreferencesDialogView.java index 089b09f693a..f3a5c245913 100644 --- a/src/main/java/org/jabref/gui/preferences/PreferencesDialogView.java +++ b/src/main/java/org/jabref/gui/preferences/PreferencesDialogView.java @@ -67,8 +67,6 @@ public PreferencesDialogViewModel getViewModel() { return viewModel; } - public ListView getPreferenceTabList() {return preferenceTabList;} - @FXML private void initialize() { viewModel = new PreferencesDialogViewModel(dialogService, preferencesService, frame); From cb3cac3f3e07ef02f291d87b7f4dcdd735f2ebd1 Mon Sep 17 00:00:00 2001 From: Jakob Ewaldsson Date: Mon, 6 Mar 2023 09:37:38 +0100 Subject: [PATCH 13/77] (fix) #2 proxy-password popup now only triggers if both proxy and authentication are enabled, before only auth was checked --- src/main/java/org/jabref/gui/JabRefGUI.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/jabref/gui/JabRefGUI.java b/src/main/java/org/jabref/gui/JabRefGUI.java index 1ee881737c9..5dda14310aa 100644 --- a/src/main/java/org/jabref/gui/JabRefGUI.java +++ b/src/main/java/org/jabref/gui/JabRefGUI.java @@ -64,7 +64,7 @@ public JabRefGUI(Stage mainStage, List databases, boolean isBlank, preferencesService.getInternalPreferences()) .checkForNewVersionDelayed(); - if (preferencesService.getProxyPreferences().shouldUseAuthentication()){ + if (preferencesService.getProxyPreferences().shouldUseProxy() && preferencesService.getProxyPreferences().shouldUseAuthentication()){ DialogService dialogService = Injector.instantiateModelOrService(DialogService.class); dialogService.showPasswordDialogAndWait("Proxy configuration", "Proxy requires password","Password") .ifPresent(newPassword -> { From 6de677328611b79a9fa335349a773f085652c54c Mon Sep 17 00:00:00 2001 From: Michael Morales Date: Mon, 6 Mar 2023 10:24:11 +0100 Subject: [PATCH 14/77] (Fix) #10 Removed dependency issue test functions --- .../java/org/jabref/logic/net/ProxyTest.java | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/test/java/org/jabref/logic/net/ProxyTest.java diff --git a/src/test/java/org/jabref/logic/net/ProxyTest.java b/src/test/java/org/jabref/logic/net/ProxyTest.java new file mode 100644 index 00000000000..3c5c77cbd46 --- /dev/null +++ b/src/test/java/org/jabref/logic/net/ProxyTest.java @@ -0,0 +1,36 @@ +package org.jabref.logic.net; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; +public class ProxyTest { + /** + * The test checks if ProxyPreference class is still able to store password and use it from memory, + * even though it's no longer stored in register. + */ + @Test + public void testProxyPreferencesStorePassword() { + //mock data + Boolean useProxy = true; + String hostname = "testName"; + String port = "8080"; + Boolean useAuthentication = true; + String username = "testUserName"; + String password = "testPassword"; + //Creates proxy preference + ProxyPreferences proxyPref = new ProxyPreferences( + useProxy, + hostname, + port, + useAuthentication, + username, + password); + //Check if mock data is stored in object memory and can be extracted + assertEquals(proxyPref.shouldUseProxy(), true); + assertEquals(proxyPref.getHostname(), hostname); + assertEquals(proxyPref.getPort(), port); + assertEquals(proxyPref.shouldUseAuthentication(), true); + assertEquals(proxyPref.getUsername(), username); + assertEquals(proxyPref.getPassword(), password); + } +} From 425753eebf9d38cd61bd3df033806949fb396939 Mon Sep 17 00:00:00 2001 From: Minhao037 <117693180+Minhao037@users.noreply.github.com> Date: Mon, 6 Mar 2023 10:28:15 +0100 Subject: [PATCH 15/77] (doc) Modified CHANGELOG.md to meet contribution requirements --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2073b82de19..5df19768616 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve - We fixed an issue where the command line export using `--exportMatches` flag does not create an output bib file [#9581](https://github.com/JabRef/jabref/issues/9581) - We fixed an issue where custom field in the custom entry types could not be set to mulitline [#9609](https://github.com/JabRef/jabref/issues/9609) - We fixed an issue where the Office XML exporter did not resolve BibTeX-Strings when exporting entries [forum#3741](https://discourse.jabref.org/t/exporting-bibtex-constant-strings-to-ms-office-2007-xml/3741) +- we fixed an issue where the password is saved locally if user wants to use proxy with authentication [#8055](https://github.com/JabRef/jabref/issues/8055) ### Removed From af8a1babf2880eaaaef2c1310d1530fff0acc1fb Mon Sep 17 00:00:00 2001 From: Minhao037 <117693180+Minhao037@users.noreply.github.com> Date: Mon, 6 Mar 2023 10:30:39 +0100 Subject: [PATCH 16/77] (fix) Corrected wrong spelling --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5df19768616..fed7836d470 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,7 +33,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve - We fixed an issue where the command line export using `--exportMatches` flag does not create an output bib file [#9581](https://github.com/JabRef/jabref/issues/9581) - We fixed an issue where custom field in the custom entry types could not be set to mulitline [#9609](https://github.com/JabRef/jabref/issues/9609) - We fixed an issue where the Office XML exporter did not resolve BibTeX-Strings when exporting entries [forum#3741](https://discourse.jabref.org/t/exporting-bibtex-constant-strings-to-ms-office-2007-xml/3741) -- we fixed an issue where the password is saved locally if user wants to use proxy with authentication [#8055](https://github.com/JabRef/jabref/issues/8055) +- We fixed an issue where the password is saved locally if user wants to use proxy with authentication [#8055](https://github.com/JabRef/jabref/issues/8055) ### Removed From 1be0dbe7799989a84593f5ceb2a7dae3afb0f6ac Mon Sep 17 00:00:00 2001 From: Jakob Ewaldsson Date: Mon, 6 Mar 2023 11:08:58 +0100 Subject: [PATCH 17/77] (fix) #2 Added Localization.lang to the english termes used for popup --- src/main/java/org/jabref/gui/JabRefGUI.java | 2 +- src/main/resources/l10n/JabRef_en.properties | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/jabref/gui/JabRefGUI.java b/src/main/java/org/jabref/gui/JabRefGUI.java index 5dda14310aa..fce0327c4b0 100644 --- a/src/main/java/org/jabref/gui/JabRefGUI.java +++ b/src/main/java/org/jabref/gui/JabRefGUI.java @@ -66,7 +66,7 @@ public JabRefGUI(Stage mainStage, List databases, boolean isBlank, if (preferencesService.getProxyPreferences().shouldUseProxy() && preferencesService.getProxyPreferences().shouldUseAuthentication()){ DialogService dialogService = Injector.instantiateModelOrService(DialogService.class); - dialogService.showPasswordDialogAndWait("Proxy configuration", "Proxy requires password","Password") + dialogService.showPasswordDialogAndWait(Localization.lang("Proxy configuration"), Localization.lang("Proxy requires password"), Localization.lang("Password")) .ifPresent(newPassword -> { preferencesService.getProxyPreferences().setPassword(newPassword); ProxyRegisterer.register(preferencesService.getProxyPreferences()); diff --git a/src/main/resources/l10n/JabRef_en.properties b/src/main/resources/l10n/JabRef_en.properties index 29d1e8ebfd8..865c06ee9b7 100644 --- a/src/main/resources/l10n/JabRef_en.properties +++ b/src/main/resources/l10n/JabRef_en.properties @@ -1,3 +1,5 @@ +Proxy\ requires\ password=Proxy requires password + Could\ not\ delete\ empty\ entries.=Could not delete empty entries. Delete\ empty\ entries=Delete empty entries From dbf9127ab88b5056ccb77be05baf60b96ef00bef Mon Sep 17 00:00:00 2001 From: jacobtr Date: Mon, 6 Mar 2023 11:13:15 +0100 Subject: [PATCH 18/77] (refactor) add back accidentally removed line --- src/main/java/org/jabref/preferences/JabRefPreferences.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/org/jabref/preferences/JabRefPreferences.java b/src/main/java/org/jabref/preferences/JabRefPreferences.java index b0a712eab29..c5104e3ad41 100644 --- a/src/main/java/org/jabref/preferences/JabRefPreferences.java +++ b/src/main/java/org/jabref/preferences/JabRefPreferences.java @@ -1545,6 +1545,7 @@ public ProxyPreferences getProxyPreferences() { if (Objects.nonNull(proxyPreferences)) { return proxyPreferences; } + proxyPreferences = new ProxyPreferences( getBoolean(PROXY_USE), get(PROXY_HOSTNAME), From e55b28cf6d03881536f186ad475c4d87821c96b1 Mon Sep 17 00:00:00 2001 From: Jakob Ewaldsson Date: Mon, 6 Mar 2023 11:53:21 +0100 Subject: [PATCH 19/77] (fix) #14 changed import order and other checkstyle requirements --- .../java/org/jabref/gui/DialogService.java | 2 +- src/main/java/org/jabref/gui/JabRefGUI.java | 4 +- .../java/org/jabref/logic/net/ProxyTest.java | 61 ++++++++++--------- 3 files changed, 34 insertions(+), 33 deletions(-) diff --git a/src/main/java/org/jabref/gui/DialogService.java b/src/main/java/org/jabref/gui/DialogService.java index 3be1432d54e..c152bdcb343 100644 --- a/src/main/java/org/jabref/gui/DialogService.java +++ b/src/main/java/org/jabref/gui/DialogService.java @@ -14,13 +14,13 @@ import javafx.scene.control.ChoiceDialog; import javafx.scene.control.DialogPane; import javafx.scene.control.TextInputDialog; -import org.controlsfx.control.textfield.CustomPasswordField; import org.jabref.gui.util.BaseDialog; import org.jabref.gui.util.DirectoryDialogConfiguration; import org.jabref.gui.util.FileDialogConfiguration; import org.jabref.logic.l10n.Localization; +import org.controlsfx.control.textfield.CustomPasswordField; import org.controlsfx.dialog.ProgressDialog; /** diff --git a/src/main/java/org/jabref/gui/JabRefGUI.java b/src/main/java/org/jabref/gui/JabRefGUI.java index fce0327c4b0..95bea74d9af 100644 --- a/src/main/java/org/jabref/gui/JabRefGUI.java +++ b/src/main/java/org/jabref/gui/JabRefGUI.java @@ -6,7 +6,6 @@ import java.util.List; import java.util.stream.Collectors; -import com.airhacks.afterburner.injection.Injector; import javafx.application.Platform; import javafx.scene.Scene; import javafx.scene.input.KeyEvent; @@ -29,6 +28,7 @@ import org.jabref.preferences.GuiPreferences; import org.jabref.preferences.PreferencesService; +import com.airhacks.afterburner.injection.Injector; import impl.org.controlsfx.skin.DecorationPane; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -64,7 +64,7 @@ public JabRefGUI(Stage mainStage, List databases, boolean isBlank, preferencesService.getInternalPreferences()) .checkForNewVersionDelayed(); - if (preferencesService.getProxyPreferences().shouldUseProxy() && preferencesService.getProxyPreferences().shouldUseAuthentication()){ + if (preferencesService.getProxyPreferences().shouldUseProxy() && preferencesService.getProxyPreferences().shouldUseAuthentication()) { DialogService dialogService = Injector.instantiateModelOrService(DialogService.class); dialogService.showPasswordDialogAndWait(Localization.lang("Proxy configuration"), Localization.lang("Proxy requires password"), Localization.lang("Password")) .ifPresent(newPassword -> { diff --git a/src/test/java/org/jabref/logic/net/ProxyTest.java b/src/test/java/org/jabref/logic/net/ProxyTest.java index 3c5c77cbd46..510f9ce1a50 100644 --- a/src/test/java/org/jabref/logic/net/ProxyTest.java +++ b/src/test/java/org/jabref/logic/net/ProxyTest.java @@ -2,35 +2,36 @@ import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertEquals; + public class ProxyTest { - /** - * The test checks if ProxyPreference class is still able to store password and use it from memory, - * even though it's no longer stored in register. - */ - @Test - public void testProxyPreferencesStorePassword() { - //mock data - Boolean useProxy = true; - String hostname = "testName"; - String port = "8080"; - Boolean useAuthentication = true; - String username = "testUserName"; - String password = "testPassword"; - //Creates proxy preference - ProxyPreferences proxyPref = new ProxyPreferences( - useProxy, - hostname, - port, - useAuthentication, - username, - password); - //Check if mock data is stored in object memory and can be extracted - assertEquals(proxyPref.shouldUseProxy(), true); - assertEquals(proxyPref.getHostname(), hostname); - assertEquals(proxyPref.getPort(), port); - assertEquals(proxyPref.shouldUseAuthentication(), true); - assertEquals(proxyPref.getUsername(), username); - assertEquals(proxyPref.getPassword(), password); - } + /** + * The test checks if ProxyPreference class is still able to store password and use it from memory, + * even though it's no longer stored in register. + */ + @Test + public void testProxyPreferencesStorePassword() { + // mock data + Boolean useProxy = true; + String hostname = "testName"; + String port = "8080"; + Boolean useAuthentication = true; + String username = "testUserName"; + String password = "testPassword"; + // Creates proxy preference + ProxyPreferences proxyPref = new ProxyPreferences( + useProxy, + hostname, + port, + useAuthentication, + username, + password); + // Check if mock data is stored in object memory and can be extracted + assertEquals(proxyPref.shouldUseProxy(), true); + assertEquals(proxyPref.getHostname(), hostname); + assertEquals(proxyPref.getPort(), port); + assertEquals(proxyPref.shouldUseAuthentication(), true); + assertEquals(proxyPref.getUsername(), username); + assertEquals(proxyPref.getPassword(), password); + } } From 133958836d6ae243495c16035da6295ab28aafb2 Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Thu, 16 Mar 2023 22:39:43 +0100 Subject: [PATCH 20/77] Always delete the `.sav` file upon successful write --- CHANGELOG.md | 1 + .../org/jabref/logic/exporter/AtomicFileOutputStream.java | 7 ++++--- .../java/org/jabref/logic/exporter/SavePreferences.java | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f1277ee13f..55ec4823ad1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve - 'Get full text' now also checks the file url. [#568](https://github.com/koppor/jabref/issues/568) - We refined the 'main directory not found' error message. [#9625](https://github.com/JabRef/jabref/pull/9625) - We modified the `Add Group` dialog to use the most recently selected group hierarchical context [#9141](https://github.com/JabRef/jabref/issues/9141) +- To avoid cluttering of the directory, We always delete the `.sav` file upon successful write. diff --git a/src/main/java/org/jabref/logic/exporter/AtomicFileOutputStream.java b/src/main/java/org/jabref/logic/exporter/AtomicFileOutputStream.java index 5694d79b803..58f98365592 100644 --- a/src/main/java/org/jabref/logic/exporter/AtomicFileOutputStream.java +++ b/src/main/java/org/jabref/logic/exporter/AtomicFileOutputStream.java @@ -62,6 +62,7 @@ public class AtomicFileOutputStream extends FilterOutputStream { private final Path temporaryFile; private final FileLock temporaryFileLock; + /** * A backup of the target file (if it exists), created when the stream is closed */ @@ -75,7 +76,7 @@ public class AtomicFileOutputStream extends FilterOutputStream { * Creates a new output stream to write to or replace the file at the specified path. * * @param path the path of the file to write to or replace - * @param keepBackup whether to keep the backup file after a successful write process + * @param keepBackup whether to keep the backup file (.sav) after a successful write process */ public AtomicFileOutputStream(Path path, boolean keepBackup) throws IOException { // Files.newOutputStream(getPathOfTemporaryFile(path)) leads to a "sun.nio.ch.ChannelOutputStream", which does not offer "lock" @@ -84,7 +85,7 @@ public AtomicFileOutputStream(Path path, boolean keepBackup) throws IOException /** * Creates a new output stream to write to or replace the file at the specified path. - * The backup file is deleted when write was successful. + * The backup file (.sav) is deleted when write was successful. * * @param path the path of the file to write to or replace */ @@ -238,7 +239,7 @@ public void close() throws IOException { } if (!keepBackup) { - // Remove backup file + // Remove backup file for saving Files.deleteIfExists(backupFile); } } finally { diff --git a/src/main/java/org/jabref/logic/exporter/SavePreferences.java b/src/main/java/org/jabref/logic/exporter/SavePreferences.java index 1165d3338c9..a566c0c3449 100644 --- a/src/main/java/org/jabref/logic/exporter/SavePreferences.java +++ b/src/main/java/org/jabref/logic/exporter/SavePreferences.java @@ -49,7 +49,7 @@ public SavePreferences(Boolean saveInOriginalOrder, this(saveInOriginalOrder, saveOrder, - true, + false, saveType, takeMetadataSaveOrderInAccount, reformatFile, From 435cfe23abce2a0681279c0a531b6962652f7a52 Mon Sep 17 00:00:00 2001 From: Lucas Freund Date: Sat, 18 Mar 2023 16:16:50 +0100 Subject: [PATCH 21/77] add missing BibStringDiff test cases --- .../bibtex/comparator/BibStringDiffTest.java | 95 ++++++++++++++++++- 1 file changed, 93 insertions(+), 2 deletions(-) diff --git a/src/test/java/org/jabref/logic/bibtex/comparator/BibStringDiffTest.java b/src/test/java/org/jabref/logic/bibtex/comparator/BibStringDiffTest.java index 1db4078fdfa..28f8ed4d801 100644 --- a/src/test/java/org/jabref/logic/bibtex/comparator/BibStringDiffTest.java +++ b/src/test/java/org/jabref/logic/bibtex/comparator/BibStringDiffTest.java @@ -1,5 +1,6 @@ package org.jabref.logic.bibtex.comparator; +import java.util.Collections; import java.util.List; import org.jabref.model.database.BibDatabase; @@ -9,6 +10,9 @@ import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -22,13 +26,100 @@ public class BibStringDiffTest { void setUp() { when(originalDataBase.hasNoStrings()).thenReturn(false); when(newDataBase.hasNoStrings()).thenReturn(false); - when(originalDataBase.getStringValues()).thenReturn(List.of(new BibtexString("name", "content"), new BibtexString("name2", "content2"))); - when(newDataBase.getStringValues()).thenReturn(List.of(new BibtexString("name", "content"), new BibtexString("name2", "content3"))); } @Test void compareTest() { + when(originalDataBase.getStringValues()).thenReturn(List.of(new BibtexString("name", "content"), new BibtexString("name2", "content2"))); + when(newDataBase.getStringValues()).thenReturn(List.of(new BibtexString("name", "content"), new BibtexString("name2", "content3"))); + List result = BibStringDiff.compare(originalDataBase, newDataBase); assertEquals(List.of(diff), result); } + + @Test + void equalTest() { + BibStringDiff other = new BibStringDiff(diff.getOriginalString(), diff.getNewString()); + assertEquals(diff, other); + assertEquals(diff.hashCode(), other.hashCode()); + } + + @Test + void notEqualTest() { + BibStringDiff other = new BibStringDiff(diff.getNewString(), diff.getOriginalString()); + assertNotEquals(diff, other); + assertNotEquals(diff.hashCode(), other.hashCode()); + } + + @Test + void identicalObjectsAreEqual() { + BibStringDiff other = diff; + assertTrue(other.equals(diff)); + } + + @Test + void compareToNullObjectIsFalse() { + assertFalse(diff.equals(null)); + } + + @Test + void compareToDifferentClassIsFalse() { + assertFalse(diff.equals(new Object())); + } + + @Test + void testGetters() { + BibtexString bsOne = new BibtexString("aKahle", "Kahle, Brewster"); + BibtexString bsTwo = new BibtexString("iMIT", "Institute of Technology"); + BibStringDiff diff = new BibStringDiff(bsOne, bsTwo); + assertEquals(diff.getOriginalString(), bsOne); + assertEquals(diff.getNewString(), bsTwo); + } + + @Test + void testCompareEmptyDatabases() { + when(originalDataBase.hasNoStrings()).thenReturn(true); + when(newDataBase.hasNoStrings()).thenReturn(true); + + assertEquals(Collections.emptyList(), BibStringDiff.compare(originalDataBase, newDataBase)); + } + + @Test + void testCompareNameChange() { + when(originalDataBase.getStringValues()).thenReturn(List.of(new BibtexString("name", "content"))); + when(newDataBase.getStringValues()).thenReturn(List.of(new BibtexString("name2", "content"))); + + List result = BibStringDiff.compare(originalDataBase, newDataBase); + BibStringDiff expectedDiff = new BibStringDiff(new BibtexString("name", "content"), new BibtexString("name2", "content")); + assertEquals(List.of(expectedDiff), result); + } + + @Test + void testCompareNoDiff() { + when(originalDataBase.getStringValues()).thenReturn(List.of(new BibtexString("name", "content"))); + when(newDataBase.getStringValues()).thenReturn(List.of(new BibtexString("name", "content"))); + + List result = BibStringDiff.compare(originalDataBase, newDataBase); + assertEquals(Collections.emptyList(), result); + } + + @Test + void testCompareRemovedString() { + when(originalDataBase.getStringValues()).thenReturn(List.of(new BibtexString("name", "content"))); + when(newDataBase.getStringValues()).thenReturn(Collections.emptyList()); + + List result = BibStringDiff.compare(originalDataBase, newDataBase); + BibStringDiff expectedDiff = new BibStringDiff(new BibtexString("name", "content"), null); + assertEquals(List.of(expectedDiff), result); + } + + @Test + void testCompareAddString() { + when(originalDataBase.getStringValues()).thenReturn(Collections.emptyList()); + when(newDataBase.getStringValues()).thenReturn(List.of(new BibtexString("name", "content"))); + + List result = BibStringDiff.compare(originalDataBase, newDataBase); + BibStringDiff expectedDiff = new BibStringDiff(null, new BibtexString("name", "content")); + assertEquals(List.of(expectedDiff), result); + } } From 2f11ed9fa67c175da270a77ddcfa46ff8ac1de15 Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Mon, 20 Mar 2023 23:01:06 +0100 Subject: [PATCH 22/77] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 313d6841bbb..7d99f5957d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,7 +29,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve - Backups of libraries are not stored per JabRef version, but collected together. - We modified the `Add Group` dialog to use the most recently selected group hierarchical context [#9141](https://github.com/JabRef/jabref/issues/9141) - We improved the Medline importer to correctly import ISO dates for `revised`. [#9536](https://github.com/JabRef/jabref/issues/9536) -- To avoid cluttering of the directory, We always delete the `.sav` file upon successful write. +- To avoid cluttering of the directory, We always delete the `.sav` file upon successful write. [#9675](https://github.com/JabRef/jabref/pull/9675) From 3ca9d444d9ec72e486fbeae348e6f1007357bf32 Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Mon, 20 Mar 2023 23:03:35 +0100 Subject: [PATCH 23/77] Fix typo --- .../guidelines-for-setting-up-a-local-workspace.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/getting-into-the-code/guidelines-for-setting-up-a-local-workspace.md b/docs/getting-into-the-code/guidelines-for-setting-up-a-local-workspace.md index 9cbc6e46dad..8a6182e9f1b 100644 --- a/docs/getting-into-the-code/guidelines-for-setting-up-a-local-workspace.md +++ b/docs/getting-into-the-code/guidelines-for-setting-up-a-local-workspace.md @@ -85,7 +85,7 @@ In the following, we will use `c:\git-repositories` as base folder: ```cmd cd \ mkdir git-repositories -cd git-reposiroties +cd git-repositories ``` **Note that putting the repo jabref directly under `C:\` or any other drive letter under windows causes compile errors** From 9d9652ceb5de49e057111e2a1b204dd50fd291f5 Mon Sep 17 00:00:00 2001 From: Durairaja Vigneshwar <39377015+vigneshdurairaj@users.noreply.github.com> Date: Wed, 22 Mar 2023 08:28:46 +0100 Subject: [PATCH 24/77] Adding text formatting for hits (#9686) * Adding text formatting for hits * Bug fix on issue 8797, by decreasing the font-size at the breakpoints * Adding entry for issue #8797 in changelog * Shortened the changelog --- CHANGELOG.md | 1 + .../java/org/jabref/gui/groups/GroupTree.css | 4 +- .../org/jabref/gui/groups/GroupTreeView.java | 39 +++++++++++++++++-- 3 files changed, 38 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ff69d86f76d..f79e5a16120 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -47,6 +47,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve - We fixed an issue where custom field in the custom entry types could not be set to mulitline [#9609](https://github.com/JabRef/jabref/issues/9609) - We fixed an issue where the Office XML exporter did not resolve BibTeX-Strings when exporting entries [forum#3741](https://discourse.jabref.org/t/exporting-bibtex-constant-strings-to-ms-office-2007-xml/3741) - JabRef is now more relaxed when parsing field content: In case a field content ended with `\`, the combination `\}` was treated as plain `}`. [#9668](https://github.com/JabRef/jabref/issues/9668) +- We resolved an issue that cut off the number of group entries when it exceedet four digits. [#8797](https://github.com/JabRef/jabref/issues/8797) ### Removed diff --git a/src/main/java/org/jabref/gui/groups/GroupTree.css b/src/main/java/org/jabref/gui/groups/GroupTree.css index 272e9a8cb83..29a4b5a204e 100644 --- a/src/main/java/org/jabref/gui/groups/GroupTree.css +++ b/src/main/java/org/jabref/gui/groups/GroupTree.css @@ -18,11 +18,11 @@ } .numberColumn > .hits { - -fx-font-size: 85%; + -fx-font-size: 0.75em; -fx-background-color: -jr-group-hits-bg; -fx-padding: 0.4em 0.4em 0.4em 0.4em; -fx-background-insets: 0; - -fx-background-radius: 0.8em; + -fx-background-radius: 0.7em; } .numberColumn > .hits .text { diff --git a/src/main/java/org/jabref/gui/groups/GroupTreeView.java b/src/main/java/org/jabref/gui/groups/GroupTreeView.java index eac9957ff29..ebfaa7d0b69 100644 --- a/src/main/java/org/jabref/gui/groups/GroupTreeView.java +++ b/src/main/java/org/jabref/gui/groups/GroupTreeView.java @@ -2,6 +2,7 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +import java.text.DecimalFormat; import java.time.Duration; import java.util.ArrayList; import java.util.LinkedList; @@ -11,6 +12,7 @@ import java.util.stream.Collectors; import javafx.application.Platform; +import javafx.beans.binding.Bindings; import javafx.beans.property.ObjectProperty; import javafx.css.PseudoClass; import javafx.scene.control.Button; @@ -114,9 +116,9 @@ private void createNodes() { mainColumn.setResizable(true); numberColumn = new TreeTableColumn<>(); numberColumn.getStyleClass().add("numberColumn"); - numberColumn.setMinWidth(40d); - numberColumn.setMaxWidth(40d); - numberColumn.setPrefWidth(40d); + numberColumn.setMinWidth(60d); + numberColumn.setMaxWidth(60d); + numberColumn.setPrefWidth(60d); numberColumn.setResizable(false); expansionNodeColumn = new TreeTableColumn<>(); expansionNodeColumn.getStyleClass().add("expansionNodeColumn"); @@ -131,7 +133,7 @@ private void createNodes() { groupTree.getColumns().addAll(List.of(mainColumn, numberColumn, expansionNodeColumn)); this.setCenter(groupTree); - mainColumn.prefWidthProperty().bind(groupTree.widthProperty().subtract(60d).subtract(15)); + mainColumn.prefWidthProperty().bind(groupTree.widthProperty().subtract(80d).subtract(15d)); addNewGroup = new Button(Localization.lang("Add group")); addNewGroup.setId("addNewGroup"); @@ -217,6 +219,35 @@ private void initialize() { } }); text.getStyleClass().setAll("text"); + text.textProperty().bind(Bindings.createStringBinding(() -> { + int hits = group.getHits().get(); + if (hits >= 1000000) { + double millions = hits / 1000000.0; + return new DecimalFormat("#,##0.#").format(millions) + "m"; + } else if (hits >= 1000) { + double thousands = hits / 1000.0; + return new DecimalFormat("#,##0.#").format(thousands) + "k"; + } else { + return Integer.toString(hits); + } + }, group.getHits())); + + text.styleProperty().bind(Bindings.createStringBinding(() -> { + double reducedFontSize; + double font_size = preferencesService.getAppearancePreferences().getMainFontSize(); + // For each breaking point, the font size is reduced 0.20 em to fix issue 8797 + if (font_size > 26.0) { + reducedFontSize = 0.25; + } else if (font_size > 22.0) { + reducedFontSize = 0.35; + } else if (font_size > 18.0) { + reducedFontSize = 0.55; + } else { + reducedFontSize = 0.75; + } + return String.format("-fx-font-size: %fem;", reducedFontSize); + }, preferencesService.getAppearancePreferences().mainFontSizeProperty())); + node.getChildren().add(text); node.setMaxWidth(Control.USE_PREF_SIZE); return node; From 9f05f23e11911ef87089f22ef5190d306d345b89 Mon Sep 17 00:00:00 2001 From: Siedlerchr Date: Wed, 22 Mar 2023 22:30:52 +0100 Subject: [PATCH 25/77] Update javafx to 20 --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 3189714f041..f85f9cf69f1 100644 --- a/build.gradle +++ b/build.gradle @@ -98,7 +98,7 @@ dependencyLocking { } javafx { - version = "19" + version = "20" modules = [ 'javafx.controls', 'javafx.fxml', 'javafx.web', 'javafx.swing' ] } From 7884da5869af24e433ae5be429601d5f341d0a0c Mon Sep 17 00:00:00 2001 From: Nitin Suresh Date: Wed, 22 Mar 2023 21:58:20 -0700 Subject: [PATCH 26/77] update mappings for dateCaptured and dateModified --- src/main/java/org/jabref/logic/exporter/ModsExporter.java | 4 ++-- .../jabref/logic/importer/fileformat/ModsImporter.java | 8 +++++--- .../logic/exporter/ModsExportFormatTestAllFields.bib | 4 ++-- .../logic/exporter/ModsExportFormatTestAllFields.xml | 2 +- .../importer/fileformat/MODSImporterTestAllFields.bib | 4 ++-- 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/main/java/org/jabref/logic/exporter/ModsExporter.java b/src/main/java/org/jabref/logic/exporter/ModsExporter.java index da8afbcbcb8..ba07204ed92 100644 --- a/src/main/java/org/jabref/logic/exporter/ModsExporter.java +++ b/src/main/java/org/jabref/logic/exporter/ModsExporter.java @@ -373,9 +373,9 @@ private void addOriginInformation(Field field, String value, OriginInfoDefinitio addDate("dateIssued", value, originInfo); } else if (field.equals(new UnknownField("created"))) { addDate("dateCreated", value, originInfo); - } else if (field.equals(new UnknownField("modified"))) { + } else if (field.equals(StandardField.MODIFICATIONDATE)) { addDate("dateModified", value, originInfo); - } else if (field.equals(new UnknownField("captured"))) { + } else if (field.equals(StandardField.CREATIONDATE)) { addDate("dateCaptured", value, originInfo); } else if (StandardField.PUBLISHER.equals(field)) { StringPlusLanguagePlusSupplied publisher = new StringPlusLanguagePlusSupplied(); diff --git a/src/main/java/org/jabref/logic/importer/fileformat/ModsImporter.java b/src/main/java/org/jabref/logic/importer/fileformat/ModsImporter.java index 1684be0e9ed..e6f9b92019a 100644 --- a/src/main/java/org/jabref/logic/importer/fileformat/ModsImporter.java +++ b/src/main/java/org/jabref/logic/importer/fileformat/ModsImporter.java @@ -516,9 +516,9 @@ private void parseIdentifier(Map fields, Identifier identifier, B private void putDate(Map fields, String elementName, String date) { if (date != null) { + Optional optionalParsedDate = Date.parse(date); switch (elementName) { case "dateIssued" -> { - Optional optionalParsedDate = Date.parse(date); optionalParsedDate .ifPresent(parsedDate -> fields.put(StandardField.DATE, parsedDate.getNormalized())); @@ -534,10 +534,12 @@ private void putDate(Map fields, String elementName, String date) fields.put(new UnknownField("created"), date); } case "dateCaptured" -> { - fields.put(new UnknownField("captured"), date); + optionalParsedDate + .ifPresent(parsedDate -> fields.put(StandardField.CREATIONDATE, parsedDate.getNormalized())); } case "dateModified" -> { - fields.put(new UnknownField("modified"), date); + optionalParsedDate + .ifPresent(parsedDate -> fields.put(StandardField.MODIFICATIONDATE, parsedDate.getNormalized())); } } } diff --git a/src/test/resources/org/jabref/logic/exporter/ModsExportFormatTestAllFields.bib b/src/test/resources/org/jabref/logic/exporter/ModsExportFormatTestAllFields.bib index 911c90bd44d..1186a51347e 100644 --- a/src/test/resources/org/jabref/logic/exporter/ModsExportFormatTestAllFields.bib +++ b/src/test/resources/org/jabref/logic/exporter/ModsExportFormatTestAllFields.bib @@ -11,7 +11,7 @@ @Article{ abstract = {abstract}, address = {India}, affiliation = {an affiliation}, - captured = {2000-11-11}, + creationdate = {2000-11-11}, created = {2000-11-10}, date = {2000}, doi = {someDoi}, @@ -21,7 +21,7 @@ @Article{ keywords = {keyword, electrophoresis, neoplasia, spectrometry, translation}, language = {en}, location = {somewhere}, - modified = {2000-12-10}, + modificationdate = {2000-12-10}, pmid = {123456789}, publisher = {Verlag verlag}, uri = {an uri}, diff --git a/src/test/resources/org/jabref/logic/exporter/ModsExportFormatTestAllFields.xml b/src/test/resources/org/jabref/logic/exporter/ModsExportFormatTestAllFields.xml index 9ffb277f992..a307e50d99e 100644 --- a/src/test/resources/org/jabref/logic/exporter/ModsExportFormatTestAllFields.xml +++ b/src/test/resources/org/jabref/logic/exporter/ModsExportFormatTestAllFields.xml @@ -51,8 +51,8 @@ India - 2000-11-11 2000-11-10 + 2000-11-11 2 monographic 2000-12-10 diff --git a/src/test/resources/org/jabref/logic/importer/fileformat/MODSImporterTestAllFields.bib b/src/test/resources/org/jabref/logic/importer/fileformat/MODSImporterTestAllFields.bib index 2e7c3edea99..b8d55dd3a9f 100644 --- a/src/test/resources/org/jabref/logic/importer/fileformat/MODSImporterTestAllFields.bib +++ b/src/test/resources/org/jabref/logic/importer/fileformat/MODSImporterTestAllFields.bib @@ -2,13 +2,13 @@ @article{TelPeak abstract = {an abstract}, affiliation = {an affiliation}, author = {Telescope}, - captured = {1955-11-30}, + creationdate = {1955-11-30}, city = {New York}, country = {United States}, created = {1955-03-22}, edition = {2}, journal = {Cell}, - modified = {1970-12-01}, + modificationdate = {1970-12-01}, pages = {50}, source = {Indiana University Digital Library Program}, title = {Telescope PK from Zabriskie Pt.}, From 22777431c8b526d83047cdd86509a40634c557fe Mon Sep 17 00:00:00 2001 From: Lucas Freund <127773292+Luggas4you@users.noreply.github.com> Date: Thu, 23 Mar 2023 12:53:59 +0100 Subject: [PATCH 27/77] remove empty javadoc comments --- .../mergeentries/newmergedialog/cell/ThreeWayMergeCell.java | 3 --- src/main/java/org/jabref/logic/layout/format/AuthorLF_FF.java | 3 --- .../java/org/jabref/logic/layout/format/AuthorLF_FFAbbr.java | 3 --- 3 files changed, 9 deletions(-) diff --git a/src/main/java/org/jabref/gui/mergeentries/newmergedialog/cell/ThreeWayMergeCell.java b/src/main/java/org/jabref/gui/mergeentries/newmergedialog/cell/ThreeWayMergeCell.java index 2a4b020aaef..1c9df85a6bd 100644 --- a/src/main/java/org/jabref/gui/mergeentries/newmergedialog/cell/ThreeWayMergeCell.java +++ b/src/main/java/org/jabref/gui/mergeentries/newmergedialog/cell/ThreeWayMergeCell.java @@ -6,9 +6,6 @@ import com.tobiasdiez.easybind.EasyBind; -/** - * - */ public abstract class ThreeWayMergeCell extends HBox { public static final String ODD_PSEUDO_CLASS = "odd"; public static final String EVEN_PSEUDO_CLASS = "even"; diff --git a/src/main/java/org/jabref/logic/layout/format/AuthorLF_FF.java b/src/main/java/org/jabref/logic/layout/format/AuthorLF_FF.java index ef394e091a3..3e027862412 100644 --- a/src/main/java/org/jabref/logic/layout/format/AuthorLF_FF.java +++ b/src/main/java/org/jabref/logic/layout/format/AuthorLF_FF.java @@ -3,9 +3,6 @@ import org.jabref.logic.layout.LayoutFormatter; import org.jabref.model.entry.AuthorList; -/** - * - */ public class AuthorLF_FF implements LayoutFormatter { @Override diff --git a/src/main/java/org/jabref/logic/layout/format/AuthorLF_FFAbbr.java b/src/main/java/org/jabref/logic/layout/format/AuthorLF_FFAbbr.java index 4fda2fd8386..01866e0ea83 100644 --- a/src/main/java/org/jabref/logic/layout/format/AuthorLF_FFAbbr.java +++ b/src/main/java/org/jabref/logic/layout/format/AuthorLF_FFAbbr.java @@ -3,9 +3,6 @@ import org.jabref.logic.layout.LayoutFormatter; import org.jabref.model.entry.AuthorList; -/** - * - */ public class AuthorLF_FFAbbr implements LayoutFormatter { @Override From 4d35effa8836b4a1aac40fb9a3b00241d2ed89b0 Mon Sep 17 00:00:00 2001 From: Oscar Topliss <97887308+OscarTopliss@users.noreply.github.com> Date: Fri, 24 Mar 2023 11:23:01 +0000 Subject: [PATCH 28/77] Grammar fix and rewording in README.md Small grammar fix and rewording, replacing "in one of the many thousand built-in citation styles" with "using one of thousands of built in citation styles". I reworded it a bit, so if people don't like the rewording that's more than fair. If the original wording is preferred, then "in one of the many thousands of built in citation styles" would maintain the wording whilst fixing the grammar. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1134969f30f..104dc70e7c2 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ It supports you in every step of your research work. - Native BibTeX and Biblatex support - Cite-as-you-write functionality for external applications such as Emacs, Kile, LyX, Texmaker, TeXstudio, Vim and WinEdt. -- Format references in one of the many thousand built-in citation styles or create your style +- Format references using one of thousands of built-in citation styles or create your style - Support for Word and LibreOffice/OpenOffice for inserting and formatting citations ### Share From 7841398e4a0c6880e9f2b3ed2eaa93bd5fb597fa Mon Sep 17 00:00:00 2001 From: Oscar Topliss <97887308+OscarTopliss@users.noreply.github.com> Date: Fri, 24 Mar 2023 11:36:01 +0000 Subject: [PATCH 29/77] more slight rewording for README.md Added the word "own", I think "create your own style" reads better. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 104dc70e7c2..6fcb79d3783 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ It supports you in every step of your research work. - Native BibTeX and Biblatex support - Cite-as-you-write functionality for external applications such as Emacs, Kile, LyX, Texmaker, TeXstudio, Vim and WinEdt. -- Format references using one of thousands of built-in citation styles or create your style +- Format references using one of thousands of built-in citation styles or create your own style - Support for Word and LibreOffice/OpenOffice for inserting and formatting citations ### Share From 3e1ba61e42ae69a8a613935976ebffd1c6943727 Mon Sep 17 00:00:00 2001 From: Carl Christian Snethlage <50491877+calixtus@users.noreply.github.com> Date: Fri, 24 Mar 2023 12:49:16 +0100 Subject: [PATCH 30/77] Updated indentation --- .../ModsExportFormatTestAllFields.bib | 50 +++++++++---------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/src/test/resources/org/jabref/logic/exporter/ModsExportFormatTestAllFields.bib b/src/test/resources/org/jabref/logic/exporter/ModsExportFormatTestAllFields.bib index 1186a51347e..9ef7a8ccdaf 100644 --- a/src/test/resources/org/jabref/logic/exporter/ModsExportFormatTestAllFields.bib +++ b/src/test/resources/org/jabref/logic/exporter/ModsExportFormatTestAllFields.bib @@ -1,31 +1,31 @@ % Encoding: UTF-8 @Article{, - author = {Don't, know and Realy, don't know}, - title = {title}, - journal = {Some journal}, - year = {2000}, - volume = {5}, - pages = {67-68}, - note = {a note, and another note}, - abstract = {abstract}, - address = {India}, - affiliation = {an affiliation}, - creationdate = {2000-11-11}, - created = {2000-11-10}, - date = {2000}, - doi = {someDoi}, - edition = {2}, - issuance = {monographic}, - issue = {10}, - keywords = {keyword, electrophoresis, neoplasia, spectrometry, translation}, - language = {en}, - location = {somewhere}, - modificationdate = {2000-12-10}, - pmid = {123456789}, - publisher = {Verlag verlag}, - uri = {an uri}, - url = {someWebSite}, + author = {Don't, know and Realy, don't know}, + title = {title}, + journal = {Some journal}, + year = {2000}, + volume = {5}, + pages = {67-68}, + note = {a note, and another note}, + abstract = {abstract}, + address = {India}, + affiliation = {an affiliation}, + creationdate = {2000-11-11}, + created = {2000-11-10}, + date = {2000}, + doi = {someDoi}, + edition = {2}, + issuance = {monographic}, + issue = {10}, + keywords = {keyword, electrophoresis, neoplasia, spectrometry, translation}, + language = {en}, + location = {somewhere}, + modificationdate = {2000-12-10}, + pmid = {123456789}, + publisher = {Verlag verlag}, + uri = {an uri}, + url = {someWebSite}, } @Comment{jabref-meta: databaseType:bibtex;} From 75b9ff20916011812a03140ed96bbea404434f75 Mon Sep 17 00:00:00 2001 From: Carl Christian Snethlage <50491877+calixtus@users.noreply.github.com> Date: Fri, 24 Mar 2023 12:51:38 +0100 Subject: [PATCH 31/77] Updated more indentation --- .../fileformat/MODSImporterTestAllFields.bib | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/test/resources/org/jabref/logic/importer/fileformat/MODSImporterTestAllFields.bib b/src/test/resources/org/jabref/logic/importer/fileformat/MODSImporterTestAllFields.bib index b8d55dd3a9f..ab9b490395f 100644 --- a/src/test/resources/org/jabref/logic/importer/fileformat/MODSImporterTestAllFields.bib +++ b/src/test/resources/org/jabref/logic/importer/fileformat/MODSImporterTestAllFields.bib @@ -1,17 +1,17 @@ @article{TelPeak, - abstract = {an abstract}, - affiliation = {an affiliation}, - author = {Telescope}, - creationdate = {1955-11-30}, - city = {New York}, - country = {United States}, - created = {1955-03-22}, - edition = {2}, - journal = {Cell}, + abstract = {an abstract}, + affiliation = {an affiliation}, + author = {Telescope}, + creationdate = {1955-11-30}, + city = {New York}, + country = {United States}, + created = {1955-03-22}, + edition = {2}, + journal = {Cell}, modificationdate = {1970-12-01}, - pages = {50}, - source = {Indiana University Digital Library Program}, - title = {Telescope PK from Zabriskie Pt.}, - url = {http://purl.dlib.indiana.edu/iudl/archives/cushman/P07803, http://quod.lib.umich.edu/m/mods/thumbs/Indiana/oai.dlib.indiana.edu/ archives/cushman/oai_3Aoai.dlib.indiana.edu_3Aarchives_5Ccushman_5CP07803.png}, - year = {1955} + pages = {50}, + source = {Indiana University Digital Library Program}, + title = {Telescope PK from Zabriskie Pt.}, + url = {http://purl.dlib.indiana.edu/iudl/archives/cushman/P07803, http://quod.lib.umich.edu/m/mods/thumbs/Indiana/oai.dlib.indiana.edu/ archives/cushman/oai_3Aoai.dlib.indiana.edu_3Aarchives_5Ccushman_5CP07803.png}, + year = {1955} } From d0cd71e9bf09eef244d9e2f31ce4236e735cdb55 Mon Sep 17 00:00:00 2001 From: dragos222 Date: Sun, 26 Mar 2023 14:02:34 +0200 Subject: [PATCH 32/77] Refactor out PlainTextOrDiff Enum(?); Use guiPreferences; add mergePlainTextOrDiff to JabrefPreferences --- src/main/java/org/jabref/gui/JabRefFrame.java | 2 +- .../org/jabref/gui/collab/ChangeScanner.java | 2 +- .../collab/DatabaseChangeResolverFactory.java | 7 +++-- .../entrychange/EntryChangeResolver.java | 8 +++-- .../jabref/gui/dialogs/BackupUIManager.java | 2 +- .../DuplicateResolverDialog.java | 6 ++-- .../jabref/gui/maintable/RightClickMenu.java | 2 +- .../gui/mergeentries/FetchAndMergeEntry.java | 9 +++--- .../gui/mergeentries/MergeEntriesAction.java | 8 +++-- .../gui/mergeentries/MergeEntriesDialog.java | 5 ++-- .../gui/mergeentries/PlainTextOrDiff.java | 29 ++++++++++++++++++ .../newmergedialog/ThreeWayMergeView.java | 11 ++++--- .../toolbar/ThreeWayMergeToolbar.java | 30 +++++++------------ .../gui/shared/SharedDatabaseUIManager.java | 2 +- .../jabref/preferences/GuiPreferences.java | 17 +++++++++++ .../jabref/preferences/JabRefPreferences.java | 6 ++++ 16 files changed, 100 insertions(+), 46 deletions(-) create mode 100644 src/main/java/org/jabref/gui/mergeentries/PlainTextOrDiff.java diff --git a/src/main/java/org/jabref/gui/JabRefFrame.java b/src/main/java/org/jabref/gui/JabRefFrame.java index 4769fd425e7..65bb117b0f5 100644 --- a/src/main/java/org/jabref/gui/JabRefFrame.java +++ b/src/main/java/org/jabref/gui/JabRefFrame.java @@ -856,7 +856,7 @@ private MenuBar createMenu() { quality.getItems().addAll( factory.createMenuItem(StandardActions.FIND_DUPLICATES, new DuplicateSearch(this, dialogService, stateManager, prefs)), - factory.createMenuItem(StandardActions.MERGE_ENTRIES, new MergeEntriesAction(dialogService, stateManager, prefs.getBibEntryPreferences())), + factory.createMenuItem(StandardActions.MERGE_ENTRIES, new MergeEntriesAction(dialogService, stateManager, prefs.getBibEntryPreferences(), prefs.getGuiPreferences())), factory.createMenuItem(StandardActions.CHECK_INTEGRITY, new IntegrityCheckAction(this, stateManager, Globals.TASK_EXECUTOR)), factory.createMenuItem(StandardActions.CLEANUP_ENTRIES, new CleanupAction(this, this.prefs, dialogService, stateManager)), diff --git a/src/main/java/org/jabref/gui/collab/ChangeScanner.java b/src/main/java/org/jabref/gui/collab/ChangeScanner.java index 72ea8768613..d438426517a 100644 --- a/src/main/java/org/jabref/gui/collab/ChangeScanner.java +++ b/src/main/java/org/jabref/gui/collab/ChangeScanner.java @@ -28,7 +28,7 @@ public ChangeScanner(BibDatabaseContext database, PreferencesService preferencesService) { this.database = database; this.preferencesService = preferencesService; - this.databaseChangeResolverFactory = new DatabaseChangeResolverFactory(dialogService, database, preferencesService.getBibEntryPreferences()); + this.databaseChangeResolverFactory = new DatabaseChangeResolverFactory(dialogService, database, preferencesService.getBibEntryPreferences(), preferencesService.getGuiPreferences()); } public List scanForChanges() { diff --git a/src/main/java/org/jabref/gui/collab/DatabaseChangeResolverFactory.java b/src/main/java/org/jabref/gui/collab/DatabaseChangeResolverFactory.java index 2aed7bb22ed..58efb6b3d26 100644 --- a/src/main/java/org/jabref/gui/collab/DatabaseChangeResolverFactory.java +++ b/src/main/java/org/jabref/gui/collab/DatabaseChangeResolverFactory.java @@ -7,21 +7,24 @@ import org.jabref.gui.collab.entrychange.EntryChangeResolver; import org.jabref.model.database.BibDatabaseContext; import org.jabref.preferences.BibEntryPreferences; +import org.jabref.preferences.GuiPreferences; public class DatabaseChangeResolverFactory { private final DialogService dialogService; private final BibDatabaseContext databaseContext; private final BibEntryPreferences bibEntryPreferences; + private final GuiPreferences guiPreferences; - public DatabaseChangeResolverFactory(DialogService dialogService, BibDatabaseContext databaseContext, BibEntryPreferences bibEntryPreferences) { + public DatabaseChangeResolverFactory(DialogService dialogService, BibDatabaseContext databaseContext, BibEntryPreferences bibEntryPreferences, GuiPreferences guiPreferences) { this.dialogService = dialogService; this.databaseContext = databaseContext; this.bibEntryPreferences = bibEntryPreferences; + this.guiPreferences = guiPreferences; } public Optional create(DatabaseChange change) { if (change instanceof EntryChange entryChange) { - return Optional.of(new EntryChangeResolver(entryChange, dialogService, databaseContext, bibEntryPreferences)); + return Optional.of(new EntryChangeResolver(entryChange, dialogService, databaseContext, bibEntryPreferences, guiPreferences)); } return Optional.empty(); diff --git a/src/main/java/org/jabref/gui/collab/entrychange/EntryChangeResolver.java b/src/main/java/org/jabref/gui/collab/entrychange/EntryChangeResolver.java index 8e5575f4196..07a902c6941 100644 --- a/src/main/java/org/jabref/gui/collab/entrychange/EntryChangeResolver.java +++ b/src/main/java/org/jabref/gui/collab/entrychange/EntryChangeResolver.java @@ -13,23 +13,25 @@ import org.jabref.logic.l10n.Localization; import org.jabref.model.database.BibDatabaseContext; import org.jabref.preferences.BibEntryPreferences; +import org.jabref.preferences.GuiPreferences; public final class EntryChangeResolver extends DatabaseChangeResolver { private final EntryChange entryChange; private final BibDatabaseContext databaseContext; private final BibEntryPreferences bibEntryPreferences; - - public EntryChangeResolver(EntryChange entryChange, DialogService dialogService, BibDatabaseContext databaseContext, BibEntryPreferences bibEntryPreferences) { + private final GuiPreferences guiPreferences; + public EntryChangeResolver(EntryChange entryChange, DialogService dialogService, BibDatabaseContext databaseContext, BibEntryPreferences bibEntryPreferences, GuiPreferences guiPreferences) { super(dialogService); this.entryChange = entryChange; this.databaseContext = databaseContext; this.bibEntryPreferences = bibEntryPreferences; + this.guiPreferences = guiPreferences; } @Override public Optional askUserToResolveChange() { - MergeEntriesDialog mergeEntriesDialog = new MergeEntriesDialog(entryChange.getOldEntry(), entryChange.getNewEntry(), bibEntryPreferences); + MergeEntriesDialog mergeEntriesDialog = new MergeEntriesDialog(entryChange.getOldEntry(), entryChange.getNewEntry(), bibEntryPreferences, guiPreferences); mergeEntriesDialog.setLeftHeaderText(Localization.lang("In JabRef")); mergeEntriesDialog.setRightHeaderText(Localization.lang("On disk")); mergeEntriesDialog.configureDiff(new ShowDiffConfig(ThreeWayMergeToolbar.DiffView.SPLIT, BasicDiffMethod.WORDS)); diff --git a/src/main/java/org/jabref/gui/dialogs/BackupUIManager.java b/src/main/java/org/jabref/gui/dialogs/BackupUIManager.java index 3c0536bf4af..8fdb0f0669b 100644 --- a/src/main/java/org/jabref/gui/dialogs/BackupUIManager.java +++ b/src/main/java/org/jabref/gui/dialogs/BackupUIManager.java @@ -66,7 +66,7 @@ private static Optional showReviewBackupDialog(DialogService dialo Path backupPath = BackupFileUtil.getPathOfLatestExisingBackupFile(originalPath, BackupFileType.BACKUP).orElseThrow(); BibDatabaseContext backupDatabase = OpenDatabase.loadDatabase(backupPath, importFormatPreferences, new DummyFileUpdateMonitor()).getDatabaseContext(); - DatabaseChangeResolverFactory changeResolverFactory = new DatabaseChangeResolverFactory(dialogService, originalDatabase, preferencesService.getBibEntryPreferences()); + DatabaseChangeResolverFactory changeResolverFactory = new DatabaseChangeResolverFactory(dialogService, originalDatabase, preferencesService.getBibEntryPreferences(), preferencesService.getGuiPreferences()); return DefaultTaskExecutor.runInJavaFXThread(() -> { List changes = DatabaseChangeList.compareAndGetChanges(originalDatabase, backupDatabase, changeResolverFactory); diff --git a/src/main/java/org/jabref/gui/duplicationFinder/DuplicateResolverDialog.java b/src/main/java/org/jabref/gui/duplicationFinder/DuplicateResolverDialog.java index 205e4df75de..e831d435d76 100644 --- a/src/main/java/org/jabref/gui/duplicationFinder/DuplicateResolverDialog.java +++ b/src/main/java/org/jabref/gui/duplicationFinder/DuplicateResolverDialog.java @@ -77,21 +77,21 @@ private void init(BibEntry one, BibEntry two, DuplicateResolverType type) { first = new ButtonType(Localization.lang("Keep left"), ButtonData.LEFT); second = new ButtonType(Localization.lang("Keep right"), ButtonData.LEFT); both = new ButtonType(Localization.lang("Keep both"), ButtonData.LEFT); - threeWayMerge = new ThreeWayMergeView(one, two, preferencesService.getBibEntryPreferences()); + threeWayMerge = new ThreeWayMergeView(one, two, preferencesService.getBibEntryPreferences(), preferencesService.getGuiPreferences()); } case DUPLICATE_SEARCH_WITH_EXACT -> { first = new ButtonType(Localization.lang("Keep left"), ButtonData.LEFT); second = new ButtonType(Localization.lang("Keep right"), ButtonData.LEFT); both = new ButtonType(Localization.lang("Keep both"), ButtonData.LEFT); removeExactVisible = true; - threeWayMerge = new ThreeWayMergeView(one, two, preferencesService.getBibEntryPreferences()); + threeWayMerge = new ThreeWayMergeView(one, two, preferencesService.getBibEntryPreferences(), preferencesService.getGuiPreferences()); } case IMPORT_CHECK -> { first = new ButtonType(Localization.lang("Keep old entry"), ButtonData.LEFT); second = new ButtonType(Localization.lang("Keep from import"), ButtonData.LEFT); both = new ButtonType(Localization.lang("Keep both"), ButtonData.LEFT); threeWayMerge = new ThreeWayMergeView(one, two, Localization.lang("Old entry"), - Localization.lang("From import"), preferencesService.getBibEntryPreferences()); + Localization.lang("From import"), preferencesService.getBibEntryPreferences(), preferencesService.getGuiPreferences()); } default -> throw new IllegalStateException("Switch expression should be exhaustive"); } diff --git a/src/main/java/org/jabref/gui/maintable/RightClickMenu.java b/src/main/java/org/jabref/gui/maintable/RightClickMenu.java index 31409e0ffc0..02ccc9a7322 100644 --- a/src/main/java/org/jabref/gui/maintable/RightClickMenu.java +++ b/src/main/java/org/jabref/gui/maintable/RightClickMenu.java @@ -52,7 +52,7 @@ public static ContextMenu create(BibEntryTableViewModel entry, createCopySubMenu(factory, dialogService, stateManager, preferencesService, clipBoardManager, taskExecutor), factory.createMenuItem(StandardActions.PASTE, new EditAction(StandardActions.PASTE, libraryTab.frame(), stateManager)), factory.createMenuItem(StandardActions.CUT, new EditAction(StandardActions.CUT, libraryTab.frame(), stateManager)), - factory.createMenuItem(StandardActions.MERGE_ENTRIES, new MergeEntriesAction(dialogService, stateManager, preferencesService.getBibEntryPreferences())), + factory.createMenuItem(StandardActions.MERGE_ENTRIES, new MergeEntriesAction(dialogService, stateManager, preferencesService.getBibEntryPreferences(), preferencesService.getGuiPreferences())), factory.createMenuItem(StandardActions.DELETE_ENTRY, new EditAction(StandardActions.DELETE_ENTRY, libraryTab.frame(), stateManager)), new SeparatorMenuItem(), diff --git a/src/main/java/org/jabref/gui/mergeentries/FetchAndMergeEntry.java b/src/main/java/org/jabref/gui/mergeentries/FetchAndMergeEntry.java index 83399cd4f7b..f4cad2b9c91 100644 --- a/src/main/java/org/jabref/gui/mergeentries/FetchAndMergeEntry.java +++ b/src/main/java/org/jabref/gui/mergeentries/FetchAndMergeEntry.java @@ -30,6 +30,7 @@ import org.jabref.model.entry.field.StandardField; import org.jabref.model.entry.types.EntryType; import org.jabref.preferences.BibEntryPreferences; +import org.jabref.preferences.GuiPreferences; import org.jabref.preferences.PreferencesService; import org.slf4j.Logger; @@ -77,7 +78,7 @@ public void fetchAndMerge(BibEntry entry, List fields) { String type = field.getDisplayName(); if (fetchedEntry.isPresent()) { cleanup.doPostCleanup(fetchedEntry.get()); - showMergeDialog(entry, fetchedEntry.get(), fetcher.get(), preferencesService.getBibEntryPreferences()); + showMergeDialog(entry, fetchedEntry.get(), fetcher.get(), preferencesService.getBibEntryPreferences(), preferencesService.getGuiPreferences()); } else { dialogService.notify(Localization.lang("Cannot get info based on given %0: %1", type, fieldContent.get())); } @@ -100,8 +101,8 @@ public void fetchAndMerge(BibEntry entry, List fields) { } } - private void showMergeDialog(BibEntry originalEntry, BibEntry fetchedEntry, WebFetcher fetcher, BibEntryPreferences bibEntryPreferences) { - MergeEntriesDialog dialog = new MergeEntriesDialog(originalEntry, fetchedEntry, bibEntryPreferences); + private void showMergeDialog(BibEntry originalEntry, BibEntry fetchedEntry, WebFetcher fetcher, BibEntryPreferences bibEntryPreferences, GuiPreferences guiPreferences) { + MergeEntriesDialog dialog = new MergeEntriesDialog(originalEntry, fetchedEntry, bibEntryPreferences, guiPreferences); dialog.setTitle(Localization.lang("Merge entry with %0 information", fetcher.getName())); dialog.setLeftHeaderText(Localization.lang("Original entry")); dialog.setRightHeaderText(Localization.lang("Entry from %0", fetcher.getName())); @@ -167,7 +168,7 @@ public void fetchAndMerge(BibEntry entry, EntryBasedFetcher fetcher) { if (fetchedEntry.isPresent()) { ImportCleanup cleanup = new ImportCleanup(libraryTab.getBibDatabaseContext().getMode()); cleanup.doPostCleanup(fetchedEntry.get()); - showMergeDialog(entry, fetchedEntry.get(), fetcher, preferencesService.getBibEntryPreferences()); + showMergeDialog(entry, fetchedEntry.get(), fetcher, preferencesService.getBibEntryPreferences(), preferencesService.getGuiPreferences()); } else { dialogService.notify(Localization.lang("Could not find any bibliographic information.")); } diff --git a/src/main/java/org/jabref/gui/mergeentries/MergeEntriesAction.java b/src/main/java/org/jabref/gui/mergeentries/MergeEntriesAction.java index 9c40605d11d..f4d9ecc587b 100644 --- a/src/main/java/org/jabref/gui/mergeentries/MergeEntriesAction.java +++ b/src/main/java/org/jabref/gui/mergeentries/MergeEntriesAction.java @@ -12,18 +12,20 @@ import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.field.InternalField; import org.jabref.preferences.BibEntryPreferences; +import org.jabref.preferences.GuiPreferences; public class MergeEntriesAction extends SimpleCommand { private static final int NUMBER_OF_ENTRIES_NEEDED = 2; private final DialogService dialogService; private final StateManager stateManager; private final BibEntryPreferences bibEntryPreferences; + private final GuiPreferences guiPreferences; - public MergeEntriesAction(DialogService dialogService, StateManager stateManager, BibEntryPreferences bibEntryPreferences) { + public MergeEntriesAction(DialogService dialogService, StateManager stateManager, BibEntryPreferences bibEntryPreferences, GuiPreferences guiPreferences) { this.dialogService = dialogService; this.stateManager = stateManager; this.bibEntryPreferences = bibEntryPreferences; - + this.guiPreferences = guiPreferences; this.executable.bind(ActionHelper.needsEntriesSelected(NUMBER_OF_ENTRIES_NEEDED, stateManager)); } @@ -59,7 +61,7 @@ public void execute() { second = one; } - MergeEntriesDialog dialog = new MergeEntriesDialog(first, second, bibEntryPreferences); + MergeEntriesDialog dialog = new MergeEntriesDialog(first, second, bibEntryPreferences, guiPreferences); dialog.setTitle(Localization.lang("Merge entries")); Optional mergeResultOpt = dialogService.showCustomDialogAndWait(dialog); diff --git a/src/main/java/org/jabref/gui/mergeentries/MergeEntriesDialog.java b/src/main/java/org/jabref/gui/mergeentries/MergeEntriesDialog.java index 23a82a1ddde..abbd7d1ca8a 100644 --- a/src/main/java/org/jabref/gui/mergeentries/MergeEntriesDialog.java +++ b/src/main/java/org/jabref/gui/mergeentries/MergeEntriesDialog.java @@ -9,14 +9,15 @@ import org.jabref.logic.l10n.Localization; import org.jabref.model.entry.BibEntry; import org.jabref.preferences.BibEntryPreferences; +import org.jabref.preferences.GuiPreferences; public class MergeEntriesDialog extends BaseDialog { private final ThreeWayMergeView threeWayMergeView; private final BibEntry one; private final BibEntry two; - public MergeEntriesDialog(BibEntry one, BibEntry two, BibEntryPreferences bibEntryPreferences) { - threeWayMergeView = new ThreeWayMergeView(one, two, bibEntryPreferences); + public MergeEntriesDialog(BibEntry one, BibEntry two, BibEntryPreferences bibEntryPreferences, GuiPreferences guiPreferences) { + threeWayMergeView = new ThreeWayMergeView(one, two, bibEntryPreferences, guiPreferences); this.one = one; this.two = two; diff --git a/src/main/java/org/jabref/gui/mergeentries/PlainTextOrDiff.java b/src/main/java/org/jabref/gui/mergeentries/PlainTextOrDiff.java new file mode 100644 index 00000000000..7b9f47d2016 --- /dev/null +++ b/src/main/java/org/jabref/gui/mergeentries/PlainTextOrDiff.java @@ -0,0 +1,29 @@ +package org.jabref.gui.mergeentries; + +import org.jabref.logic.l10n.Localization; + +public enum PlainTextOrDiff { + PLAIN_TEXT(Localization.lang("Plain Text")), Diff(Localization.lang("Show Diff")); + + private final String value; + + PlainTextOrDiff(String value) { + this.value = value; + } + + public static PlainTextOrDiff parse(String name) { + try { + return PlainTextOrDiff.valueOf(name); + } catch (IllegalArgumentException e) { + return Diff; // default + } + } + + public String getValue() { + return value; + } + + public static PlainTextOrDiff fromString(String str) { + return Enum.valueOf(PlainTextOrDiff.class, str); + } +} diff --git a/src/main/java/org/jabref/gui/mergeentries/newmergedialog/ThreeWayMergeView.java b/src/main/java/org/jabref/gui/mergeentries/newmergedialog/ThreeWayMergeView.java index 5767d747a4c..fd352757c02 100644 --- a/src/main/java/org/jabref/gui/mergeentries/newmergedialog/ThreeWayMergeView.java +++ b/src/main/java/org/jabref/gui/mergeentries/newmergedialog/ThreeWayMergeView.java @@ -18,6 +18,8 @@ import org.jabref.model.entry.field.Field; import org.jabref.model.entry.field.FieldProperty; import org.jabref.preferences.BibEntryPreferences; +import org.jabref.preferences.GuiPreferences; +import org.jabref.preferences.PreferencesService; public class ThreeWayMergeView extends VBox { public static final int GRID_COLUMN_MIN_WIDTH = 250; @@ -40,7 +42,7 @@ public class ThreeWayMergeView extends VBox { private final FieldMergerFactory fieldMergerFactory; private final String keywordSeparator; - public ThreeWayMergeView(BibEntry leftEntry, BibEntry rightEntry, String leftHeader, String rightHeader, BibEntryPreferences bibEntryPreferences) { + public ThreeWayMergeView(BibEntry leftEntry, BibEntry rightEntry, String leftHeader, String rightHeader, BibEntryPreferences bibEntryPreferences, GuiPreferences guiPreferences) { getStylesheets().add(ThreeWayMergeView.class.getResource("ThreeWayMergeView.css").toExternalForm()); viewModel = new ThreeWayMergeViewModel((BibEntry) leftEntry.clone(), (BibEntry) rightEntry.clone(), leftHeader, rightHeader); this.fieldMergerFactory = new FieldMergerFactory(bibEntryPreferences); @@ -49,7 +51,8 @@ public ThreeWayMergeView(BibEntry leftEntry, BibEntry rightEntry, String leftHea mergeGridPane = new GridPane(); scrollPane = new ScrollPane(); headerView = new ThreeWayMergeHeaderView(leftHeader, rightHeader); - toolbar = new ThreeWayMergeToolbar(); + + toolbar = new ThreeWayMergeToolbar(guiPreferences); initializeColumnConstraints(); initializeMergeGridPane(); @@ -63,8 +66,8 @@ public ThreeWayMergeView(BibEntry leftEntry, BibEntry rightEntry, String leftHea getChildren().addAll(toolbar, headerView, scrollPane); } - public ThreeWayMergeView(BibEntry leftEntry, BibEntry rightEntry, BibEntryPreferences bibEntryPreferences) { - this(leftEntry, rightEntry, LEFT_DEFAULT_HEADER, RIGHT_DEFAULT_HEADER, bibEntryPreferences); + public ThreeWayMergeView(BibEntry leftEntry, BibEntry rightEntry, BibEntryPreferences bibEntryPreferences, GuiPreferences guiPreferences) { + this(leftEntry, rightEntry, LEFT_DEFAULT_HEADER, RIGHT_DEFAULT_HEADER, bibEntryPreferences, guiPreferences); } private void initializeToolbar() { diff --git a/src/main/java/org/jabref/gui/mergeentries/newmergedialog/toolbar/ThreeWayMergeToolbar.java b/src/main/java/org/jabref/gui/mergeentries/newmergedialog/toolbar/ThreeWayMergeToolbar.java index 8a656830e4d..4761be59dc9 100644 --- a/src/main/java/org/jabref/gui/mergeentries/newmergedialog/toolbar/ThreeWayMergeToolbar.java +++ b/src/main/java/org/jabref/gui/mergeentries/newmergedialog/toolbar/ThreeWayMergeToolbar.java @@ -14,9 +14,11 @@ import javafx.scene.layout.AnchorPane; import javafx.util.StringConverter; +import org.jabref.gui.mergeentries.PlainTextOrDiff; import org.jabref.gui.mergeentries.newmergedialog.DiffMethod; import org.jabref.gui.mergeentries.newmergedialog.diffhighlighter.DiffHighlighter.BasicDiffMethod; import org.jabref.logic.l10n.Localization; +import org.jabref.preferences.GuiPreferences; import org.jabref.preferences.PreferencesService; import com.airhacks.afterburner.views.ViewLoader; @@ -55,8 +57,9 @@ public class ThreeWayMergeToolbar extends AnchorPane { private final ObjectProperty diffHighlightingMethod = new SimpleObjectProperty<>(); private final BooleanProperty onlyShowChangedFields = new SimpleBooleanProperty(); private EasyBinding showDiff; - - public ThreeWayMergeToolbar() { + private GuiPreferences guiPreferences; + public ThreeWayMergeToolbar(GuiPreferences guiPreferences) { + this.guiPreferences = guiPreferences; ViewLoader.view(this) .root(this) .load(); @@ -67,6 +70,11 @@ public void initialize() { showDiff = EasyBind.map(plainTextOrDiffComboBox.valueProperty(), plainTextOrDiff -> plainTextOrDiff == PlainTextOrDiff.Diff); plainTextOrDiffComboBox.getItems().addAll(PlainTextOrDiff.values()); plainTextOrDiffComboBox.getSelectionModel().select(PlainTextOrDiff.Diff); + + plainTextOrDiffComboBox.getSelectionModel().selectedItemProperty().addListener((options, oldValue, newValue) -> { + System.out.println(newValue); + }); + plainTextOrDiffComboBox.setConverter(new StringConverter<>() { @Override public String toString(PlainTextOrDiff plainTextOrDiff) { @@ -176,24 +184,6 @@ public void setOnSelectRightEntryValuesButtonClicked(Runnable onClick) { selectRightEntryValuesButton.setOnMouseClicked(e -> onClick.run()); } - public enum PlainTextOrDiff { - PLAIN_TEXT(Localization.lang("Plain Text")), Diff(Localization.lang("Show Diff")); - - private final String value; - - PlainTextOrDiff(String value) { - this.value = value; - } - - public String getValue() { - return value; - } - - public static PlainTextOrDiff fromString(String str) { - return Enum.valueOf(PlainTextOrDiff.class, str); - } - } - public enum DiffView { UNIFIED(Localization.lang("Unified View")), SPLIT(Localization.lang("Split View")); diff --git a/src/main/java/org/jabref/gui/shared/SharedDatabaseUIManager.java b/src/main/java/org/jabref/gui/shared/SharedDatabaseUIManager.java index 67593b9fbb5..8a5a2a27475 100644 --- a/src/main/java/org/jabref/gui/shared/SharedDatabaseUIManager.java +++ b/src/main/java/org/jabref/gui/shared/SharedDatabaseUIManager.java @@ -96,7 +96,7 @@ public void listen(UpdateRefusedEvent updateRefusedEvent) { Optional response = dialogService.showCustomButtonDialogAndWait(AlertType.CONFIRMATION, Localization.lang("Update refused"), message, ButtonType.CANCEL, merge); if (response.isPresent() && response.get().equals(merge)) { - MergeEntriesDialog dialog = new MergeEntriesDialog(localBibEntry, sharedBibEntry, preferencesService.getBibEntryPreferences()); + MergeEntriesDialog dialog = new MergeEntriesDialog(localBibEntry, sharedBibEntry, preferencesService.getBibEntryPreferences(), preferencesService.getGuiPreferences()); dialog.setTitle(Localization.lang("Update refused")); Optional mergedEntry = dialogService.showCustomDialogAndWait(dialog).map(EntriesMergeResult::mergedEntry); diff --git a/src/main/java/org/jabref/preferences/GuiPreferences.java b/src/main/java/org/jabref/preferences/GuiPreferences.java index fc0bd899286..8c86e96f980 100644 --- a/src/main/java/org/jabref/preferences/GuiPreferences.java +++ b/src/main/java/org/jabref/preferences/GuiPreferences.java @@ -15,6 +15,7 @@ import javafx.collections.ObservableList; import org.jabref.gui.mergeentries.DiffMode; +import org.jabref.gui.mergeentries.PlainTextOrDiff; import org.jabref.logic.util.io.FileHistory; public class GuiPreferences { @@ -33,6 +34,8 @@ public class GuiPreferences { private final StringProperty lastSelectedIdBasedFetcher; private final ObjectProperty mergeDiffMode; + private final ObjectProperty mergePlainTextOrDiff; + private final BooleanProperty mergeShowChangedFieldsOnly; private final DoubleProperty sidePaneWidth; @@ -46,6 +49,7 @@ public GuiPreferences(double positionX, FileHistory fileHistory, String lastSelectedIdBasedFetcher, DiffMode mergeDiffMode, + PlainTextOrDiff mergePlainTextOrDiff, double sidePaneWidth, boolean mergeShowChangedFieldsOnly) { this.positionX = new SimpleDoubleProperty(positionX); @@ -57,6 +61,7 @@ public GuiPreferences(double positionX, this.lastFocusedFile = new SimpleObjectProperty<>(lastFocusedFile); this.lastSelectedIdBasedFetcher = new SimpleStringProperty(lastSelectedIdBasedFetcher); this.mergeDiffMode = new SimpleObjectProperty<>(mergeDiffMode); + this.mergePlainTextOrDiff = new SimpleObjectProperty<>(mergePlainTextOrDiff); this.sidePaneWidth = new SimpleDoubleProperty(sidePaneWidth); this.fileHistory = fileHistory; this.mergeShowChangedFieldsOnly = new SimpleBooleanProperty(mergeShowChangedFieldsOnly); @@ -170,6 +175,18 @@ public void setMergeDiffMode(DiffMode mergeDiffMode) { this.mergeDiffMode.set(mergeDiffMode); } + public PlainTextOrDiff getMergePlainTextOrDiff() { + return mergePlainTextOrDiff.get(); + } + + public ObjectProperty mergePlainTextOrDiffProperty() { + return mergePlainTextOrDiff; + } + + public void setMergePlainTextOrDiff(PlainTextOrDiff mergePlainTextOrDiff) { + this.mergePlainTextOrDiff.set(mergePlainTextOrDiff); + } + public double getSidePaneWidth() { return sidePaneWidth.get(); } diff --git a/src/main/java/org/jabref/preferences/JabRefPreferences.java b/src/main/java/org/jabref/preferences/JabRefPreferences.java index f3202faa549..62c140c204f 100644 --- a/src/main/java/org/jabref/preferences/JabRefPreferences.java +++ b/src/main/java/org/jabref/preferences/JabRefPreferences.java @@ -55,6 +55,7 @@ import org.jabref.gui.maintable.NameDisplayPreferences.AbbreviationStyle; import org.jabref.gui.maintable.NameDisplayPreferences.DisplayStyle; import org.jabref.gui.mergeentries.DiffMode; +import org.jabref.gui.mergeentries.PlainTextOrDiff; import org.jabref.gui.push.PushToApplications; import org.jabref.gui.search.SearchDisplayMode; import org.jabref.gui.sidepane.SidePaneType; @@ -238,6 +239,8 @@ public class JabRefPreferences implements PreferencesService { // merge related public static final String MERGE_ENTRIES_DIFF_MODE = "mergeEntriesDiffMode"; + public static final String MERGE_ENTRIES_PLAIN_TEXT_OR_DIFF = "mergeEntriesPlainTextOrDiff"; + public static final String MERGE_SHOW_ONLY_CHANGED_FIELDS = "mergeShowOnlyChangedFields"; public static final String CUSTOM_EXPORT_FORMAT = "customExportFormat"; @@ -584,6 +587,7 @@ private JabRefPreferences() { defaults.put(DEFAULT_SHOW_SOURCE, Boolean.FALSE); defaults.put(MERGE_ENTRIES_DIFF_MODE, DiffMode.WORD.name()); + defaults.put(MERGE_ENTRIES_PLAIN_TEXT_OR_DIFF, PlainTextOrDiff.Diff.name()); defaults.put(MERGE_SHOW_ONLY_CHANGED_FIELDS, Boolean.FALSE); defaults.put(SHOW_RECOMMENDATIONS, Boolean.TRUE); @@ -2508,6 +2512,7 @@ public GuiPreferences getGuiPreferences() { getFileHistory(), get(ID_ENTRY_GENERATOR), DiffMode.parse(get(MERGE_ENTRIES_DIFF_MODE)), + PlainTextOrDiff.parse(get(MERGE_ENTRIES_PLAIN_TEXT_OR_DIFF)), getDouble(SIDE_PANE_WIDTH), getBoolean(MERGE_SHOW_ONLY_CHANGED_FIELDS)); @@ -2533,6 +2538,7 @@ public GuiPreferences getGuiPreferences() { guiPreferences.getFileHistory().addListener((InvalidationListener) change -> storeFileHistory(guiPreferences.getFileHistory())); EasyBind.listen(guiPreferences.lastSelectedIdBasedFetcherProperty(), (obs, oldValue, newValue) -> put(ID_ENTRY_GENERATOR, newValue)); EasyBind.listen(guiPreferences.mergeDiffModeProperty(), (obs, oldValue, newValue) -> put(MERGE_ENTRIES_DIFF_MODE, newValue.name())); + EasyBind.listen(guiPreferences.mergePlainTextOrDiffProperty(), (obs, oldValue, newValue) -> put(MERGE_ENTRIES_PLAIN_TEXT_OR_DIFF, newValue.name())); EasyBind.listen(guiPreferences.sidePaneWidthProperty(), (obs, oldValue, newValue) -> putDouble(SIDE_PANE_WIDTH, newValue.doubleValue())); EasyBind.listen(guiPreferences.mergeShowChangedFieldOnlyProperty(), (obs, oldValue, newValue) -> putBoolean(MERGE_SHOW_ONLY_CHANGED_FIELDS, newValue)); From 998ac479f96b1be85e0ca6c93829022e8ee05cd9 Mon Sep 17 00:00:00 2001 From: dragos222 Date: Sun, 26 Mar 2023 14:52:15 +0200 Subject: [PATCH 33/77] Update preference; remove guiPreference redundant objects --- src/main/java/org/jabref/gui/JabRefFrame.java | 2 +- .../java/org/jabref/gui/collab/ChangeScanner.java | 2 +- .../gui/collab/DatabaseChangeResolverFactory.java | 7 ++----- .../gui/collab/entrychange/EntryChangeResolver.java | 7 +++---- .../java/org/jabref/gui/dialogs/BackupUIManager.java | 2 +- .../duplicationFinder/DuplicateResolverDialog.java | 6 +++--- .../org/jabref/gui/maintable/RightClickMenu.java | 2 +- .../jabref/gui/mergeentries/FetchAndMergeEntry.java | 9 ++++----- .../jabref/gui/mergeentries/MergeEntriesAction.java | 7 ++----- .../jabref/gui/mergeentries/MergeEntriesDialog.java | 5 ++--- .../newmergedialog/ThreeWayMergeView.java | 10 ++++------ .../newmergedialog/toolbar/ThreeWayMergeToolbar.java | 12 +++++------- .../jabref/gui/shared/SharedDatabaseUIManager.java | 2 +- 13 files changed, 30 insertions(+), 43 deletions(-) diff --git a/src/main/java/org/jabref/gui/JabRefFrame.java b/src/main/java/org/jabref/gui/JabRefFrame.java index 65bb117b0f5..4769fd425e7 100644 --- a/src/main/java/org/jabref/gui/JabRefFrame.java +++ b/src/main/java/org/jabref/gui/JabRefFrame.java @@ -856,7 +856,7 @@ private MenuBar createMenu() { quality.getItems().addAll( factory.createMenuItem(StandardActions.FIND_DUPLICATES, new DuplicateSearch(this, dialogService, stateManager, prefs)), - factory.createMenuItem(StandardActions.MERGE_ENTRIES, new MergeEntriesAction(dialogService, stateManager, prefs.getBibEntryPreferences(), prefs.getGuiPreferences())), + factory.createMenuItem(StandardActions.MERGE_ENTRIES, new MergeEntriesAction(dialogService, stateManager, prefs.getBibEntryPreferences())), factory.createMenuItem(StandardActions.CHECK_INTEGRITY, new IntegrityCheckAction(this, stateManager, Globals.TASK_EXECUTOR)), factory.createMenuItem(StandardActions.CLEANUP_ENTRIES, new CleanupAction(this, this.prefs, dialogService, stateManager)), diff --git a/src/main/java/org/jabref/gui/collab/ChangeScanner.java b/src/main/java/org/jabref/gui/collab/ChangeScanner.java index d438426517a..72ea8768613 100644 --- a/src/main/java/org/jabref/gui/collab/ChangeScanner.java +++ b/src/main/java/org/jabref/gui/collab/ChangeScanner.java @@ -28,7 +28,7 @@ public ChangeScanner(BibDatabaseContext database, PreferencesService preferencesService) { this.database = database; this.preferencesService = preferencesService; - this.databaseChangeResolverFactory = new DatabaseChangeResolverFactory(dialogService, database, preferencesService.getBibEntryPreferences(), preferencesService.getGuiPreferences()); + this.databaseChangeResolverFactory = new DatabaseChangeResolverFactory(dialogService, database, preferencesService.getBibEntryPreferences()); } public List scanForChanges() { diff --git a/src/main/java/org/jabref/gui/collab/DatabaseChangeResolverFactory.java b/src/main/java/org/jabref/gui/collab/DatabaseChangeResolverFactory.java index 58efb6b3d26..2aed7bb22ed 100644 --- a/src/main/java/org/jabref/gui/collab/DatabaseChangeResolverFactory.java +++ b/src/main/java/org/jabref/gui/collab/DatabaseChangeResolverFactory.java @@ -7,24 +7,21 @@ import org.jabref.gui.collab.entrychange.EntryChangeResolver; import org.jabref.model.database.BibDatabaseContext; import org.jabref.preferences.BibEntryPreferences; -import org.jabref.preferences.GuiPreferences; public class DatabaseChangeResolverFactory { private final DialogService dialogService; private final BibDatabaseContext databaseContext; private final BibEntryPreferences bibEntryPreferences; - private final GuiPreferences guiPreferences; - public DatabaseChangeResolverFactory(DialogService dialogService, BibDatabaseContext databaseContext, BibEntryPreferences bibEntryPreferences, GuiPreferences guiPreferences) { + public DatabaseChangeResolverFactory(DialogService dialogService, BibDatabaseContext databaseContext, BibEntryPreferences bibEntryPreferences) { this.dialogService = dialogService; this.databaseContext = databaseContext; this.bibEntryPreferences = bibEntryPreferences; - this.guiPreferences = guiPreferences; } public Optional create(DatabaseChange change) { if (change instanceof EntryChange entryChange) { - return Optional.of(new EntryChangeResolver(entryChange, dialogService, databaseContext, bibEntryPreferences, guiPreferences)); + return Optional.of(new EntryChangeResolver(entryChange, dialogService, databaseContext, bibEntryPreferences)); } return Optional.empty(); diff --git a/src/main/java/org/jabref/gui/collab/entrychange/EntryChangeResolver.java b/src/main/java/org/jabref/gui/collab/entrychange/EntryChangeResolver.java index 07a902c6941..6edc7592b33 100644 --- a/src/main/java/org/jabref/gui/collab/entrychange/EntryChangeResolver.java +++ b/src/main/java/org/jabref/gui/collab/entrychange/EntryChangeResolver.java @@ -20,18 +20,17 @@ public final class EntryChangeResolver extends DatabaseChangeResolver { private final BibDatabaseContext databaseContext; private final BibEntryPreferences bibEntryPreferences; - private final GuiPreferences guiPreferences; - public EntryChangeResolver(EntryChange entryChange, DialogService dialogService, BibDatabaseContext databaseContext, BibEntryPreferences bibEntryPreferences, GuiPreferences guiPreferences) { + + public EntryChangeResolver(EntryChange entryChange, DialogService dialogService, BibDatabaseContext databaseContext, BibEntryPreferences bibEntryPreferences) { super(dialogService); this.entryChange = entryChange; this.databaseContext = databaseContext; this.bibEntryPreferences = bibEntryPreferences; - this.guiPreferences = guiPreferences; } @Override public Optional askUserToResolveChange() { - MergeEntriesDialog mergeEntriesDialog = new MergeEntriesDialog(entryChange.getOldEntry(), entryChange.getNewEntry(), bibEntryPreferences, guiPreferences); + MergeEntriesDialog mergeEntriesDialog = new MergeEntriesDialog(entryChange.getOldEntry(), entryChange.getNewEntry(), bibEntryPreferences); mergeEntriesDialog.setLeftHeaderText(Localization.lang("In JabRef")); mergeEntriesDialog.setRightHeaderText(Localization.lang("On disk")); mergeEntriesDialog.configureDiff(new ShowDiffConfig(ThreeWayMergeToolbar.DiffView.SPLIT, BasicDiffMethod.WORDS)); diff --git a/src/main/java/org/jabref/gui/dialogs/BackupUIManager.java b/src/main/java/org/jabref/gui/dialogs/BackupUIManager.java index 8fdb0f0669b..3c0536bf4af 100644 --- a/src/main/java/org/jabref/gui/dialogs/BackupUIManager.java +++ b/src/main/java/org/jabref/gui/dialogs/BackupUIManager.java @@ -66,7 +66,7 @@ private static Optional showReviewBackupDialog(DialogService dialo Path backupPath = BackupFileUtil.getPathOfLatestExisingBackupFile(originalPath, BackupFileType.BACKUP).orElseThrow(); BibDatabaseContext backupDatabase = OpenDatabase.loadDatabase(backupPath, importFormatPreferences, new DummyFileUpdateMonitor()).getDatabaseContext(); - DatabaseChangeResolverFactory changeResolverFactory = new DatabaseChangeResolverFactory(dialogService, originalDatabase, preferencesService.getBibEntryPreferences(), preferencesService.getGuiPreferences()); + DatabaseChangeResolverFactory changeResolverFactory = new DatabaseChangeResolverFactory(dialogService, originalDatabase, preferencesService.getBibEntryPreferences()); return DefaultTaskExecutor.runInJavaFXThread(() -> { List changes = DatabaseChangeList.compareAndGetChanges(originalDatabase, backupDatabase, changeResolverFactory); diff --git a/src/main/java/org/jabref/gui/duplicationFinder/DuplicateResolverDialog.java b/src/main/java/org/jabref/gui/duplicationFinder/DuplicateResolverDialog.java index e831d435d76..205e4df75de 100644 --- a/src/main/java/org/jabref/gui/duplicationFinder/DuplicateResolverDialog.java +++ b/src/main/java/org/jabref/gui/duplicationFinder/DuplicateResolverDialog.java @@ -77,21 +77,21 @@ private void init(BibEntry one, BibEntry two, DuplicateResolverType type) { first = new ButtonType(Localization.lang("Keep left"), ButtonData.LEFT); second = new ButtonType(Localization.lang("Keep right"), ButtonData.LEFT); both = new ButtonType(Localization.lang("Keep both"), ButtonData.LEFT); - threeWayMerge = new ThreeWayMergeView(one, two, preferencesService.getBibEntryPreferences(), preferencesService.getGuiPreferences()); + threeWayMerge = new ThreeWayMergeView(one, two, preferencesService.getBibEntryPreferences()); } case DUPLICATE_SEARCH_WITH_EXACT -> { first = new ButtonType(Localization.lang("Keep left"), ButtonData.LEFT); second = new ButtonType(Localization.lang("Keep right"), ButtonData.LEFT); both = new ButtonType(Localization.lang("Keep both"), ButtonData.LEFT); removeExactVisible = true; - threeWayMerge = new ThreeWayMergeView(one, two, preferencesService.getBibEntryPreferences(), preferencesService.getGuiPreferences()); + threeWayMerge = new ThreeWayMergeView(one, two, preferencesService.getBibEntryPreferences()); } case IMPORT_CHECK -> { first = new ButtonType(Localization.lang("Keep old entry"), ButtonData.LEFT); second = new ButtonType(Localization.lang("Keep from import"), ButtonData.LEFT); both = new ButtonType(Localization.lang("Keep both"), ButtonData.LEFT); threeWayMerge = new ThreeWayMergeView(one, two, Localization.lang("Old entry"), - Localization.lang("From import"), preferencesService.getBibEntryPreferences(), preferencesService.getGuiPreferences()); + Localization.lang("From import"), preferencesService.getBibEntryPreferences()); } default -> throw new IllegalStateException("Switch expression should be exhaustive"); } diff --git a/src/main/java/org/jabref/gui/maintable/RightClickMenu.java b/src/main/java/org/jabref/gui/maintable/RightClickMenu.java index 02ccc9a7322..31409e0ffc0 100644 --- a/src/main/java/org/jabref/gui/maintable/RightClickMenu.java +++ b/src/main/java/org/jabref/gui/maintable/RightClickMenu.java @@ -52,7 +52,7 @@ public static ContextMenu create(BibEntryTableViewModel entry, createCopySubMenu(factory, dialogService, stateManager, preferencesService, clipBoardManager, taskExecutor), factory.createMenuItem(StandardActions.PASTE, new EditAction(StandardActions.PASTE, libraryTab.frame(), stateManager)), factory.createMenuItem(StandardActions.CUT, new EditAction(StandardActions.CUT, libraryTab.frame(), stateManager)), - factory.createMenuItem(StandardActions.MERGE_ENTRIES, new MergeEntriesAction(dialogService, stateManager, preferencesService.getBibEntryPreferences(), preferencesService.getGuiPreferences())), + factory.createMenuItem(StandardActions.MERGE_ENTRIES, new MergeEntriesAction(dialogService, stateManager, preferencesService.getBibEntryPreferences())), factory.createMenuItem(StandardActions.DELETE_ENTRY, new EditAction(StandardActions.DELETE_ENTRY, libraryTab.frame(), stateManager)), new SeparatorMenuItem(), diff --git a/src/main/java/org/jabref/gui/mergeentries/FetchAndMergeEntry.java b/src/main/java/org/jabref/gui/mergeentries/FetchAndMergeEntry.java index f4cad2b9c91..83399cd4f7b 100644 --- a/src/main/java/org/jabref/gui/mergeentries/FetchAndMergeEntry.java +++ b/src/main/java/org/jabref/gui/mergeentries/FetchAndMergeEntry.java @@ -30,7 +30,6 @@ import org.jabref.model.entry.field.StandardField; import org.jabref.model.entry.types.EntryType; import org.jabref.preferences.BibEntryPreferences; -import org.jabref.preferences.GuiPreferences; import org.jabref.preferences.PreferencesService; import org.slf4j.Logger; @@ -78,7 +77,7 @@ public void fetchAndMerge(BibEntry entry, List fields) { String type = field.getDisplayName(); if (fetchedEntry.isPresent()) { cleanup.doPostCleanup(fetchedEntry.get()); - showMergeDialog(entry, fetchedEntry.get(), fetcher.get(), preferencesService.getBibEntryPreferences(), preferencesService.getGuiPreferences()); + showMergeDialog(entry, fetchedEntry.get(), fetcher.get(), preferencesService.getBibEntryPreferences()); } else { dialogService.notify(Localization.lang("Cannot get info based on given %0: %1", type, fieldContent.get())); } @@ -101,8 +100,8 @@ public void fetchAndMerge(BibEntry entry, List fields) { } } - private void showMergeDialog(BibEntry originalEntry, BibEntry fetchedEntry, WebFetcher fetcher, BibEntryPreferences bibEntryPreferences, GuiPreferences guiPreferences) { - MergeEntriesDialog dialog = new MergeEntriesDialog(originalEntry, fetchedEntry, bibEntryPreferences, guiPreferences); + private void showMergeDialog(BibEntry originalEntry, BibEntry fetchedEntry, WebFetcher fetcher, BibEntryPreferences bibEntryPreferences) { + MergeEntriesDialog dialog = new MergeEntriesDialog(originalEntry, fetchedEntry, bibEntryPreferences); dialog.setTitle(Localization.lang("Merge entry with %0 information", fetcher.getName())); dialog.setLeftHeaderText(Localization.lang("Original entry")); dialog.setRightHeaderText(Localization.lang("Entry from %0", fetcher.getName())); @@ -168,7 +167,7 @@ public void fetchAndMerge(BibEntry entry, EntryBasedFetcher fetcher) { if (fetchedEntry.isPresent()) { ImportCleanup cleanup = new ImportCleanup(libraryTab.getBibDatabaseContext().getMode()); cleanup.doPostCleanup(fetchedEntry.get()); - showMergeDialog(entry, fetchedEntry.get(), fetcher, preferencesService.getBibEntryPreferences(), preferencesService.getGuiPreferences()); + showMergeDialog(entry, fetchedEntry.get(), fetcher, preferencesService.getBibEntryPreferences()); } else { dialogService.notify(Localization.lang("Could not find any bibliographic information.")); } diff --git a/src/main/java/org/jabref/gui/mergeentries/MergeEntriesAction.java b/src/main/java/org/jabref/gui/mergeentries/MergeEntriesAction.java index f4d9ecc587b..d9d16636715 100644 --- a/src/main/java/org/jabref/gui/mergeentries/MergeEntriesAction.java +++ b/src/main/java/org/jabref/gui/mergeentries/MergeEntriesAction.java @@ -12,20 +12,17 @@ import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.field.InternalField; import org.jabref.preferences.BibEntryPreferences; -import org.jabref.preferences.GuiPreferences; public class MergeEntriesAction extends SimpleCommand { private static final int NUMBER_OF_ENTRIES_NEEDED = 2; private final DialogService dialogService; private final StateManager stateManager; private final BibEntryPreferences bibEntryPreferences; - private final GuiPreferences guiPreferences; - public MergeEntriesAction(DialogService dialogService, StateManager stateManager, BibEntryPreferences bibEntryPreferences, GuiPreferences guiPreferences) { + public MergeEntriesAction(DialogService dialogService, StateManager stateManager, BibEntryPreferences bibEntryPreferences) { this.dialogService = dialogService; this.stateManager = stateManager; this.bibEntryPreferences = bibEntryPreferences; - this.guiPreferences = guiPreferences; this.executable.bind(ActionHelper.needsEntriesSelected(NUMBER_OF_ENTRIES_NEEDED, stateManager)); } @@ -61,7 +58,7 @@ public void execute() { second = one; } - MergeEntriesDialog dialog = new MergeEntriesDialog(first, second, bibEntryPreferences, guiPreferences); + MergeEntriesDialog dialog = new MergeEntriesDialog(first, second, bibEntryPreferences); dialog.setTitle(Localization.lang("Merge entries")); Optional mergeResultOpt = dialogService.showCustomDialogAndWait(dialog); diff --git a/src/main/java/org/jabref/gui/mergeentries/MergeEntriesDialog.java b/src/main/java/org/jabref/gui/mergeentries/MergeEntriesDialog.java index abbd7d1ca8a..23a82a1ddde 100644 --- a/src/main/java/org/jabref/gui/mergeentries/MergeEntriesDialog.java +++ b/src/main/java/org/jabref/gui/mergeentries/MergeEntriesDialog.java @@ -9,15 +9,14 @@ import org.jabref.logic.l10n.Localization; import org.jabref.model.entry.BibEntry; import org.jabref.preferences.BibEntryPreferences; -import org.jabref.preferences.GuiPreferences; public class MergeEntriesDialog extends BaseDialog { private final ThreeWayMergeView threeWayMergeView; private final BibEntry one; private final BibEntry two; - public MergeEntriesDialog(BibEntry one, BibEntry two, BibEntryPreferences bibEntryPreferences, GuiPreferences guiPreferences) { - threeWayMergeView = new ThreeWayMergeView(one, two, bibEntryPreferences, guiPreferences); + public MergeEntriesDialog(BibEntry one, BibEntry two, BibEntryPreferences bibEntryPreferences) { + threeWayMergeView = new ThreeWayMergeView(one, two, bibEntryPreferences); this.one = one; this.two = two; diff --git a/src/main/java/org/jabref/gui/mergeentries/newmergedialog/ThreeWayMergeView.java b/src/main/java/org/jabref/gui/mergeentries/newmergedialog/ThreeWayMergeView.java index fd352757c02..2dd2acaaf1a 100644 --- a/src/main/java/org/jabref/gui/mergeentries/newmergedialog/ThreeWayMergeView.java +++ b/src/main/java/org/jabref/gui/mergeentries/newmergedialog/ThreeWayMergeView.java @@ -18,8 +18,6 @@ import org.jabref.model.entry.field.Field; import org.jabref.model.entry.field.FieldProperty; import org.jabref.preferences.BibEntryPreferences; -import org.jabref.preferences.GuiPreferences; -import org.jabref.preferences.PreferencesService; public class ThreeWayMergeView extends VBox { public static final int GRID_COLUMN_MIN_WIDTH = 250; @@ -42,7 +40,7 @@ public class ThreeWayMergeView extends VBox { private final FieldMergerFactory fieldMergerFactory; private final String keywordSeparator; - public ThreeWayMergeView(BibEntry leftEntry, BibEntry rightEntry, String leftHeader, String rightHeader, BibEntryPreferences bibEntryPreferences, GuiPreferences guiPreferences) { + public ThreeWayMergeView(BibEntry leftEntry, BibEntry rightEntry, String leftHeader, String rightHeader, BibEntryPreferences bibEntryPreferences) { getStylesheets().add(ThreeWayMergeView.class.getResource("ThreeWayMergeView.css").toExternalForm()); viewModel = new ThreeWayMergeViewModel((BibEntry) leftEntry.clone(), (BibEntry) rightEntry.clone(), leftHeader, rightHeader); this.fieldMergerFactory = new FieldMergerFactory(bibEntryPreferences); @@ -52,7 +50,7 @@ public ThreeWayMergeView(BibEntry leftEntry, BibEntry rightEntry, String leftHea scrollPane = new ScrollPane(); headerView = new ThreeWayMergeHeaderView(leftHeader, rightHeader); - toolbar = new ThreeWayMergeToolbar(guiPreferences); + toolbar = new ThreeWayMergeToolbar(); initializeColumnConstraints(); initializeMergeGridPane(); @@ -66,8 +64,8 @@ public ThreeWayMergeView(BibEntry leftEntry, BibEntry rightEntry, String leftHea getChildren().addAll(toolbar, headerView, scrollPane); } - public ThreeWayMergeView(BibEntry leftEntry, BibEntry rightEntry, BibEntryPreferences bibEntryPreferences, GuiPreferences guiPreferences) { - this(leftEntry, rightEntry, LEFT_DEFAULT_HEADER, RIGHT_DEFAULT_HEADER, bibEntryPreferences, guiPreferences); + public ThreeWayMergeView(BibEntry leftEntry, BibEntry rightEntry, BibEntryPreferences bibEntryPreferences) { + this(leftEntry, rightEntry, LEFT_DEFAULT_HEADER, RIGHT_DEFAULT_HEADER, bibEntryPreferences); } private void initializeToolbar() { diff --git a/src/main/java/org/jabref/gui/mergeentries/newmergedialog/toolbar/ThreeWayMergeToolbar.java b/src/main/java/org/jabref/gui/mergeentries/newmergedialog/toolbar/ThreeWayMergeToolbar.java index 4761be59dc9..7630f9aeadc 100644 --- a/src/main/java/org/jabref/gui/mergeentries/newmergedialog/toolbar/ThreeWayMergeToolbar.java +++ b/src/main/java/org/jabref/gui/mergeentries/newmergedialog/toolbar/ThreeWayMergeToolbar.java @@ -18,7 +18,6 @@ import org.jabref.gui.mergeentries.newmergedialog.DiffMethod; import org.jabref.gui.mergeentries.newmergedialog.diffhighlighter.DiffHighlighter.BasicDiffMethod; import org.jabref.logic.l10n.Localization; -import org.jabref.preferences.GuiPreferences; import org.jabref.preferences.PreferencesService; import com.airhacks.afterburner.views.ViewLoader; @@ -57,9 +56,8 @@ public class ThreeWayMergeToolbar extends AnchorPane { private final ObjectProperty diffHighlightingMethod = new SimpleObjectProperty<>(); private final BooleanProperty onlyShowChangedFields = new SimpleBooleanProperty(); private EasyBinding showDiff; - private GuiPreferences guiPreferences; - public ThreeWayMergeToolbar(GuiPreferences guiPreferences) { - this.guiPreferences = guiPreferences; + + public ThreeWayMergeToolbar() { ViewLoader.view(this) .root(this) .load(); @@ -69,10 +67,10 @@ public ThreeWayMergeToolbar(GuiPreferences guiPreferences) { public void initialize() { showDiff = EasyBind.map(plainTextOrDiffComboBox.valueProperty(), plainTextOrDiff -> plainTextOrDiff == PlainTextOrDiff.Diff); plainTextOrDiffComboBox.getItems().addAll(PlainTextOrDiff.values()); - plainTextOrDiffComboBox.getSelectionModel().select(PlainTextOrDiff.Diff); + plainTextOrDiffComboBox.getSelectionModel().select(preferencesService.getGuiPreferences().getMergePlainTextOrDiff()); plainTextOrDiffComboBox.getSelectionModel().selectedItemProperty().addListener((options, oldValue, newValue) -> { - System.out.println(newValue); + preferencesService.getGuiPreferences().setMergePlainTextOrDiff(newValue); }); plainTextOrDiffComboBox.setConverter(new StringConverter<>() { @@ -114,7 +112,7 @@ public DiffView fromString(String string) { })); diffHighlightingMethodToggleGroup.selectToggle(highlightWordsRadioButton); - plainTextOrDiffComboBox.valueProperty().set(PlainTextOrDiff.Diff); + plainTextOrDiffComboBox.valueProperty().set(preferencesService.getGuiPreferences().getMergePlainTextOrDiff()); onlyShowChangedFieldsCheck.selectedProperty().bindBidirectional(preferencesService.getGuiPreferences().mergeShowChangedFieldOnlyProperty()); onlyShowChangedFields.bind(onlyShowChangedFieldsCheck.selectedProperty()); diff --git a/src/main/java/org/jabref/gui/shared/SharedDatabaseUIManager.java b/src/main/java/org/jabref/gui/shared/SharedDatabaseUIManager.java index 8a5a2a27475..67593b9fbb5 100644 --- a/src/main/java/org/jabref/gui/shared/SharedDatabaseUIManager.java +++ b/src/main/java/org/jabref/gui/shared/SharedDatabaseUIManager.java @@ -96,7 +96,7 @@ public void listen(UpdateRefusedEvent updateRefusedEvent) { Optional response = dialogService.showCustomButtonDialogAndWait(AlertType.CONFIRMATION, Localization.lang("Update refused"), message, ButtonType.CANCEL, merge); if (response.isPresent() && response.get().equals(merge)) { - MergeEntriesDialog dialog = new MergeEntriesDialog(localBibEntry, sharedBibEntry, preferencesService.getBibEntryPreferences(), preferencesService.getGuiPreferences()); + MergeEntriesDialog dialog = new MergeEntriesDialog(localBibEntry, sharedBibEntry, preferencesService.getBibEntryPreferences()); dialog.setTitle(Localization.lang("Update refused")); Optional mergedEntry = dialogService.showCustomDialogAndWait(dialog).map(EntriesMergeResult::mergedEntry); From 1e52e7479b2e70ae7353b445246a5e8ecbabea50 Mon Sep 17 00:00:00 2001 From: dragos222 Date: Sun, 26 Mar 2023 20:00:16 +0200 Subject: [PATCH 34/77] Update jabrefPreferences and GuiPreferences for all mergeentries threewaytoolbar fields --- .../entrychange/EntryChangeResolver.java | 1 - .../gui/mergeentries/PlainTextOrDiff.java | 29 -------------- .../toolbar/ThreeWayMergeToolbar.java | 39 +++++++++++++++++-- .../jabref/preferences/GuiPreferences.java | 34 +++++++++++++++- .../jabref/preferences/JabRefPreferences.java | 11 +++++- 5 files changed, 79 insertions(+), 35 deletions(-) delete mode 100644 src/main/java/org/jabref/gui/mergeentries/PlainTextOrDiff.java diff --git a/src/main/java/org/jabref/gui/collab/entrychange/EntryChangeResolver.java b/src/main/java/org/jabref/gui/collab/entrychange/EntryChangeResolver.java index 6edc7592b33..8e5575f4196 100644 --- a/src/main/java/org/jabref/gui/collab/entrychange/EntryChangeResolver.java +++ b/src/main/java/org/jabref/gui/collab/entrychange/EntryChangeResolver.java @@ -13,7 +13,6 @@ import org.jabref.logic.l10n.Localization; import org.jabref.model.database.BibDatabaseContext; import org.jabref.preferences.BibEntryPreferences; -import org.jabref.preferences.GuiPreferences; public final class EntryChangeResolver extends DatabaseChangeResolver { private final EntryChange entryChange; diff --git a/src/main/java/org/jabref/gui/mergeentries/PlainTextOrDiff.java b/src/main/java/org/jabref/gui/mergeentries/PlainTextOrDiff.java deleted file mode 100644 index 7b9f47d2016..00000000000 --- a/src/main/java/org/jabref/gui/mergeentries/PlainTextOrDiff.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.jabref.gui.mergeentries; - -import org.jabref.logic.l10n.Localization; - -public enum PlainTextOrDiff { - PLAIN_TEXT(Localization.lang("Plain Text")), Diff(Localization.lang("Show Diff")); - - private final String value; - - PlainTextOrDiff(String value) { - this.value = value; - } - - public static PlainTextOrDiff parse(String name) { - try { - return PlainTextOrDiff.valueOf(name); - } catch (IllegalArgumentException e) { - return Diff; // default - } - } - - public String getValue() { - return value; - } - - public static PlainTextOrDiff fromString(String str) { - return Enum.valueOf(PlainTextOrDiff.class, str); - } -} diff --git a/src/main/java/org/jabref/gui/mergeentries/newmergedialog/toolbar/ThreeWayMergeToolbar.java b/src/main/java/org/jabref/gui/mergeentries/newmergedialog/toolbar/ThreeWayMergeToolbar.java index 7630f9aeadc..cbd89a4d363 100644 --- a/src/main/java/org/jabref/gui/mergeentries/newmergedialog/toolbar/ThreeWayMergeToolbar.java +++ b/src/main/java/org/jabref/gui/mergeentries/newmergedialog/toolbar/ThreeWayMergeToolbar.java @@ -14,7 +14,6 @@ import javafx.scene.layout.AnchorPane; import javafx.util.StringConverter; -import org.jabref.gui.mergeentries.PlainTextOrDiff; import org.jabref.gui.mergeentries.newmergedialog.DiffMethod; import org.jabref.gui.mergeentries.newmergedialog.diffhighlighter.DiffHighlighter.BasicDiffMethod; import org.jabref.logic.l10n.Localization; @@ -87,7 +86,7 @@ public PlainTextOrDiff fromString(String string) { diffViewComboBox.disableProperty().bind(notShowDiffProperty()); diffViewComboBox.getItems().addAll(DiffView.values()); - diffViewComboBox.getSelectionModel().select(DiffView.UNIFIED); + diffViewComboBox.getSelectionModel().select(preferencesService.getGuiPreferences().getMergeDiffView()); diffViewComboBox.setConverter(new StringConverter<>() { @Override public String toString(DiffView diffView) { @@ -111,7 +110,7 @@ public DiffView fromString(String string) { } })); - diffHighlightingMethodToggleGroup.selectToggle(highlightWordsRadioButton); + diffHighlightingMethodToggleGroup.selectToggle(preferencesService.getGuiPreferences().getMergeHighlightWords() ? highlightWordsRadioButton : highlightCharactersRadioButtons); plainTextOrDiffComboBox.valueProperty().set(preferencesService.getGuiPreferences().getMergePlainTextOrDiff()); onlyShowChangedFieldsCheck.selectedProperty().bindBidirectional(preferencesService.getGuiPreferences().mergeShowChangedFieldOnlyProperty()); @@ -182,6 +181,32 @@ public void setOnSelectRightEntryValuesButtonClicked(Runnable onClick) { selectRightEntryValuesButton.setOnMouseClicked(e -> onClick.run()); } + public enum PlainTextOrDiff { + PLAIN_TEXT(Localization.lang("Plain Text")), Diff(Localization.lang("Show Diff")); + + private final String value; + + PlainTextOrDiff(String value) { + this.value = value; + } + + public static PlainTextOrDiff parse(String name) { + try { + return PlainTextOrDiff.valueOf(name); + } catch (IllegalArgumentException e) { + return Diff; // default + } + } + + public String getValue() { + return value; + } + + public static PlainTextOrDiff fromString(String str) { + return Enum.valueOf(PlainTextOrDiff.class, str); + } + } + public enum DiffView { UNIFIED(Localization.lang("Unified View")), SPLIT(Localization.lang("Split View")); @@ -191,6 +216,14 @@ public enum DiffView { this.value = value; } + public static DiffView parse(String name) { + try { + return DiffView.valueOf(name); + } catch (IllegalArgumentException e) { + return UNIFIED; // default + } + } + public String getValue() { return value; } diff --git a/src/main/java/org/jabref/preferences/GuiPreferences.java b/src/main/java/org/jabref/preferences/GuiPreferences.java index 8c86e96f980..12a19a3f0a4 100644 --- a/src/main/java/org/jabref/preferences/GuiPreferences.java +++ b/src/main/java/org/jabref/preferences/GuiPreferences.java @@ -15,7 +15,8 @@ import javafx.collections.ObservableList; import org.jabref.gui.mergeentries.DiffMode; -import org.jabref.gui.mergeentries.PlainTextOrDiff; +import org.jabref.gui.mergeentries.newmergedialog.toolbar.ThreeWayMergeToolbar.DiffView; +import org.jabref.gui.mergeentries.newmergedialog.toolbar.ThreeWayMergeToolbar.PlainTextOrDiff; import org.jabref.logic.util.io.FileHistory; public class GuiPreferences { @@ -35,6 +36,8 @@ public class GuiPreferences { private final StringProperty lastSelectedIdBasedFetcher; private final ObjectProperty mergeDiffMode; private final ObjectProperty mergePlainTextOrDiff; + private final ObjectProperty mergeDiffView; + private final BooleanProperty mergeHighlightsWords; private final BooleanProperty mergeShowChangedFieldsOnly; private final DoubleProperty sidePaneWidth; @@ -50,6 +53,8 @@ public GuiPreferences(double positionX, String lastSelectedIdBasedFetcher, DiffMode mergeDiffMode, PlainTextOrDiff mergePlainTextOrDiff, + DiffView mergeDiffView, + boolean mergeHighlightsWords, double sidePaneWidth, boolean mergeShowChangedFieldsOnly) { this.positionX = new SimpleDoubleProperty(positionX); @@ -62,6 +67,9 @@ public GuiPreferences(double positionX, this.lastSelectedIdBasedFetcher = new SimpleStringProperty(lastSelectedIdBasedFetcher); this.mergeDiffMode = new SimpleObjectProperty<>(mergeDiffMode); this.mergePlainTextOrDiff = new SimpleObjectProperty<>(mergePlainTextOrDiff); + this.mergeDiffView = new SimpleObjectProperty<>(mergeDiffView); + this.mergeHighlightsWords = new SimpleBooleanProperty(mergeHighlightsWords); + this.sidePaneWidth = new SimpleDoubleProperty(sidePaneWidth); this.fileHistory = fileHistory; this.mergeShowChangedFieldsOnly = new SimpleBooleanProperty(mergeShowChangedFieldsOnly); @@ -187,6 +195,30 @@ public void setMergePlainTextOrDiff(PlainTextOrDiff mergePlainTextOrDiff) { this.mergePlainTextOrDiff.set(mergePlainTextOrDiff); } + public DiffView getMergeDiffView() { + return mergeDiffView.get(); + } + + public ObjectProperty mergeDiffViewProperty() { + return mergeDiffView; + } + + public void setMergeDiffMode(DiffView mergeDiffView) { + this.mergeDiffView.set(mergeDiffView); + } + + public boolean getMergeHighlightWords() { + return mergeHighlightsWords.get(); + } + + public BooleanProperty mergeHighlightWordsProperty() { + return mergeHighlightsWords; + } + + public void setMergeHighlightWords(boolean mergeHighlightsWords) { + this.mergeHighlightsWords.set(mergeHighlightsWords); + } + public double getSidePaneWidth() { return sidePaneWidth.get(); } diff --git a/src/main/java/org/jabref/preferences/JabRefPreferences.java b/src/main/java/org/jabref/preferences/JabRefPreferences.java index 62c140c204f..38da552700c 100644 --- a/src/main/java/org/jabref/preferences/JabRefPreferences.java +++ b/src/main/java/org/jabref/preferences/JabRefPreferences.java @@ -55,7 +55,8 @@ import org.jabref.gui.maintable.NameDisplayPreferences.AbbreviationStyle; import org.jabref.gui.maintable.NameDisplayPreferences.DisplayStyle; import org.jabref.gui.mergeentries.DiffMode; -import org.jabref.gui.mergeentries.PlainTextOrDiff; +import org.jabref.gui.mergeentries.newmergedialog.toolbar.ThreeWayMergeToolbar.DiffView; +import org.jabref.gui.mergeentries.newmergedialog.toolbar.ThreeWayMergeToolbar.PlainTextOrDiff; import org.jabref.gui.push.PushToApplications; import org.jabref.gui.search.SearchDisplayMode; import org.jabref.gui.sidepane.SidePaneType; @@ -240,6 +241,10 @@ public class JabRefPreferences implements PreferencesService { // merge related public static final String MERGE_ENTRIES_DIFF_MODE = "mergeEntriesDiffMode"; public static final String MERGE_ENTRIES_PLAIN_TEXT_OR_DIFF = "mergeEntriesPlainTextOrDiff"; + public static final String MERGE_ENTRIES_DIFF_VIEW = "mergeEntriesDiffView"; + public static final String MERGE_ENTRIES_HIGHLIGHT_WORDS = "mergeEntriesHighlightWords"; + public static final String MERGE_ENTRIES_HIGHLIGHT_ONLY_SHOW_CHANGED_FIELDS = "mergeEntriesOnlyShowChangedFields"; + public static final String MERGE_SHOW_ONLY_CHANGED_FIELDS = "mergeShowOnlyChangedFields"; @@ -588,6 +593,8 @@ private JabRefPreferences() { defaults.put(MERGE_ENTRIES_DIFF_MODE, DiffMode.WORD.name()); defaults.put(MERGE_ENTRIES_PLAIN_TEXT_OR_DIFF, PlainTextOrDiff.Diff.name()); + defaults.put(MERGE_ENTRIES_DIFF_VIEW, DiffView.UNIFIED.name()); + defaults.put(MERGE_ENTRIES_HIGHLIGHT_WORDS, Boolean.FALSE); defaults.put(MERGE_SHOW_ONLY_CHANGED_FIELDS, Boolean.FALSE); defaults.put(SHOW_RECOMMENDATIONS, Boolean.TRUE); @@ -2513,6 +2520,8 @@ public GuiPreferences getGuiPreferences() { get(ID_ENTRY_GENERATOR), DiffMode.parse(get(MERGE_ENTRIES_DIFF_MODE)), PlainTextOrDiff.parse(get(MERGE_ENTRIES_PLAIN_TEXT_OR_DIFF)), + DiffView.parse(get(MERGE_ENTRIES_DIFF_VIEW)), + getBoolean(MERGE_ENTRIES_HIGHLIGHT_WORDS), getDouble(SIDE_PANE_WIDTH), getBoolean(MERGE_SHOW_ONLY_CHANGED_FIELDS)); From 6a2222f578373445e51756c09de058383721ce11 Mon Sep 17 00:00:00 2001 From: dragos222 Date: Sun, 26 Mar 2023 20:45:03 +0200 Subject: [PATCH 35/77] Stop using record ShowDiffConfig; use preferences for diffViewComboBox --- .../gui/mergeentries/newmergedialog/ThreeWayMergeView.java | 3 --- .../newmergedialog/toolbar/ThreeWayMergeToolbar.java | 5 +++++ src/main/java/org/jabref/preferences/GuiPreferences.java | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/jabref/gui/mergeentries/newmergedialog/ThreeWayMergeView.java b/src/main/java/org/jabref/gui/mergeentries/newmergedialog/ThreeWayMergeView.java index 2dd2acaaf1a..7822fbb47c2 100644 --- a/src/main/java/org/jabref/gui/mergeentries/newmergedialog/ThreeWayMergeView.java +++ b/src/main/java/org/jabref/gui/mergeentries/newmergedialog/ThreeWayMergeView.java @@ -180,9 +180,6 @@ public void selectRightEntryValues() { } public void showDiff(ShowDiffConfig diffConfig) { - toolbar.setDiffView(diffConfig.diffView()); - toolbar.setDiffHighlightingMethod(diffConfig.diffHighlightingMethod()); - toolbar.setShowDiff(true); } public BibEntry getLeftEntry() { diff --git a/src/main/java/org/jabref/gui/mergeentries/newmergedialog/toolbar/ThreeWayMergeToolbar.java b/src/main/java/org/jabref/gui/mergeentries/newmergedialog/toolbar/ThreeWayMergeToolbar.java index cbd89a4d363..4037dd7e8e5 100644 --- a/src/main/java/org/jabref/gui/mergeentries/newmergedialog/toolbar/ThreeWayMergeToolbar.java +++ b/src/main/java/org/jabref/gui/mergeentries/newmergedialog/toolbar/ThreeWayMergeToolbar.java @@ -87,6 +87,9 @@ public PlainTextOrDiff fromString(String string) { diffViewComboBox.disableProperty().bind(notShowDiffProperty()); diffViewComboBox.getItems().addAll(DiffView.values()); diffViewComboBox.getSelectionModel().select(preferencesService.getGuiPreferences().getMergeDiffView()); + diffViewComboBox.getSelectionModel().selectedItemProperty().addListener((options, oldValue, newValue) -> { + preferencesService.getGuiPreferences().setMergeDiffView(newValue); + }); diffViewComboBox.setConverter(new StringConverter<>() { @Override public String toString(DiffView diffView) { @@ -99,6 +102,8 @@ public DiffView fromString(String string) { } }); + setDiffView(preferencesService.getGuiPreferences().getMergeDiffView()); + highlightWordsRadioButton.disableProperty().bind(notShowDiffProperty()); highlightCharactersRadioButtons.disableProperty().bind(notShowDiffProperty()); diff --git a/src/main/java/org/jabref/preferences/GuiPreferences.java b/src/main/java/org/jabref/preferences/GuiPreferences.java index 12a19a3f0a4..39122980d56 100644 --- a/src/main/java/org/jabref/preferences/GuiPreferences.java +++ b/src/main/java/org/jabref/preferences/GuiPreferences.java @@ -203,7 +203,7 @@ public ObjectProperty mergeDiffViewProperty() { return mergeDiffView; } - public void setMergeDiffMode(DiffView mergeDiffView) { + public void setMergeDiffView(DiffView mergeDiffView) { this.mergeDiffView.set(mergeDiffView); } From 9bda40bdaa69ed7fd42379641cb57955c711bd30 Mon Sep 17 00:00:00 2001 From: dragos222 Date: Sun, 26 Mar 2023 20:53:21 +0200 Subject: [PATCH 36/77] Remove redundant call functions; add easybind listener to guipreferences diff view --- .../jabref/gui/collab/entrychange/EntryChangeResolver.java | 4 ---- .../java/org/jabref/gui/mergeentries/MergeEntriesDialog.java | 5 ----- .../gui/mergeentries/newmergedialog/ThreeWayMergeView.java | 3 --- .../newmergedialog/toolbar/ThreeWayMergeToolbar.java | 1 + src/main/java/org/jabref/preferences/JabRefPreferences.java | 1 + 5 files changed, 2 insertions(+), 12 deletions(-) diff --git a/src/main/java/org/jabref/gui/collab/entrychange/EntryChangeResolver.java b/src/main/java/org/jabref/gui/collab/entrychange/EntryChangeResolver.java index 8e5575f4196..dc296db80a1 100644 --- a/src/main/java/org/jabref/gui/collab/entrychange/EntryChangeResolver.java +++ b/src/main/java/org/jabref/gui/collab/entrychange/EntryChangeResolver.java @@ -7,9 +7,6 @@ import org.jabref.gui.collab.DatabaseChangeResolver; import org.jabref.gui.mergeentries.EntriesMergeResult; import org.jabref.gui.mergeentries.MergeEntriesDialog; -import org.jabref.gui.mergeentries.newmergedialog.ShowDiffConfig; -import org.jabref.gui.mergeentries.newmergedialog.diffhighlighter.DiffHighlighter.BasicDiffMethod; -import org.jabref.gui.mergeentries.newmergedialog.toolbar.ThreeWayMergeToolbar; import org.jabref.logic.l10n.Localization; import org.jabref.model.database.BibDatabaseContext; import org.jabref.preferences.BibEntryPreferences; @@ -32,7 +29,6 @@ public Optional askUserToResolveChange() { MergeEntriesDialog mergeEntriesDialog = new MergeEntriesDialog(entryChange.getOldEntry(), entryChange.getNewEntry(), bibEntryPreferences); mergeEntriesDialog.setLeftHeaderText(Localization.lang("In JabRef")); mergeEntriesDialog.setRightHeaderText(Localization.lang("On disk")); - mergeEntriesDialog.configureDiff(new ShowDiffConfig(ThreeWayMergeToolbar.DiffView.SPLIT, BasicDiffMethod.WORDS)); return dialogService.showCustomDialogAndWait(mergeEntriesDialog) .map(this::mapMergeResultToExternalChange); diff --git a/src/main/java/org/jabref/gui/mergeentries/MergeEntriesDialog.java b/src/main/java/org/jabref/gui/mergeentries/MergeEntriesDialog.java index 23a82a1ddde..51ecd10b5a8 100644 --- a/src/main/java/org/jabref/gui/mergeentries/MergeEntriesDialog.java +++ b/src/main/java/org/jabref/gui/mergeentries/MergeEntriesDialog.java @@ -3,7 +3,6 @@ import javafx.scene.control.ButtonBar; import javafx.scene.control.ButtonType; -import org.jabref.gui.mergeentries.newmergedialog.ShowDiffConfig; import org.jabref.gui.mergeentries.newmergedialog.ThreeWayMergeView; import org.jabref.gui.util.BaseDialog; import org.jabref.logic.l10n.Localization; @@ -51,8 +50,4 @@ public void setLeftHeaderText(String leftHeaderText) { public void setRightHeaderText(String rightHeaderText) { threeWayMergeView.setRightHeader(rightHeaderText); } - - public void configureDiff(ShowDiffConfig diffConfig) { - threeWayMergeView.showDiff(diffConfig); - } } diff --git a/src/main/java/org/jabref/gui/mergeentries/newmergedialog/ThreeWayMergeView.java b/src/main/java/org/jabref/gui/mergeentries/newmergedialog/ThreeWayMergeView.java index 7822fbb47c2..576d11954d2 100644 --- a/src/main/java/org/jabref/gui/mergeentries/newmergedialog/ThreeWayMergeView.java +++ b/src/main/java/org/jabref/gui/mergeentries/newmergedialog/ThreeWayMergeView.java @@ -179,9 +179,6 @@ public void selectRightEntryValues() { fieldRows.forEach(FieldRowView::selectRightValue); } - public void showDiff(ShowDiffConfig diffConfig) { - } - public BibEntry getLeftEntry() { return viewModel.getLeftEntry(); } diff --git a/src/main/java/org/jabref/gui/mergeentries/newmergedialog/toolbar/ThreeWayMergeToolbar.java b/src/main/java/org/jabref/gui/mergeentries/newmergedialog/toolbar/ThreeWayMergeToolbar.java index 4037dd7e8e5..fa6564cae4c 100644 --- a/src/main/java/org/jabref/gui/mergeentries/newmergedialog/toolbar/ThreeWayMergeToolbar.java +++ b/src/main/java/org/jabref/gui/mergeentries/newmergedialog/toolbar/ThreeWayMergeToolbar.java @@ -117,6 +117,7 @@ public DiffView fromString(String string) { diffHighlightingMethodToggleGroup.selectToggle(preferencesService.getGuiPreferences().getMergeHighlightWords() ? highlightWordsRadioButton : highlightCharactersRadioButtons); plainTextOrDiffComboBox.valueProperty().set(preferencesService.getGuiPreferences().getMergePlainTextOrDiff()); + diffViewComboBox.valueProperty().set(preferencesService.getGuiPreferences().getMergeDiffView()); onlyShowChangedFieldsCheck.selectedProperty().bindBidirectional(preferencesService.getGuiPreferences().mergeShowChangedFieldOnlyProperty()); onlyShowChangedFields.bind(onlyShowChangedFieldsCheck.selectedProperty()); diff --git a/src/main/java/org/jabref/preferences/JabRefPreferences.java b/src/main/java/org/jabref/preferences/JabRefPreferences.java index 38da552700c..d17d84479b7 100644 --- a/src/main/java/org/jabref/preferences/JabRefPreferences.java +++ b/src/main/java/org/jabref/preferences/JabRefPreferences.java @@ -2548,6 +2548,7 @@ public GuiPreferences getGuiPreferences() { EasyBind.listen(guiPreferences.lastSelectedIdBasedFetcherProperty(), (obs, oldValue, newValue) -> put(ID_ENTRY_GENERATOR, newValue)); EasyBind.listen(guiPreferences.mergeDiffModeProperty(), (obs, oldValue, newValue) -> put(MERGE_ENTRIES_DIFF_MODE, newValue.name())); EasyBind.listen(guiPreferences.mergePlainTextOrDiffProperty(), (obs, oldValue, newValue) -> put(MERGE_ENTRIES_PLAIN_TEXT_OR_DIFF, newValue.name())); + EasyBind.listen(guiPreferences.mergeDiffViewProperty(), (obs, oldValue, newValue) -> put(MERGE_ENTRIES_DIFF_VIEW, newValue.name())); EasyBind.listen(guiPreferences.sidePaneWidthProperty(), (obs, oldValue, newValue) -> putDouble(SIDE_PANE_WIDTH, newValue.doubleValue())); EasyBind.listen(guiPreferences.mergeShowChangedFieldOnlyProperty(), (obs, oldValue, newValue) -> putBoolean(MERGE_SHOW_ONLY_CHANGED_FIELDS, newValue)); From a137fe46d7e70d4185996f9de6a3011003377b39 Mon Sep 17 00:00:00 2001 From: dragos222 Date: Sun, 26 Mar 2023 21:47:53 +0200 Subject: [PATCH 37/77] Default value for highlight words TRUE; set the values for highlight word preference in listener method --- .../newmergedialog/toolbar/ThreeWayMergeToolbar.java | 3 +++ src/main/java/org/jabref/preferences/JabRefPreferences.java | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/jabref/gui/mergeentries/newmergedialog/toolbar/ThreeWayMergeToolbar.java b/src/main/java/org/jabref/gui/mergeentries/newmergedialog/toolbar/ThreeWayMergeToolbar.java index fa6564cae4c..a2b99c52159 100644 --- a/src/main/java/org/jabref/gui/mergeentries/newmergedialog/toolbar/ThreeWayMergeToolbar.java +++ b/src/main/java/org/jabref/gui/mergeentries/newmergedialog/toolbar/ThreeWayMergeToolbar.java @@ -110,11 +110,14 @@ public DiffView fromString(String string) { diffHighlightingMethodToggleGroup.selectedToggleProperty().addListener((observable -> { if (diffHighlightingMethodToggleGroup.getSelectedToggle().equals(highlightCharactersRadioButtons)) { diffHighlightingMethod.set(BasicDiffMethod.CHARS); + preferencesService.getGuiPreferences().setMergeHighlightWords(false); } else { diffHighlightingMethod.set(BasicDiffMethod.WORDS); + preferencesService.getGuiPreferences().setMergeHighlightWords(true); } })); + System.out.println(preferencesService.getGuiPreferences().getMergeHighlightWords()); diffHighlightingMethodToggleGroup.selectToggle(preferencesService.getGuiPreferences().getMergeHighlightWords() ? highlightWordsRadioButton : highlightCharactersRadioButtons); plainTextOrDiffComboBox.valueProperty().set(preferencesService.getGuiPreferences().getMergePlainTextOrDiff()); diffViewComboBox.valueProperty().set(preferencesService.getGuiPreferences().getMergeDiffView()); diff --git a/src/main/java/org/jabref/preferences/JabRefPreferences.java b/src/main/java/org/jabref/preferences/JabRefPreferences.java index d17d84479b7..5ee2bc47317 100644 --- a/src/main/java/org/jabref/preferences/JabRefPreferences.java +++ b/src/main/java/org/jabref/preferences/JabRefPreferences.java @@ -594,7 +594,7 @@ private JabRefPreferences() { defaults.put(MERGE_ENTRIES_DIFF_MODE, DiffMode.WORD.name()); defaults.put(MERGE_ENTRIES_PLAIN_TEXT_OR_DIFF, PlainTextOrDiff.Diff.name()); defaults.put(MERGE_ENTRIES_DIFF_VIEW, DiffView.UNIFIED.name()); - defaults.put(MERGE_ENTRIES_HIGHLIGHT_WORDS, Boolean.FALSE); + defaults.put(MERGE_ENTRIES_HIGHLIGHT_WORDS, Boolean.TRUE); defaults.put(MERGE_SHOW_ONLY_CHANGED_FIELDS, Boolean.FALSE); defaults.put(SHOW_RECOMMENDATIONS, Boolean.TRUE); @@ -2549,6 +2549,7 @@ public GuiPreferences getGuiPreferences() { EasyBind.listen(guiPreferences.mergeDiffModeProperty(), (obs, oldValue, newValue) -> put(MERGE_ENTRIES_DIFF_MODE, newValue.name())); EasyBind.listen(guiPreferences.mergePlainTextOrDiffProperty(), (obs, oldValue, newValue) -> put(MERGE_ENTRIES_PLAIN_TEXT_OR_DIFF, newValue.name())); EasyBind.listen(guiPreferences.mergeDiffViewProperty(), (obs, oldValue, newValue) -> put(MERGE_ENTRIES_DIFF_VIEW, newValue.name())); + EasyBind.listen(guiPreferences.mergeHighlightWordsProperty(), (obs, oldValue, newValue) -> putBoolean(MERGE_ENTRIES_HIGHLIGHT_WORDS, newValue)); EasyBind.listen(guiPreferences.sidePaneWidthProperty(), (obs, oldValue, newValue) -> putDouble(SIDE_PANE_WIDTH, newValue.doubleValue())); EasyBind.listen(guiPreferences.mergeShowChangedFieldOnlyProperty(), (obs, oldValue, newValue) -> putBoolean(MERGE_SHOW_ONLY_CHANGED_FIELDS, newValue)); From 8722fa1a89255a375112c1cd4f9b609265345d50 Mon Sep 17 00:00:00 2001 From: dragos222 Date: Sun, 26 Mar 2023 21:54:32 +0200 Subject: [PATCH 38/77] Remove redundant method & method call; remove unused var --- .../newmergedialog/toolbar/ThreeWayMergeToolbar.java | 7 ------- .../java/org/jabref/preferences/JabRefPreferences.java | 1 - 2 files changed, 8 deletions(-) diff --git a/src/main/java/org/jabref/gui/mergeentries/newmergedialog/toolbar/ThreeWayMergeToolbar.java b/src/main/java/org/jabref/gui/mergeentries/newmergedialog/toolbar/ThreeWayMergeToolbar.java index a2b99c52159..84bdb72d237 100644 --- a/src/main/java/org/jabref/gui/mergeentries/newmergedialog/toolbar/ThreeWayMergeToolbar.java +++ b/src/main/java/org/jabref/gui/mergeentries/newmergedialog/toolbar/ThreeWayMergeToolbar.java @@ -102,8 +102,6 @@ public DiffView fromString(String string) { } }); - setDiffView(preferencesService.getGuiPreferences().getMergeDiffView()); - highlightWordsRadioButton.disableProperty().bind(notShowDiffProperty()); highlightCharactersRadioButtons.disableProperty().bind(notShowDiffProperty()); @@ -117,7 +115,6 @@ public DiffView fromString(String string) { } })); - System.out.println(preferencesService.getGuiPreferences().getMergeHighlightWords()); diffHighlightingMethodToggleGroup.selectToggle(preferencesService.getGuiPreferences().getMergeHighlightWords() ? highlightWordsRadioButton : highlightCharactersRadioButtons); plainTextOrDiffComboBox.valueProperty().set(preferencesService.getGuiPreferences().getMergePlainTextOrDiff()); diffViewComboBox.valueProperty().set(preferencesService.getGuiPreferences().getMergeDiffView()); @@ -134,10 +131,6 @@ public DiffView getDiffView() { return diffViewProperty().get(); } - public void setDiffView(DiffView diffView) { - diffViewProperty().set(diffView); - } - public EasyBinding showDiffProperty() { return showDiff; } diff --git a/src/main/java/org/jabref/preferences/JabRefPreferences.java b/src/main/java/org/jabref/preferences/JabRefPreferences.java index 5ee2bc47317..c2467c98ea2 100644 --- a/src/main/java/org/jabref/preferences/JabRefPreferences.java +++ b/src/main/java/org/jabref/preferences/JabRefPreferences.java @@ -243,7 +243,6 @@ public class JabRefPreferences implements PreferencesService { public static final String MERGE_ENTRIES_PLAIN_TEXT_OR_DIFF = "mergeEntriesPlainTextOrDiff"; public static final String MERGE_ENTRIES_DIFF_VIEW = "mergeEntriesDiffView"; public static final String MERGE_ENTRIES_HIGHLIGHT_WORDS = "mergeEntriesHighlightWords"; - public static final String MERGE_ENTRIES_HIGHLIGHT_ONLY_SHOW_CHANGED_FIELDS = "mergeEntriesOnlyShowChangedFields"; public static final String MERGE_SHOW_ONLY_CHANGED_FIELDS = "mergeShowOnlyChangedFields"; From 29f77383313499bff4ba7c1b2e7610fe123292c4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 27 Mar 2023 14:07:59 +0000 Subject: [PATCH 39/77] Bump com.puppycrawl.tools:checkstyle from 10.8.1 to 10.9.3 Bumps [com.puppycrawl.tools:checkstyle](https://github.com/checkstyle/checkstyle) from 10.8.1 to 10.9.3. - [Release notes](https://github.com/checkstyle/checkstyle/releases) - [Commits](https://github.com/checkstyle/checkstyle/compare/checkstyle-10.8.1...checkstyle-10.9.3) --- updated-dependencies: - dependency-name: com.puppycrawl.tools:checkstyle dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index f85f9cf69f1..cbb3671bfeb 100644 --- a/build.gradle +++ b/build.gradle @@ -216,7 +216,7 @@ dependencies { testImplementation "org.testfx:testfx-junit5:4.0.16-alpha" testImplementation "org.hamcrest:hamcrest-library:2.2" - checkstyle 'com.puppycrawl.tools:checkstyle:10.8.1' + checkstyle 'com.puppycrawl.tools:checkstyle:10.9.3' // xjc needs the runtime as well for the ant task, otherwise it fails xjc group: 'org.glassfish.jaxb', name: 'jaxb-xjc', version: '3.0.2' xjc group: 'org.glassfish.jaxb', name: 'jaxb-runtime', version: '3.0.2' From 9f1c3082656dbd99e44f89d4d158ff3b51651ce6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 27 Mar 2023 14:08:14 +0000 Subject: [PATCH 40/77] Bump org.tinylog:tinylog-impl from 2.6.0 to 2.6.1 Bumps [org.tinylog:tinylog-impl](https://github.com/tinylog-org/tinylog) from 2.6.0 to 2.6.1. - [Release notes](https://github.com/tinylog-org/tinylog/releases) - [Changelog](https://github.com/tinylog-org/tinylog/blob/v2.7/release.md) - [Commits](https://github.com/tinylog-org/tinylog/compare/2.6.0...2.6.1) --- updated-dependencies: - dependency-name: org.tinylog:tinylog-impl dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index f85f9cf69f1..e38692c6612 100644 --- a/build.gradle +++ b/build.gradle @@ -180,7 +180,7 @@ dependencies { implementation 'org.slf4j:slf4j-api:2.0.7' implementation "org.tinylog:tinylog-api:2.6.1" implementation "org.tinylog:slf4j-tinylog:2.6.1" - implementation "org.tinylog:tinylog-impl:2.6.0" + implementation "org.tinylog:tinylog-impl:2.6.1" implementation 'de.undercouch:citeproc-java:3.0.0-alpha.6' From 20080ddca4b73b46897dfe002ad8c83566060467 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 27 Mar 2023 14:08:53 +0000 Subject: [PATCH 41/77] Bump org.libreoffice:libreoffice from 7.5.0 to 7.5.1 Bumps org.libreoffice:libreoffice from 7.5.0 to 7.5.1. --- updated-dependencies: - dependency-name: org.libreoffice:libreoffice dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index f85f9cf69f1..2b1b132d326 100644 --- a/build.gradle +++ b/build.gradle @@ -131,8 +131,8 @@ dependencies { implementation 'commons-cli:commons-cli:1.5.0' - implementation 'org.libreoffice:unoloader:7.5.0' - implementation 'org.libreoffice:libreoffice:7.5.0' + implementation 'org.libreoffice:unoloader:7.5.1' + implementation 'org.libreoffice:libreoffice:7.5.1' implementation 'io.github.java-diff-utils:java-diff-utils:4.12' implementation 'info.debatty:java-string-similarity:2.0.0' From e9f65fdb6ccee31574e972b1560c01cdd66dc7d2 Mon Sep 17 00:00:00 2001 From: Siedlerchr Date: Mon, 27 Mar 2023 17:25:22 +0200 Subject: [PATCH 42/77] Fix updating of group numbers Fixes #9708 --- .../org/jabref/gui/groups/GroupTreeView.java | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/main/java/org/jabref/gui/groups/GroupTreeView.java b/src/main/java/org/jabref/gui/groups/GroupTreeView.java index ebfaa7d0b69..eda4cca37d4 100644 --- a/src/main/java/org/jabref/gui/groups/GroupTreeView.java +++ b/src/main/java/org/jabref/gui/groups/GroupTreeView.java @@ -215,22 +215,11 @@ private void initialize() { } if (newValue) { - text.textProperty().bind(group.getHits().asString()); + text.textProperty().bind(group.getHits().map(Number::intValue).map(this::getFormattedNumber)); } }); text.getStyleClass().setAll("text"); - text.textProperty().bind(Bindings.createStringBinding(() -> { - int hits = group.getHits().get(); - if (hits >= 1000000) { - double millions = hits / 1000000.0; - return new DecimalFormat("#,##0.#").format(millions) + "m"; - } else if (hits >= 1000) { - double thousands = hits / 1000.0; - return new DecimalFormat("#,##0.#").format(thousands) + "k"; - } else { - return Integer.toString(hits); - } - }, group.getHits())); + text.styleProperty().bind(Bindings.createStringBinding(() -> { double reducedFontSize; @@ -528,6 +517,17 @@ private void addNewGroup() { viewModel.addNewGroupToRoot(); } + private String getFormattedNumber(int hits) { + if (hits >= 1000000) { + double millions = hits / 1000000.0; + return new DecimalFormat("#,##0.#").format(millions) + "m"; + } else if (hits >= 1000) { + double thousands = hits / 1000.0; + return new DecimalFormat("#,##0.#").format(thousands) + "k"; + } + return Integer.toString(hits); + } + /** * Workaround taken from https://github.com/controlsfx/controlsfx/issues/330 */ @@ -565,4 +565,5 @@ public void expandGroup(TreeItem treeItem) { } } } + } From 12f09d1b7d01c55d21d0c506b6ec500a5ebedc99 Mon Sep 17 00:00:00 2001 From: Siedlerchr Date: Mon, 27 Mar 2023 17:27:27 +0200 Subject: [PATCH 43/77] checkstyle --- src/main/java/org/jabref/gui/groups/GroupTreeView.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/org/jabref/gui/groups/GroupTreeView.java b/src/main/java/org/jabref/gui/groups/GroupTreeView.java index eda4cca37d4..27aa3346490 100644 --- a/src/main/java/org/jabref/gui/groups/GroupTreeView.java +++ b/src/main/java/org/jabref/gui/groups/GroupTreeView.java @@ -220,7 +220,6 @@ private void initialize() { }); text.getStyleClass().setAll("text"); - text.styleProperty().bind(Bindings.createStringBinding(() -> { double reducedFontSize; double font_size = preferencesService.getAppearancePreferences().getMainFontSize(); From 8e605966d74f9f9f73bab05be2b8b4efb0d38742 Mon Sep 17 00:00:00 2001 From: Siedlerchr Date: Mon, 27 Mar 2023 17:34:45 +0200 Subject: [PATCH 44/77] fix checkstyle --- src/main/java/org/jabref/gui/groups/GroupTreeView.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/org/jabref/gui/groups/GroupTreeView.java b/src/main/java/org/jabref/gui/groups/GroupTreeView.java index 27aa3346490..9cc3ce11d27 100644 --- a/src/main/java/org/jabref/gui/groups/GroupTreeView.java +++ b/src/main/java/org/jabref/gui/groups/GroupTreeView.java @@ -564,5 +564,4 @@ public void expandGroup(TreeItem treeItem) { } } } - } From ce915a2305986405cc2582d5fad5eefa61bf2172 Mon Sep 17 00:00:00 2001 From: hiddevanesch Date: Tue, 28 Mar 2023 16:11:04 +0200 Subject: [PATCH 45/77] Created DeleteFileAction class + changed the call in LinkedFilesEditor to use the new DeleteFileAction class Co-Authored-By: FlorisPex <64036156+FlorisPex@users.noreply.github.com> --- .../gui/fieldeditors/LinkedFilesEditor.java | 8 +- .../gui/linkedfile/DeleteFileAction.java | 136 ++++++++++++++++++ 2 files changed, 139 insertions(+), 5 deletions(-) create mode 100644 src/main/java/org/jabref/gui/linkedfile/DeleteFileAction.java diff --git a/src/main/java/org/jabref/gui/fieldeditors/LinkedFilesEditor.java b/src/main/java/org/jabref/gui/fieldeditors/LinkedFilesEditor.java index e93c3952858..b59d1a3164d 100644 --- a/src/main/java/org/jabref/gui/fieldeditors/LinkedFilesEditor.java +++ b/src/main/java/org/jabref/gui/fieldeditors/LinkedFilesEditor.java @@ -1,6 +1,5 @@ package org.jabref.gui.fieldeditors; -import java.util.List; import java.util.Optional; import javafx.beans.binding.Bindings; @@ -41,6 +40,7 @@ import org.jabref.gui.icon.IconTheme; import org.jabref.gui.importer.GrobidOptInDialogHelper; import org.jabref.gui.keyboard.KeyBinding; +import org.jabref.gui.linkedfile.DeleteFileAction; import org.jabref.gui.util.BindingsHelper; import org.jabref.gui.util.TaskExecutor; import org.jabref.gui.util.ViewModelListCellFactory; @@ -218,10 +218,8 @@ private void setUpKeyBindings() { if (keyBinding.isPresent()) { switch (keyBinding.get()) { case DELETE_ENTRY: - List toBeDeleted = List.copyOf(listView.getSelectionModel().getSelectedItems()); - for (LinkedFileViewModel selectedItem : toBeDeleted) { - viewModel.deleteFile(selectedItem); - } + new DeleteFileAction(dialogService, preferencesService, databaseContext, + viewModel, listView).execute(); event.consume(); break; default: diff --git a/src/main/java/org/jabref/gui/linkedfile/DeleteFileAction.java b/src/main/java/org/jabref/gui/linkedfile/DeleteFileAction.java new file mode 100644 index 00000000000..d925a713f48 --- /dev/null +++ b/src/main/java/org/jabref/gui/linkedfile/DeleteFileAction.java @@ -0,0 +1,136 @@ +package org.jabref.gui.linkedfile; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.List; +import java.util.Optional; + +import javafx.scene.control.Alert; +import javafx.scene.control.ButtonBar; +import javafx.scene.control.ButtonType; +import javafx.scene.control.ListView; + +import org.jabref.gui.DialogService; +import org.jabref.gui.actions.SimpleCommand; +import org.jabref.gui.fieldeditors.LinkedFileViewModel; +import org.jabref.gui.fieldeditors.LinkedFilesEditorViewModel; +import org.jabref.logic.l10n.Localization; +import org.jabref.model.database.BibDatabaseContext; +import org.jabref.model.entry.LinkedFile; +import org.jabref.preferences.PreferencesService; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class DeleteFileAction extends SimpleCommand { + + private static final Logger LOGGER = LoggerFactory.getLogger(DeleteFileAction.class); + + private final DialogService dialogService; + private final PreferencesService preferences; + private final BibDatabaseContext databaseContext; + private final LinkedFilesEditorViewModel viewModel; + private final ListView listView; + + public DeleteFileAction(DialogService dialogService, + PreferencesService preferences, + BibDatabaseContext databaseContext, + LinkedFilesEditorViewModel viewModel, + ListView listView) { + this.dialogService = dialogService; + this.preferences = preferences; + this.databaseContext = databaseContext; + this.viewModel = viewModel; + this.listView = listView; + } + + @Override + public void execute() { + List toBeDeleted = List.copyOf(listView.getSelectionModel().getSelectedItems()); + + if (toBeDeleted.isEmpty()) { + dialogService.notify(Localization.lang("This operation requires selected linked files.")); + return; + } + + String dialogTitle; + String dialogContent; + + if (toBeDeleted.size() != 1) { + dialogTitle = Localization.lang("Delete %0 files", toBeDeleted.size()); + dialogContent = Localization.lang("Delete %0 files permanently from disk, or just remove the files from the entry? " + + "Pressing Delete will delete the files permanently from disk.", toBeDeleted.size()); + } else { + Optional file = toBeDeleted.get(0).getFile().findIn(databaseContext, preferences.getFilePreferences()); + + if (file.isPresent()) { + dialogTitle = Localization.lang("Delete '%0'", file.get().getFileName().toString()); + dialogContent = Localization.lang("Delete '%0' permanently from disk, or just remove the file from the entry? " + + "Pressing Delete will delete the file permanently from disk.", file.get().toString()); + } else { + dialogService.notify(Localization.lang("Error accessing file '%0'.", toBeDeleted.get(0).getFile().getLink())); + return; + } + } + + ButtonType removeFromEntry = new ButtonType(Localization.lang("Remove from entry"), ButtonBar.ButtonData.YES); + ButtonType deleteFromEntry = new ButtonType(Localization.lang("Delete from disk")); + Optional buttonType = dialogService.showCustomButtonDialogAndWait(Alert.AlertType.INFORMATION, + dialogTitle, dialogContent, removeFromEntry, deleteFromEntry, ButtonType.CANCEL); + + if (buttonType.isPresent()) { + if (buttonType.get().equals(removeFromEntry)) { + deleteFiles(toBeDeleted, false); + } + + if (buttonType.get().equals(deleteFromEntry)) { + deleteFiles(toBeDeleted, true); + } + } + } + + /** + * Deletes the files from the entry and optionally from disk. + * + * @param toBeDeleted the files to be deleted + * @param deleteFromDisk if true, the files are deleted from disk, otherwise they are only removed from the entry + */ + private void deleteFiles(List toBeDeleted, boolean deleteFromDisk) { + for (LinkedFileViewModel fileViewModel : toBeDeleted) { + if (fileViewModel.getFile().isOnlineLink()) { + viewModel.removeFileLink(fileViewModel); + } else { + if (deleteFromDisk) { + deleteFileFromDisk(fileViewModel); + } + viewModel.getFiles().remove(fileViewModel); + } + } + } + + /** + * Deletes the file from disk without asking the user for confirmation. + * + * @param fileViewModel the file to be deleted + */ + public void deleteFileFromDisk(LinkedFileViewModel fileViewModel) { + LinkedFile linkedFile = fileViewModel.getFile(); + + Optional file = linkedFile.findIn(databaseContext, preferences.getFilePreferences()); + + if (file.isEmpty()) { + LOGGER.warn("Could not find file " + linkedFile.getLink()); + } + + if (file.isPresent()) { + try { + Files.delete(file.get()); + } catch ( + IOException ex) { + dialogService.showErrorDialogAndWait(Localization.lang("Cannot delete file"), Localization.lang("File permission error")); + LOGGER.warn("File permission error while deleting: " + linkedFile, ex); + } + } + } +} From 821a720540647c47b7d6b8c1e9215fa9872fc942 Mon Sep 17 00:00:00 2001 From: hiddevanesch Date: Tue, 28 Mar 2023 16:34:46 +0200 Subject: [PATCH 46/77] Added changes to changelog and added language keys Co-Authored-By: FlorisPex <64036156+FlorisPex@users.noreply.github.com> --- CHANGELOG.md | 2 +- src/main/resources/l10n/JabRef_en.properties | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 406e02ed7fe..b7db5173292 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,7 +35,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve - `log.txt` does not contain entries for non-found files during PDF indexing. [#9678](https://github.com/JabRef/jabref/pull/9678) - We improved the Medline importer to correctly import ISO dates for `revised`. [#9536](https://github.com/JabRef/jabref/issues/9536) - To avoid cluttering of the directory, We always delete the `.sav` file upon successful write. [#9675](https://github.com/JabRef/jabref/pull/9675) - +- We improved the unlinking/deletion of multiple linked files of an entry using the Delete key [#9473](https://github.com/JabRef/jabref/issues/9473) ### Fixed diff --git a/src/main/resources/l10n/JabRef_en.properties b/src/main/resources/l10n/JabRef_en.properties index 035b291a4fd..c772cf06f87 100644 --- a/src/main/resources/l10n/JabRef_en.properties +++ b/src/main/resources/l10n/JabRef_en.properties @@ -2539,3 +2539,8 @@ Please\ select\ a\ valid\ main\ directory\ under=Please select a valid main dire Search\ from\ history...=Search from history... your\ search\ history\ is\ empty=your search history is empty Clear\ history =Clear history + +Delete\ %0\ files=Delete %0 files +Delete\ %0\ files\ permanently\ from\ disk,\ or\ just\ remove\ the\ files\ from\ the\ entry?\ Pressing\ Delete\ will\ delete\ the\ files\ permanently\ from\ disk.=Delete %0 files permanently from disk, or just remove the files from the entry? Pressing Delete will delete the files permanently from disk. +Error\ accessing\ file\ '%0'.=Error accessing file '%0'. +This\ operation\ requires\ selected\ linked\ files.=This operation requires selected linked files. From 369104f49f1582b1195d1b084b224ddca62b5b5b Mon Sep 17 00:00:00 2001 From: dragos222 Date: Tue, 28 Mar 2023 18:46:48 +0200 Subject: [PATCH 47/77] Only save merge toolbar config when merge entries button is pressed --- .../gui/mergeentries/MergeEntriesDialog.java | 1 + .../newmergedialog/ThreeWayMergeView.java | 4 ++++ .../toolbar/ThreeWayMergeToolbar.java | 20 +++++++++---------- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/main/java/org/jabref/gui/mergeentries/MergeEntriesDialog.java b/src/main/java/org/jabref/gui/mergeentries/MergeEntriesDialog.java index 51ecd10b5a8..3f557bbfb6c 100644 --- a/src/main/java/org/jabref/gui/mergeentries/MergeEntriesDialog.java +++ b/src/main/java/org/jabref/gui/mergeentries/MergeEntriesDialog.java @@ -36,6 +36,7 @@ private void init() { this.getDialogPane().getButtonTypes().setAll(ButtonType.CANCEL, replaceEntries); this.setResultConverter(buttonType -> { if (buttonType.equals(replaceEntries)) { + threeWayMergeView.getThreeWayToolbar().saveGuiPreferences(); return new EntriesMergeResult(one, two, threeWayMergeView.getLeftEntry(), threeWayMergeView.getRightEntry(), threeWayMergeView.getMergedEntry()); } else { return null; diff --git a/src/main/java/org/jabref/gui/mergeentries/newmergedialog/ThreeWayMergeView.java b/src/main/java/org/jabref/gui/mergeentries/newmergedialog/ThreeWayMergeView.java index 576d11954d2..8912d56b393 100644 --- a/src/main/java/org/jabref/gui/mergeentries/newmergedialog/ThreeWayMergeView.java +++ b/src/main/java/org/jabref/gui/mergeentries/newmergedialog/ThreeWayMergeView.java @@ -186,4 +186,8 @@ public BibEntry getLeftEntry() { public BibEntry getRightEntry() { return viewModel.getRightEntry(); } + + public ThreeWayMergeToolbar getThreeWayToolbar() { + return toolbar; + } } diff --git a/src/main/java/org/jabref/gui/mergeentries/newmergedialog/toolbar/ThreeWayMergeToolbar.java b/src/main/java/org/jabref/gui/mergeentries/newmergedialog/toolbar/ThreeWayMergeToolbar.java index 84bdb72d237..9a8ce7e1cab 100644 --- a/src/main/java/org/jabref/gui/mergeentries/newmergedialog/toolbar/ThreeWayMergeToolbar.java +++ b/src/main/java/org/jabref/gui/mergeentries/newmergedialog/toolbar/ThreeWayMergeToolbar.java @@ -68,11 +68,7 @@ public void initialize() { plainTextOrDiffComboBox.getItems().addAll(PlainTextOrDiff.values()); plainTextOrDiffComboBox.getSelectionModel().select(preferencesService.getGuiPreferences().getMergePlainTextOrDiff()); - plainTextOrDiffComboBox.getSelectionModel().selectedItemProperty().addListener((options, oldValue, newValue) -> { - preferencesService.getGuiPreferences().setMergePlainTextOrDiff(newValue); - }); - - plainTextOrDiffComboBox.setConverter(new StringConverter<>() { + plainTextOrDiffComboBox.setConverter(new StringConverter<> () { @Override public String toString(PlainTextOrDiff plainTextOrDiff) { return plainTextOrDiff.getValue(); @@ -87,9 +83,7 @@ public PlainTextOrDiff fromString(String string) { diffViewComboBox.disableProperty().bind(notShowDiffProperty()); diffViewComboBox.getItems().addAll(DiffView.values()); diffViewComboBox.getSelectionModel().select(preferencesService.getGuiPreferences().getMergeDiffView()); - diffViewComboBox.getSelectionModel().selectedItemProperty().addListener((options, oldValue, newValue) -> { - preferencesService.getGuiPreferences().setMergeDiffView(newValue); - }); + diffViewComboBox.setConverter(new StringConverter<>() { @Override public String toString(DiffView diffView) { @@ -108,10 +102,8 @@ public DiffView fromString(String string) { diffHighlightingMethodToggleGroup.selectedToggleProperty().addListener((observable -> { if (diffHighlightingMethodToggleGroup.getSelectedToggle().equals(highlightCharactersRadioButtons)) { diffHighlightingMethod.set(BasicDiffMethod.CHARS); - preferencesService.getGuiPreferences().setMergeHighlightWords(false); } else { diffHighlightingMethod.set(BasicDiffMethod.WORDS); - preferencesService.getGuiPreferences().setMergeHighlightWords(true); } })); @@ -183,6 +175,14 @@ public void setOnSelectRightEntryValuesButtonClicked(Runnable onClick) { selectRightEntryValuesButton.setOnMouseClicked(e -> onClick.run()); } + public void saveGuiPreferences() { + preferencesService.getGuiPreferences().setMergePlainTextOrDiff(plainTextOrDiffComboBox.getValue()); + preferencesService.getGuiPreferences().setMergeDiffView(diffViewComboBox.getValue()); + + boolean highlightWordsRadioButtonValue = diffHighlightingMethodToggleGroup.getSelectedToggle().equals(highlightWordsRadioButton); + preferencesService.getGuiPreferences().setMergeHighlightWords(highlightWordsRadioButtonValue); + } + public enum PlainTextOrDiff { PLAIN_TEXT(Localization.lang("Plain Text")), Diff(Localization.lang("Show Diff")); From 2f832e7f29b040b687c1ecfb0419b14b1b0c24b3 Mon Sep 17 00:00:00 2001 From: dragos222 Date: Tue, 28 Mar 2023 19:01:00 +0200 Subject: [PATCH 48/77] Readd deletions; fix typo in GuiPreferences --- .../gui/collab/entrychange/EntryChangeResolver.java | 4 ++++ .../jabref/gui/mergeentries/MergeEntriesAction.java | 1 + .../jabref/gui/mergeentries/MergeEntriesDialog.java | 5 +++++ .../newmergedialog/ThreeWayMergeView.java | 7 ++++++- .../newmergedialog/toolbar/ThreeWayMergeToolbar.java | 6 +++++- .../java/org/jabref/preferences/GuiPreferences.java | 11 +++++------ 6 files changed, 26 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/jabref/gui/collab/entrychange/EntryChangeResolver.java b/src/main/java/org/jabref/gui/collab/entrychange/EntryChangeResolver.java index dc296db80a1..8e5575f4196 100644 --- a/src/main/java/org/jabref/gui/collab/entrychange/EntryChangeResolver.java +++ b/src/main/java/org/jabref/gui/collab/entrychange/EntryChangeResolver.java @@ -7,6 +7,9 @@ import org.jabref.gui.collab.DatabaseChangeResolver; import org.jabref.gui.mergeentries.EntriesMergeResult; import org.jabref.gui.mergeentries.MergeEntriesDialog; +import org.jabref.gui.mergeentries.newmergedialog.ShowDiffConfig; +import org.jabref.gui.mergeentries.newmergedialog.diffhighlighter.DiffHighlighter.BasicDiffMethod; +import org.jabref.gui.mergeentries.newmergedialog.toolbar.ThreeWayMergeToolbar; import org.jabref.logic.l10n.Localization; import org.jabref.model.database.BibDatabaseContext; import org.jabref.preferences.BibEntryPreferences; @@ -29,6 +32,7 @@ public Optional askUserToResolveChange() { MergeEntriesDialog mergeEntriesDialog = new MergeEntriesDialog(entryChange.getOldEntry(), entryChange.getNewEntry(), bibEntryPreferences); mergeEntriesDialog.setLeftHeaderText(Localization.lang("In JabRef")); mergeEntriesDialog.setRightHeaderText(Localization.lang("On disk")); + mergeEntriesDialog.configureDiff(new ShowDiffConfig(ThreeWayMergeToolbar.DiffView.SPLIT, BasicDiffMethod.WORDS)); return dialogService.showCustomDialogAndWait(mergeEntriesDialog) .map(this::mapMergeResultToExternalChange); diff --git a/src/main/java/org/jabref/gui/mergeentries/MergeEntriesAction.java b/src/main/java/org/jabref/gui/mergeentries/MergeEntriesAction.java index d9d16636715..9c40605d11d 100644 --- a/src/main/java/org/jabref/gui/mergeentries/MergeEntriesAction.java +++ b/src/main/java/org/jabref/gui/mergeentries/MergeEntriesAction.java @@ -23,6 +23,7 @@ public MergeEntriesAction(DialogService dialogService, StateManager stateManager this.dialogService = dialogService; this.stateManager = stateManager; this.bibEntryPreferences = bibEntryPreferences; + this.executable.bind(ActionHelper.needsEntriesSelected(NUMBER_OF_ENTRIES_NEEDED, stateManager)); } diff --git a/src/main/java/org/jabref/gui/mergeentries/MergeEntriesDialog.java b/src/main/java/org/jabref/gui/mergeentries/MergeEntriesDialog.java index 3f557bbfb6c..02768e7b620 100644 --- a/src/main/java/org/jabref/gui/mergeentries/MergeEntriesDialog.java +++ b/src/main/java/org/jabref/gui/mergeentries/MergeEntriesDialog.java @@ -3,6 +3,7 @@ import javafx.scene.control.ButtonBar; import javafx.scene.control.ButtonType; +import org.jabref.gui.mergeentries.newmergedialog.ShowDiffConfig; import org.jabref.gui.mergeentries.newmergedialog.ThreeWayMergeView; import org.jabref.gui.util.BaseDialog; import org.jabref.logic.l10n.Localization; @@ -51,4 +52,8 @@ public void setLeftHeaderText(String leftHeaderText) { public void setRightHeaderText(String rightHeaderText) { threeWayMergeView.setRightHeader(rightHeaderText); } + + public void configureDiff(ShowDiffConfig diffConfig) { + threeWayMergeView.showDiff(diffConfig); + } } diff --git a/src/main/java/org/jabref/gui/mergeentries/newmergedialog/ThreeWayMergeView.java b/src/main/java/org/jabref/gui/mergeentries/newmergedialog/ThreeWayMergeView.java index 8912d56b393..ec95e154d29 100644 --- a/src/main/java/org/jabref/gui/mergeentries/newmergedialog/ThreeWayMergeView.java +++ b/src/main/java/org/jabref/gui/mergeentries/newmergedialog/ThreeWayMergeView.java @@ -49,7 +49,6 @@ public ThreeWayMergeView(BibEntry leftEntry, BibEntry rightEntry, String leftHea mergeGridPane = new GridPane(); scrollPane = new ScrollPane(); headerView = new ThreeWayMergeHeaderView(leftHeader, rightHeader); - toolbar = new ThreeWayMergeToolbar(); initializeColumnConstraints(); @@ -179,6 +178,12 @@ public void selectRightEntryValues() { fieldRows.forEach(FieldRowView::selectRightValue); } + public void showDiff(ShowDiffConfig diffConfig) { + toolbar.setDiffView(diffConfig.diffView()); + toolbar.setDiffHighlightingMethod(diffConfig.diffHighlightingMethod()); + toolbar.setShowDiff(true); + } + public BibEntry getLeftEntry() { return viewModel.getLeftEntry(); } diff --git a/src/main/java/org/jabref/gui/mergeentries/newmergedialog/toolbar/ThreeWayMergeToolbar.java b/src/main/java/org/jabref/gui/mergeentries/newmergedialog/toolbar/ThreeWayMergeToolbar.java index 9a8ce7e1cab..eb8932099db 100644 --- a/src/main/java/org/jabref/gui/mergeentries/newmergedialog/toolbar/ThreeWayMergeToolbar.java +++ b/src/main/java/org/jabref/gui/mergeentries/newmergedialog/toolbar/ThreeWayMergeToolbar.java @@ -68,7 +68,7 @@ public void initialize() { plainTextOrDiffComboBox.getItems().addAll(PlainTextOrDiff.values()); plainTextOrDiffComboBox.getSelectionModel().select(preferencesService.getGuiPreferences().getMergePlainTextOrDiff()); - plainTextOrDiffComboBox.setConverter(new StringConverter<> () { + plainTextOrDiffComboBox.setConverter(new StringConverter<>() { @Override public String toString(PlainTextOrDiff plainTextOrDiff) { return plainTextOrDiff.getValue(); @@ -123,6 +123,10 @@ public DiffView getDiffView() { return diffViewProperty().get(); } + public void setDiffView(DiffView diffView) { + diffViewProperty().set(diffView); + } + public EasyBinding showDiffProperty() { return showDiff; } diff --git a/src/main/java/org/jabref/preferences/GuiPreferences.java b/src/main/java/org/jabref/preferences/GuiPreferences.java index 39122980d56..1ef780dcfe0 100644 --- a/src/main/java/org/jabref/preferences/GuiPreferences.java +++ b/src/main/java/org/jabref/preferences/GuiPreferences.java @@ -37,8 +37,7 @@ public class GuiPreferences { private final ObjectProperty mergeDiffMode; private final ObjectProperty mergePlainTextOrDiff; private final ObjectProperty mergeDiffView; - private final BooleanProperty mergeHighlightsWords; - + private final BooleanProperty mergeHighlightWords; private final BooleanProperty mergeShowChangedFieldsOnly; private final DoubleProperty sidePaneWidth; @@ -68,7 +67,7 @@ public GuiPreferences(double positionX, this.mergeDiffMode = new SimpleObjectProperty<>(mergeDiffMode); this.mergePlainTextOrDiff = new SimpleObjectProperty<>(mergePlainTextOrDiff); this.mergeDiffView = new SimpleObjectProperty<>(mergeDiffView); - this.mergeHighlightsWords = new SimpleBooleanProperty(mergeHighlightsWords); + this.mergeHighlightWords = new SimpleBooleanProperty(mergeHighlightsWords); this.sidePaneWidth = new SimpleDoubleProperty(sidePaneWidth); this.fileHistory = fileHistory; @@ -208,15 +207,15 @@ public void setMergeDiffView(DiffView mergeDiffView) { } public boolean getMergeHighlightWords() { - return mergeHighlightsWords.get(); + return mergeHighlightWords.get(); } public BooleanProperty mergeHighlightWordsProperty() { - return mergeHighlightsWords; + return mergeHighlightWords; } public void setMergeHighlightWords(boolean mergeHighlightsWords) { - this.mergeHighlightsWords.set(mergeHighlightsWords); + this.mergeHighlightWords.set(mergeHighlightsWords); } public double getSidePaneWidth() { From bcd83c77e5e8dce077083dd45522d2ee5bd05191 Mon Sep 17 00:00:00 2001 From: hiddevanesch Date: Tue, 28 Mar 2023 19:38:18 +0200 Subject: [PATCH 49/77] Added extra error handling + suggestion on PR --- .../org/jabref/gui/fieldeditors/LinkedFileViewModel.java | 4 ++-- .../java/org/jabref/gui/linkedfile/DeleteFileAction.java | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/jabref/gui/fieldeditors/LinkedFileViewModel.java b/src/main/java/org/jabref/gui/fieldeditors/LinkedFileViewModel.java index f18975dad88..1e3daafffe7 100644 --- a/src/main/java/org/jabref/gui/fieldeditors/LinkedFileViewModel.java +++ b/src/main/java/org/jabref/gui/fieldeditors/LinkedFileViewModel.java @@ -385,7 +385,7 @@ public boolean delete() { Optional file = linkedFile.findIn(databaseContext, preferences.getFilePreferences()); if (file.isEmpty()) { - LOGGER.warn("Could not find file " + linkedFile.getLink()); + LOGGER.warn("Could not find file {}", linkedFile.getLink()); return true; } @@ -407,7 +407,7 @@ public boolean delete() { return true; } catch (IOException ex) { dialogService.showErrorDialogAndWait(Localization.lang("Cannot delete file"), Localization.lang("File permission error")); - LOGGER.warn("File permission error while deleting: " + linkedFile, ex); + LOGGER.warn("File permission error while deleting: {}", linkedFile, ex); } } } diff --git a/src/main/java/org/jabref/gui/linkedfile/DeleteFileAction.java b/src/main/java/org/jabref/gui/linkedfile/DeleteFileAction.java index d925a713f48..a1f9ef3bb15 100644 --- a/src/main/java/org/jabref/gui/linkedfile/DeleteFileAction.java +++ b/src/main/java/org/jabref/gui/linkedfile/DeleteFileAction.java @@ -120,7 +120,7 @@ public void deleteFileFromDisk(LinkedFileViewModel fileViewModel) { Optional file = linkedFile.findIn(databaseContext, preferences.getFilePreferences()); if (file.isEmpty()) { - LOGGER.warn("Could not find file " + linkedFile.getLink()); + LOGGER.warn("Could not find file {}", linkedFile.getLink()); } if (file.isPresent()) { @@ -129,8 +129,10 @@ public void deleteFileFromDisk(LinkedFileViewModel fileViewModel) { } catch ( IOException ex) { dialogService.showErrorDialogAndWait(Localization.lang("Cannot delete file"), Localization.lang("File permission error")); - LOGGER.warn("File permission error while deleting: " + linkedFile, ex); + LOGGER.warn("File permission error while deleting: {}", linkedFile, ex); } + } else { + dialogService.notify(Localization.lang("Error accessing file '%0'.", linkedFile.getLink())); } } } From 062d727520ce131a1909d113f6815df947fbb8b2 Mon Sep 17 00:00:00 2001 From: dragos222 Date: Tue, 28 Mar 2023 19:41:37 +0200 Subject: [PATCH 50/77] Fix typo --- src/main/java/org/jabref/preferences/GuiPreferences.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/jabref/preferences/GuiPreferences.java b/src/main/java/org/jabref/preferences/GuiPreferences.java index 1ef780dcfe0..6da41ec6111 100644 --- a/src/main/java/org/jabref/preferences/GuiPreferences.java +++ b/src/main/java/org/jabref/preferences/GuiPreferences.java @@ -53,7 +53,7 @@ public GuiPreferences(double positionX, DiffMode mergeDiffMode, PlainTextOrDiff mergePlainTextOrDiff, DiffView mergeDiffView, - boolean mergeHighlightsWords, + boolean mergeHighlightWords, double sidePaneWidth, boolean mergeShowChangedFieldsOnly) { this.positionX = new SimpleDoubleProperty(positionX); @@ -67,7 +67,7 @@ public GuiPreferences(double positionX, this.mergeDiffMode = new SimpleObjectProperty<>(mergeDiffMode); this.mergePlainTextOrDiff = new SimpleObjectProperty<>(mergePlainTextOrDiff); this.mergeDiffView = new SimpleObjectProperty<>(mergeDiffView); - this.mergeHighlightWords = new SimpleBooleanProperty(mergeHighlightsWords); + this.mergeHighlightWords = new SimpleBooleanProperty(mergeHighlightWords); this.sidePaneWidth = new SimpleDoubleProperty(sidePaneWidth); this.fileHistory = fileHistory; From 92feafeea200a241fd0d3def9af9a99f9312ae32 Mon Sep 17 00:00:00 2001 From: dragos222 Date: Tue, 28 Mar 2023 19:59:03 +0200 Subject: [PATCH 51/77] Add change to the changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f1277ee13f..ecf8fc049a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,7 +37,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve - We fixed an issue where the command line export using `--exportMatches` flag does not create an output bib file [#9581](https://github.com/JabRef/jabref/issues/9581) - We fixed an issue where custom field in the custom entry types could not be set to mulitline [#9609](https://github.com/JabRef/jabref/issues/9609) - We fixed an issue where the Office XML exporter did not resolve BibTeX-Strings when exporting entries [forum#3741](https://discourse.jabref.org/t/exporting-bibtex-constant-strings-to-ms-office-2007-xml/3741) - +- We fixed an issue where the Merge Entries Toolbar configuration was not saved after hitting 'Merge Entries' button [#9091](https://github.com/JabRef/jabref/issues/9091) ### Removed From 98ddc4aeb33d0c4d36214dd104f3b57102f97bc4 Mon Sep 17 00:00:00 2001 From: dragos222 Date: Wed, 29 Mar 2023 08:51:12 +0200 Subject: [PATCH 52/77] MergeEntriesDialog does not need toolbar object; delegate save gui preferences to threewaymergeview object --- .../java/org/jabref/gui/mergeentries/MergeEntriesDialog.java | 2 +- .../gui/mergeentries/newmergedialog/ThreeWayMergeView.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/jabref/gui/mergeentries/MergeEntriesDialog.java b/src/main/java/org/jabref/gui/mergeentries/MergeEntriesDialog.java index 02768e7b620..1aac777c57e 100644 --- a/src/main/java/org/jabref/gui/mergeentries/MergeEntriesDialog.java +++ b/src/main/java/org/jabref/gui/mergeentries/MergeEntriesDialog.java @@ -37,7 +37,7 @@ private void init() { this.getDialogPane().getButtonTypes().setAll(ButtonType.CANCEL, replaceEntries); this.setResultConverter(buttonType -> { if (buttonType.equals(replaceEntries)) { - threeWayMergeView.getThreeWayToolbar().saveGuiPreferences(); + threeWayMergeView.saveToolbarGuiPreferences(); return new EntriesMergeResult(one, two, threeWayMergeView.getLeftEntry(), threeWayMergeView.getRightEntry(), threeWayMergeView.getMergedEntry()); } else { return null; diff --git a/src/main/java/org/jabref/gui/mergeentries/newmergedialog/ThreeWayMergeView.java b/src/main/java/org/jabref/gui/mergeentries/newmergedialog/ThreeWayMergeView.java index ec95e154d29..22a5fb78e21 100644 --- a/src/main/java/org/jabref/gui/mergeentries/newmergedialog/ThreeWayMergeView.java +++ b/src/main/java/org/jabref/gui/mergeentries/newmergedialog/ThreeWayMergeView.java @@ -192,7 +192,7 @@ public BibEntry getRightEntry() { return viewModel.getRightEntry(); } - public ThreeWayMergeToolbar getThreeWayToolbar() { - return toolbar; + public void saveToolbarGuiPreferences() { + toolbar.saveGuiPreferences(); } } From 974b9ec7ad6088a384dc6c0cf3a87fe5b4dae674 Mon Sep 17 00:00:00 2001 From: dragos222 Date: Wed, 29 Mar 2023 20:33:56 +0200 Subject: [PATCH 53/77] Enum parse using getIfPresent to prevent exception being thrown --- .../toolbar/ThreeWayMergeToolbar.java | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/main/java/org/jabref/gui/mergeentries/newmergedialog/toolbar/ThreeWayMergeToolbar.java b/src/main/java/org/jabref/gui/mergeentries/newmergedialog/toolbar/ThreeWayMergeToolbar.java index eb8932099db..7ad12b62745 100644 --- a/src/main/java/org/jabref/gui/mergeentries/newmergedialog/toolbar/ThreeWayMergeToolbar.java +++ b/src/main/java/org/jabref/gui/mergeentries/newmergedialog/toolbar/ThreeWayMergeToolbar.java @@ -20,6 +20,7 @@ import org.jabref.preferences.PreferencesService; import com.airhacks.afterburner.views.ViewLoader; +import com.google.common.base.Enums; import com.tobiasdiez.easybind.EasyBind; import com.tobiasdiez.easybind.EasyBinding; import jakarta.inject.Inject; @@ -197,11 +198,7 @@ public enum PlainTextOrDiff { } public static PlainTextOrDiff parse(String name) { - try { - return PlainTextOrDiff.valueOf(name); - } catch (IllegalArgumentException e) { - return Diff; // default - } + return Enums.getIfPresent(PlainTextOrDiff.class, name).or(Diff); } public String getValue() { @@ -223,11 +220,7 @@ public enum DiffView { } public static DiffView parse(String name) { - try { - return DiffView.valueOf(name); - } catch (IllegalArgumentException e) { - return UNIFIED; // default - } + return Enums.getIfPresent(DiffView.class, name).or(UNIFIED); } public String getValue() { From d633e42882d4f418d1417129929264f6260cff35 Mon Sep 17 00:00:00 2001 From: vigneshdurairaj Date: Thu, 30 Mar 2023 12:13:40 +0200 Subject: [PATCH 54/77] Consuming action on the editMenu fix for issue 9367 --- src/main/java/org/jabref/gui/JabRefFrame.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java/org/jabref/gui/JabRefFrame.java b/src/main/java/org/jabref/gui/JabRefFrame.java index 4769fd425e7..7f993aefbdd 100644 --- a/src/main/java/org/jabref/gui/JabRefFrame.java +++ b/src/main/java/org/jabref/gui/JabRefFrame.java @@ -18,6 +18,7 @@ import javafx.beans.binding.StringBinding; import javafx.collections.transformation.FilteredList; import javafx.concurrent.Task; +import javafx.event.ActionEvent; import javafx.geometry.Orientation; import javafx.scene.Group; import javafx.scene.Node; @@ -39,6 +40,7 @@ import javafx.scene.control.Tooltip; import javafx.scene.control.skin.TabPaneSkin; import javafx.scene.input.Dragboard; +import javafx.scene.input.KeyCode; import javafx.scene.input.KeyEvent; import javafx.scene.input.TransferMode; import javafx.scene.layout.BorderPane; @@ -842,6 +844,14 @@ private MenuBar createMenu() { SpecialFieldMenuItemFactory.getSpecialFieldSingleItem(SpecialField.PRINTED, factory, this, dialogService, prefs, undoManager, stateManager), SpecialFieldMenuItemFactory.createSpecialFieldMenu(SpecialField.PRIORITY, factory, this, dialogService, prefs, undoManager, stateManager), SpecialFieldMenuItemFactory.createSpecialFieldMenu(SpecialField.READ_STATUS, factory, this, dialogService, prefs, undoManager, stateManager)); + edit.addEventHandler(ActionEvent.ACTION, event -> { + // Work around for mac only issue, where cmd+v on a dialogue triggers the paste action of menu item, resulting in addition of the pasted content in the MainTable. + // If the mainscreen is not focused, the actions captured by menu are consumed. + if (OS.OS_X && !mainStage.focusedProperty().get()) { + event.consume(); + } + }); + // @formatter:off library.getItems().addAll( From 2ed9b677718b3558522bfa08f23bc7987ba1fd33 Mon Sep 17 00:00:00 2001 From: vigneshdurairaj Date: Thu, 30 Mar 2023 13:31:07 +0200 Subject: [PATCH 55/77] checkstyle issue fixes --- src/main/java/org/jabref/gui/JabRefFrame.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/org/jabref/gui/JabRefFrame.java b/src/main/java/org/jabref/gui/JabRefFrame.java index 7f993aefbdd..aef94bdf1dd 100644 --- a/src/main/java/org/jabref/gui/JabRefFrame.java +++ b/src/main/java/org/jabref/gui/JabRefFrame.java @@ -40,7 +40,6 @@ import javafx.scene.control.Tooltip; import javafx.scene.control.skin.TabPaneSkin; import javafx.scene.input.Dragboard; -import javafx.scene.input.KeyCode; import javafx.scene.input.KeyEvent; import javafx.scene.input.TransferMode; import javafx.scene.layout.BorderPane; @@ -852,7 +851,6 @@ private MenuBar createMenu() { } }); - // @formatter:off library.getItems().addAll( factory.createMenuItem(StandardActions.NEW_ENTRY, new NewEntryAction(this, dialogService, prefs, stateManager)), From 25e35eae06821de3f5599f661fdf5e4ebcb6f834 Mon Sep 17 00:00:00 2001 From: vigneshdurairaj Date: Thu, 30 Mar 2023 20:18:57 +0200 Subject: [PATCH 56/77] updating changelog for pr9716 --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 406e02ed7fe..bb34758201a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -50,6 +50,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve - We fixed an issue where the password is saved locally if user wants to use proxy with authentication [#8055](https://github.com/JabRef/jabref/issues/8055) - JabRef is now more relaxed when parsing field content: In case a field content ended with `\`, the combination `\}` was treated as plain `}`. [#9668](https://github.com/JabRef/jabref/issues/9668) - We resolved an issue that cut off the number of group entries when it exceedet four digits. [#8797](https://github.com/JabRef/jabref/issues/8797) +- We fixed the double pasting issue when `Cmd` + `v` is pressed on 'New entry from plaintext' dialog. [#9367](https://github.com/JabRef/jabref/issues/9367) ### Removed From 808a4f08552c72ed93a965021e479a865ef95834 Mon Sep 17 00:00:00 2001 From: vigneshdurairaj Date: Thu, 30 Mar 2023 20:51:31 +0200 Subject: [PATCH 57/77] updated changelog for pr9716 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bb34758201a..e2e50893fc6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -50,7 +50,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve - We fixed an issue where the password is saved locally if user wants to use proxy with authentication [#8055](https://github.com/JabRef/jabref/issues/8055) - JabRef is now more relaxed when parsing field content: In case a field content ended with `\`, the combination `\}` was treated as plain `}`. [#9668](https://github.com/JabRef/jabref/issues/9668) - We resolved an issue that cut off the number of group entries when it exceedet four digits. [#8797](https://github.com/JabRef/jabref/issues/8797) -- We fixed the double pasting issue when `Cmd` + `v` is pressed on 'New entry from plaintext' dialog. [#9367](https://github.com/JabRef/jabref/issues/9367) +- We fixed the double paste issue when `Cmd` + `v` is pressed on 'New entry from plaintext' dialog. [#9367](https://github.com/JabRef/jabref/issues/9367) ### Removed From 99de05f6b55a439c55d41ffb3ef14aa10f7f28fc Mon Sep 17 00:00:00 2001 From: vigneshdurairaj Date: Thu, 30 Mar 2023 21:03:11 +0200 Subject: [PATCH 58/77] resolved changelog for pr9716 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e2e50893fc6..56343f7adb1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -50,7 +50,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve - We fixed an issue where the password is saved locally if user wants to use proxy with authentication [#8055](https://github.com/JabRef/jabref/issues/8055) - JabRef is now more relaxed when parsing field content: In case a field content ended with `\`, the combination `\}` was treated as plain `}`. [#9668](https://github.com/JabRef/jabref/issues/9668) - We resolved an issue that cut off the number of group entries when it exceedet four digits. [#8797](https://github.com/JabRef/jabref/issues/8797) -- We fixed the double paste issue when `Cmd` + `v` is pressed on 'New entry from plaintext' dialog. [#9367](https://github.com/JabRef/jabref/issues/9367) +- We fixed the double paste issue when Cmd + v is pressed on 'New entry from plaintext' dialog. [#9367](https://github.com/JabRef/jabref/issues/9367) ### Removed From 409d5fa3e66c914cc5715c4c11cee6eda0c5b111 Mon Sep 17 00:00:00 2001 From: NightOrchid Date: Fri, 31 Mar 2023 23:19:28 +0200 Subject: [PATCH 59/77] Global Search UI preview is dark in dark theme when no entry is shown (#9718) --- CHANGELOG.md | 1 + src/main/java/org/jabref/gui/preview/PreviewViewer.java | 3 ++- .../java/org/jabref/gui/search/GlobalSearchResultDialog.java | 5 +++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 56343f7adb1..3529222a37f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -50,6 +50,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve - We fixed an issue where the password is saved locally if user wants to use proxy with authentication [#8055](https://github.com/JabRef/jabref/issues/8055) - JabRef is now more relaxed when parsing field content: In case a field content ended with `\`, the combination `\}` was treated as plain `}`. [#9668](https://github.com/JabRef/jabref/issues/9668) - We resolved an issue that cut off the number of group entries when it exceedet four digits. [#8797](https://github.com/JabRef/jabref/issues/8797) +- We fixed an issue where the Global Search UI preview is still white in dark theme. [#9362](https://github.com/JabRef/jabref/issues/9362) - We fixed the double paste issue when Cmd + v is pressed on 'New entry from plaintext' dialog. [#9367](https://github.com/JabRef/jabref/issues/9367) diff --git a/src/main/java/org/jabref/gui/preview/PreviewViewer.java b/src/main/java/org/jabref/gui/preview/PreviewViewer.java index 78a7d47d2ee..222478609e0 100644 --- a/src/main/java/org/jabref/gui/preview/PreviewViewer.java +++ b/src/main/java/org/jabref/gui/preview/PreviewViewer.java @@ -244,7 +244,8 @@ public void setEntry(BibEntry newEntry) { private void update() { if (entry.isEmpty() || (layout == null)) { - // Nothing to do + // Make sure that the preview panel is not completely white, especially with dark theme on + setPreviewText(""); return; } diff --git a/src/main/java/org/jabref/gui/search/GlobalSearchResultDialog.java b/src/main/java/org/jabref/gui/search/GlobalSearchResultDialog.java index 1b330015949..3109bb7d6a4 100644 --- a/src/main/java/org/jabref/gui/search/GlobalSearchResultDialog.java +++ b/src/main/java/org/jabref/gui/search/GlobalSearchResultDialog.java @@ -58,6 +58,11 @@ private void initialize() { resultsTable.getColumns().removeIf(col -> col instanceof SpecialFieldColumn); resultsTable.getSelectionModel().selectFirst(); + + if (resultsTable.getSelectionModel().getSelectedItem() != null) { + previewViewer.setEntry(resultsTable.getSelectionModel().getSelectedItem().getEntry()); + } + resultsTable.getSelectionModel().selectedItemProperty().addListener((obs, old, newValue) -> { if (newValue != null) { previewViewer.setEntry(newValue.getEntry()); From 88e335d9db3c871164732f964f773253a6fc631e Mon Sep 17 00:00:00 2001 From: github actions Date: Sat, 1 Apr 2023 02:19:11 +0000 Subject: [PATCH 60/77] Squashed 'buildres/csl/csl-styles/' changes from ca943b70d7..41531558a8 41531558a8 Fix unsigned newspaper articles throughout Chicago 17 (#6486) 7678212826 Create trames.csl (#6479) 0cae26ac85 Update hochschule-fur-soziale-arbeit-fhnw.csl (#6480) 85c4b693a2 Update to UP Harvard Theology & Religion (#6485) c273aa7e43 Update ieee.csl (#6481) fe67b80e47 Update open-window.csl (#6367) f2229705ef Create iainutuban-tarbiyah.csl (#6361) 1867a56a26 Create business-and-human-rights-journal (#6359) 1371dbdf26 Update iso690-author-date-es.csl (#6477) 6953a43efd Update ieee.csl (#6478) f56d5ef1cc Create czech-journal-of-international-relations.csl (#6453) 678b53f99c Update harvard-stellenbosch-university.csl (#6464) 3074938038 Update ucl-university-college-apa.csl (#6475) 27dab9ea0f Update iso690-author-date-es.csl (#6476) a8aea63d00 Create elsevier-american-chemical-society.csl (#6342) f8f290fa63 Update iso690-author-date-es.csl (#6472) 7fdc621eee Update journal-of-neolithic-archaeology (#6466) 7025568e70 Update offa.csl (#6465) 2d69299b19 Create uni-fribourg-theologie.csl (#6473) 8db531a73e Create travail-et-emploi.csl (#6351) c8b54fc531 Make monash-university-harvard dependent style (#6470) b95f59ff5c Update journal-of-the-marine-biological-association-of-the-united-kingdom.csl (#6456) a12b513119 Update universite-du-quebec-a-montreal.csl (#6463) 048e6641e4 Update zeitschrift-fur-geschichtsdidaktik.csl (#6454) f0d3d7ef15 Update journal-fur-kulturpflanzen-journal-of-cultivated-plants.csl (#6447) 3b814fe048 Update the-accounting-review.csl (#6459) f24befd580 Update survey-of-ophthalmology.csl from ama.csl to its own independent style (#6460) c868ab54f6 Create vancouver-alphabetical.csl (#6461) 782e39cfe1 Update american-institute-of-physics.csl (#6457) a56cf03e3c Fix Chicago Cases & Newspaper sorting (#6458) git-subtree-dir: buildres/csl/csl-styles git-subtree-split: 41531558a873b2533f2d17d8d6484c2408174fce --- american-institute-of-physics.csl | 29 +- business-and-human-rights-journal.csl | 251 +++++++++++ chicago-annotated-bibliography.csl | 50 ++- ...te-bibliography-short-title-subsequent.csl | 50 ++- chicago-fullnote-bibliography-with-ibid.csl | 50 ++- chicago-fullnote-bibliography.csl | 52 ++- chicago-library-list.csl | 50 ++- chicago-note-bibliography-with-ibid.csl | 50 ++- chicago-note-bibliography.csl | 50 ++- czech-journal-of-international-relations.csl | 268 ++++++++++++ dependent/monash-university-harvard.csl | 14 + dependent/survey-of-ophthalmology.csl | 16 - elsevier-american-chemical-society.csl | 292 +++++++++++++ harvard-stellenbosch-university.csl | 75 ++-- hochschule-fur-soziale-arbeit-fhnw.csl | 2 +- ...ity-harvard.csl => iainutuban-tarbiyah.csl | 158 ++++--- ieee.csl | 59 ++- iso690-author-date-es.csl | 20 +- ...rpflanzen-journal-of-cultivated-plants.csl | 20 +- journal-of-neolithic-archaeology.csl | 60 ++- ...ical-association-of-the-united-kingdom.csl | 42 +- offa.csl | 57 ++- open-window.csl | 215 ++++++---- survey-of-ophthalmology.csl | 350 ++++++++++++++++ the-accounting-review.csl | 11 +- trames.csl | 243 +++++++++++ travail-et-emploi.csl | 394 ++++++++++++++++++ ucl-university-college-apa.csl | 1 - uni-fribourg-theologie.csl | 266 ++++++++++++ universite-du-quebec-a-montreal.csl | 24 +- ...-of-pretoria-harvard-theology-religion.csl | 76 +++- vancouver-alphabetical.csl | 346 +++++++++++++++ zeitschrift-fur-geschichtsdidaktik.csl | 19 +- 33 files changed, 3236 insertions(+), 424 deletions(-) create mode 100644 business-and-human-rights-journal.csl create mode 100644 czech-journal-of-international-relations.csl create mode 100644 dependent/monash-university-harvard.csl delete mode 100644 dependent/survey-of-ophthalmology.csl create mode 100644 elsevier-american-chemical-society.csl rename monash-university-harvard.csl => iainutuban-tarbiyah.csl (81%) create mode 100644 survey-of-ophthalmology.csl create mode 100644 trames.csl create mode 100644 travail-et-emploi.csl create mode 100644 uni-fribourg-theologie.csl create mode 100644 vancouver-alphabetical.csl diff --git a/american-institute-of-physics.csl b/american-institute-of-physics.csl index 5480ac8e545..b6ae0dc82e8 100644 --- a/american-institute-of-physics.csl +++ b/american-institute-of-physics.csl @@ -1,27 +1,30 @@ diff --git a/chicago-annotated-bibliography.csl b/chicago-annotated-bibliography.csl index 06b2bf8c859..82534d49163 100644 --- a/chicago-annotated-bibliography.csl +++ b/chicago-annotated-bibliography.csl @@ -185,9 +185,12 @@ - - + + + + + @@ -218,6 +221,11 @@ + + + + + @@ -561,7 +569,20 @@ - + + + + + + + + + + + + @@ -1145,9 +1166,17 @@ - - + + + + + + + + + + @@ -1158,9 +1187,16 @@ - - + + + + + + + + + diff --git a/chicago-fullnote-bibliography-short-title-subsequent.csl b/chicago-fullnote-bibliography-short-title-subsequent.csl index 16d2dca4044..3b987c9acb3 100644 --- a/chicago-fullnote-bibliography-short-title-subsequent.csl +++ b/chicago-fullnote-bibliography-short-title-subsequent.csl @@ -186,9 +186,12 @@ - - + + + + + @@ -219,6 +222,11 @@ + + + + + @@ -562,7 +570,20 @@ - + + + + + + + + + + + + @@ -1146,9 +1167,17 @@ - - + + + + + + + + + + @@ -1159,9 +1188,16 @@ - - + + + + + + + + + diff --git a/chicago-fullnote-bibliography-with-ibid.csl b/chicago-fullnote-bibliography-with-ibid.csl index a37796ea16c..bc0eedcac9f 100644 --- a/chicago-fullnote-bibliography-with-ibid.csl +++ b/chicago-fullnote-bibliography-with-ibid.csl @@ -185,9 +185,12 @@ - - + + + + + @@ -218,6 +221,11 @@ + + + + + @@ -561,7 +569,20 @@ - + + + + + + + + + + + + @@ -1145,9 +1166,17 @@ - - + + + + + + + + + + @@ -1158,9 +1187,16 @@ - - + + + + + + + + + diff --git a/chicago-fullnote-bibliography.csl b/chicago-fullnote-bibliography.csl index da4969f115d..23e94cda08e 100644 --- a/chicago-fullnote-bibliography.csl +++ b/chicago-fullnote-bibliography.csl @@ -34,7 +34,7 @@ Chicago format with full notes and bibliography - 2017-10-12T12:00:00+00:00 + 2022-01-16T19:46:01+00:00 This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 License @@ -185,9 +185,12 @@ - - + + + + + @@ -218,6 +221,11 @@ + + + + + @@ -561,7 +569,20 @@ - + + + + + + + + + + + + @@ -1145,9 +1166,17 @@ - - + + + + + + + + + + @@ -1158,9 +1187,16 @@ - - + + + + + + + + + diff --git a/chicago-library-list.csl b/chicago-library-list.csl index 0f268c412ca..50adb02a727 100644 --- a/chicago-library-list.csl +++ b/chicago-library-list.csl @@ -185,9 +185,12 @@ - - + + + + + @@ -218,6 +221,11 @@ + + + + + @@ -561,7 +569,20 @@ - + + + + + + + + + + + + @@ -1145,9 +1166,17 @@ - - + + + + + + + + + + @@ -1158,9 +1187,16 @@ - - + + + + + + + + + diff --git a/chicago-note-bibliography-with-ibid.csl b/chicago-note-bibliography-with-ibid.csl index 66406945d34..93c2cb214af 100644 --- a/chicago-note-bibliography-with-ibid.csl +++ b/chicago-note-bibliography-with-ibid.csl @@ -185,9 +185,12 @@ - - + + + + + @@ -218,6 +221,11 @@ + + + + + @@ -561,7 +569,20 @@ - + + + + + + + + + + + + @@ -1145,9 +1166,17 @@ - - + + + + + + + + + + @@ -1158,9 +1187,16 @@ - - + + + + + + + + + diff --git a/chicago-note-bibliography.csl b/chicago-note-bibliography.csl index 83da96cb4de..217c873b527 100644 --- a/chicago-note-bibliography.csl +++ b/chicago-note-bibliography.csl @@ -185,9 +185,12 @@ - - + + + + + @@ -218,6 +221,11 @@ + + + + + @@ -561,7 +569,20 @@ - + + + + + + + + + + + + @@ -1145,9 +1166,17 @@ - - + + + + + + + + + + @@ -1158,9 +1187,16 @@ - - + + + + + + + + + diff --git a/czech-journal-of-international-relations.csl b/czech-journal-of-international-relations.csl new file mode 100644 index 00000000000..b979582f4a0 --- /dev/null +++ b/czech-journal-of-international-relations.csl @@ -0,0 +1,268 @@ + + diff --git a/dependent/monash-university-harvard.csl b/dependent/monash-university-harvard.csl new file mode 100644 index 00000000000..3280a0c88fc --- /dev/null +++ b/dependent/monash-university-harvard.csl @@ -0,0 +1,14 @@ + + diff --git a/dependent/survey-of-ophthalmology.csl b/dependent/survey-of-ophthalmology.csl deleted file mode 100644 index 654b1e0da0c..00000000000 --- a/dependent/survey-of-ophthalmology.csl +++ /dev/null @@ -1,16 +0,0 @@ - - diff --git a/elsevier-american-chemical-society.csl b/elsevier-american-chemical-society.csl new file mode 100644 index 00000000000..e1f9d46fabd --- /dev/null +++ b/elsevier-american-chemical-society.csl @@ -0,0 +1,292 @@ + + diff --git a/harvard-stellenbosch-university.csl b/harvard-stellenbosch-university.csl index 67e4d4d85ca..af978c13db6 100644 --- a/harvard-stellenbosch-university.csl +++ b/harvard-stellenbosch-university.csl @@ -18,7 +18,7 @@ - v. + vol. available @@ -31,7 +31,7 @@ - @@ -39,15 +39,16 @@ - - - + + + @@ -175,26 +178,25 @@ - - - - - + + + + + + + + + + - - - - - - + - + @@ -225,7 +227,7 @@ - + @@ -239,7 +241,12 @@ - + + + + + + @@ -282,12 +289,20 @@ - - - - + + + + + + + + + + + + + - diff --git a/hochschule-fur-soziale-arbeit-fhnw.csl b/hochschule-fur-soziale-arbeit-fhnw.csl index d579949b5a9..915a1821eb3 100644 --- a/hochschule-fur-soziale-arbeit-fhnw.csl +++ b/hochschule-fur-soziale-arbeit-fhnw.csl @@ -177,7 +177,7 @@ - + diff --git a/monash-university-harvard.csl b/iainutuban-tarbiyah.csl similarity index 81% rename from monash-university-harvard.csl rename to iainutuban-tarbiyah.csl index 6021110b2d1..500c582cd59 100644 --- a/monash-university-harvard.csl +++ b/iainutuban-tarbiyah.csl @@ -1,28 +1,29 @@ - diff --git a/the-accounting-review.csl b/the-accounting-review.csl index a0931ad6bbf..64133cc8699 100644 --- a/the-accounting-review.csl +++ b/the-accounting-review.csl @@ -4,7 +4,7 @@ The Accounting Review http://www.zotero.org/styles/the-accounting-review - + Sebastian Karcher @@ -12,11 +12,14 @@ Julian Onions julian.onions@gmail.com + + Patrick O'Brien + 0001-4826 1558-7967 - 2012-10-25T21:15:26+00:00 + 2023-03-16T09:10:03+00:00 This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 License @@ -392,7 +395,7 @@ - + @@ -403,7 +406,7 @@ - + diff --git a/trames.csl b/trames.csl new file mode 100644 index 00000000000..ba1a59d3a7b --- /dev/null +++ b/trames.csl @@ -0,0 +1,243 @@ + + diff --git a/travail-et-emploi.csl b/travail-et-emploi.csl new file mode 100644 index 00000000000..8da76eb6d48 --- /dev/null +++ b/travail-et-emploi.csl @@ -0,0 +1,394 @@ + + diff --git a/ucl-university-college-apa.csl b/ucl-university-college-apa.csl index 283f14aef7b..7f514e6fbfb 100644 --- a/ucl-university-college-apa.csl +++ b/ucl-university-college-apa.csl @@ -1580,7 +1580,6 @@ - diff --git a/uni-fribourg-theologie.csl b/uni-fribourg-theologie.csl new file mode 100644 index 00000000000..508154f893e --- /dev/null +++ b/uni-fribourg-theologie.csl @@ -0,0 +1,266 @@ + + diff --git a/universite-du-quebec-a-montreal.csl b/universite-du-quebec-a-montreal.csl index fbb02bda7e4..11211efce41 100644 --- a/universite-du-quebec-a-montreal.csl +++ b/universite-du-quebec-a-montreal.csl @@ -408,6 +408,12 @@ + + + + + + @@ -511,10 +517,20 @@ - - - - + + + + + + + + + + + + + + diff --git a/university-of-pretoria-harvard-theology-religion.csl b/university-of-pretoria-harvard-theology-religion.csl index f59a9edfa0a..4bb738acb44 100644 --- a/university-of-pretoria-harvard-theology-religion.csl +++ b/university-of-pretoria-harvard-theology-religion.csl @@ -13,7 +13,7 @@ - 2022-06-22T00:06:00+00:00 + 2023-03-30T00:13:00+00:00 This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 License @@ -249,23 +249,25 @@ - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + @@ -313,6 +315,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/vancouver-alphabetical.csl b/vancouver-alphabetical.csl new file mode 100644 index 00000000000..4731ecd88ac --- /dev/null +++ b/vancouver-alphabetical.csl @@ -0,0 +1,346 @@ + + diff --git a/zeitschrift-fur-geschichtsdidaktik.csl b/zeitschrift-fur-geschichtsdidaktik.csl index 47f088f4bd6..35b692db828 100644 --- a/zeitschrift-fur-geschichtsdidaktik.csl +++ b/zeitschrift-fur-geschichtsdidaktik.csl @@ -8,6 +8,7 @@ + Patrick O'Brien @@ -16,12 +17,12 @@ 1610-5982 2196-8292 - 2021-07-26T10:07:30+00:00 + 2023-03-13T09:23:25+00:00 This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 License - u. a. + u.a. gesehen am H. @@ -29,15 +30,15 @@ - - + + - - + + @@ -85,7 +86,7 @@ - + @@ -117,7 +118,7 @@ @@ -297,7 +298,7 @@ - + From 1ee171d220d824ad133864367928a0e0a9a1c97e Mon Sep 17 00:00:00 2001 From: github actions Date: Sat, 1 Apr 2023 02:19:11 +0000 Subject: [PATCH 61/77] Refresh example styles --- src/main/resources/csl-styles/ieee.csl | 59 +++++++++++++++++--------- 1 file changed, 39 insertions(+), 20 deletions(-) diff --git a/src/main/resources/csl-styles/ieee.csl b/src/main/resources/csl-styles/ieee.csl index 8238e0aac1d..19081952c37 100644 --- a/src/main/resources/csl-styles/ieee.csl +++ b/src/main/resources/csl-styles/ieee.csl @@ -183,7 +183,6 @@ - @@ -295,6 +294,19 @@ + + + + + + + + + + + + + @@ -337,16 +349,38 @@ - + + + + + + - + + + + + + + + + + + + + + + + + + @@ -399,6 +433,7 @@ + @@ -417,29 +452,13 @@ - - - - - - - - - - - - - - - - - + From 02b68e5ae9e9d2496c6fec137ac59f590b950c7d Mon Sep 17 00:00:00 2001 From: github actions Date: Sat, 1 Apr 2023 02:19:13 +0000 Subject: [PATCH 62/77] Squashed 'buildres/csl/csl-locales/' changes from 47edde1be3..a7c6f63e25 a7c6f63e25 correct license to match the SPDX license identifier. (#281) d704bf80af Update locales-nl-NL.xml (#229) 5ffb73b05a Bump nokogiri from 1.13.9 to 1.13.10 (#280) 04be62eda6 Update locales-pt-BR.xml (#251) b4db583787 Update locales-pt-BR.xml (#265) b656b1b6f9 Fix date format for Basque (#274) e7ec9bff94 Bump nokogiri from 1.13.4 to 1.13.9 (#272) 9125705f62 Update locales-nl-NL.xml (#279) 87445b0b65 Add composer.json (#161) 2919a84bff Fix page label in NO locales git-subtree-dir: buildres/csl/csl-locales git-subtree-split: a7c6f63e25323ac2f375943417d7f778f875f11c --- Gemfile.lock | 8 +- composer.json | 19 +++++ locales-eu.xml | 41 ++++++----- locales-nb-NO.xml | 2 +- locales-nl-NL.xml | 4 +- locales-nn-NO.xml | 2 +- locales-pt-BR.xml | 181 +++++++++++++++++++++++----------------------- 7 files changed, 141 insertions(+), 116 deletions(-) create mode 100644 composer.json diff --git a/Gemfile.lock b/Gemfile.lock index a15585eddab..56198040bff 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -62,20 +62,20 @@ GEM ruby-progressbar (~> 1.4) git_diff (0.4.3) hashdiff (0.3.7) - mini_portile2 (2.8.0) + mini_portile2 (2.8.1) multipart-post (2.1.1) namae (1.1.1) - nokogiri (1.13.4) + nokogiri (1.13.10) mini_portile2 (~> 2.8.0) racc (~> 1.4) - nokogiri (1.13.4-x64-mingw32) + nokogiri (1.13.10-x64-mingw32) racc (~> 1.4) octokit (4.21.0) faraday (>= 0.9) sawyer (~> 0.8.0, >= 0.5.3) ostruct (0.5.2) public_suffix (4.0.6) - racc (1.6.0) + racc (1.6.2) rake (13.0.6) reverse_markdown (2.1.1) nokogiri diff --git a/composer.json b/composer.json new file mode 100644 index 00000000000..d458ecc68b5 --- /dev/null +++ b/composer.json @@ -0,0 +1,19 @@ +{ + "name": "citation-style-language/locales", + "description": "Citation Style Language (CSL) Locales", + "type": "library", + "license": "CC-BY-SA-3.0", + "homepage": "http://citationstyles.org/", + "authors": [ + { + "name": "Citation Style Language (CSL) Team", + "homepage": "http://citationstyles.org/about/#Credits" + } + ], + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "require": {} +} diff --git a/locales-eu.xml b/locales-eu.xml index 2579e55227c..20bf2efbb0a 100644 --- a/locales-eu.xml +++ b/locales-eu.xml @@ -4,6 +4,9 @@ Amaraun + + Miren BZ + This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 License 2012-07-04T23:31:02+00:00 @@ -11,7 +14,7 @@ - + @@ -64,7 +67,7 @@ arg. et al. bidean - -(e)tik + hemendik: ibíd. in moldiztegian @@ -84,7 +87,7 @@ berreskuratua scale - version + bertsioa preprint @@ -170,7 +173,7 @@ . - lehengo + lehenengo bigarren hirugarren laugarren @@ -291,8 +294,8 @@ bertsoak - luburikia - luburukiak + liburukia + liburukiak @@ -565,23 +568,23 @@ -(e)k arg. eta itzul. - urtarrilak - otsailak - martxoak - apirilak - maiatzak - ekainak - uztailak - abuztuak - irailak - urriak - azaroak - abenduak + urtarrila + otsaila + martxoa + apirila + maiatza + ekaina + uztaila + abuztua + iraila + urria + azaroa + abendua urt. ots. - martx. + mar. apr. mai. eka. diff --git a/locales-nb-NO.xml b/locales-nb-NO.xml index d1b4499d0eb..2731a9ca648 100644 --- a/locales-nb-NO.xml +++ b/locales-nb-NO.xml @@ -307,7 +307,7 @@ op. s. - ss. + s. s. diff --git a/locales-nl-NL.xml b/locales-nl-NL.xml index 8852c3c340c..c03460db270 100644 --- a/locales-nl-NL.xml +++ b/locales-nl-NL.xml @@ -162,7 +162,7 @@ - + - : , ; @@ -614,7 +614,7 @@ lente zomer - herst + herfst winter diff --git a/locales-nn-NO.xml b/locales-nn-NO.xml index 8a5be2999b2..99f55cb4b33 100644 --- a/locales-nn-NO.xml +++ b/locales-nn-NO.xml @@ -307,7 +307,7 @@ op. s. - ss. + s. s. diff --git a/locales-pt-BR.xml b/locales-pt-BR.xml index 2b45696c987..d187312e3f1 100644 --- a/locales-pt-BR.xml +++ b/locales-pt-BR.xml @@ -6,6 +6,9 @@ Meira da Rocha + + + Renato Cirino This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 License 2016-05-16T00:00:00+03:00 @@ -23,9 +26,9 @@ advance online publication - album - audio recording - film + álbum + gravação de áudio + filme henceforth loc. cit. no place @@ -34,22 +37,22 @@ n.p. on op. cit. - original work published + trabalho original publicado comunicação pessoal podcast - podcast episode + episódio de podcast preprint - radio broadcast - radio series - radio series episode - special issue - special section - television broadcast - television series - television series episode - video + transmissão de rádio + série radiofônica + episódio de série radiofônica + edição especial + sessão especial + transmissão de tv + série de tv + episódio de série de tv + vídeo working paper - acessado + acesso em e e outros anônimo @@ -91,48 +94,48 @@ preprint - journal article - magazine article - newspaper article - bill - - broadcast - - classic - collection + artigo de periódico + artigo de revista + artigo de jornal + lei + livro + transmissão + capítulo de livro + clássico + coleção dataset - document + documento entry - dictionary entry - encyclopedia entry - event + verbete de dicionário + verbete de enciclopédia + evento - graphic - hearing + gráfico + audiência entrevista legal case - legislation - manuscript - map - video recording + legislação + manuscrito + mapa + gravação de vídeo musical score - pamphlet - conference paper - patent + panleto + artigo de conferência + patente performance periodical comunicação pessoal - post - blog post + postagem + postagem de blog regulation report - review - book review + revisão + revisão de livro software - audio recording - presentation - standard - thesis + gravação de áudio + apresentação + padrão + tese treaty webpage @@ -150,7 +153,7 @@ video rec. rep. rev. - bk. rev. + rev. liv. audio rec. @@ -198,16 +201,16 @@ - act - acts + ato + atos - appendix - appendices + apêndice + apêndices - article - articles + artigo + artigos canon @@ -218,28 +221,28 @@ locations - equation - equations + equação + equações - rule - rules + regra + regras - scene - scenes + cena + cenas - table - tables + tabela + tabelas - title - titles + título + títulos livro @@ -396,52 +399,52 @@ chairs - compiler - compilers + compilador + compiladores - contributor - contributors + contribuidor + contribuidores - curator - curators + curador + curadores - executive producer - executive producers + produtor executivo + produtores executivos - guest - guests + convidado + convidados - host - hosts + anfitrião + anfitriões - narrator - narrators + narrador + narradores - organizer - organizers + organizador + organizadores performer performers - producer - producers + produtor + produtores - writer - writers + escritor + escritores - series creator - series creators + criador da série + criadores da série diretor @@ -543,11 +546,11 @@ with guest hosted by narrated by - organized by - performed by - produced by - written by - created by + organizado por + performado por + produzido por + escrito por + criado por por dirigido por organizado por From 32dc9e52c5e886686cb2b3ef382848f3810ecaca Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Sat, 1 Apr 2023 13:20:06 +0200 Subject: [PATCH 63/77] Convert BibField from class to record --- .../customentrytypes/EntryTypeViewModel.java | 8 ++++---- .../jabref/gui/entryeditor/OtherFieldsTab.java | 2 +- .../jabref/logic/bibtex/BibEntryWriter.java | 2 +- .../jabref/logic/database/DuplicateCheck.java | 2 +- .../logic/integrity/NoBibtexFieldChecker.java | 2 +- .../org/jabref/model/entry/BibEntryType.java | 18 +++++++++--------- .../model/entry/BibEntryTypeBuilder.java | 2 +- .../model/entry/BibEntryTypesManager.java | 2 +- .../org/jabref/model/entry/field/BibField.java | 18 +----------------- .../org/jabref/model/entry/BibEntryTest.java | 4 ++-- 10 files changed, 22 insertions(+), 38 deletions(-) diff --git a/src/main/java/org/jabref/gui/customentrytypes/EntryTypeViewModel.java b/src/main/java/org/jabref/gui/customentrytypes/EntryTypeViewModel.java index 1faca05630a..0e176c0bb2e 100644 --- a/src/main/java/org/jabref/gui/customentrytypes/EntryTypeViewModel.java +++ b/src/main/java/org/jabref/gui/customentrytypes/EntryTypeViewModel.java @@ -22,10 +22,10 @@ public EntryTypeViewModel(BibEntryType entryType, Predicate isMultiline) this.entryType.set(entryType); List allFieldsForType = entryType.getAllBibFields() - .stream().map(bibField -> new FieldViewModel(bibField.getField(), - entryType.isRequired(bibField.getField()), - bibField.getPriority(), - isMultiline.test(bibField.getField()))) + .stream().map(bibField -> new FieldViewModel(bibField.field(), + entryType.isRequired(bibField.field()), + bibField.priority(), + isMultiline.test(bibField.field()))) .collect(Collectors.toList()); fields = FXCollections.observableArrayList((allFieldsForType)); } diff --git a/src/main/java/org/jabref/gui/entryeditor/OtherFieldsTab.java b/src/main/java/org/jabref/gui/entryeditor/OtherFieldsTab.java index 50a8066d2cd..180ea465c53 100644 --- a/src/main/java/org/jabref/gui/entryeditor/OtherFieldsTab.java +++ b/src/main/java/org/jabref/gui/entryeditor/OtherFieldsTab.java @@ -75,7 +75,7 @@ protected Set determineFieldsToShow(BibEntry entry) { Set otherFields = entry.getFields().stream().filter(field -> !allKnownFields.contains(field)).collect(Collectors.toCollection(LinkedHashSet::new)); otherFields.removeAll(entryType.get().getDeprecatedFields(mode)); - otherFields.removeAll(entryType.get().getOptionalFields().stream().map(BibField::getField).collect(Collectors.toSet())); + otherFields.removeAll(entryType.get().getOptionalFields().stream().map(BibField::field).collect(Collectors.toSet())); otherFields.remove(InternalField.KEY_FIELD); otherFields.removeAll(customTabFieldNames); return otherFields; diff --git a/src/main/java/org/jabref/logic/bibtex/BibEntryWriter.java b/src/main/java/org/jabref/logic/bibtex/BibEntryWriter.java index 4632d13cc3d..11ebd5ffebe 100644 --- a/src/main/java/org/jabref/logic/bibtex/BibEntryWriter.java +++ b/src/main/java/org/jabref/logic/bibtex/BibEntryWriter.java @@ -117,7 +117,7 @@ private void writeRequiredFieldsFirstRemainingFieldsSecond(BibEntry entry, BibWr List optionalFields = type.get() .getOptionalFields() .stream() - .map(BibField::getField) + .map(BibField::field) .sorted(Comparator.comparing(Field::getName)) .collect(Collectors.toList()); diff --git a/src/main/java/org/jabref/logic/database/DuplicateCheck.java b/src/main/java/org/jabref/logic/database/DuplicateCheck.java index b2053c21120..c665fe5aec9 100644 --- a/src/main/java/org/jabref/logic/database/DuplicateCheck.java +++ b/src/main/java/org/jabref/logic/database/DuplicateCheck.java @@ -123,7 +123,7 @@ private static boolean compareOptionalFields(final BibEntryType type, if (optionalFields.isEmpty()) { return req[0] >= DuplicateCheck.DUPLICATE_THRESHOLD; } - final double[] opt = DuplicateCheck.compareFieldSet(optionalFields.stream().map(BibField::getField).collect(Collectors.toSet()), one, two); + final double[] opt = DuplicateCheck.compareFieldSet(optionalFields.stream().map(BibField::field).collect(Collectors.toSet()), one, two); final double numerator = (DuplicateCheck.REQUIRED_WEIGHT * req[0] * req[1]) + (opt[0] * opt[1]); final double denominator = (req[1] * DuplicateCheck.REQUIRED_WEIGHT) + opt[1]; final double totValue = numerator / denominator; diff --git a/src/main/java/org/jabref/logic/integrity/NoBibtexFieldChecker.java b/src/main/java/org/jabref/logic/integrity/NoBibtexFieldChecker.java index 7d46cb42052..feb29ad750d 100644 --- a/src/main/java/org/jabref/logic/integrity/NoBibtexFieldChecker.java +++ b/src/main/java/org/jabref/logic/integrity/NoBibtexFieldChecker.java @@ -22,7 +22,7 @@ private Set getAllBiblatexOnlyFields() { return BiblatexEntryTypeDefinitions.ALL.stream() .flatMap(type -> type.getAllBibFields().stream()) .filter(field -> !allBibtexFields.contains(field)) - .map(BibField::getField) + .map(BibField::field) // these fields are displayed by JabRef as default .filter(field -> !field.equals(StandardField.ABSTRACT)) .filter(field -> !field.equals(StandardField.COMMENT)) diff --git a/src/main/java/org/jabref/model/entry/BibEntryType.java b/src/main/java/org/jabref/model/entry/BibEntryType.java index c8eb7b92b6e..d08221e0e61 100644 --- a/src/main/java/org/jabref/model/entry/BibEntryType.java +++ b/src/main/java/org/jabref/model/entry/BibEntryType.java @@ -38,7 +38,7 @@ public EntryType getType() { */ public Set getOptionalFields() { return getAllBibFields().stream() - .filter(field -> !isRequired(field.getField())) + .filter(field -> !isRequired(field.field())) .collect(Collectors.toCollection(LinkedHashSet::new)); } @@ -66,20 +66,20 @@ public Set getAllBibFields() { } public Set getAllFields() { - return fields.stream().map(BibField::getField).collect(Collectors.toCollection(LinkedHashSet::new)); + return fields.stream().map(BibField::field).collect(Collectors.toCollection(LinkedHashSet::new)); } public Set getPrimaryOptionalFields() { return getOptionalFields().stream() - .filter(field -> field.getPriority() == FieldPriority.IMPORTANT) - .map(BibField::getField) + .filter(field -> field.priority() == FieldPriority.IMPORTANT) + .map(BibField::field) .collect(Collectors.toCollection(LinkedHashSet::new)); } public Set getSecondaryOptionalFields() { return getOptionalFields().stream() - .filter(field -> field.getPriority() == FieldPriority.DETAIL) - .map(BibField::getField) + .filter(field -> field.priority() == FieldPriority.DETAIL) + .map(BibField::field) .collect(Collectors.toCollection(LinkedHashSet::new)); } @@ -112,9 +112,9 @@ public Set getSecondaryOptionalNotDeprecatedFields(BibDatabaseMode mode) private Set getOptionalFieldsAndAliases() { Set optionalFieldsAndAliases = new LinkedHashSet<>(getOptionalFields().size()); for (BibField field : getOptionalFields()) { - optionalFieldsAndAliases.add(field.getField()); - if (EntryConverter.FIELD_ALIASES_BIBTEX_TO_BIBLATEX.containsKey(field.getField())) { - optionalFieldsAndAliases.add(field.getField()); + optionalFieldsAndAliases.add(field.field()); + if (EntryConverter.FIELD_ALIASES_BIBTEX_TO_BIBLATEX.containsKey(field.field())) { + optionalFieldsAndAliases.add(field.field()); } } return optionalFieldsAndAliases; diff --git a/src/main/java/org/jabref/model/entry/BibEntryTypeBuilder.java b/src/main/java/org/jabref/model/entry/BibEntryTypeBuilder.java index 08f294bc3e1..ddc510d7d4b 100644 --- a/src/main/java/org/jabref/model/entry/BibEntryTypeBuilder.java +++ b/src/main/java/org/jabref/model/entry/BibEntryTypeBuilder.java @@ -29,7 +29,7 @@ public BibEntryTypeBuilder withType(EntryType type) { } public BibEntryTypeBuilder withImportantFields(Set newFields) { - return withImportantFields(newFields.stream().map(BibField::getField).collect(Collectors.toCollection(LinkedHashSet::new))); + return withImportantFields(newFields.stream().map(BibField::field).collect(Collectors.toCollection(LinkedHashSet::new))); } public BibEntryTypeBuilder withImportantFields(Collection newFields) { diff --git a/src/main/java/org/jabref/model/entry/BibEntryTypesManager.java b/src/main/java/org/jabref/model/entry/BibEntryTypesManager.java index 39e9f7ecdb3..81183b2bd5e 100644 --- a/src/main/java/org/jabref/model/entry/BibEntryTypesManager.java +++ b/src/main/java/org/jabref/model/entry/BibEntryTypesManager.java @@ -61,7 +61,7 @@ public static String serialize(BibEntryType entryType) { builder.append(FieldFactory.serializeFieldsList( entryType.getOptionalFields() .stream() - .map(BibField::getField) + .map(BibField::field) .collect(Collectors.toList()))); builder.append("]"); return builder.toString(); diff --git a/src/main/java/org/jabref/model/entry/field/BibField.java b/src/main/java/org/jabref/model/entry/field/BibField.java index 3aefdd9ec29..4d0729e4f4a 100644 --- a/src/main/java/org/jabref/model/entry/field/BibField.java +++ b/src/main/java/org/jabref/model/entry/field/BibField.java @@ -2,23 +2,7 @@ import java.util.Objects; -public class BibField implements Comparable { - - private final FieldPriority priority; - private final Field field; - - public BibField(Field field, FieldPriority priority) { - this.priority = priority; - this.field = field; - } - - public Field getField() { - return field; - } - - public FieldPriority getPriority() { - return priority; - } +public record BibField(Field field, FieldPriority priority) implements Comparable { @Override public boolean equals(Object o) { diff --git a/src/test/java/org/jabref/model/entry/BibEntryTest.java b/src/test/java/org/jabref/model/entry/BibEntryTest.java index a27c2ccdc61..784f5f03431 100644 --- a/src/test/java/org/jabref/model/entry/BibEntryTest.java +++ b/src/test/java/org/jabref/model/entry/BibEntryTest.java @@ -64,7 +64,7 @@ void getFieldIsCaseInsensitive() throws Exception { @Test void getFieldWorksWithBibFieldAsWell() throws Exception { entry.setField(StandardField.AUTHOR, "value"); - assertEquals(Optional.of("value"), entry.getField(new BibField(StandardField.AUTHOR, FieldPriority.IMPORTANT).getField())); + assertEquals(Optional.of("value"), entry.getField(new BibField(StandardField.AUTHOR, FieldPriority.IMPORTANT).field())); } @Test @@ -80,7 +80,7 @@ void setFieldLeadsToAChangedEntry() throws Exception { @Test void setFieldWorksWithBibFieldAsWell() throws Exception { - entry.setField(new BibField(StandardField.AUTHOR, FieldPriority.IMPORTANT).getField(), "value"); + entry.setField(new BibField(StandardField.AUTHOR, FieldPriority.IMPORTANT).field(), "value"); assertEquals(Optional.of("value"), entry.getField(StandardField.AUTHOR)); } From 6326d360fd1cf227262fedbe9c7b06175943c6c6 Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Sat, 1 Apr 2023 13:20:13 +0200 Subject: [PATCH 64/77] Add links in JavaDoc --- .../model/entry/types/BibtexEntryTypeDefinitions.java | 6 ++---- .../org/jabref/model/entry/types/StandardEntryType.java | 8 +++++++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/jabref/model/entry/types/BibtexEntryTypeDefinitions.java b/src/main/java/org/jabref/model/entry/types/BibtexEntryTypeDefinitions.java index 8ee79a27c30..594301642b7 100644 --- a/src/main/java/org/jabref/model/entry/types/BibtexEntryTypeDefinitions.java +++ b/src/main/java/org/jabref/model/entry/types/BibtexEntryTypeDefinitions.java @@ -9,10 +9,8 @@ import org.jabref.model.entry.field.StandardField; /** - * This class represents all supported BibTex entry types. - *

- * Article, Book, Booklet, Conference, Inbook, Incollection, Inproceedings, - * Manual, Mastersthesis, Misc, Phdthesis, Proceedings, Techreport, Unpublished + * This class represents all supported BibTeX entry types. + * The BibLaTeX entry types are defined at {@link BiblatexEntryTypeDefinitions}. */ public class BibtexEntryTypeDefinitions { /** diff --git a/src/main/java/org/jabref/model/entry/types/StandardEntryType.java b/src/main/java/org/jabref/model/entry/types/StandardEntryType.java index 6f6f91ac6a5..6f5d11b1160 100644 --- a/src/main/java/org/jabref/model/entry/types/StandardEntryType.java +++ b/src/main/java/org/jabref/model/entry/types/StandardEntryType.java @@ -2,6 +2,12 @@ import java.util.Locale; +/** + * Defines standard entry types as defined by BibTeX and BibLaTeX. + * At {@link BibtexEntryTypeDefinitions}, the required and optional fields for each type (for BibTeX) is defined. + * The BibLaTeX entry types are defined at {@link BiblatexEntryTypeDefinitions}. + * More reading on BibTeX and its fields is collected at JabRef's documentation. + */ public enum StandardEntryType implements EntryType { // BibTeX Article("Article"), @@ -19,7 +25,7 @@ public enum StandardEntryType implements EntryType { Proceedings("Proceedings"), TechReport("TechReport"), Unpublished("Unpublished"), - // Biblatex + // BibLaTeX BookInBook("BookInBook"), InReference("InReference"), MvBook("MvBook"), From a659d14177d36c114ca9f22221817f1c4f0336f0 Mon Sep 17 00:00:00 2001 From: Christoph Date: Sat, 1 Apr 2023 14:48:38 +0200 Subject: [PATCH 65/77] Update citeproc to beta (#9721) Co-authored-by: Carl Christian Snethlage <50491877+calixtus@users.noreply.github.com> --- build.gradle | 6 +++--- .../citationstyle/CitationStyleGeneratorTest.java | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/build.gradle b/build.gradle index 50aff47f9be..797ae2a52e8 100644 --- a/build.gradle +++ b/build.gradle @@ -137,8 +137,8 @@ dependencies { implementation 'io.github.java-diff-utils:java-diff-utils:4.12' implementation 'info.debatty:java-string-similarity:2.0.0' - antlr4 'org.antlr:antlr4:4.9.3' - implementation 'org.antlr:antlr4-runtime:4.9.3' + antlr4 'org.antlr:antlr4:4.12.0' + implementation 'org.antlr:antlr4-runtime:4.12.0' implementation group: 'org.eclipse.jgit', name: 'org.eclipse.jgit', version: '6.5.0.202303070854-r' @@ -182,7 +182,7 @@ dependencies { implementation "org.tinylog:slf4j-tinylog:2.6.1" implementation "org.tinylog:tinylog-impl:2.6.1" - implementation 'de.undercouch:citeproc-java:3.0.0-alpha.6' + implementation 'de.undercouch:citeproc-java:3.0.0-beta.2' // jakarta.activation is already dependency of glassfish implementation group: 'jakarta.xml.bind', name: 'jakarta.xml.bind-api', version: '3.0.1' diff --git a/src/test/java/org/jabref/logic/citationstyle/CitationStyleGeneratorTest.java b/src/test/java/org/jabref/logic/citationstyle/CitationStyleGeneratorTest.java index cf01446944a..a6694088d99 100644 --- a/src/test/java/org/jabref/logic/citationstyle/CitationStyleGeneratorTest.java +++ b/src/test/java/org/jabref/logic/citationstyle/CitationStyleGeneratorTest.java @@ -34,7 +34,7 @@ void testACMCitation() { // if the acm-siggraph.csl citation style changes this has to be modified String expected = "

" - + "Smith, B., Jones, B., and Williams, J. 2016-07. Title of the test entry. BibTeX Journal 34, 3, 45–67." + + "Smith, B., Jones, B., and Williams, J. 2016. Title of the test entry. BibTeX Journal 34, 3, 45–67." + "
\n" + ""; @@ -51,7 +51,7 @@ void testAPACitation() { // if the apa-7th-citation.csl citation style changes this has to be modified String expected = "
" - + "Smith, B., Jones, B., & Williams, J. (2016-07). Title of the test entry. BibTeX Journal, 34(3), 45–67. https://doi.org/10.1001/bla.blubb" + + "Smith, B., Jones, B., & Williams, J. (2016). Title of the test entry. BibTeX Journal, 34(3), 45–67. https://doi.org/10.1001/bla.blubb" + "
\n" + ""; @@ -94,7 +94,7 @@ void testMissingCitationStyle() { @Test void testHtmlFormat() { String expectedCitation = "
\n" + - "
[1]
B. Smith, B. Jones, and J. Williams, “Title of the test entry,” BibTeX Journal, vol. 34, no. 3, pp. 45–67, 2016-07, doi: 10.1001/bla.blubb.
\n" + + "
[1]
B. Smith, B. Jones, and J. Williams, “Title of the test entry,” BibTeX Journal, vol. 34, no. 3, pp. 45–67, Jul. 2016, doi: 10.1001/bla.blubb.
\n" + "
\n"; BibEntry entry = TestEntry.getTestEntry(); @@ -107,7 +107,7 @@ void testHtmlFormat() { @Test void testTextFormat() { - String expectedCitation = "[1]B. Smith, B. Jones, and J. Williams, “Title of the test entry,” BibTeX Journal, vol. 34, no. 3, pp. 45–67, 2016-07, doi: 10.1001/bla.blubb.\n"; + String expectedCitation = "[1]B. Smith, B. Jones, and J. Williams, “Title of the test entry,” BibTeX Journal, vol. 34, no. 3, pp. 45–67, Jul. 2016, doi: 10.1001/bla.blubb.\n"; BibEntry entry = TestEntry.getTestEntry(); String style = CitationStyle.getDefault().getSource(); @@ -133,7 +133,7 @@ void testHandleDiacritics() { @Test void testHandleAmpersand() { - String expectedCitation = "[1]B. Smith, B. Jones, and J. Williams, “Famous quote: “&TitleTest&” - that is it,” BibTeX Journal, vol. 34, no. 3, pp. 45–67, 2016-07, doi: 10.1001/bla.blubb.\n"; + String expectedCitation = "[1]B. Smith, B. Jones, and J. Williams, “Famous quote: “&TitleTest&” - that is it,” BibTeX Journal, vol. 34, no. 3, pp. 45–67, Jul. 2016, doi: 10.1001/bla.blubb.\n"; BibEntry entry = TestEntry.getTestEntry(); entry.setField(StandardField.TITLE, "Famous quote: “&TitleTest&” - that is it"); String style = CitationStyle.getDefault().getSource(); @@ -160,7 +160,7 @@ void testHandleCrossRefFields() { .withField(StandardField.YEAR, "2021") .withField(StandardField.ADDRESS, "Somewhere"); - String expectedCitation = "[1]B. Smith, “An article,” J. Jones, Ed. Somewhere: Great Publisher, 2021, pp. 1–10.\n"; + String expectedCitation = "[1]B. Smith, “An article,” J. Jones, Ed., Somewhere: Great Publisher, 2021, pp. 1–10.\n"; BibDatabaseContext bibDatabaseContext = new BibDatabaseContext(new BibDatabase(List.of(firstEntry, secondEntry))); String style = CitationStyle.getDefault().getSource(); From fcfa16ff1e61a17fa848cb7e2f387bffc25aa2fb Mon Sep 17 00:00:00 2001 From: dragos222 Date: Sat, 1 Apr 2023 19:25:28 +0200 Subject: [PATCH 66/77] Store preference as boolean instead of enum --- .../toolbar/ThreeWayMergeToolbar.java | 15 ++++---- .../jabref/preferences/GuiPreferences.java | 36 +++++++++---------- .../jabref/preferences/JabRefPreferences.java | 16 ++++----- 3 files changed, 35 insertions(+), 32 deletions(-) diff --git a/src/main/java/org/jabref/gui/mergeentries/newmergedialog/toolbar/ThreeWayMergeToolbar.java b/src/main/java/org/jabref/gui/mergeentries/newmergedialog/toolbar/ThreeWayMergeToolbar.java index 7ad12b62745..d0945610252 100644 --- a/src/main/java/org/jabref/gui/mergeentries/newmergedialog/toolbar/ThreeWayMergeToolbar.java +++ b/src/main/java/org/jabref/gui/mergeentries/newmergedialog/toolbar/ThreeWayMergeToolbar.java @@ -24,6 +24,7 @@ import com.tobiasdiez.easybind.EasyBind; import com.tobiasdiez.easybind.EasyBinding; import jakarta.inject.Inject; +import org.apache.commons.lang3.builder.Diff; public class ThreeWayMergeToolbar extends AnchorPane { @FXML @@ -67,7 +68,8 @@ public ThreeWayMergeToolbar() { public void initialize() { showDiff = EasyBind.map(plainTextOrDiffComboBox.valueProperty(), plainTextOrDiff -> plainTextOrDiff == PlainTextOrDiff.Diff); plainTextOrDiffComboBox.getItems().addAll(PlainTextOrDiff.values()); - plainTextOrDiffComboBox.getSelectionModel().select(preferencesService.getGuiPreferences().getMergePlainTextOrDiff()); + PlainTextOrDiff plainTextOrDiffPreference = preferencesService.getGuiPreferences().getMergeShouldShowDiff() ? PlainTextOrDiff.Diff : PlainTextOrDiff.PLAIN_TEXT; + plainTextOrDiffComboBox.getSelectionModel().select(plainTextOrDiffPreference); plainTextOrDiffComboBox.setConverter(new StringConverter<>() { @Override @@ -83,7 +85,8 @@ public PlainTextOrDiff fromString(String string) { diffViewComboBox.disableProperty().bind(notShowDiffProperty()); diffViewComboBox.getItems().addAll(DiffView.values()); - diffViewComboBox.getSelectionModel().select(preferencesService.getGuiPreferences().getMergeDiffView()); + DiffView diffViewPreference = preferencesService.getGuiPreferences().getMergeShouldShowUnifiedDiff() ? DiffView.UNIFIED : DiffView.SPLIT; + diffViewComboBox.getSelectionModel().select(diffViewPreference); diffViewComboBox.setConverter(new StringConverter<>() { @Override @@ -109,8 +112,8 @@ public DiffView fromString(String string) { })); diffHighlightingMethodToggleGroup.selectToggle(preferencesService.getGuiPreferences().getMergeHighlightWords() ? highlightWordsRadioButton : highlightCharactersRadioButtons); - plainTextOrDiffComboBox.valueProperty().set(preferencesService.getGuiPreferences().getMergePlainTextOrDiff()); - diffViewComboBox.valueProperty().set(preferencesService.getGuiPreferences().getMergeDiffView()); + plainTextOrDiffComboBox.valueProperty().set(plainTextOrDiffPreference); + diffViewComboBox.valueProperty().set(diffViewPreference); onlyShowChangedFieldsCheck.selectedProperty().bindBidirectional(preferencesService.getGuiPreferences().mergeShowChangedFieldOnlyProperty()); onlyShowChangedFields.bind(onlyShowChangedFieldsCheck.selectedProperty()); @@ -181,8 +184,8 @@ public void setOnSelectRightEntryValuesButtonClicked(Runnable onClick) { } public void saveGuiPreferences() { - preferencesService.getGuiPreferences().setMergePlainTextOrDiff(plainTextOrDiffComboBox.getValue()); - preferencesService.getGuiPreferences().setMergeDiffView(diffViewComboBox.getValue()); + preferencesService.getGuiPreferences().setMergeShouldShowDiff(plainTextOrDiffComboBox.getValue() == PlainTextOrDiff.Diff); + preferencesService.getGuiPreferences().setMergeShouldShowUnifiedDiff(diffViewComboBox.getValue() == DiffView.UNIFIED); boolean highlightWordsRadioButtonValue = diffHighlightingMethodToggleGroup.getSelectedToggle().equals(highlightWordsRadioButton); preferencesService.getGuiPreferences().setMergeHighlightWords(highlightWordsRadioButtonValue); diff --git a/src/main/java/org/jabref/preferences/GuiPreferences.java b/src/main/java/org/jabref/preferences/GuiPreferences.java index 6da41ec6111..307469b35c7 100644 --- a/src/main/java/org/jabref/preferences/GuiPreferences.java +++ b/src/main/java/org/jabref/preferences/GuiPreferences.java @@ -35,8 +35,8 @@ public class GuiPreferences { private final StringProperty lastSelectedIdBasedFetcher; private final ObjectProperty mergeDiffMode; - private final ObjectProperty mergePlainTextOrDiff; - private final ObjectProperty mergeDiffView; + private final BooleanProperty mergeShouldShowDiff; + private final BooleanProperty mergeShouldShowUnifiedDiff; private final BooleanProperty mergeHighlightWords; private final BooleanProperty mergeShowChangedFieldsOnly; private final DoubleProperty sidePaneWidth; @@ -51,8 +51,8 @@ public GuiPreferences(double positionX, FileHistory fileHistory, String lastSelectedIdBasedFetcher, DiffMode mergeDiffMode, - PlainTextOrDiff mergePlainTextOrDiff, - DiffView mergeDiffView, + boolean mergeShouldShowDiff, + boolean mergeShouldShowUnifiedDiff, boolean mergeHighlightWords, double sidePaneWidth, boolean mergeShowChangedFieldsOnly) { @@ -65,8 +65,8 @@ public GuiPreferences(double positionX, this.lastFocusedFile = new SimpleObjectProperty<>(lastFocusedFile); this.lastSelectedIdBasedFetcher = new SimpleStringProperty(lastSelectedIdBasedFetcher); this.mergeDiffMode = new SimpleObjectProperty<>(mergeDiffMode); - this.mergePlainTextOrDiff = new SimpleObjectProperty<>(mergePlainTextOrDiff); - this.mergeDiffView = new SimpleObjectProperty<>(mergeDiffView); + this.mergeShouldShowDiff = new SimpleBooleanProperty(mergeShouldShowDiff); + this.mergeShouldShowUnifiedDiff = new SimpleBooleanProperty(mergeShouldShowUnifiedDiff); this.mergeHighlightWords = new SimpleBooleanProperty(mergeHighlightWords); this.sidePaneWidth = new SimpleDoubleProperty(sidePaneWidth); @@ -182,28 +182,28 @@ public void setMergeDiffMode(DiffMode mergeDiffMode) { this.mergeDiffMode.set(mergeDiffMode); } - public PlainTextOrDiff getMergePlainTextOrDiff() { - return mergePlainTextOrDiff.get(); + public boolean getMergeShouldShowDiff() { + return mergeShouldShowDiff.get(); } - public ObjectProperty mergePlainTextOrDiffProperty() { - return mergePlainTextOrDiff; + public BooleanProperty mergeShouldShowDiffProperty() { + return mergeShouldShowDiff; } - public void setMergePlainTextOrDiff(PlainTextOrDiff mergePlainTextOrDiff) { - this.mergePlainTextOrDiff.set(mergePlainTextOrDiff); + public void setMergeShouldShowDiff(boolean mergeShouldShowDiff) { + this.mergeShouldShowDiff.set(mergeShouldShowDiff); } - public DiffView getMergeDiffView() { - return mergeDiffView.get(); + public boolean getMergeShouldShowUnifiedDiff() { + return mergeShouldShowUnifiedDiff.get(); } - public ObjectProperty mergeDiffViewProperty() { - return mergeDiffView; + public BooleanProperty mergeShouldShowUnifiedDiffProperty() { + return mergeShouldShowUnifiedDiff; } - public void setMergeDiffView(DiffView mergeDiffView) { - this.mergeDiffView.set(mergeDiffView); + public void setMergeShouldShowUnifiedDiff(boolean mergeShouldShowUnifiedDiff) { + this.mergeShouldShowUnifiedDiff.set(mergeShouldShowUnifiedDiff); } public boolean getMergeHighlightWords() { diff --git a/src/main/java/org/jabref/preferences/JabRefPreferences.java b/src/main/java/org/jabref/preferences/JabRefPreferences.java index 89aa914c1bd..dff4f6a1589 100644 --- a/src/main/java/org/jabref/preferences/JabRefPreferences.java +++ b/src/main/java/org/jabref/preferences/JabRefPreferences.java @@ -240,8 +240,8 @@ public class JabRefPreferences implements PreferencesService { // merge related public static final String MERGE_ENTRIES_DIFF_MODE = "mergeEntriesDiffMode"; - public static final String MERGE_ENTRIES_PLAIN_TEXT_OR_DIFF = "mergeEntriesPlainTextOrDiff"; - public static final String MERGE_ENTRIES_DIFF_VIEW = "mergeEntriesDiffView"; + public static final String MERGE_ENTRIES_SHOULD_SHOW_DIFF = "mergeEntriesShouldShowDiff"; + public static final String MERGE_ENTRIES_SHOULD_SHOW_UNIFIED_DIFF = "mergeEntriesShouldShowUnifiedDiff"; public static final String MERGE_ENTRIES_HIGHLIGHT_WORDS = "mergeEntriesHighlightWords"; @@ -594,8 +594,8 @@ private JabRefPreferences() { defaults.put(DEFAULT_SHOW_SOURCE, Boolean.FALSE); defaults.put(MERGE_ENTRIES_DIFF_MODE, DiffMode.WORD.name()); - defaults.put(MERGE_ENTRIES_PLAIN_TEXT_OR_DIFF, PlainTextOrDiff.Diff.name()); - defaults.put(MERGE_ENTRIES_DIFF_VIEW, DiffView.UNIFIED.name()); + defaults.put(MERGE_ENTRIES_SHOULD_SHOW_DIFF, Boolean.TRUE); + defaults.put(MERGE_ENTRIES_SHOULD_SHOW_UNIFIED_DIFF, Boolean.TRUE); defaults.put(MERGE_ENTRIES_HIGHLIGHT_WORDS, Boolean.TRUE); defaults.put(MERGE_SHOW_ONLY_CHANGED_FIELDS, Boolean.FALSE); @@ -2520,8 +2520,8 @@ public GuiPreferences getGuiPreferences() { getFileHistory(), get(ID_ENTRY_GENERATOR), DiffMode.parse(get(MERGE_ENTRIES_DIFF_MODE)), - PlainTextOrDiff.parse(get(MERGE_ENTRIES_PLAIN_TEXT_OR_DIFF)), - DiffView.parse(get(MERGE_ENTRIES_DIFF_VIEW)), + getBoolean(MERGE_ENTRIES_SHOULD_SHOW_DIFF), + getBoolean(MERGE_ENTRIES_SHOULD_SHOW_UNIFIED_DIFF), getBoolean(MERGE_ENTRIES_HIGHLIGHT_WORDS), getDouble(SIDE_PANE_WIDTH), getBoolean(MERGE_SHOW_ONLY_CHANGED_FIELDS)); @@ -2548,8 +2548,8 @@ public GuiPreferences getGuiPreferences() { guiPreferences.getFileHistory().addListener((InvalidationListener) change -> storeFileHistory(guiPreferences.getFileHistory())); EasyBind.listen(guiPreferences.lastSelectedIdBasedFetcherProperty(), (obs, oldValue, newValue) -> put(ID_ENTRY_GENERATOR, newValue)); EasyBind.listen(guiPreferences.mergeDiffModeProperty(), (obs, oldValue, newValue) -> put(MERGE_ENTRIES_DIFF_MODE, newValue.name())); - EasyBind.listen(guiPreferences.mergePlainTextOrDiffProperty(), (obs, oldValue, newValue) -> put(MERGE_ENTRIES_PLAIN_TEXT_OR_DIFF, newValue.name())); - EasyBind.listen(guiPreferences.mergeDiffViewProperty(), (obs, oldValue, newValue) -> put(MERGE_ENTRIES_DIFF_VIEW, newValue.name())); + EasyBind.listen(guiPreferences.mergeShouldShowDiffProperty(), (obs, oldValue, newValue) -> putBoolean(MERGE_ENTRIES_SHOULD_SHOW_DIFF, newValue)); + EasyBind.listen(guiPreferences.mergeShouldShowUnifiedDiffProperty(), (obs, oldValue, newValue) -> putBoolean(MERGE_ENTRIES_SHOULD_SHOW_UNIFIED_DIFF, newValue)); EasyBind.listen(guiPreferences.mergeHighlightWordsProperty(), (obs, oldValue, newValue) -> putBoolean(MERGE_ENTRIES_HIGHLIGHT_WORDS, newValue)); EasyBind.listen(guiPreferences.sidePaneWidthProperty(), (obs, oldValue, newValue) -> putDouble(SIDE_PANE_WIDTH, newValue.doubleValue())); EasyBind.listen(guiPreferences.mergeShowChangedFieldOnlyProperty(), (obs, oldValue, newValue) -> putBoolean(MERGE_SHOW_ONLY_CHANGED_FIELDS, newValue)); From cfc58308fc2d05caeb5d8af10dc9d307947e6b04 Mon Sep 17 00:00:00 2001 From: dragos222 Date: Sat, 1 Apr 2023 19:55:15 +0200 Subject: [PATCH 67/77] Save three way merge view toolbar preferences in duplicateslverdialog --- .../gui/duplicationFinder/DuplicateResolverDialog.java | 9 +++++++++ .../newmergedialog/toolbar/ThreeWayMergeToolbar.java | 1 - src/main/java/org/jabref/preferences/GuiPreferences.java | 2 -- .../java/org/jabref/preferences/JabRefPreferences.java | 2 -- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/jabref/gui/duplicationFinder/DuplicateResolverDialog.java b/src/main/java/org/jabref/gui/duplicationFinder/DuplicateResolverDialog.java index 205e4df75de..520aa451a44 100644 --- a/src/main/java/org/jabref/gui/duplicationFinder/DuplicateResolverDialog.java +++ b/src/main/java/org/jabref/gui/duplicationFinder/DuplicateResolverDialog.java @@ -124,14 +124,19 @@ private void init(BibEntry one, BibEntry two, DuplicateResolverType type) { stateManager.setDialogWindowState(getClass().getSimpleName(), new DialogWindowState(this.getX(), this.getY(), this.getDialogPane().getHeight(), this.getDialogPane().getWidth())); if (button.equals(first)) { + saveThreeWayMergeToolbarPreferences(); return DuplicateResolverResult.KEEP_LEFT; } else if (button.equals(second)) { + saveThreeWayMergeToolbarPreferences(); return DuplicateResolverResult.KEEP_RIGHT; } else if (button.equals(both)) { + saveThreeWayMergeToolbarPreferences(); return DuplicateResolverResult.KEEP_BOTH; } else if (button.equals(merge)) { + saveThreeWayMergeToolbarPreferences(); return DuplicateResolverResult.KEEP_MERGE; } else if (button.equals(removeExact)) { + saveThreeWayMergeToolbarPreferences(); return DuplicateResolverResult.AUTOREMOVE_EXACT; } return null; @@ -144,6 +149,10 @@ private void init(BibEntry one, BibEntry two, DuplicateResolverType type) { getDialogPane().setContent(borderPane); } + private void saveThreeWayMergeToolbarPreferences(){ + threeWayMerge.saveToolbarGuiPreferences(); + } + public BibEntry getMergedEntry() { return threeWayMerge.getMergedEntry(); } diff --git a/src/main/java/org/jabref/gui/mergeentries/newmergedialog/toolbar/ThreeWayMergeToolbar.java b/src/main/java/org/jabref/gui/mergeentries/newmergedialog/toolbar/ThreeWayMergeToolbar.java index d0945610252..4485297787c 100644 --- a/src/main/java/org/jabref/gui/mergeentries/newmergedialog/toolbar/ThreeWayMergeToolbar.java +++ b/src/main/java/org/jabref/gui/mergeentries/newmergedialog/toolbar/ThreeWayMergeToolbar.java @@ -24,7 +24,6 @@ import com.tobiasdiez.easybind.EasyBind; import com.tobiasdiez.easybind.EasyBinding; import jakarta.inject.Inject; -import org.apache.commons.lang3.builder.Diff; public class ThreeWayMergeToolbar extends AnchorPane { @FXML diff --git a/src/main/java/org/jabref/preferences/GuiPreferences.java b/src/main/java/org/jabref/preferences/GuiPreferences.java index 307469b35c7..c868ba3d751 100644 --- a/src/main/java/org/jabref/preferences/GuiPreferences.java +++ b/src/main/java/org/jabref/preferences/GuiPreferences.java @@ -15,8 +15,6 @@ import javafx.collections.ObservableList; import org.jabref.gui.mergeentries.DiffMode; -import org.jabref.gui.mergeentries.newmergedialog.toolbar.ThreeWayMergeToolbar.DiffView; -import org.jabref.gui.mergeentries.newmergedialog.toolbar.ThreeWayMergeToolbar.PlainTextOrDiff; import org.jabref.logic.util.io.FileHistory; public class GuiPreferences { diff --git a/src/main/java/org/jabref/preferences/JabRefPreferences.java b/src/main/java/org/jabref/preferences/JabRefPreferences.java index dff4f6a1589..8db213d76c4 100644 --- a/src/main/java/org/jabref/preferences/JabRefPreferences.java +++ b/src/main/java/org/jabref/preferences/JabRefPreferences.java @@ -55,8 +55,6 @@ import org.jabref.gui.maintable.NameDisplayPreferences.AbbreviationStyle; import org.jabref.gui.maintable.NameDisplayPreferences.DisplayStyle; import org.jabref.gui.mergeentries.DiffMode; -import org.jabref.gui.mergeentries.newmergedialog.toolbar.ThreeWayMergeToolbar.DiffView; -import org.jabref.gui.mergeentries.newmergedialog.toolbar.ThreeWayMergeToolbar.PlainTextOrDiff; import org.jabref.gui.push.PushToApplications; import org.jabref.gui.search.SearchDisplayMode; import org.jabref.gui.sidepane.SidePaneType; From db6d569902443731802d6222012e8c42bac8ba02 Mon Sep 17 00:00:00 2001 From: dragos222 Date: Sat, 1 Apr 2023 20:05:22 +0200 Subject: [PATCH 68/77] Fix typo --- .../jabref/gui/duplicationFinder/DuplicateResolverDialog.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/jabref/gui/duplicationFinder/DuplicateResolverDialog.java b/src/main/java/org/jabref/gui/duplicationFinder/DuplicateResolverDialog.java index 520aa451a44..38eb77f7a39 100644 --- a/src/main/java/org/jabref/gui/duplicationFinder/DuplicateResolverDialog.java +++ b/src/main/java/org/jabref/gui/duplicationFinder/DuplicateResolverDialog.java @@ -149,7 +149,7 @@ private void init(BibEntry one, BibEntry two, DuplicateResolverType type) { getDialogPane().setContent(borderPane); } - private void saveThreeWayMergeToolbarPreferences(){ + private void saveThreeWayMergeToolbarPreferences() { threeWayMerge.saveToolbarGuiPreferences(); } From 7b636bfff70a37c77c425f12bacf1fe87d03300a Mon Sep 17 00:00:00 2001 From: dragos222 Date: Sat, 1 Apr 2023 23:16:58 +0200 Subject: [PATCH 69/77] Refactor --- .../duplicationFinder/DuplicateResolverDialog.java | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/jabref/gui/duplicationFinder/DuplicateResolverDialog.java b/src/main/java/org/jabref/gui/duplicationFinder/DuplicateResolverDialog.java index 38eb77f7a39..4e1fb2032e9 100644 --- a/src/main/java/org/jabref/gui/duplicationFinder/DuplicateResolverDialog.java +++ b/src/main/java/org/jabref/gui/duplicationFinder/DuplicateResolverDialog.java @@ -123,20 +123,18 @@ private void init(BibEntry one, BibEntry two, DuplicateResolverType type) { // Updates the window state on button press stateManager.setDialogWindowState(getClass().getSimpleName(), new DialogWindowState(this.getX(), this.getY(), this.getDialogPane().getHeight(), this.getDialogPane().getWidth())); + if (!button.equals(cancel)) { + threeWayMerge.saveToolbarGuiPreferences(); + } if (button.equals(first)) { - saveThreeWayMergeToolbarPreferences(); return DuplicateResolverResult.KEEP_LEFT; } else if (button.equals(second)) { - saveThreeWayMergeToolbarPreferences(); return DuplicateResolverResult.KEEP_RIGHT; } else if (button.equals(both)) { - saveThreeWayMergeToolbarPreferences(); return DuplicateResolverResult.KEEP_BOTH; } else if (button.equals(merge)) { - saveThreeWayMergeToolbarPreferences(); return DuplicateResolverResult.KEEP_MERGE; } else if (button.equals(removeExact)) { - saveThreeWayMergeToolbarPreferences(); return DuplicateResolverResult.AUTOREMOVE_EXACT; } return null; @@ -149,10 +147,6 @@ private void init(BibEntry one, BibEntry two, DuplicateResolverType type) { getDialogPane().setContent(borderPane); } - private void saveThreeWayMergeToolbarPreferences() { - threeWayMerge.saveToolbarGuiPreferences(); - } - public BibEntry getMergedEntry() { return threeWayMerge.getMergedEntry(); } From 9994c57c7c76eaeeb84fdcb40a27d017a53d0bf8 Mon Sep 17 00:00:00 2001 From: Houssem Nasri Date: Sat, 1 Apr 2023 22:45:50 +0100 Subject: [PATCH 70/77] Refactor ThreeWayMergeToolbar --- .../toolbar/ThreeWayMergeToolbar.java | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/jabref/gui/mergeentries/newmergedialog/toolbar/ThreeWayMergeToolbar.java b/src/main/java/org/jabref/gui/mergeentries/newmergedialog/toolbar/ThreeWayMergeToolbar.java index 4485297787c..5f21058cc41 100644 --- a/src/main/java/org/jabref/gui/mergeentries/newmergedialog/toolbar/ThreeWayMergeToolbar.java +++ b/src/main/java/org/jabref/gui/mergeentries/newmergedialog/toolbar/ThreeWayMergeToolbar.java @@ -17,6 +17,7 @@ import org.jabref.gui.mergeentries.newmergedialog.DiffMethod; import org.jabref.gui.mergeentries.newmergedialog.diffhighlighter.DiffHighlighter.BasicDiffMethod; import org.jabref.logic.l10n.Localization; +import org.jabref.preferences.GuiPreferences; import org.jabref.preferences.PreferencesService; import com.airhacks.afterburner.views.ViewLoader; @@ -67,8 +68,6 @@ public ThreeWayMergeToolbar() { public void initialize() { showDiff = EasyBind.map(plainTextOrDiffComboBox.valueProperty(), plainTextOrDiff -> plainTextOrDiff == PlainTextOrDiff.Diff); plainTextOrDiffComboBox.getItems().addAll(PlainTextOrDiff.values()); - PlainTextOrDiff plainTextOrDiffPreference = preferencesService.getGuiPreferences().getMergeShouldShowDiff() ? PlainTextOrDiff.Diff : PlainTextOrDiff.PLAIN_TEXT; - plainTextOrDiffComboBox.getSelectionModel().select(plainTextOrDiffPreference); plainTextOrDiffComboBox.setConverter(new StringConverter<>() { @Override @@ -84,8 +83,6 @@ public PlainTextOrDiff fromString(String string) { diffViewComboBox.disableProperty().bind(notShowDiffProperty()); diffViewComboBox.getItems().addAll(DiffView.values()); - DiffView diffViewPreference = preferencesService.getGuiPreferences().getMergeShouldShowUnifiedDiff() ? DiffView.UNIFIED : DiffView.SPLIT; - diffViewComboBox.getSelectionModel().select(diffViewPreference); diffViewComboBox.setConverter(new StringConverter<>() { @Override @@ -110,12 +107,22 @@ public DiffView fromString(String string) { } })); - diffHighlightingMethodToggleGroup.selectToggle(preferencesService.getGuiPreferences().getMergeHighlightWords() ? highlightWordsRadioButton : highlightCharactersRadioButtons); - plainTextOrDiffComboBox.valueProperty().set(plainTextOrDiffPreference); - diffViewComboBox.valueProperty().set(diffViewPreference); - onlyShowChangedFieldsCheck.selectedProperty().bindBidirectional(preferencesService.getGuiPreferences().mergeShowChangedFieldOnlyProperty()); onlyShowChangedFields.bind(onlyShowChangedFieldsCheck.selectedProperty()); + + loadStoredPreferences(); + } + + private void loadStoredPreferences() { + GuiPreferences guiPreferences = preferencesService.getGuiPreferences(); + + PlainTextOrDiff plainTextOrDiffPreference = guiPreferences.getMergeShouldShowDiff() ? PlainTextOrDiff.Diff : PlainTextOrDiff.PLAIN_TEXT; + plainTextOrDiffComboBox.getSelectionModel().select(plainTextOrDiffPreference); + + DiffView diffViewPreference = guiPreferences.getMergeShouldShowUnifiedDiff() ? DiffView.UNIFIED : DiffView.SPLIT; + diffViewComboBox.getSelectionModel().select(diffViewPreference); + + diffHighlightingMethodToggleGroup.selectToggle(guiPreferences.getMergeHighlightWords() ? highlightWordsRadioButton : highlightCharactersRadioButtons); } public ObjectProperty diffViewProperty() { From b382d39d6b3dac7bf40374ed5cbc8914411e6aeb Mon Sep 17 00:00:00 2001 From: Houssem Nasri Date: Sat, 1 Apr 2023 22:52:52 +0100 Subject: [PATCH 71/77] Save configuration regardless of the action performed (cancel included) - Also changed some names and code structure --- .../DuplicateResolverDialog.java | 4 +--- .../gui/mergeentries/MergeEntriesDialog.java | 2 +- .../newmergedialog/ThreeWayMergeView.java | 4 ++-- .../toolbar/ThreeWayMergeToolbar.java | 20 +++++++++---------- 4 files changed, 14 insertions(+), 16 deletions(-) diff --git a/src/main/java/org/jabref/gui/duplicationFinder/DuplicateResolverDialog.java b/src/main/java/org/jabref/gui/duplicationFinder/DuplicateResolverDialog.java index 4e1fb2032e9..15a27d4f810 100644 --- a/src/main/java/org/jabref/gui/duplicationFinder/DuplicateResolverDialog.java +++ b/src/main/java/org/jabref/gui/duplicationFinder/DuplicateResolverDialog.java @@ -122,10 +122,8 @@ private void init(BibEntry one, BibEntry two, DuplicateResolverType type) { this.setResultConverter(button -> { // Updates the window state on button press stateManager.setDialogWindowState(getClass().getSimpleName(), new DialogWindowState(this.getX(), this.getY(), this.getDialogPane().getHeight(), this.getDialogPane().getWidth())); + threeWayMerge.saveConfiguration(); - if (!button.equals(cancel)) { - threeWayMerge.saveToolbarGuiPreferences(); - } if (button.equals(first)) { return DuplicateResolverResult.KEEP_LEFT; } else if (button.equals(second)) { diff --git a/src/main/java/org/jabref/gui/mergeentries/MergeEntriesDialog.java b/src/main/java/org/jabref/gui/mergeentries/MergeEntriesDialog.java index 1aac777c57e..8be99e1bfee 100644 --- a/src/main/java/org/jabref/gui/mergeentries/MergeEntriesDialog.java +++ b/src/main/java/org/jabref/gui/mergeentries/MergeEntriesDialog.java @@ -36,8 +36,8 @@ private void init() { ButtonType replaceEntries = new ButtonType(Localization.lang("Merge entries"), ButtonBar.ButtonData.OK_DONE); this.getDialogPane().getButtonTypes().setAll(ButtonType.CANCEL, replaceEntries); this.setResultConverter(buttonType -> { + threeWayMergeView.saveConfiguration(); if (buttonType.equals(replaceEntries)) { - threeWayMergeView.saveToolbarGuiPreferences(); return new EntriesMergeResult(one, two, threeWayMergeView.getLeftEntry(), threeWayMergeView.getRightEntry(), threeWayMergeView.getMergedEntry()); } else { return null; diff --git a/src/main/java/org/jabref/gui/mergeentries/newmergedialog/ThreeWayMergeView.java b/src/main/java/org/jabref/gui/mergeentries/newmergedialog/ThreeWayMergeView.java index 22a5fb78e21..fd2b1b3105f 100644 --- a/src/main/java/org/jabref/gui/mergeentries/newmergedialog/ThreeWayMergeView.java +++ b/src/main/java/org/jabref/gui/mergeentries/newmergedialog/ThreeWayMergeView.java @@ -192,7 +192,7 @@ public BibEntry getRightEntry() { return viewModel.getRightEntry(); } - public void saveToolbarGuiPreferences() { - toolbar.saveGuiPreferences(); + public void saveConfiguration() { + toolbar.saveToolbarConfiguration(); } } diff --git a/src/main/java/org/jabref/gui/mergeentries/newmergedialog/toolbar/ThreeWayMergeToolbar.java b/src/main/java/org/jabref/gui/mergeentries/newmergedialog/toolbar/ThreeWayMergeToolbar.java index 5f21058cc41..03a595741e5 100644 --- a/src/main/java/org/jabref/gui/mergeentries/newmergedialog/toolbar/ThreeWayMergeToolbar.java +++ b/src/main/java/org/jabref/gui/mergeentries/newmergedialog/toolbar/ThreeWayMergeToolbar.java @@ -110,10 +110,10 @@ public DiffView fromString(String string) { onlyShowChangedFieldsCheck.selectedProperty().bindBidirectional(preferencesService.getGuiPreferences().mergeShowChangedFieldOnlyProperty()); onlyShowChangedFields.bind(onlyShowChangedFieldsCheck.selectedProperty()); - loadStoredPreferences(); + loadSavedConfiguration(); } - private void loadStoredPreferences() { + private void loadSavedConfiguration() { GuiPreferences guiPreferences = preferencesService.getGuiPreferences(); PlainTextOrDiff plainTextOrDiffPreference = guiPreferences.getMergeShouldShowDiff() ? PlainTextOrDiff.Diff : PlainTextOrDiff.PLAIN_TEXT; @@ -125,6 +125,14 @@ private void loadStoredPreferences() { diffHighlightingMethodToggleGroup.selectToggle(guiPreferences.getMergeHighlightWords() ? highlightWordsRadioButton : highlightCharactersRadioButtons); } + public void saveToolbarConfiguration() { + preferencesService.getGuiPreferences().setMergeShouldShowDiff(plainTextOrDiffComboBox.getValue() == PlainTextOrDiff.Diff); + preferencesService.getGuiPreferences().setMergeShouldShowUnifiedDiff(diffViewComboBox.getValue() == DiffView.UNIFIED); + + boolean highlightWordsRadioButtonValue = diffHighlightingMethodToggleGroup.getSelectedToggle().equals(highlightWordsRadioButton); + preferencesService.getGuiPreferences().setMergeHighlightWords(highlightWordsRadioButtonValue); + } + public ObjectProperty diffViewProperty() { return diffViewComboBox.valueProperty(); } @@ -189,14 +197,6 @@ public void setOnSelectRightEntryValuesButtonClicked(Runnable onClick) { selectRightEntryValuesButton.setOnMouseClicked(e -> onClick.run()); } - public void saveGuiPreferences() { - preferencesService.getGuiPreferences().setMergeShouldShowDiff(plainTextOrDiffComboBox.getValue() == PlainTextOrDiff.Diff); - preferencesService.getGuiPreferences().setMergeShouldShowUnifiedDiff(diffViewComboBox.getValue() == DiffView.UNIFIED); - - boolean highlightWordsRadioButtonValue = diffHighlightingMethodToggleGroup.getSelectedToggle().equals(highlightWordsRadioButton); - preferencesService.getGuiPreferences().setMergeHighlightWords(highlightWordsRadioButtonValue); - } - public enum PlainTextOrDiff { PLAIN_TEXT(Localization.lang("Plain Text")), Diff(Localization.lang("Show Diff")); From 193aebe00bcfe2ab63d51c2b9761750c85591930 Mon Sep 17 00:00:00 2001 From: Houssem Nasri Date: Sun, 2 Apr 2023 01:21:23 +0100 Subject: [PATCH 72/77] Fix CitationStyleTest#testDefaultCitation test --- .../jabref/logic/citationstyle/CitationStyleTest.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/test/java/org/jabref/logic/citationstyle/CitationStyleTest.java b/src/test/java/org/jabref/logic/citationstyle/CitationStyleTest.java index b05aed909a5..6bdbac10b98 100644 --- a/src/test/java/org/jabref/logic/citationstyle/CitationStyleTest.java +++ b/src/test/java/org/jabref/logic/citationstyle/CitationStyleTest.java @@ -27,10 +27,11 @@ void testDefaultCitation() { String citation = CitationStyleGenerator.generateCitation(TestEntry.getTestEntry(), CitationStyle.getDefault().getSource(), CitationStyleOutputFormat.HTML, context, new BibEntryTypesManager()); // if the default citation style changes this has to be modified - String expected = "
\n" - + "
[1]
B. Smith, B. Jones, and J. Williams, “Title of the test entry,” BibTeX Journal, vol. 34, no. 3, pp. 45–67, 2016-07, doi: 10.1001/bla.blubb.
\n" - + "
\n" - + ""; + String expected = """ +
+
[1]
B. Smith, B. Jones, and J. Williams, “Title of the test entry,” BibTeX Journal, vol. 34, no. 3, pp. 45–67, Jul. 2016, doi: 10.1001/bla.blubb.
+
+ """; assertEquals(expected, citation); } From 38582dd34b7834e7d33099e481c884358156136b Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Mon, 3 Apr 2023 00:38:56 +0200 Subject: [PATCH 73/77] Fix dots in changelog --- CHANGELOG.md | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b53610dda62..a0bcff8672e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve ### Added - We added a field showing the BibTeX/biblatex source for added and deleted entries in the "External Changes Resolver" dialog. [#9509](https://github.com/JabRef/jabref/issues/9509) -- We added a search history list in the search field's right click menu [#7906](https://github.com/JabRef/jabref/issues/7906) +- We added a search history list in the search field's right click menu. [#7906](https://github.com/JabRef/jabref/issues/7906) - We added a full text fetcher for IACR eprints. [#9651](https://github.com/JabRef/jabref/pull/9651) - We added "Attach file from URL" to right-click context menu to download and store a file with the reference library. [#9646](https://github.com/JabRef/jabref/issues/9646) - We enabled updating an existing entry with data from InspireHEP. [#9351](https://github.com/JabRef/jabref/issues/9351) @@ -24,31 +24,31 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve ### Changed - 'Get full text' now also checks the file url. [#568](https://github.com/koppor/jabref/issues/568) -- `log.txt` now contains an entry if a BibTeX entry could not be parsed. - JabRef writes a new backup file only if there is a change. Before, JabRef created a backup upon start. [#9679](https://github.com/JabRef/jabref/pull/9679) - We modified the `Add Group` dialog to use the most recently selected group hierarchical context. [#9141](https://github.com/JabRef/jabref/issues/9141) - We refined the 'main directory not found' error message. [#9625](https://github.com/JabRef/jabref/pull/9625) - JabRef writes a new backup file only if there is a change. Before, JabRef created a backup upon start. [#9679](https://github.com/JabRef/jabref/pull/9679) - Backups of libraries are not stored per JabRef version, but collected together. - We streamlined the paths for logs and backups: The parent path fragement is always `logs` or `backups`. +- `log.txt` now contains an entry if a BibTeX entry could not be parsed. - `log.txt` now contains debug messages. Debugging needs to be enabled explicitly. [#9678](https://github.com/JabRef/jabref/pull/9678) - `log.txt` does not contain entries for non-found files during PDF indexing. [#9678](https://github.com/JabRef/jabref/pull/9678) - We improved the Medline importer to correctly import ISO dates for `revised`. [#9536](https://github.com/JabRef/jabref/issues/9536) - To avoid cluttering of the directory, We always delete the `.sav` file upon successful write. [#9675](https://github.com/JabRef/jabref/pull/9675) -- We improved the unlinking/deletion of multiple linked files of an entry using the Delete key [#9473](https://github.com/JabRef/jabref/issues/9473) +- We improved the unlinking/deletion of multiple linked files of an entry using the Delete key. [#9473](https://github.com/JabRef/jabref/issues/9473) ### Fixed -- We fixed an issue where the browser import would add ' characters before the BibTeX entry on Linux [#9588](https://github.com/JabRef/jabref/issues/9588) -- We fixed an issue where searching for a specific term with the DOAB fetcher lead to an exception [#9571](https://github.com/JabRef/jabref/issues/9571) -- We fixed an issue where the "Import" -> "Library to import to" did not show the correct library name if two opened libraries had the same suffix [#9567](https://github.com/JabRef/jabref/issues/9567) -- We fixed an issue where the rpm-Version of JabRef could not be properly uninstalled and reinstalled [#9558](https://github.com/JabRef/jabref/issues/9558), [#9603](https://github.com/JabRef/jabref/issues/9603) -- We fixed an issue where the command line export using `--exportMatches` flag does not create an output bib file [#9581](https://github.com/JabRef/jabref/issues/9581) -- We fixed an issue where custom field in the custom entry types could not be set to mulitline [#9609](https://github.com/JabRef/jabref/issues/9609) -- We fixed an issue where the Office XML exporter did not resolve BibTeX-Strings when exporting entries [forum#3741](https://discourse.jabref.org/t/exporting-bibtex-constant-strings-to-ms-office-2007-xml/3741) -- We fixed an issue where the Merge Entries Toolbar configuration was not saved after hitting 'Merge Entries' button [#9091](https://github.com/JabRef/jabref/issues/9091) -- We fixed an issue where the password is saved locally if user wants to use proxy with authentication [#8055](https://github.com/JabRef/jabref/issues/8055) +- We fixed an issue where the browser import would add ' characters before the BibTeX entry on Linux. [#9588](https://github.com/JabRef/jabref/issues/9588) +- We fixed an issue where searching for a specific term with the DOAB fetcher lead to an exception. [#9571](https://github.com/JabRef/jabref/issues/9571) +- We fixed an issue where the "Import" -> "Library to import to" did not show the correct library name if two opened libraries had the same suffix. [#9567](https://github.com/JabRef/jabref/issues/9567) +- We fixed an issue where the rpm-Version of JabRef could not be properly uninstalled and reinstalled. [#9558](https://github.com/JabRef/jabref/issues/9558), [#9603](https://github.com/JabRef/jabref/issues/9603) +- We fixed an issue where the command line export using `--exportMatches` flag does not create an output bib file. [#9581](https://github.com/JabRef/jabref/issues/9581) +- We fixed an issue where custom field in the custom entry types could not be set to mulitline. [#9609](https://github.com/JabRef/jabref/issues/9609) +- We fixed an issue where the Office XML exporter did not resolve BibTeX-Strings when exporting entries. [forum#3741](https://discourse.jabref.org/t/exporting-bibtex-constant-strings-to-ms-office-2007-xml/3741) +- We fixed an issue where the Merge Entries Toolbar configuration was not saved after hitting 'Merge Entries' button. [#9091](https://github.com/JabRef/jabref/issues/9091) +- We fixed an issue where the password is saved locally if user wants to use proxy with authentication. [#8055](https://github.com/JabRef/jabref/issues/8055) - JabRef is now more relaxed when parsing field content: In case a field content ended with `\`, the combination `\}` was treated as plain `}`. [#9668](https://github.com/JabRef/jabref/issues/9668) - We resolved an issue that cut off the number of group entries when it exceedet four digits. [#8797](https://github.com/JabRef/jabref/issues/8797) - We fixed an issue where the Global Search UI preview is still white in dark theme. [#9362](https://github.com/JabRef/jabref/issues/9362) @@ -57,7 +57,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve ### Removed -- We removed the support of BibTeXML.[#9540](https://github.com/JabRef/jabref/issues/9540) +- We removed the support of BibTeXML. [#9540](https://github.com/JabRef/jabref/issues/9540) From 1896c99201b299fbfd88545a2a27a37e462490a6 Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Mon, 3 Apr 2023 01:13:06 +0200 Subject: [PATCH 74/77] Remove support for Markdown syntax for strikethrough and task lists (#9726) --- CHANGELOG.md | 1 + build.gradle | 2 -- src/main/java/module-info.java | 2 -- .../logic/layout/format/MarkdownFormatter.java | 9 --------- .../layout/format/MarkdownFormatterTest.java | 18 ------------------ 5 files changed, 1 insertion(+), 31 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a0bcff8672e..edd8aae36d7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -58,6 +58,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve ### Removed - We removed the support of BibTeXML. [#9540](https://github.com/JabRef/jabref/issues/9540) +- We removed support for Markdown syntax for strikethrough and task lists in comment fields. [#9726](https://github.com/JabRef/jabref/pull/9726) diff --git a/build.gradle b/build.gradle index 797ae2a52e8..22905397b0b 100644 --- a/build.gradle +++ b/build.gradle @@ -198,8 +198,6 @@ dependencies { } implementation 'com.vladsch.flexmark:flexmark:0.64.0' - implementation 'com.vladsch.flexmark:flexmark-ext-gfm-strikethrough:0.64.0' - implementation 'com.vladsch.flexmark:flexmark-ext-gfm-tasklist:0.64.0' implementation group: 'net.harawata', name: 'appdirs', version: '1.2.1' diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java index ca7ed66cc97..86078c9afb0 100644 --- a/src/main/java/module-info.java +++ b/src/main/java/module-info.java @@ -94,8 +94,6 @@ requires com.ibm.icu; requires flexmark; - requires flexmark.ext.gfm.strikethrough; - requires flexmark.ext.gfm.tasklist; requires flexmark.util.ast; requires flexmark.util.data; requires com.h2database.mvstore; diff --git a/src/main/java/org/jabref/logic/layout/format/MarkdownFormatter.java b/src/main/java/org/jabref/logic/layout/format/MarkdownFormatter.java index f387dc40224..39accb95b8c 100644 --- a/src/main/java/org/jabref/logic/layout/format/MarkdownFormatter.java +++ b/src/main/java/org/jabref/logic/layout/format/MarkdownFormatter.java @@ -1,12 +1,9 @@ package org.jabref.logic.layout.format; -import java.util.List; import java.util.Objects; import org.jabref.logic.layout.LayoutFormatter; -import com.vladsch.flexmark.ext.gfm.strikethrough.StrikethroughExtension; -import com.vladsch.flexmark.ext.gfm.tasklist.TaskListExtension; import com.vladsch.flexmark.html.HtmlRenderer; import com.vladsch.flexmark.parser.Parser; import com.vladsch.flexmark.util.ast.Node; @@ -19,12 +16,6 @@ public class MarkdownFormatter implements LayoutFormatter { public MarkdownFormatter() { MutableDataSet options = new MutableDataSet(); - // in case a new extension is added here, the depedency has to be added to build.gradle, too. - options.set(Parser.EXTENSIONS, List.of( - StrikethroughExtension.create(), - TaskListExtension.create() - )); - parser = Parser.builder(options).build(); renderer = HtmlRenderer.builder(options).build(); } diff --git a/src/test/java/org/jabref/logic/layout/format/MarkdownFormatterTest.java b/src/test/java/org/jabref/logic/layout/format/MarkdownFormatterTest.java index 595bc6fcc1d..e5e1f9281e6 100644 --- a/src/test/java/org/jabref/logic/layout/format/MarkdownFormatterTest.java +++ b/src/test/java/org/jabref/logic/layout/format/MarkdownFormatterTest.java @@ -6,7 +6,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertTrue; class MarkdownFormatterTest { @@ -37,21 +36,4 @@ void formatWhenFormattingNullThenThrowsException() { Exception exception = assertThrows(NullPointerException.class, () -> markdownFormatter.format(null)); assertEquals("Field Text should not be null, when handed to formatter", exception.getMessage()); } - - @Test - void formatWhenMarkupContainingStrikethroughThenContainsMatchingDel() { - // Only test strikethrough extension - assertTrue(markdownFormatter.format("a ~~b~~ b").contains("b")); - } - - @Test - void formatWhenMarkupContainingTaskListThenContainsFormattedTaskList() { - String actual = markdownFormatter.format("Some text\n" + - "* [ ] open task\n" + - "* [x] closed task\n\n" + - "some other text"); - // Only test list items - assertTrue(actual.contains("
  •  open task
  • ")); - assertTrue(actual.contains("
  •  closed task
  • ")); - } } From 5a4bd68f884b2fd3059670274db70dfcb495be82 Mon Sep 17 00:00:00 2001 From: Lucas Freund <127773292+Luggas4you@users.noreply.github.com> Date: Mon, 3 Apr 2023 09:29:43 +0200 Subject: [PATCH 75/77] add missing BibStringDiff test cases --- .../bibtex/comparator/BibStringDiff.java | 2 +- .../bibtex/comparator/BibStringDiffTest.java | 95 ++++++++++++++++++- 2 files changed, 94 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/jabref/logic/bibtex/comparator/BibStringDiff.java b/src/main/java/org/jabref/logic/bibtex/comparator/BibStringDiff.java index 8050af537fa..65fe125a765 100644 --- a/src/main/java/org/jabref/logic/bibtex/comparator/BibStringDiff.java +++ b/src/main/java/org/jabref/logic/bibtex/comparator/BibStringDiff.java @@ -57,7 +57,7 @@ public static List compare(BibDatabase originalDatabase, BibDatab Optional match = newDatabase .getStringValues().stream() - .filter(test -> test.getName().equals(original.getName())) + .filter(test -> test.getContent().equals(original.getContent())) .findAny(); if (match.isPresent()) { // We have found a string with the same content. It cannot have the same diff --git a/src/test/java/org/jabref/logic/bibtex/comparator/BibStringDiffTest.java b/src/test/java/org/jabref/logic/bibtex/comparator/BibStringDiffTest.java index 1db4078fdfa..28f8ed4d801 100644 --- a/src/test/java/org/jabref/logic/bibtex/comparator/BibStringDiffTest.java +++ b/src/test/java/org/jabref/logic/bibtex/comparator/BibStringDiffTest.java @@ -1,5 +1,6 @@ package org.jabref.logic.bibtex.comparator; +import java.util.Collections; import java.util.List; import org.jabref.model.database.BibDatabase; @@ -9,6 +10,9 @@ import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -22,13 +26,100 @@ public class BibStringDiffTest { void setUp() { when(originalDataBase.hasNoStrings()).thenReturn(false); when(newDataBase.hasNoStrings()).thenReturn(false); - when(originalDataBase.getStringValues()).thenReturn(List.of(new BibtexString("name", "content"), new BibtexString("name2", "content2"))); - when(newDataBase.getStringValues()).thenReturn(List.of(new BibtexString("name", "content"), new BibtexString("name2", "content3"))); } @Test void compareTest() { + when(originalDataBase.getStringValues()).thenReturn(List.of(new BibtexString("name", "content"), new BibtexString("name2", "content2"))); + when(newDataBase.getStringValues()).thenReturn(List.of(new BibtexString("name", "content"), new BibtexString("name2", "content3"))); + List result = BibStringDiff.compare(originalDataBase, newDataBase); assertEquals(List.of(diff), result); } + + @Test + void equalTest() { + BibStringDiff other = new BibStringDiff(diff.getOriginalString(), diff.getNewString()); + assertEquals(diff, other); + assertEquals(diff.hashCode(), other.hashCode()); + } + + @Test + void notEqualTest() { + BibStringDiff other = new BibStringDiff(diff.getNewString(), diff.getOriginalString()); + assertNotEquals(diff, other); + assertNotEquals(diff.hashCode(), other.hashCode()); + } + + @Test + void identicalObjectsAreEqual() { + BibStringDiff other = diff; + assertTrue(other.equals(diff)); + } + + @Test + void compareToNullObjectIsFalse() { + assertFalse(diff.equals(null)); + } + + @Test + void compareToDifferentClassIsFalse() { + assertFalse(diff.equals(new Object())); + } + + @Test + void testGetters() { + BibtexString bsOne = new BibtexString("aKahle", "Kahle, Brewster"); + BibtexString bsTwo = new BibtexString("iMIT", "Institute of Technology"); + BibStringDiff diff = new BibStringDiff(bsOne, bsTwo); + assertEquals(diff.getOriginalString(), bsOne); + assertEquals(diff.getNewString(), bsTwo); + } + + @Test + void testCompareEmptyDatabases() { + when(originalDataBase.hasNoStrings()).thenReturn(true); + when(newDataBase.hasNoStrings()).thenReturn(true); + + assertEquals(Collections.emptyList(), BibStringDiff.compare(originalDataBase, newDataBase)); + } + + @Test + void testCompareNameChange() { + when(originalDataBase.getStringValues()).thenReturn(List.of(new BibtexString("name", "content"))); + when(newDataBase.getStringValues()).thenReturn(List.of(new BibtexString("name2", "content"))); + + List result = BibStringDiff.compare(originalDataBase, newDataBase); + BibStringDiff expectedDiff = new BibStringDiff(new BibtexString("name", "content"), new BibtexString("name2", "content")); + assertEquals(List.of(expectedDiff), result); + } + + @Test + void testCompareNoDiff() { + when(originalDataBase.getStringValues()).thenReturn(List.of(new BibtexString("name", "content"))); + when(newDataBase.getStringValues()).thenReturn(List.of(new BibtexString("name", "content"))); + + List result = BibStringDiff.compare(originalDataBase, newDataBase); + assertEquals(Collections.emptyList(), result); + } + + @Test + void testCompareRemovedString() { + when(originalDataBase.getStringValues()).thenReturn(List.of(new BibtexString("name", "content"))); + when(newDataBase.getStringValues()).thenReturn(Collections.emptyList()); + + List result = BibStringDiff.compare(originalDataBase, newDataBase); + BibStringDiff expectedDiff = new BibStringDiff(new BibtexString("name", "content"), null); + assertEquals(List.of(expectedDiff), result); + } + + @Test + void testCompareAddString() { + when(originalDataBase.getStringValues()).thenReturn(Collections.emptyList()); + when(newDataBase.getStringValues()).thenReturn(List.of(new BibtexString("name", "content"))); + + List result = BibStringDiff.compare(originalDataBase, newDataBase); + BibStringDiff expectedDiff = new BibStringDiff(null, new BibtexString("name", "content")); + assertEquals(List.of(expectedDiff), result); + } } From 207774d206be31846c7e100997827b27f6c809a9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 3 Apr 2023 14:56:49 +0000 Subject: [PATCH 76/77] Bump org.jsoup:jsoup from 1.15.3 to 1.15.4 Bumps [org.jsoup:jsoup](https://github.com/jhy/jsoup) from 1.15.3 to 1.15.4. - [Release notes](https://github.com/jhy/jsoup/releases) - [Changelog](https://github.com/jhy/jsoup/blob/master/CHANGES) - [Commits](https://github.com/jhy/jsoup/compare/jsoup-1.15.3...jsoup-1.15.4) --- updated-dependencies: - dependency-name: org.jsoup:jsoup dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 22905397b0b..c1d53cbba77 100644 --- a/build.gradle +++ b/build.gradle @@ -174,7 +174,7 @@ dependencies { implementation 'com.jfoenix:jfoenix:9.0.10' implementation 'org.controlsfx:controlsfx:11.1.2' - implementation 'org.jsoup:jsoup:1.15.3' + implementation 'org.jsoup:jsoup:1.15.4' implementation 'com.konghq:unirest-java:3.14.2' implementation 'org.slf4j:slf4j-api:2.0.7' From ae159f426e8ba35b9490e19fc66e547c5acc1878 Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Mon, 3 Apr 2023 18:05:14 +0200 Subject: [PATCH 77/77] Ignore docs/Gemfile.lock (since we don't need reproducible docs build) --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index fd187d3f735..f2a7cad5e5e 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,9 @@ src-gen/ docs/book.pdf docs/_book/ +# Jekyll for docs/ +docs/Gemfile.lock + # ignore the generated markdown file if the user forgets to delete it status.md