From 989fa19fae75b8220924528e0c42c7629bada302 Mon Sep 17 00:00:00 2001 From: Joerg Lenhard Date: Sat, 25 Nov 2017 16:43:20 +0100 Subject: [PATCH 1/7] Remove dependency to jgoodies-looks --- CHANGELOG.md | 1 + build.gradle | 1 - external-libraries.txt | 5 ----- src/main/java/org/jabref/JabRefGUI.java | 9 ++------- src/main/java/org/jabref/JabRefMain.java | 1 + src/main/java/org/jabref/gui/JabRefFrame.java | 4 ---- .../org/jabref/gui/preftabs/AppearancePrefsTab.java | 2 -- .../gui/specialfields/SpecialFieldDropDown.java | 4 ---- .../jabref/migrations/PreferencesMigrations.java | 13 +++++++++++++ .../org/jabref/preferences/JabRefPreferences.java | 4 ++-- 10 files changed, 19 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 25e77cd291f..82bbf20fe06 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `# - We added an option to mass append to fields via the Quality -> set/clear/append/rename fields dialog. [#2721](https://github.com/JabRef/jabref/issues/2721) - We added a check on startup to ensure JabRef is run with an adequate Java version. [3310](https://github.com/JabRef/jabref/issues/3310) - In the preference, all installed java Look and Feels are now listed and selectable +- We removed the Look and Feels from jgoodies, because these are not compatible with Java 9 ### Fixed - We fixed the translation of \textendash in the entry preview [#3307](https://github.com/JabRef/jabref/issues/3307) diff --git a/build.gradle b/build.gradle index 891b3eeb0ab..72d046df368 100644 --- a/build.gradle +++ b/build.gradle @@ -78,7 +78,6 @@ dependencies { compile 'com.jgoodies:jgoodies-common:1.8.1' compile 'com.jgoodies:jgoodies-forms:1.9.0' - compile 'com.jgoodies:jgoodies-looks:2.7.0' // update to 2.0.x is not possible - see https://github.com/JabRef/jabref/pull/1096#issuecomment-208857517 compile 'org.apache.pdfbox:pdfbox:1.8.13' diff --git a/external-libraries.txt b/external-libraries.txt index dafc72002ee..5f654af0f8a 100644 --- a/external-libraries.txt +++ b/external-libraries.txt @@ -65,11 +65,6 @@ Project: JGoodies Forms URL: http://www.jgoodies.com/downloads/libraries/ License: BSD -Id: com.jgoodies:jgoodies-looks -Project: JGoodies Looks -URL: http://www.jgoodies.com/downloads/libraries/ -License: BSD - Id: com.mashape.unirest Project: Unirest for Java URL: https://github.com/Mashape/unirest-java diff --git a/src/main/java/org/jabref/JabRefGUI.java b/src/main/java/org/jabref/JabRefGUI.java index 3e17bf108b6..ac942f76ef7 100644 --- a/src/main/java/org/jabref/JabRefGUI.java +++ b/src/main/java/org/jabref/JabRefGUI.java @@ -14,7 +14,7 @@ import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; import javax.swing.plaf.FontUIResource; -import javax.swing.plaf.metal.MetalLookAndFeel; +import javax.swing.plaf.nimbus.NimbusLookAndFeel; import org.jabref.gui.BasePanel; import org.jabref.gui.GUIGlobals; @@ -35,8 +35,6 @@ import org.jabref.shared.exception.InvalidDBMSConnectionPropertiesException; import org.jabref.shared.exception.NotASharedDatabaseException; -import com.jgoodies.looks.plastic.Plastic3DLookAndFeel; -import com.jgoodies.looks.plastic.theme.SkyBluer; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -251,10 +249,7 @@ private void setLookAndFeel() { if (UIManager.getCrossPlatformLookAndFeelClassName().equals(lookFeel) && !System.getProperty("java.runtime.name").contains("OpenJDK")) { // try to avoid ending up with the ugly Metal L&F - Plastic3DLookAndFeel lnf = new Plastic3DLookAndFeel(); - MetalLookAndFeel.setCurrentTheme(new SkyBluer()); - com.jgoodies.looks.Options.setPopupDropShadowEnabled(true); - UIManager.setLookAndFeel(lnf); + UIManager.setLookAndFeel(new NimbusLookAndFeel()); } else { try { UIManager.setLookAndFeel(lookFeel); diff --git a/src/main/java/org/jabref/JabRefMain.java b/src/main/java/org/jabref/JabRefMain.java index 428fdd5cdd6..4df22d2f7df 100644 --- a/src/main/java/org/jabref/JabRefMain.java +++ b/src/main/java/org/jabref/JabRefMain.java @@ -129,6 +129,7 @@ private static void start(String[] args) { PreferencesMigrations.upgradeStoredCustomEntryTypes(); PreferencesMigrations.upgradeKeyBindingsToJavaFX(); PreferencesMigrations.addCrossRefRelatedFieldsForAutoComplete(); + PreferencesMigrations.upgradeObsoleteLookAndFeels(); // Update handling of special fields based on preferences InternalBibtexFields diff --git a/src/main/java/org/jabref/gui/JabRefFrame.java b/src/main/java/org/jabref/gui/JabRefFrame.java index 3e30b97409c..eb8bf3c4d81 100644 --- a/src/main/java/org/jabref/gui/JabRefFrame.java +++ b/src/main/java/org/jabref/gui/JabRefFrame.java @@ -143,8 +143,6 @@ import org.jabref.preferences.SearchPreferences; import com.google.common.eventbus.Subscribe; -import com.jgoodies.looks.HeaderStyle; -import com.jgoodies.looks.Options; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import osx.macadapter.MacAdapter; @@ -895,7 +893,6 @@ public boolean quit() { } private void initLayout() { - tabbedPane.putClientProperty(Options.NO_CONTENT_BORDER_KEY, Boolean.TRUE); setProgressBarVisible(false); @@ -1307,7 +1304,6 @@ public void addParserResult(ParserResult pr, boolean focusPanel) { } private void createToolBar() { - tlb.putClientProperty(Options.HEADER_STYLE_KEY, HeaderStyle.BOTH); tlb.setBorder(null); tlb.setRollover(true); diff --git a/src/main/java/org/jabref/gui/preftabs/AppearancePrefsTab.java b/src/main/java/org/jabref/gui/preftabs/AppearancePrefsTab.java index ab2b6c6136d..2203b159fe1 100644 --- a/src/main/java/org/jabref/gui/preftabs/AppearancePrefsTab.java +++ b/src/main/java/org/jabref/gui/preftabs/AppearancePrefsTab.java @@ -60,8 +60,6 @@ static class LookAndFeel { public static Set getAvailableLookAndFeels() { Set lookAndFeels = new HashSet<>(); - lookAndFeels.add("com.jgoodies.looks.plastic.Plastic3DLookAndFeel"); - lookAndFeels.add("com.jgoodies.looks.windows.WindowsLookAndFeel"); for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { lookAndFeels.add(info.getClassName()); diff --git a/src/main/java/org/jabref/gui/specialfields/SpecialFieldDropDown.java b/src/main/java/org/jabref/gui/specialfields/SpecialFieldDropDown.java index 02e4d4d3966..7e3245571fc 100644 --- a/src/main/java/org/jabref/gui/specialfields/SpecialFieldDropDown.java +++ b/src/main/java/org/jabref/gui/specialfields/SpecialFieldDropDown.java @@ -15,9 +15,6 @@ import org.jabref.model.entry.specialfields.SpecialField; import org.jabref.model.entry.specialfields.SpecialFieldValue; -import com.jgoodies.looks.HeaderStyle; -import com.jgoodies.looks.Options; - public class SpecialFieldDropDown { private SpecialFieldDropDown() { @@ -40,7 +37,6 @@ public static JButton generateSpecialFieldButtonWithDropDown(SpecialField field, button.setSize(buttonDim); button.setMinimumSize(buttonDim); button.setMaximumSize(buttonDim); - button.putClientProperty(Options.HEADER_STYLE_KEY, HeaderStyle.BOTH); button.addActionListener(new MenuButtonActionListener(field, frame, button, buttonDim)); return button; } diff --git a/src/main/java/org/jabref/migrations/PreferencesMigrations.java b/src/main/java/org/jabref/migrations/PreferencesMigrations.java index 508e052fa4c..60e266f78fd 100644 --- a/src/main/java/org/jabref/migrations/PreferencesMigrations.java +++ b/src/main/java/org/jabref/migrations/PreferencesMigrations.java @@ -12,6 +12,7 @@ import org.jabref.Globals; import org.jabref.JabRefMain; +import org.jabref.logic.util.OS; import org.jabref.model.bibtexkeypattern.GlobalBibtexKeyPattern; import org.jabref.model.entry.FieldName; import org.jabref.preferences.JabRefPreferences; @@ -281,4 +282,16 @@ private static void migrateTypedKeyPrefs(JabRefPreferences prefs, Preferences ol prefs.putKeyPattern(keyPattern); } + public static void upgradeObsoleteLookAndFeels() { + JabRefPreferences prefs = Globals.prefs; + if (prefs.get(JabRefPreferences.WIN_LOOK_AND_FEEL).equals("com.jgoodies.looks.windows.WindowsLookAndFeel") || + prefs.get(JabRefPreferences.WIN_LOOK_AND_FEEL).equals("com.jgoodies.plaf.plastic.Plastic3DLookAndFeel") ) { + if (OS.WINDOWS) { + prefs.put(JabRefPreferences.WIN_LOOK_AND_FEEL, "com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); + } else { + prefs.put(JabRefPreferences.WIN_LOOK_AND_FEEL, "javax.swing.plaf.nimbus.NimbusLookAndFeel"); + } + } + } + } diff --git a/src/main/java/org/jabref/preferences/JabRefPreferences.java b/src/main/java/org/jabref/preferences/JabRefPreferences.java index 6bbd42f0710..51966b6c744 100644 --- a/src/main/java/org/jabref/preferences/JabRefPreferences.java +++ b/src/main/java/org/jabref/preferences/JabRefPreferences.java @@ -466,12 +466,12 @@ private JabRefPreferences() { defaults.put(WIN_LOOK_AND_FEEL, UIManager.getSystemLookAndFeelClassName()); defaults.put(EMACS_PATH, "emacsclient"); } else if (OS.WINDOWS) { - defaults.put(WIN_LOOK_AND_FEEL, "com.jgoodies.looks.windows.WindowsLookAndFeel"); + defaults.put(WIN_LOOK_AND_FEEL, "com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); defaults.put(EMACS_PATH, "emacsclient.exe"); } else { // Linux defaults.put(FONT_FAMILY, "SansSerif"); - defaults.put(WIN_LOOK_AND_FEEL, "com.jgoodies.plaf.plastic.Plastic3DLookAndFeel"); + defaults.put(WIN_LOOK_AND_FEEL, "javax.swing.plaf.nimbus.NimbusLookAndFeel"); defaults.put(EMACS_PATH, "emacsclient"); } From 38bcaae3a4285f8847625afe27c917185fc0c499 Mon Sep 17 00:00:00 2001 From: Joerg Lenhard Date: Sat, 25 Nov 2017 16:57:01 +0100 Subject: [PATCH 2/7] Add logging in case the preferences get migrated --- .../java/org/jabref/migrations/PreferencesMigrations.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/jabref/migrations/PreferencesMigrations.java b/src/main/java/org/jabref/migrations/PreferencesMigrations.java index 60e266f78fd..3f9f7ea259b 100644 --- a/src/main/java/org/jabref/migrations/PreferencesMigrations.java +++ b/src/main/java/org/jabref/migrations/PreferencesMigrations.java @@ -284,12 +284,15 @@ private static void migrateTypedKeyPrefs(JabRefPreferences prefs, Preferences ol public static void upgradeObsoleteLookAndFeels() { JabRefPreferences prefs = Globals.prefs; - if (prefs.get(JabRefPreferences.WIN_LOOK_AND_FEEL).equals("com.jgoodies.looks.windows.WindowsLookAndFeel") || - prefs.get(JabRefPreferences.WIN_LOOK_AND_FEEL).equals("com.jgoodies.plaf.plastic.Plastic3DLookAndFeel") ) { + String currentLandF = prefs.get(JabRefPreferences.WIN_LOOK_AND_FEEL); + if (currentLandF.equals("com.jgoodies.looks.windows.WindowsLookAndFeel") || + currentLandF.equals("com.jgoodies.plaf.plastic.Plastic3DLookAndFeel") ) { if (OS.WINDOWS) { prefs.put(JabRefPreferences.WIN_LOOK_AND_FEEL, "com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); + LOGGER.info("Switched from obsolete look and feel " + currentLandF + " to com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); } else { prefs.put(JabRefPreferences.WIN_LOOK_AND_FEEL, "javax.swing.plaf.nimbus.NimbusLookAndFeel"); + LOGGER.info("Switched from obsolete look and feel " + currentLandF + " to javax.swing.plaf.nimbus.NimbusLookAndFeel"); } } } From 626fbce82ecd2e29b3d2a4cf937a1ee0a3ec008d Mon Sep 17 00:00:00 2001 From: Joerg Lenhard Date: Sat, 25 Nov 2017 20:48:38 +0100 Subject: [PATCH 3/7] Switch arguments in equals and extract local variable --- .../jabref/migrations/PreferencesMigrations.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/jabref/migrations/PreferencesMigrations.java b/src/main/java/org/jabref/migrations/PreferencesMigrations.java index 3f9f7ea259b..5a32fe85f91 100644 --- a/src/main/java/org/jabref/migrations/PreferencesMigrations.java +++ b/src/main/java/org/jabref/migrations/PreferencesMigrations.java @@ -285,14 +285,16 @@ private static void migrateTypedKeyPrefs(JabRefPreferences prefs, Preferences ol public static void upgradeObsoleteLookAndFeels() { JabRefPreferences prefs = Globals.prefs; String currentLandF = prefs.get(JabRefPreferences.WIN_LOOK_AND_FEEL); - if (currentLandF.equals("com.jgoodies.looks.windows.WindowsLookAndFeel") || - currentLandF.equals("com.jgoodies.plaf.plastic.Plastic3DLookAndFeel") ) { + if ("com.jgoodies.looks.windows.WindowsLookAndFeel".equals(currentLandF) || + "com.jgoodies.plaf.plastic.Plastic3DLookAndFeel".equals(currentLandF) ) { if (OS.WINDOWS) { - prefs.put(JabRefPreferences.WIN_LOOK_AND_FEEL, "com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); - LOGGER.info("Switched from obsolete look and feel " + currentLandF + " to com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); + String windowsLandF = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel"; + prefs.put(JabRefPreferences.WIN_LOOK_AND_FEEL, windowsLandF); + LOGGER.info("Switched from obsolete look and feel " + currentLandF + " to " + windowsLandF); } else { - prefs.put(JabRefPreferences.WIN_LOOK_AND_FEEL, "javax.swing.plaf.nimbus.NimbusLookAndFeel"); - LOGGER.info("Switched from obsolete look and feel " + currentLandF + " to javax.swing.plaf.nimbus.NimbusLookAndFeel"); + String nimbusLandF = "javax.swing.plaf.nimbus.NimbusLookAndFeel"; + prefs.put(JabRefPreferences.WIN_LOOK_AND_FEEL, nimbusLandF); + LOGGER.info("Switched from obsolete look and feel " + currentLandF + " to " + nimbusLandF); } } } From 129e7ee5cfd34e806c4ed3b9662657fbef3dc960 Mon Sep 17 00:00:00 2001 From: Joerg Lenhard Date: Mon, 27 Nov 2017 13:53:59 +0100 Subject: [PATCH 4/7] Set LandF through String representation --- src/main/java/org/jabref/JabRefGUI.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/jabref/JabRefGUI.java b/src/main/java/org/jabref/JabRefGUI.java index ac942f76ef7..343d5c05f8d 100644 --- a/src/main/java/org/jabref/JabRefGUI.java +++ b/src/main/java/org/jabref/JabRefGUI.java @@ -249,7 +249,7 @@ private void setLookAndFeel() { if (UIManager.getCrossPlatformLookAndFeelClassName().equals(lookFeel) && !System.getProperty("java.runtime.name").contains("OpenJDK")) { // try to avoid ending up with the ugly Metal L&F - UIManager.setLookAndFeel(new NimbusLookAndFeel()); + UIManager.setLookAndFeel("javax.swing.plaf.nimbus.NimbusLookAndFeel"); } else { try { UIManager.setLookAndFeel(lookFeel); From 99232fe106eab9f3736b345ab685dc6214735194 Mon Sep 17 00:00:00 2001 From: Joerg Lenhard Date: Mon, 27 Nov 2017 14:10:20 +0100 Subject: [PATCH 5/7] Remove unused import --- src/main/java/org/jabref/JabRefGUI.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/org/jabref/JabRefGUI.java b/src/main/java/org/jabref/JabRefGUI.java index 343d5c05f8d..039532430b3 100644 --- a/src/main/java/org/jabref/JabRefGUI.java +++ b/src/main/java/org/jabref/JabRefGUI.java @@ -14,7 +14,6 @@ import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; import javax.swing.plaf.FontUIResource; -import javax.swing.plaf.nimbus.NimbusLookAndFeel; import org.jabref.gui.BasePanel; import org.jabref.gui.GUIGlobals; From f2038c3caa06924d7cd79ea04134a3ff56e2d16e Mon Sep 17 00:00:00 2001 From: Joerg Lenhard Date: Mon, 27 Nov 2017 16:57:28 +0100 Subject: [PATCH 6/7] Turn array computation into stream --- .../org/jabref/gui/preftabs/AppearancePrefsTab.java | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/jabref/gui/preftabs/AppearancePrefsTab.java b/src/main/java/org/jabref/gui/preftabs/AppearancePrefsTab.java index 2203b159fe1..5fda2e1bebf 100644 --- a/src/main/java/org/jabref/gui/preftabs/AppearancePrefsTab.java +++ b/src/main/java/org/jabref/gui/preftabs/AppearancePrefsTab.java @@ -3,8 +3,10 @@ import java.awt.BorderLayout; import java.awt.Font; import java.awt.GridBagLayout; +import java.util.Arrays; import java.util.HashSet; import java.util.Set; +import java.util.stream.Collectors; import javax.swing.BorderFactory; import javax.swing.JButton; @@ -58,14 +60,7 @@ class AppearancePrefsTab extends JPanel implements PrefsTab { static class LookAndFeel { public static Set getAvailableLookAndFeels() { - - Set lookAndFeels = new HashSet<>(); - - for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { - lookAndFeels.add(info.getClassName()); - } - - return lookAndFeels; + return Arrays.stream(UIManager.getInstalledLookAndFeels()).map(LookAndFeelInfo::getClassName).collect(Collectors.toSet()); } } From 72a1cbda53e3fc9fb680dbb762cf91d9b13345b0 Mon Sep 17 00:00:00 2001 From: Joerg Lenhard Date: Mon, 27 Nov 2017 16:58:00 +0100 Subject: [PATCH 7/7] Remove unused import --- src/main/java/org/jabref/gui/preftabs/AppearancePrefsTab.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/org/jabref/gui/preftabs/AppearancePrefsTab.java b/src/main/java/org/jabref/gui/preftabs/AppearancePrefsTab.java index 5fda2e1bebf..7991e5aef33 100644 --- a/src/main/java/org/jabref/gui/preftabs/AppearancePrefsTab.java +++ b/src/main/java/org/jabref/gui/preftabs/AppearancePrefsTab.java @@ -4,7 +4,6 @@ import java.awt.Font; import java.awt.GridBagLayout; import java.util.Arrays; -import java.util.HashSet; import java.util.Set; import java.util.stream.Collectors;