Skip to content

Commit

Permalink
Remove unnecessary look and feel migration (#4204)
Browse files Browse the repository at this point in the history
* Remove unnecessary look and feel migration

* Remove unused look and feel references

* Fix checkstyle issue
  • Loading branch information
tobiasdiez authored Jul 15, 2018
1 parent efe7c17 commit a44d316
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 47 deletions.
4 changes: 0 additions & 4 deletions src/main/java/org/jabref/JabRefGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@

public class JabRefGUI {

private static final String NIMBUS_LOOK_AND_FEEL = "javax.swing.plaf.nimbus.NimbusLookAndFeel";
private static final String WINDOWS_LOOK_AND_FEEL = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
private static final String OSX_AQUA_LOOK_AND_FEEL = "apple.laf.AquaLookAndFeel";

private static final Logger LOGGER = LoggerFactory.getLogger(JabRefGUI.class);

private static JabRefFrame mainFrame;
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/org/jabref/logic/util/io/FileBasedLock.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,11 @@
import org.slf4j.LoggerFactory;

public class FileBasedLock {
private static final Logger LOGGER = LoggerFactory.getLogger(FileBasedLock.class);

/**
* The age in ms of a lockfile before JabRef will offer to "steal" the locked file.
*/
public static final long LOCKFILE_CRITICAL_AGE = 60000;

private static final Logger LOGGER = LoggerFactory.getLogger(FileBasedLock.class);
private static final String LOCKFILE_SUFFIX = ".lock";

// default retry count for acquiring file lock
Expand All @@ -31,7 +29,7 @@ private FileBasedLock() {
* there is, it waits for 500 ms. This is repeated until the lock is gone
* or we have waited the maximum number of times.
*
* @param file The file to check the lock for.
* @param file The file to check the lock for.
* @param maxWaitCount The maximum number of times to wait.
* @return true if the lock file is gone, false if it is still there.
*/
Expand All @@ -58,6 +56,7 @@ public static boolean waitForFileLock(Path file) {

/**
* Check whether a lock file exists for this file.
*
* @param file The file to check.
* @return true if a lock file exists, false otherwise.
*/
Expand All @@ -68,6 +67,7 @@ public static boolean hasLockFile(Path file) {

/**
* Find the lock file's last modified time, if it has a lock file.
*
* @param file The file to check.
* @return the last modified time if lock file exists, empty optional otherwise.
*/
Expand Down
25 changes: 0 additions & 25 deletions src/main/java/org/jabref/migrations/PreferencesMigrations.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@
import java.util.function.UnaryOperator;
import java.util.prefs.BackingStoreException;
import java.util.prefs.Preferences;
import java.util.stream.Stream;

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;
Expand Down Expand Up @@ -43,7 +41,6 @@ public static void runMigrations() {
upgradeStoredCustomEntryTypes(Globals.prefs, mainPrefsNode);
upgradeKeyBindingsToJavaFX(Globals.prefs);
addCrossRefRelatedFieldsForAutoComplete(Globals.prefs);
upgradeObsoleteLookAndFeels(Globals.prefs);
upgradePreviewStyleFromReviewToComment(Globals.prefs);
}

Expand Down Expand Up @@ -285,28 +282,6 @@ private static void migrateTypedKeyPrefs(JabRefPreferences prefs, Preferences ol
prefs.putKeyPattern(keyPattern);
}

private static void upgradeObsoleteLookAndFeels(JabRefPreferences prefs) {

String currentLandF = prefs.getLookAndFeel();

Stream.of("com.jgoodies.looks.windows.WindowsLookAndFeel", "com.jgoodies.looks.plastic.PlasticLookAndFeel",
"com.jgoodies.looks.plastic.Plastic3DLookAndFeel", "com.jgoodies.looks.plastic.PlasticXPLookAndFeel",
"com.sun.java.swing.plaf.gtk.GTKLookAndFeel")
.filter(style -> style.equals(currentLandF))
.findAny()
.ifPresent(loolAndFeel -> {
if (OS.WINDOWS) {
String windowsLandF = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
prefs.setLookAndFeel(windowsLandF);
LOGGER.info("Switched from obsolete look and feel " + currentLandF + " to " + windowsLandF);
} else {
String nimbusLandF = "javax.swing.plaf.nimbus.NimbusLookAndFeel";
prefs.setLookAndFeel(nimbusLandF);
LOGGER.info("Switched from obsolete look and feel " + currentLandF + " to " + nimbusLandF);
}
});
}

static void upgradePreviewStyleFromReviewToComment(JabRefPreferences prefs) {
String currentPreviewStyle = prefs.getPreviewStyle();
String migratedStyle = currentPreviewStyle.replace("\\begin{review}<BR><BR><b>Review: </b> \\format[HTMLChars]{\\review} \\end{review}", "\\begin{comment}<BR><BR><b>Comment: </b> \\format[HTMLChars]{\\comment} \\end{comment}");
Expand Down
14 changes: 0 additions & 14 deletions src/main/java/org/jabref/preferences/JabRefPreferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@
import java.util.prefs.Preferences;
import java.util.stream.Collectors;

import javax.swing.UIManager;

import org.jabref.Globals;
import org.jabref.JabRefException;
import org.jabref.JabRefMain;
Expand Down Expand Up @@ -115,7 +113,6 @@ public class JabRefPreferences implements PreferencesService {
public static final String LYXPIPE = "lyxpipe";
public static final String EXTERNAL_FILE_TYPES = "externalFileTypes";
public static final String FONT_FAMILY = "fontFamily";
public static final String WIN_LOOK_AND_FEEL = "lookAndFeel";
public static final String FX_FONT_RENDERING_TWEAK = "fxFontRenderingTweak";
public static final String LANGUAGE = "language";
public static final String NAMES_LAST_ONLY = "namesLastOnly";
Expand Down Expand Up @@ -461,15 +458,12 @@ private JabRefPreferences() {

if (OS.OS_X) {
defaults.put(FONT_FAMILY, "SansSerif");
defaults.put(WIN_LOOK_AND_FEEL, UIManager.getSystemLookAndFeelClassName());
defaults.put(EMACS_PATH, "emacsclient");
} else if (OS.WINDOWS) {
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, "javax.swing.plaf.nimbus.NimbusLookAndFeel");
defaults.put(EMACS_PATH, "emacsclient");
}

Expand Down Expand Up @@ -1899,14 +1893,6 @@ public void setGroupViewMode(GroupViewMode mode) {
put(GROUP_INTERSECT_UNION_VIEW_MODE, mode.name());
}

public String getLookAndFeel() {
return get(WIN_LOOK_AND_FEEL);
}

public void setLookAndFeel(String lookAndFeelClassName) {
put(WIN_LOOK_AND_FEEL, lookAndFeelClassName);
}

public void setPreviewStyle(String previewStyle) {
put(PREVIEW_STYLE, previewStyle);
}
Expand Down

0 comments on commit a44d316

Please sign in to comment.