X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fbin%2FJalview.java;h=6f4a8d5508208ebe5c865b13af1d45986b82163b;hb=e1add5cebbfbea0dbff04f5009a33e010dbb9936;hp=b1af2498cb79ea4733b2857ac75b8291005cddde;hpb=5e5969a28e0a81f4bcb8f6e47d6dc286b6b1bd48;p=jalview.git diff --git a/src/jalview/bin/Jalview.java b/src/jalview/bin/Jalview.java index b1af249..6f4a8d5 100755 --- a/src/jalview/bin/Jalview.java +++ b/src/jalview/bin/Jalview.java @@ -11,31 +11,103 @@ package jalview.bin; import jalview.gui.*; import javax.swing.*; +import java.awt.event.*; +import jalview.io.*; -public class Jalview +import org.apache.log4j.*; + +public class Jalview extends JApplet { + public static JApplet applet; + Desktop frame; + public void init() + { + applet = this; + + frame = new Desktop(); + frame.setResizable(true); + frame.setVisible(true); + frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); + frame.addWindowListener(new WindowAdapter() + { + public void windowClosing(WindowEvent e) + { + applet.stop(); + applet.destroy(); + } + }); + + String file = getParameter("alignment"); + + if(file!=null) + { + jalview.bin.Cache.setProperty("LAST_DIRECTORY", file); + String protocol = "File"; + if (file.indexOf("http:") > -1) + protocol = "URL"; + + String format = jalview.io.IdentifyFile.Identify(file, protocol); + + frame.LoadFile(file, protocol, format); + } + } + public void destroy() + { + if(applet!=null) + applet.stop(); + else + System.exit(0); + frame.setVisible(false); + } + + private static void initLogger() { + Logger l = Logger.getLogger("org.apache.axis"); + if (Cache.getProperty("logs.Axis.Level")==null) { + Cache.setProperty("logs.Axis.Level", Level.INFO.toString()); + } + + l.setLevel(Level.toLevel(Cache.getProperty("logs.Axis.Level"))); + ConsoleAppender ap = new ConsoleAppender(new SimpleLayout(),"System.err"); + ap.setName("Axis"); + l.addAppender(ap); + } public static void main(String[] args) { - try{ - UIManager.setLookAndFeel //("javax.swing.plaf.metal.MetalLookAndFeel"); - ( UIManager.getCrossPlatformLookAndFeelClassName() ); - // ("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); - // ("com.sun.java.swing.plaf.motif.MotifLookAndFeel" ); + Cache.loadProperties(); + try { + initLogger(); + } catch (Exception e) { + System.out.println("Problems initializing the log4j system\n"+e); + } + try{ + UIManager.setLookAndFeel( + // "javax.swing.plaf.metal.MetalLookAndFeel" + // "javax.swing.plaf.multi.MultiLookAndFeel" + UIManager.getSystemLookAndFeelClassName() + // UIManager.getCrossPlatformLookAndFeelClassName() + // "com.sun.java.swing.plaf.gtk.GTKLookAndFeel" + // "com.sun.java.swing.plaf.windows.WindowsLookAndFeel" + // "com.sun.java.swing.plaf.motif.MotifLookAndFeel" + ); } catch (Exception ex) {} - // JFrame.setDefaultLookAndFeelDecorated(true); Desktop frame = new Desktop(); frame.setResizable(true); frame.setVisible(true); + if(args!=null && args.length>0) { - String file = args[0]; - jalview.bin.Cache.LAST_DIRECTORY = file; + String file=null; + if(args[0].equals("-open")) + file = args[1]; + else + file = args[0]; + String protocol = "File"; if(file.indexOf("http:")>-1) protocol = "URL"; @@ -48,3 +120,4 @@ public class Jalview } } +