X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FDesktop.java;h=36183bb1f9804df638bec763214e0d3f1d7c197f;hb=0306c5b7a2aa4cc232ad0590a8ef285022eabd51;hp=889227f99df0c7848699de2a80c0c2cd89651ae2;hpb=d9b5411f1f2cd0acf62eab94188428a754094926;p=jalview.git diff --git a/src/jalview/gui/Desktop.java b/src/jalview/gui/Desktop.java index 889227f..36183bb 100755 --- a/src/jalview/gui/Desktop.java +++ b/src/jalview/gui/Desktop.java @@ -15,20 +15,23 @@ import jalview.datamodel.*; import javax.swing.*; import java.awt.*; import java.awt.event.*; +import java.awt.dnd.*; +import javax.swing.*; +import java.awt.datatransfer.*; +import jalview.bin.Cache; -public class Desktop extends jalview.jbgui.GDesktop +public class Desktop extends jalview.jbgui.GDesktop implements DropTargetListener { public static JDesktopPane desktop; static int openFrameCount = 0; static final int xOffset = 30, yOffset = 30; - static boolean splashScreenVisible = false; public Desktop() { Image image =null; try{ - java.net.URL url = getClass().getResource("/BartonGroupBanner.gif"); + java.net.URL url = getClass().getResource("/images/logo.gif"); if(url!=null) { image = java.awt.Toolkit.getDefaultToolkit().createImage(url); @@ -42,66 +45,93 @@ public class Desktop extends jalview.jbgui.GDesktop setTitle("Jalview 2005"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - setVisible(true); desktop = new JDesktopPane(); + desktop.setBackground(Color.white); setContentPane(desktop); desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE); + + // This line prevents Windows Look&Feel resizing all new windows to maximum + // if previous window was maximised + desktop.setDesktopManager( new DefaultDesktopManager() ); + + Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); - int width = 1200, height = 800; - if(screenSize.getWidth()0) + { + AlignFrame af = new AlignFrame(new Alignment(sequences)); + addInternalFrame(af, file, AlignFrame.NEW_WINDOW_WIDTH, AlignFrame.NEW_WINDOW_HEIGHT); + af.currentFileFormat = format; + af.statusBar.setText("Successfully loaded file " + file); + try{ + af.setMaximum(Preferences.showFullscreen); + }catch(Exception ex){} + + } + else + JOptionPane.showInternalMessageDialog(Desktop.desktop, "Couldn't open file.\n" + + "Formats currently supported are\n" + + "Fasta, MSF, Clustal, BLC, PIR, MSP, and PFAM" // JBPNote - message should be generated through FormatAdapter! + ,"Error loading file", + JOptionPane.WARNING_MESSAGE); + } } + public void inputURLMenuItem_actionPerformed(ActionEvent e) { String url = JOptionPane.showInternalInputDialog(Desktop.desktop,"Enter url of input file", "Input alignment from URL", - JOptionPane.QUESTION_MESSAGE); + JOptionPane.QUESTION_MESSAGE, + null, null, + "http://www.").toString(); if (url == null) return; String format = IdentifyFile.Identify(url, "URL"); - System.out.println(format +" format"); if (format.equals("URL NOT FOUND")) { JOptionPane.showInternalMessageDialog(Desktop.desktop,"Couldn't locate " + url, @@ -193,23 +288,25 @@ public class Desktop extends jalview.jbgui.GDesktop String format = IdentifyFile.Identify(cap.getText(), "Paste"); SequenceI [] sequences = null; - if (FormatProperties.contains( format )) - sequences = FormatAdapter.read(cap.getText(), "Paste", format); + if (FormatAdapter.formats.contains( format )) + sequences = FormatAdapter.readFile(cap.getText(), "Paste", format); if(sequences!=null) { AlignFrame af = new AlignFrame(new Alignment(sequences)); - addInternalFrame(af, "Cut & Paste input - "+format, 700, 500); + af.currentFileFormat = format; + addInternalFrame(af, "Cut & Paste input - "+format, + AlignFrame.NEW_WINDOW_WIDTH, + AlignFrame.NEW_WINDOW_HEIGHT); af.statusBar.setText("Successfully pasted alignment file"); } else JOptionPane.showInternalMessageDialog(Desktop.desktop, "Couldn't read the pasted text.\n" +"Formats currently supported are\n" - +"Fasta, MSF, Clustal, BLC, PIR, MSP or PFAM", + +"Fasta, MSF, Clustal, BLC, PIR, MSP, and PFAM", "Error parsing text", JOptionPane.WARNING_MESSAGE); - } } @@ -218,35 +315,86 @@ public class Desktop extends jalview.jbgui.GDesktop */ public void quit_actionPerformed(ActionEvent e) { - this.setVisible(false); - System.exit(0); + if(jalview.bin.Jalview.applet!=null) + jalview.bin.Jalview.applet.destroy(); + else + System.exit(0); } - protected void colourIndexMenuItem_actionPerformed(ActionEvent e) - { - ColourKey colourKey = new ColourKey(null); - addInternalFrame(colourKey, "Colour scheme key", 400, 320); - } - public void aboutMenuItem_actionPerformed(ActionEvent e) { JOptionPane.showInternalMessageDialog(Desktop.desktop, - "JalView 2005" - +"\nAuthors: Michele Clamp, James Cuff, Steve Searle, Andrew Waterhouse and Geoff Barton." + "JalView 2005 version " + jalview.bin.Cache.VERSION+"; last updated: "+jalview.bin.Cache.BUILD_DATE + +"\nAuthors: Michele Clamp, James Cuff, Steve Searle, Andrew Waterhouse, Jim Procter & Geoff Barton." +"\nCurrent development managed by Andrew Waterhouse; Barton Group, University of Dundee." - +"\nIf you use JalView, please cite: \"Clamp, M., Cuff, J., Searle, S. M. and Barton, G. J. (2004), The Jalview Java Alignment Editor\"", + +"\nIf you use JalView, please cite:" + +"\n\"Clamp, M., Cuff, J., Searle, S. M. and Barton, G. J. (2004), The Jalview Java Alignment Editor\"" + +"\nBioinformatics, 2004 12;426-7.", "About Jalview", JOptionPane.INFORMATION_MESSAGE); } public void documentationMenuItem_actionPerformed(ActionEvent e) { - try{ - jalview.util.BrowserLauncher.openURL("http://jalview.org/documentation.html"); - }catch(Exception ex){} + try + { + ClassLoader cl = jalview.gui.Desktop.class.getClassLoader(); + java.net.URL url = javax.help.HelpSet.findHelpSet(cl,"help/help"); + javax.help.HelpSet hs = new javax.help.HelpSet(cl,url); + + javax.help.HelpBroker hb = hs.createHelpBroker(); + hb.setLocation(new Point(200, 50)); + hb.setSize(new Dimension(800,700)); + hb.setCurrentID("home"); + hb.setDisplayed(true); + } + catch (Exception ex) + { + ex.printStackTrace(); + } } + protected void preferences_actionPerformed(ActionEvent e) + { + Preferences pref = new Preferences(); + } + public void saveState_actionPerformed(ActionEvent e) + { + JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache. + getProperty("LAST_DIRECTORY"), + new String[] + {"xml"}, new String[]{"Jalview Project"}, "Jalview Project"); + + chooser.setFileView(new JalviewFileView()); + chooser.setDialogTitle("Save State"); + int value = chooser.showSaveDialog(this); + if (value == JalviewFileChooser.APPROVE_OPTION) + { + java.io.File choice = chooser.getSelectedFile(); + jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice.getParent()); + Jalview2XML.SaveState(choice); + } + + } + + + public void loadState_actionPerformed(ActionEvent e) + { + JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache.getProperty("LAST_DIRECTORY"), + new String[]{"xml"}, new String[]{"Jalview Project"}, "Jalview Project"); + chooser.setFileView(new JalviewFileView()); + chooser.setDialogTitle("Restore state"); + int value = chooser.showOpenDialog(this); + if(value == JalviewFileChooser.APPROVE_OPTION) + { + String choice = chooser.getSelectedFile().getAbsolutePath(); + jalview.bin.Cache.setProperty("LAST_DIRECTORY", chooser.getSelectedFile().getParent()); + Jalview2XML.LoadState(choice); + } + } } + +