From 92cb745e71728622b90966ee93c8f06479390370 Mon Sep 17 00:00:00 2001 From: Ben Soares Date: Wed, 8 Jul 2020 00:02:18 +0100 Subject: [PATCH] JAL-3608 Changes from code review CR-JAL-236 --- src/jalview/bin/Cache.java | 30 ++++--- src/jalview/bin/Jalview.java | 185 ++++++++++++++++++++++-------------------- 2 files changed, 117 insertions(+), 98 deletions(-) diff --git a/src/jalview/bin/Cache.java b/src/jalview/bin/Cache.java index dbe85fe..6e44b0c 100755 --- a/src/jalview/bin/Cache.java +++ b/src/jalview/bin/Cache.java @@ -1105,20 +1105,23 @@ public class Cache public static String getVersionDetailsForConsole() { StringBuilder sb = new StringBuilder(); - sb.append("Jalview Version: " - + jalview.bin.Cache.getDefault("VERSION", "TEST")); + sb.append("Jalview Version: "); + sb.append(jalview.bin.Cache.getDefault("VERSION", "TEST")); sb.append("\n"); - sb.append("Jalview Installation: " - + jalview.bin.Cache.getDefault("INSTALLATION", "unknown")); + sb.append("Jalview Installation: "); + sb.append(jalview.bin.Cache.getDefault("INSTALLATION", "unknown")); sb.append("\n"); - sb.append("Build Date: " - + jalview.bin.Cache.getDefault("BUILD_DATE", "unknown")); + sb.append("Build Date: "); + sb.append(jalview.bin.Cache.getDefault("BUILD_DATE", "unknown")); sb.append("\n"); - sb.append("Java version: " + System.getProperty("java.version")); + sb.append("Java version: "); + sb.append(System.getProperty("java.version")); sb.append("\n"); - sb.append(System.getProperty("os.arch") + " " - + System.getProperty("os.name") + " " - + System.getProperty("os.version")); + sb.append(System.getProperty("os.arch")); + sb.append(" "); + sb.append(System.getProperty("os.name")); + sb.append(" "); + sb.append(System.getProperty("os.version")); sb.append("\n"); appendIfNotNull(sb, "Install4j version: ", System.getProperty("sys.install4jVersion"), "\n", null); @@ -1129,8 +1132,11 @@ public class Cache LookAndFeel laf = UIManager.getLookAndFeel(); String lafName = laf == null ? "Not obtained" : laf.getName(); String lafClass = laf == null ? "unknown" : laf.getClass().getName(); - appendIfNotNull(sb, "LookAndFeel: ", lafName + " (" + lafClass + ")", - "\n", null); + sb.append("LookAndFeel: "); + sb.append(lafName); + sb.append(" ("); + sb.append(lafClass); + sb.append(")\n"); // Not displayed in release version ( determined by possible version number // regex 9[9.]*9[.-_a9]* ) if (Pattern.matches("^\\d[\\d\\.]*\\d[\\.\\-\\w]*$", diff --git a/src/jalview/bin/Jalview.java b/src/jalview/bin/Jalview.java index f7fdece..b99f4c3 100755 --- a/src/jalview/bin/Jalview.java +++ b/src/jalview/bin/Jalview.java @@ -297,92 +297,7 @@ public class Jalview desktop = null; - // property laf = "crossplatform", "system", "gtk", "metal", "nimbus" or - // "mac" - // If not set (or chosen laf fails), use the normal SystemLaF and if on Mac, - // try Quaqua/Vaqua. - String lafProp = System.getProperty("laf"); - String lafSetting = Cache.getDefault("PREFERRED_LAF", null); - String laf = "none"; - if (lafProp != null) - { - laf = lafProp; - } - else if (lafSetting != null) - { - laf = lafSetting; - } - boolean lafSet = false; - switch (laf) - { - case "crossplatform": - lafSet = setCrossPlatformLookAndFeel(); - if (!lafSet) - { - Cache.log.error("Could not set requested laf=" + laf); - } - break; - case "system": - lafSet = setSystemLookAndFeel(); - if (!lafSet) - { - Cache.log.error("Could not set requested laf=" + laf); - } - break; - case "gtk": - lafSet = setGtkLookAndFeel(); - { - Cache.log.error("Could not set requested laf=" + laf); - } - break; - case "metal": - lafSet = setMetalLookAndFeel(); - { - Cache.log.error("Could not set requested laf=" + laf); - } - break; - case "nimbus": - lafSet = setNimbusLookAndFeel(); - { - Cache.log.error("Could not set requested laf=" + laf); - } - break; - case "quaqua": - lafSet = setQuaquaLookAndFeel(); - { - Cache.log.error("Could not set requested laf=" + laf); - } - break; - case "vaqua": - lafSet = setVaquaLookAndFeel(); - { - Cache.log.error("Could not set requested laf=" + laf); - } - break; - case "mac": - lafSet = setMacLookAndFeel(); - if (!lafSet) - { - Cache.log.error("Could not set requested laf=" + laf); - } - break; - case "none": - break; - default: - Cache.log.error("Requested laf=" + laf + " not implemented"); - } - if (!lafSet) - { - setSystemLookAndFeel(); - if (Platform.isLinux()) - { - setMetalLookAndFeel(); - } - if (Platform.isAMac()) - { - setMacLookAndFeel(); - } - } + setLookAndFeel(); /* * configure 'full' SO model if preferences say to, else use the default (SO @@ -804,6 +719,101 @@ public class Jalview } } + private static void setLookAndFeel() + { + // property laf = "crossplatform", "system", "gtk", "metal", "nimbus" or + // "mac" + // If not set (or chosen laf fails), use the normal SystemLaF and if on Mac, + // try Quaqua/Vaqua. + String lafProp = System.getProperty("laf"); + String lafSetting = Cache.getDefault("PREFERRED_LAF", null); + String laf = "none"; + if (lafProp != null) + { + laf = lafProp; + } + else if (lafSetting != null) + { + laf = lafSetting; + } + boolean lafSet = false; + switch (laf) + { + case "crossplatform": + lafSet = setCrossPlatformLookAndFeel(); + if (!lafSet) + { + Cache.log.error("Could not set requested laf=" + laf); + } + break; + case "system": + lafSet = setSystemLookAndFeel(); + if (!lafSet) + { + Cache.log.error("Could not set requested laf=" + laf); + } + break; + case "gtk": + lafSet = setGtkLookAndFeel(); + if (!lafSet) + { + Cache.log.error("Could not set requested laf=" + laf); + } + break; + case "metal": + lafSet = setMetalLookAndFeel(); + if (!lafSet) + { + Cache.log.error("Could not set requested laf=" + laf); + } + break; + case "nimbus": + lafSet = setNimbusLookAndFeel(); + if (!lafSet) + { + Cache.log.error("Could not set requested laf=" + laf); + } + break; + case "quaqua": + lafSet = setQuaquaLookAndFeel(); + if (!lafSet) + { + Cache.log.error("Could not set requested laf=" + laf); + } + break; + case "vaqua": + lafSet = setVaquaLookAndFeel(); + if (!lafSet) + { + Cache.log.error("Could not set requested laf=" + laf); + } + break; + case "mac": + lafSet = setMacLookAndFeel(); + if (!lafSet) + { + Cache.log.error("Could not set requested laf=" + laf); + } + break; + case "none": + break; + default: + Cache.log.error("Requested laf=" + laf + " not implemented"); + } + if (!lafSet) + { + setSystemLookAndFeel(); + if (Platform.isLinux()) + { + setMetalLookAndFeel(); + } + if (Platform.isAMac()) + { + setMacLookAndFeel(); + } + } + } + private static boolean setCrossPlatformLookAndFeel() { boolean set = false; @@ -815,6 +825,7 @@ public class Jalview } catch (Exception ex) { Cache.log.error("Unexpected Look and Feel Exception"); + Cache.log.error(ex.getMessage()); Cache.log.debug(Cache.getStackTraceString(ex)); } return set; @@ -830,6 +841,7 @@ public class Jalview } catch (Exception ex) { Cache.log.error("Unexpected Look and Feel Exception"); + Cache.log.error(ex.getMessage()); Cache.log.debug(Cache.getStackTraceString(ex)); } return set; @@ -857,6 +869,7 @@ public class Jalview } catch (Exception ex) { Cache.log.error("Unexpected Look and Feel Exception"); + Cache.log.error(ex.getMessage()); Cache.log.debug(Cache.getStackTraceString(ex)); } return set; -- 1.7.10.2