X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fgui%2FAlignFrame.java;h=725a702da877fce68aab0c669e68abaa7f32be87;hb=67fe33692d163752fd467468b18ace4a9b4eac7d;hp=a21aabe7c25ca3a54071fba19ce810cf97ca2949;hpb=affd24332b831acf0ffe4697dc1efafe8e414b31;p=jalview.git diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index a21aabe..725a702 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.get(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); @@ -112,7 +108,7 @@ public class AlignFrame extends GAlignFrame cap.formatForOutput(); frame.setContentPane(cap); Desktop.addInternalFrame(frame, "Alignment output - "+e.getActionCommand(), 600, 500); - cap.setText( FormatAdapter.get(e.getActionCommand(), viewport.getAlignment().getSequences())); + cap.setText( FormatAdapter.formatSequences(e.getActionCommand(), viewport.getAlignment().getSequences())); } protected void htmlMenuItem_actionPerformed(ActionEvent e) @@ -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