X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FDesktop.java;h=36183bb1f9804df638bec763214e0d3f1d7c197f;hb=0f31ab4d7d3c5fdf3af01f3f2f497962d9602725;hp=6baa2bb92f28de8ae59bd47ebb54cac29cb62ad0;hpb=c1fad33365988bdf8e335982df0c3ff84dd0bb8b;p=jalview.git diff --git a/src/jalview/gui/Desktop.java b/src/jalview/gui/Desktop.java index 6baa2bb..36183bb 100755 --- a/src/jalview/gui/Desktop.java +++ b/src/jalview/gui/Desktop.java @@ -12,14 +12,13 @@ package jalview.gui; import jalview.gui.*; import jalview.io.*; import jalview.datamodel.*; -import jalview.schemes.*; import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.awt.dnd.*; import javax.swing.*; import java.awt.datatransfer.*; -import java.io.*; +import jalview.bin.Cache; public class Desktop extends jalview.jbgui.GDesktop implements DropTargetListener @@ -47,11 +46,16 @@ public class Desktop extends jalview.jbgui.GDesktop implements DropTargetListene setTitle("Jalview 2005"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); desktop = new JDesktopPane(); - desktop.setBackground(new Color(220,220,230)); + 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(); String x = jalview.bin.Cache.getProperty("SCREEN_X"); String y = jalview.bin.Cache.getProperty("SCREEN_Y"); @@ -85,56 +89,49 @@ setVisible(true); this.setDropTarget(new java.awt.dnd.DropTarget(desktop, this)); - +/////////Add a splashscreen on startup /////////Add a splashscreen on startup JInternalFrame frame = new JInternalFrame(); SplashScreen splash = new SplashScreen(frame, image); frame.setContentPane(splash); - desktop.add(frame); - - openFrameCount++; - try - { - frame.setSelected(true); - } - catch (java.beans.PropertyVetoException e) - {} - frame.setResizable(true); - frame.setSize(750, 160); + frame.setLayer(JLayeredPane.PALETTE_LAYER); + addInternalFrame(frame, "", 750,160, false); frame.setLocation( (int)((getWidth()-750) /2), (int)((getHeight()-160) /2)); - frame.setClosable(false); - frame.setIconifiable(false); - frame.setMaximizable(false); - frame.setFrameIcon(null); - frame.setVisible(true); - } - public static void addInternalFrame(final JInternalFrame frame, String title, int w, int h) { + addInternalFrame(frame, title, w, h, true); + } + + public static void addInternalFrame(final JInternalFrame frame, String title, + int w, + int h, + boolean resizable ) + { desktop.add(frame); openFrameCount++; try { frame.setSelected(true); } catch (java.beans.PropertyVetoException e) {} frame.setTitle(title); - frame.setResizable(true); frame.setSize(w,h); frame.setClosable(true); - frame.setMaximizable(true); - frame.setIconifiable(true); + frame.setResizable(resizable); + frame.setMaximizable(resizable); + frame.setIconifiable(resizable); frame.setFrameIcon(null); frame.setLocation(xOffset*openFrameCount, yOffset*openFrameCount); frame.toFront(); final JMenuItem menuItem = new JMenuItem(title); frame.addInternalFrameListener(new javax.swing.event.InternalFrameAdapter() - { public void internalFrameClosed(javax.swing.event.InternalFrameEvent evt) - { - openFrameCount--; - windowMenu.remove(menuItem); - }; - }); + { + public void internalFrameClosed(javax.swing.event.InternalFrameEvent evt) + { + openFrameCount--; + windowMenu.remove(menuItem); + }; + }); menuItem.addActionListener(new ActionListener() { @@ -167,58 +164,99 @@ this.setDropTarget(new java.awt.dnd.DropTarget(desktop, this)); { String file = files.get(i).toString(); String protocol = "File"; - String format = jalview.io.IdentifyFile.Identify(file, protocol); - LoadFile(file, protocol, format); + if(file.endsWith(".jar")) + Jalview2XML.LoadJalviewAlign(file); + else + { + String format = jalview.io.IdentifyFile.Identify(file, protocol); + LoadFile(file, protocol, format); + } } }catch(Exception ex){ex.printStackTrace();} } + public void inputLocalFileMenuItem_actionPerformed(ActionEvent e) { JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache.getProperty("LAST_DIRECTORY"), - new String[]{"fa", "fasta", "fastq", "blc", "msf", "pfam", "aln", "pir"}, "Alignment files"); + new String[]{"fa, fasta, fastq", "aln", "pfam", "msf", "pir","blc","jar"}, + new String[]{"Fasta", "Clustal", "PFAM", "MSF", "PIR", "BLC", "Jalview"} + ,jalview.bin.Cache.getProperty("DEFAULT_FILE_FORMAT")); + chooser.setFileView(new JalviewFileView()); chooser.setDialogTitle("Open local file"); chooser.setToolTipText("Open"); int value = chooser.showOpenDialog(this); if(value == JalviewFileChooser.APPROVE_OPTION) { + jalview.bin.Cache.setProperty("DEFAULT_FILE_FORMAT", chooser.getSelectedFormat()); String choice = chooser.getSelectedFile().getPath(); - jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice); - String format = IdentifyFile.Identify(choice, "File"); - LoadFile(choice, "File", format); + jalview.bin.Cache.setProperty("LAST_DIRECTORY", chooser.getSelectedFile().getParent()); + if(chooser.getSelectedFormat().equals("Jalview")) + { + Jalview2XML.LoadJalviewAlign(choice); + } + else + { + String format = IdentifyFile.Identify(choice, "File"); + LoadFile(choice, "File", format); + } } } public void LoadFile(String file, String protocol, String format) { - SequenceI [] sequences = null; + LoadingThread loader = new LoadingThread(file, protocol, format); + loader.start(); + } - if (FormatProperties.contains(format)) - sequences = FormatAdapter.read(file, protocol, format); + class LoadingThread extends Thread + { + String file, protocol, format; - if (sequences != null && sequences.length>0) + public LoadingThread(String file, String protocol, String format) { - AlignFrame af = new AlignFrame(new Alignment(sequences)); - addInternalFrame(af, file, 700, 500); - af.statusBar.setText("Successfully loaded file " + file); - + this.file = file; + this.protocol = protocol; + this.format = format; } - else - JOptionPane.showInternalMessageDialog(Desktop.desktop, "Couldn't open file.\n" - + "Formats currently supported are\n" - + "Fasta, MSF, Clustal, BLC, PIR, MSP or PFAM" // JBPNote - message should be generated through FormatAdapter! - ,"Error loading file", - JOptionPane.WARNING_MESSAGE); + public void run() + { + SequenceI [] sequences = null; + + if (FormatAdapter.formats.contains(format)) + sequences = FormatAdapter.readFile(file, protocol, format); + + if (sequences != null && sequences.length>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; @@ -250,20 +288,23 @@ this.setDropTarget(new java.awt.dnd.DropTarget(desktop, this)); 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); } @@ -288,8 +329,9 @@ this.setDropTarget(new java.awt.dnd.DropTarget(desktop, this)); "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: Bioinformatics, 2004 12;426-7." - +"\n\"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); } @@ -314,92 +356,45 @@ this.setDropTarget(new java.awt.dnd.DropTarget(desktop, this)); } } - static JInternalFrame conservationSlider; - static JInternalFrame PIDSlider; - public static int setConservationSliderSource(AlignmentPanel ap, ColourSchemeI cs, String source) + protected void preferences_actionPerformed(ActionEvent e) { - SliderPanel sp = null; - ConservationColourScheme ccs = (ConservationColourScheme)cs; - int value = ccs.inc; - - if(conservationSlider == null) - { - sp = new SliderPanel(ap, value, true, cs); - conservationSlider = new JInternalFrame(); - conservationSlider.setContentPane(sp); - addInternalFrame(conservationSlider, "Conservation Colour Increment ("+source+")", 420, 90); - conservationSlider.setResizable(false); - conservationSlider.setMaximizable(false); - conservationSlider.addInternalFrameListener(new javax.swing.event.InternalFrameAdapter() - { - public void internalFrameClosed(javax.swing.event.InternalFrameEvent e) - { - conservationSlider = null; - } - }); - } - else - { - - conservationSlider.setTitle("Conservation Colour Increment ("+source+")"); - sp = (SliderPanel)conservationSlider.getContentPane(); - sp.cs = cs; - sp.setValue(value); - } - - if(ap.av.alignment.getGroups()!=null) - sp.setAllGroupsCheckEnabled( true ); - else - sp.setAllGroupsCheckEnabled( false); - - return sp.getValue(); - + Preferences pref = new Preferences(); } - public static void hideConservationSlider() + public void saveState_actionPerformed(ActionEvent e) { - try{ - conservationSlider.setClosed(true); - conservationSlider = null; - }catch(Exception ex){} -} + 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 static void hidePIDSlider() - { - try{ - PIDSlider.setClosed(true); - PIDSlider = null; - }catch(Exception ex){} } - public static int setPIDSliderSource(AlignmentPanel ap, ColourSchemeI cs, String source) + + public void loadState_actionPerformed(ActionEvent e) { - SliderPanel pid = null; - if(PIDSlider == null) - { - pid = new SliderPanel(ap, 50, false, cs); - PIDSlider = new JInternalFrame(); - PIDSlider.setContentPane(pid); - addInternalFrame(PIDSlider, "Percentage Identity Threshold ("+source+")", 420, 90); - PIDSlider.setResizable(false); - PIDSlider.setMaximizable(false); - } - else + 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) { - PIDSlider.setTitle("Percentage Identity Threshold ("+source+")"); - pid = (SliderPanel)PIDSlider.getContentPane(); - pid.cs = cs; + String choice = chooser.getSelectedFile().getAbsolutePath(); + jalview.bin.Cache.setProperty("LAST_DIRECTORY", chooser.getSelectedFile().getParent()); + Jalview2XML.LoadState(choice); } - - if (ap.av.alignment.getGroups() != null) - pid.setAllGroupsCheckEnabled(true); - else - pid.setAllGroupsCheckEnabled(false); - - - return pid.getValue(); - } - } + +