Skip to content
Snippets Groups Projects
BamFrame.java 2.09 KiB
Newer Older
  • Learn to ignore specific revisions
  • tjc's avatar
    tjc committed
    package uk.ac.sanger.artemis.components.alignment;
    
    import javax.swing.JFrame;
    import javax.swing.JOptionPane;
    
     class BamFrame extends JFrame
      {
        private static final long serialVersionUID = 1L;
        private String bamFile = null;
    
        BamFrame()
        {
          super();
          if(isMac())
            initMac();
        }
        
        private void initMac()
        {
          try
          {
            // Generate and register the OSXAdapter, passing it a hash of all the
            // methods we wish to
            // use as delegates for various com.apple.eawt.ApplicationListener
            // methods
    
    tcarver's avatar
    tcarver committed
            Class<?> bamClass = Class.forName("uk.ac.sanger.artemis.components.alignment.BamFrame");
    
    tjc's avatar
    tjc committed
            BamOSXAdapter.setQuitHandler(this, bamClass.getDeclaredMethod(
    
    tjc's avatar
    tjc committed
                "exitApp", (Class[]) null));
    
    tjc's avatar
    tjc committed
            BamOSXAdapter.setAboutHandler(this, bamClass.getDeclaredMethod("about",
    
    tjc's avatar
    tjc committed
                (Class[]) null));
            // OSXAdapter.setPreferencesHandler(this,
            // splashClass.getDeclaredMethod("preferences", (Class[])null));
    
    tjc's avatar
    tjc committed
            BamOSXAdapter.setFileHandler(this, bamClass.getDeclaredMethod(
    
    tjc's avatar
    tjc committed
                "loadFile", new Class[]
                { String.class }));
          }
          catch (Exception e)
          {
            e.printStackTrace();
          }
        }
    
        protected void about()
        {
          JOptionPane.showMessageDialog(this,
              "BamView\nthis is free software and is distributed"
                  + "\nunder the terms of the GNU General Public License.",
    
    tjc's avatar
    tjc committed
              "About", JOptionPane.INFORMATION_MESSAGE);
    
    tjc's avatar
    tjc committed
        }
    
        protected void loadFile(final String bamFile)
        {
    
    tjc's avatar
    tjc committed
          this.bamFile = bamFile;
    
    tjc's avatar
    tjc committed
        }
    
        protected void exitApp()
        {
          int status = JOptionPane.showConfirmDialog(this, "Exit?",
              "BamView", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
          if(status == JOptionPane.CANCEL_OPTION)
            return;
          System.exit(0);
        }
    
        protected String getBamFile()
        {
          return bamFile;
        }
        
    
    tjc's avatar
    tjc committed
        protected static boolean isMac()
    
    tjc's avatar
    tjc committed
        {
    
    tcarver's avatar
    tcarver committed
          return System.getProperty("mrj.version") != null ||
                 System.getProperty("os.name").toLowerCase().indexOf("mac") >= 0;