X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fbin%2FJalview.java;h=4c21624cab731cbbdc98b5fdfb40f398eb06f981;hb=132fa48b35a4821ca0d8e241ba27989e573e61e5;hp=f5b7009fff377aa44da6ea92fc09b74552881fcb;hpb=339d1bf247a3b0d000044892bee3d5668a8d9b11;p=jalview.git diff --git a/src/jalview/bin/Jalview.java b/src/jalview/bin/Jalview.java index f5b7009..4c21624 100755 --- a/src/jalview/bin/Jalview.java +++ b/src/jalview/bin/Jalview.java @@ -60,6 +60,7 @@ import jalview.io.DataSourceType; import jalview.io.FileFormat; import jalview.io.FileFormatException; import jalview.io.FileFormatI; +import jalview.io.FileFormats; import jalview.io.FileLoader; import jalview.io.HtmlSvgOutput; import jalview.io.IdentifyFile; @@ -67,6 +68,8 @@ import jalview.io.NewickFile; import jalview.io.gff.SequenceOntologyFactory; import jalview.schemes.ColourSchemeI; import jalview.schemes.ColourSchemeProperty; +import jalview.util.ChannelProperties; +import jalview.util.HttpUtils; import jalview.util.MessageManager; import jalview.util.Platform; import jalview.ws.jws2.Jws2Discoverer; @@ -93,8 +96,9 @@ public class Jalview Platform.getURLCommandArguments(); } - // singleton instance of this class - + /* + * singleton instance of this class + */ private static Jalview instance; private Desktop desktop; @@ -327,8 +331,8 @@ public class Jalview "Invalid jabaws parameter: " + jabawsUrl + " ignored"); } } - } + String defs = aparser.getValue("setprop"); while (defs != null) { @@ -344,6 +348,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 +374,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) @@ -465,17 +388,28 @@ public class Jalview if (!headless) { + Desktop.nosplash = aparser.contains("nosplash"); desktop = new Desktop(); desktop.setInBatchMode(true); // indicate we are starting up 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()) @@ -485,7 +419,10 @@ public class Jalview * @j2sIgnore */ { - desktop.startServiceDiscovery(); + if (!aparser.contains("nowebservicediscovery")) + { + desktop.startServiceDiscovery(); + } if (!aparser.contains("nousagestats")) { startUsageStats(desktop); @@ -593,8 +530,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()) { @@ -792,17 +728,37 @@ public class Jalview af.createEPS(outputFile); continue; } - - af.saveAlignment(file, format); - if (af.isSaveAlignmentSuccessful()) + FileFormatI outFormat = null; + try + { + outFormat = FileFormats.getInstance().forName(outputFormat); + } catch (Exception formatP) { - System.out.println("Written alignment in " + format - + " format to " + file); + System.out.println("Couldn't parse " + outFormat + + " as a valid Jalview format string."); } - else + if (outFormat != null) { - System.out.println("Error writing file " + file + " in " - + format + " format!!"); + if (!outFormat.isWritable()) + { + System.out.println( + "This version of Jalview does not support alignment export as " + + outputFormat); + } + else + { + af.saveAlignment(file, outFormat); + if (af.isSaveAlignmentSuccessful()) + { + System.out.println("Written alignment in " + + outFormat.getName() + " format to " + file); + } + else + { + System.out.println("Error writing file " + file + " in " + + outFormat.getName() + " format!!"); + } + } } } @@ -838,12 +794,7 @@ public class Jalview Cache.removeProperty("STARTUP_FILE"); } - protocol = DataSourceType.FILE; - - if (file.indexOf("http:") > -1) - { - protocol = DataSourceType.URL; - } + protocol = AppletFormatAdapter.checkProtocol(file); if (file.endsWith(".jar")) { @@ -891,29 +842,130 @@ public class Jalview } } - private static boolean setCrossPlatformLookAndFeel() + private static void setLookAndFeel() { - return setGenericLookAndFeel(false); + // 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 setSystemLookAndFeel() + private static boolean setCrossPlatformLookAndFeel() { - return setGenericLookAndFeel(true); + boolean set = false; + try + { + UIManager.setLookAndFeel( + UIManager.getCrossPlatformLookAndFeelClassName()); + set = true; + } catch (Exception ex) + { + Cache.log.error("Unexpected Look and Feel Exception"); + Cache.log.error(ex.getMessage()); + Cache.log.debug(Cache.getStackTraceString(ex)); + } + return set; } - private static boolean setGenericLookAndFeel(boolean system) + private static boolean setSystemLookAndFeel() { boolean set = false; try { - UIManager.setLookAndFeel( - system ? UIManager.getSystemLookAndFeelClassName() - : UIManager.getCrossPlatformLookAndFeelClassName()); + UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); 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; } @@ -939,8 +991,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; } @@ -981,7 +1034,7 @@ public class Jalview { boolean set = false; System.setProperty("com.apple.mrj.application.apple.menu.about.name", - "Jalview"); + ChannelProperties.getProperty("app_name")); System.setProperty("apple.laf.useScreenMenuBar", "true"); set = setQuaquaLookAndFeel(); if ((!set) || !UIManager.getLookAndFeel().getClass().toString()