From: amwaterhouse Date: Thu, 19 May 2005 17:57:34 +0000 (+0000) Subject: loading/saving changes X-Git-Tag: Release_2_0~278 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=6c733ae20b3a34d16ad79923eeb5543e0205a1ca;p=jalview.git loading/saving changes --- diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index 4fbdb72..300be96 100755 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -32,18 +32,12 @@ public class AlignFrame extends GAlignFrame final AlignViewport viewport; public static final int NEW_WINDOW_WIDTH = 700; public static final int NEW_WINDOW_HEIGHT = 500; + public String currentFileFormat = "Jalview"; public AlignFrame(AlignmentI al) { - try{ - String ip = java.net.InetAddress.getLocalHost().getHostAddress(); - if( !ip.startsWith("10.")) - webService.setVisible(false); - } - catch(java.net.UnknownHostException e){} viewport = new AlignViewport(al); - alignPanel = new AlignmentPanel(this, viewport); alignPanel.annotationPanel.adjustPanelHeight(); alignPanel.annotationSpaceFillerHolder.setPreferredSize(alignPanel.annotationPanel.getPreferredSize()); @@ -67,34 +61,36 @@ public class AlignFrame extends GAlignFrame } - protected void saveAs_actionPerformed(ActionEvent e) + public void saveAlignmentMenu_actionPerformed(ActionEvent e) { - String suffix [] = null; - if(e.getActionCommand().equals("FASTA")) - suffix = new String[]{"fa", "fasta"}; - else if(e.getActionCommand().equals("MSF")) - suffix = new String[]{"msf"}; - else if(e.getActionCommand().equals("CLUSTAL")) - suffix = new String[]{"aln"}; - else if(e.getActionCommand().equals("BLC")) - suffix = new String[]{"blc"}; - else if(e.getActionCommand().equals("PIR")) - suffix = new String[]{"pir"}; - else if(e.getActionCommand().equals("PFAM")) - suffix = new String[]{"pfam"}; - - JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache.getProperty("LAST_DIRECTORY") - , suffix, e.getActionCommand()+" file"); + , new String[]{"fa, fasta, fastq", "aln", "pfam", "msf", "pir","blc","jar"}, + new String[]{"FASTA", "CLUSTAL", "PFAM", "MSF", "PIR", "BLC", "Jalview"}, + currentFileFormat); + + chooser.setAcceptAllFileFilterUsed(false); chooser.setFileView(new JalviewFileView()); - chooser.setDialogTitle("Save Alignment to file - "+e.getActionCommand() +" format."); + chooser.setDialogTitle("Save Alignment to file"); chooser.setToolTipText("Save"); int value = chooser.showSaveDialog(this); if(value == JalviewFileChooser.APPROVE_OPTION) { + currentFileFormat = chooser.getSelectedFormat(); + + if (currentFileFormat.equals("Jalview")) + { + String shortName = title.replace('/', '_'); + title = title.replace('\\', '_'); + String choice = chooser.getSelectedFile().getPath(); + Jalview2XML.SaveState(this, System.currentTimeMillis(), shortName, + choice); + // USE Jalview2XML to save this file + return; + } + String choice = chooser.getSelectedFile().getPath(); jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice); - String output = FormatAdapter.formatSequences(e.getActionCommand(), viewport.getAlignment().getSequences()); + String output = FormatAdapter.formatSequences(currentFileFormat, viewport.getAlignment().getSequences()); try{ java.io.PrintWriter out = new java.io.PrintWriter( new java.io.FileWriter( choice ) ); out.println(output); @@ -205,6 +201,7 @@ public class AlignFrame extends GAlignFrame { // must make sure we add new sequence objects her, not refs to the existing sequences redoList.clear(); + SequenceI[] seq = new SequenceI[viewport.getAlignment().getHeight()]; for(int i=0; i