X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fbin%2FJalview.java;h=341bcba46ba473708e03fd05178544cdec3ef8c7;hb=5c1262f120d4fca072bc8fd9800a1a856cc46843;hp=2e33474c1567645e783e3ce34dd696e73c69c372;hpb=2288325efdb30bead1f6a3ad264d5e0c6b9cc752;p=jalview.git diff --git a/src/jalview/bin/Jalview.java b/src/jalview/bin/Jalview.java index 2e33474..341bcba 100755 --- a/src/jalview/bin/Jalview.java +++ b/src/jalview/bin/Jalview.java @@ -20,6 +20,28 @@ */ package jalview.bin; +import jalview.ext.so.SequenceOntology; +import jalview.gui.AlignFrame; +import jalview.gui.Desktop; +import jalview.gui.PromptUserConfig; +import jalview.io.AppletFormatAdapter; +import jalview.io.BioJsHTMLOutput; +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; +import jalview.io.NewickFile; +import jalview.io.gff.SequenceOntologyFactory; +import jalview.schemes.ColourSchemeI; +import jalview.schemes.ColourSchemeProperty; +import jalview.util.MessageManager; +import jalview.util.Platform; +import jalview.ws.jws2.Jws2Discoverer; + import java.io.BufferedReader; import java.io.File; import java.io.FileOutputStream; @@ -297,90 +319,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()) { - setMetalLookAndFeel(); - } - if (Platform.isAMac()) - { - setMacLookAndFeel(); - } - } + setLookAndFeel(); /* * configure 'full' SO model if preferences say to, else use the default (SO @@ -402,11 +341,13 @@ public class Jalview JalviewTaskbar.setTaskbar(this); } catch (Exception e) { - System.out.println("Cannot set Taskbar"); + Cache.log.info("Cannot set Taskbar"); + Cache.log.error(e.getMessage()); // e.printStackTrace(); } catch (Throwable t) { - System.out.println("Cannot set Taskbar"); + Cache.log.info("Cannot set Taskbar"); + Cache.log.error(t.getMessage()); // t.printStackTrace(); } @@ -707,18 +648,34 @@ public class Jalview af.createEPS(outputFile); continue; } - - if (af.saveAlignment(file, format)) - { - System.out.println("Written alignment in " + format - + " format to " + file); + FileFormatI outFormat=null; + try { + outFormat = FileFormats.getInstance().forName(outputFormat); + } catch (Exception formatP) { + 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 + { + if (af.saveAlignment(file, outFormat)) + { + System.out.println("Written alignment in " + format + + " format to " + file); + } + else + { + System.out.println("Error writing file " + file + " in " + + format + " format!!"); + } + } } - } while (aparser.getSize() > 0) @@ -801,33 +758,125 @@ public class Jalview } } - private static boolean setCrossPlatformLookAndFeel() + private static void setLookAndFeel() { - boolean set = false; - try + // 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) { - UIManager.setLookAndFeel( - UIManager.getCrossPlatformLookAndFeelClassName()); - set = true; - } catch (Exception ex) + laf = lafProp; + } + else if (lafSetting != null) { - System.err.println("Unexpected Look and Feel Exception"); - ex.printStackTrace(); + laf = lafSetting; } - return set; + 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() + { + return setGenericLookAndFeel(false); } private static boolean setSystemLookAndFeel() { + return setGenericLookAndFeel(true); + } + + private static boolean setGenericLookAndFeel(boolean system) + { boolean set = false; try { - UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); + UIManager.setLookAndFeel( + system ? UIManager.getSystemLookAndFeelClassName() + : UIManager.getCrossPlatformLookAndFeelClassName()); 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; } @@ -853,8 +902,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; }