X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fbin%2FJalview.java;h=b1ea60bed10ab2144f2c4808af369e3c20d6235a;hb=7664ccad29d55ad2355d72feeac23d8bdd49a2a7;hp=08c12d632175938582776d2f48a603ca3ab06c0f;hpb=dc13933d1655206660d32c4e55e150dcf672ba48;p=jalview.git diff --git a/src/jalview/bin/Jalview.java b/src/jalview/bin/Jalview.java index 08c12d6..b1ea60b 100755 --- a/src/jalview/bin/Jalview.java +++ b/src/jalview/bin/Jalview.java @@ -67,6 +67,7 @@ import jalview.io.NewickFile; import jalview.io.gff.SequenceOntologyFactory; import jalview.schemes.ColourSchemeI; import jalview.schemes.ColourSchemeProperty; +import jalview.util.HttpUtils; import jalview.util.MessageManager; import jalview.util.Platform; import jalview.ws.jws2.Jws2Discoverer; @@ -93,8 +94,9 @@ public class Jalview Platform.getURLCommandArguments(); } - // singleton instance of this class - + /* + * singleton instance of this class + */ private static Jalview instance; private Desktop desktop; @@ -285,6 +287,17 @@ public class Jalview ArgsParser aparser = new ArgsParser(args); boolean headless = false; + if (aparser.contains("help") || aparser.contains("h")) + { + showUsage(); + System.exit(0); + } + if (aparser.contains("nodisplay") || aparser.contains("nogui") + || aparser.contains("headless")) + { + System.setProperty("java.awt.headless", "true"); + headless = true; + } String usrPropsFile = aparser.getValue("props"); Cache.loadProperties(usrPropsFile); // must do this before if (usrPropsFile != null) @@ -327,8 +340,8 @@ public class Jalview "Invalid jabaws parameter: " + jabawsUrl + " ignored"); } } - } + String defs = aparser.getValue("setprop"); while (defs != null) { @@ -344,6 +357,9 @@ public class Jalview { Cache.setProperty(defs.substring(0, p), defs.substring(p + 1)); } + // DISABLED FOR SECURITY REASONS + // TODO: add a property to allow properties to be overriden by cli args + // Cache.setProperty(defs.substring(0,p), defs.substring(p+1)); } defs = aparser.getValue("setprop"); } @@ -367,91 +383,7 @@ public class Jalview desktop = null; - // property laf = "crossplatform", "system", "gtk", "metal" 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) - { - System.err.println("Could not set requested laf=" + laf); - } - break; - case "system": - lafSet = setSystemLookAndFeel(); - if (!lafSet) - { - System.err.println("Could not set requested laf=" + laf); - } - break; - case "gtk": - lafSet = setGtkLookAndFeel(); - { - System.err.println("Could not set requested laf=" + laf); - } - break; - case "metal": - lafSet = setMetalLookAndFeel(); - { - System.err.println("Could not set requested laf=" + laf); - } - break; - case "nimbus": - lafSet = setNimbusLookAndFeel(); - { - System.err.println("Could not set requested laf=" + laf); - } - break; - case "quaqua": - lafSet = setQuaquaLookAndFeel(); - { - System.err.println("Could not set requested laf=" + laf); - } - break; - case "vaqua": - lafSet = setVaquaLookAndFeel(); - { - System.err.println("Could not set requested laf=" + laf); - } - break; - case "mac": - lafSet = setMacLookAndFeel(); - if (!lafSet) - { - System.err.println("Could not set requested laf=" + laf); - } - break; - case "none": - break; - default: - System.err.println("Requested laf=" + laf + " not implemented"); - } - if (!lafSet) - { - setSystemLookAndFeel(); - if (Platform.isLinux() && !Platform.isJS()) - { - setMetalLookAndFeel(); - } - if (Platform.isAMacAndNotJS()) - { - setMacLookAndFeel(); - } - } + setLookAndFeel(); /* * configure 'full' SO model if preferences say to, else use the default (full SO) @@ -471,11 +403,21 @@ public class Jalview try { JalviewTaskbar.setTaskbar(this); + } catch (Exception e) + { + Cache.log.info("Cannot set Taskbar"); + Cache.log.error(e.getMessage()); + // e.printStackTrace(); } catch (Throwable t) { - System.out.println("Error setting Taskbar: " + t.getMessage()); + Cache.log.info("Cannot set Taskbar"); + Cache.log.error(t.getMessage()); + // t.printStackTrace(); } + // set Proxy settings before all the internet calls + Cache.setProxyPropertiesFromPreferences(); + desktop.setVisible(true); if (!Platform.isJS()) @@ -593,8 +535,7 @@ public class Jalview * @j2sIgnore */ { - if (!file.startsWith("http://") && !file.startsWith("https://")) - // BH 2019 added https check for Java + if (!HttpUtils.startsWithHttpOrHttps(file)) { if (!(new File(file)).exists()) { @@ -891,6 +832,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.isMac()) + { + setMacLookAndFeel(); + } + } + } + private static boolean setCrossPlatformLookAndFeel() { boolean set = false; @@ -901,8 +937,9 @@ public class Jalview set = true; } catch (Exception ex) { - System.err.println("Unexpected Look and Feel Exception"); - ex.printStackTrace(); + Cache.log.error("Unexpected Look and Feel Exception"); + Cache.log.error(ex.getMessage()); + Cache.log.debug(Cache.getStackTraceString(ex)); } return set; } @@ -916,8 +953,9 @@ public class Jalview set = true; } catch (Exception ex) { - System.err.println("Unexpected Look and Feel Exception"); - ex.printStackTrace(); + Cache.log.error("Unexpected Look and Feel Exception"); + Cache.log.error(ex.getMessage()); + Cache.log.debug(Cache.getStackTraceString(ex)); } return set; } @@ -943,8 +981,9 @@ public class Jalview set = true; } catch (Exception ex) { - System.err.println("Unexpected Look and Feel Exception"); - ex.printStackTrace(); + Cache.log.error("Unexpected Look and Feel Exception"); + Cache.log.error(ex.getMessage()); + Cache.log.debug(Cache.getStackTraceString(ex)); } return set; }