From: gmungoc Date: Tue, 30 Aug 2016 11:56:34 +0000 (+0100) Subject: Merge branch 'develop' into features/filetypeEnum X-Git-Tag: Release_2_10_3b1~410 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=8b27085fa7fc5f2877e078421284c2636b85b8c6;p=jalview.git Merge branch 'develop' into features/filetypeEnum Conflicts: src/jalview/io/AppletFormatAdapter.java src/jalview/io/FormatAdapter.java src/jalview/io/MSFfile.java src/jalview/io/RnamlFile.java src/jalview/io/StockholmFile.java src/jalview/ws/dbsources/Pdb.java test/jalview/ext/jmol/JmolParserTest.java test/jalview/gui/AlignViewportTest.java test/jalview/ws/jabaws/RNAStructExportImport.java --- 8b27085fa7fc5f2877e078421284c2636b85b8c6 diff --cc src/MCview/PDBfile.java index 6da867d,2746807..060de45 --- a/src/MCview/PDBfile.java +++ b/src/MCview/PDBfile.java @@@ -23,10 -23,8 +23,9 @@@ package MCview import jalview.datamodel.AlignmentAnnotation; import jalview.datamodel.DBRefSource; import jalview.datamodel.SequenceI; - import jalview.io.FileParse; +import jalview.io.DataSourceType; + import jalview.io.FileParse; import jalview.io.StructureFile; - import jalview.structure.StructureImportSettings; import jalview.util.MessageManager; import java.io.IOException; @@@ -67,7 -64,7 +66,7 @@@ public class PDBfile extends StructureF } @Override -- public String print() ++ public String print(SequenceI[] seqs, boolean jvSuffix) { return null; } diff --cc src/jalview/bin/JalviewLite.java index 0f3feb2,210a07a..7f15b3e --- a/src/jalview/bin/JalviewLite.java +++ b/src/jalview/bin/JalviewLite.java @@@ -37,8 -37,6 +37,9 @@@ import jalview.datamodel.SequenceGroup import jalview.datamodel.SequenceI; import jalview.io.AnnotationFile; import jalview.io.AppletFormatAdapter; +import jalview.io.DataSourceType; ++import jalview.io.FileFormat; +import jalview.io.FileFormatI; import jalview.io.FileParse; import jalview.io.IdentifyFile; import jalview.io.JPredFile; @@@ -522,21 -513,21 +517,23 @@@ public class JalviewLite extends Apple { try { ++ FileFormatI theFormat = FileFormat.valueOf(format); boolean seqlimits = suffix.equalsIgnoreCase(TRUE); if (alf.viewport.getSelectionGroup() != null) { // JBPNote: getSelectionAsNewSequence behaviour has changed - this // method now returns a full copy of sequence data // TODO consider using getSequenceSelection instead here -- String reply = new AppletFormatAdapter().formatSequences(format, ++ String reply = new AppletFormatAdapter().formatSequences(theFormat, new Alignment(alf.viewport.getSelectionAsNewSequence()), seqlimits); return reply; } -- } catch (Exception ex) ++ } catch (IllegalArgumentException ex) { ex.printStackTrace(); -- return "Error retrieving alignment in " + format + " format. "; ++ return "Error retrieving alignment, possibly invalid format specifier: " ++ + format; } return ""; } @@@ -718,13 -709,13 +715,15 @@@ { boolean seqlimits = suffix.equalsIgnoreCase(TRUE); -- String reply = new AppletFormatAdapter().formatSequences(format, ++ FileFormatI theFormat = FileFormat.valueOf(format); ++ String reply = new AppletFormatAdapter().formatSequences(theFormat, alf.viewport.getAlignment(), seqlimits); return reply; -- } catch (Exception ex) ++ } catch (IllegalArgumentException ex) { ex.printStackTrace(); -- return "Error retrieving alignment in " + format + " format. "; ++ return "Error retrieving alignment, possibly invalid format specifier: " ++ + format; } } diff --cc src/jalview/datamodel/Alignment.java index f14539b,32bb761..286e284 --- a/src/jalview/datamodel/Alignment.java +++ b/src/jalview/datamodel/Alignment.java @@@ -1737,7 -1742,7 +1742,7 @@@ public class Alignment implements Align @Override public String toString() { -- return new FastaFile().print(getSequencesArray()); ++ return new FastaFile().print(getSequencesArray(), true); } /** diff --cc src/jalview/datamodel/PDBEntry.java index 243e00c,1c7df49..37dfdbf --- a/src/jalview/datamodel/PDBEntry.java +++ b/src/jalview/datamodel/PDBEntry.java @@@ -34,10 -34,10 +34,30 @@@ public class PDBEntr public enum Type { -- PDB, MMCIF, FILE ++ // TODO is FILE needed; if not is this needed or can we ++ // use FileFormatI for PDB, MMCIF? ++ PDB("pdb", "xml"), MMCIF("mmcif", "mmcif"), FILE("?", "?"); ++ String ext; ++ ++ String format; ++ ++ private Type(String fmt, String ex) ++ { ++ format = fmt; ++ ext = ex; ++ } ++ ++ public String getFormat() ++ { ++ return format; ++ } ++ public String getExtension() ++ { ++ return ext; ++ } } - Hashtable properties; + Hashtable properties; /* * (non-Javadoc) diff --cc src/jalview/ext/ensembl/EnsemblRestClient.java index e651ddf,72efdc1..653d5d5 --- a/src/jalview/ext/ensembl/EnsemblRestClient.java +++ b/src/jalview/ext/ensembl/EnsemblRestClient.java @@@ -1,5 -1,5 +1,6 @@@ package jalview.ext.ensembl; ++import jalview.io.DataSourceType; import jalview.io.FileParse; import jalview.util.StringUtils; @@@ -196,7 -208,7 +209,7 @@@ abstract class EnsemblRestClient extend URL url = getUrl(ids); BufferedReader reader = getHttpResponse(url, ids); -- FileParse fp = new FileParse(reader, url.toString(), "HTTP_POST"); ++ FileParse fp = new FileParse(reader, url.toString(), DataSourceType.URL); return fp; } diff --cc src/jalview/ext/jmol/JmolParser.java index ba57329,848e7db..858aac7 --- a/src/jalview/ext/jmol/JmolParser.java +++ b/src/jalview/ext/jmol/JmolParser.java @@@ -22,10 -22,8 +22,9 @@@ package jalview.ext.jmol import jalview.datamodel.AlignmentAnnotation; import jalview.datamodel.Annotation; - import jalview.datamodel.DBRefSource; import jalview.datamodel.SequenceI; - import jalview.io.FileParse; +import jalview.io.DataSourceType; + import jalview.io.FileParse; import jalview.io.StructureFile; import jalview.schemes.ResidueProperties; import jalview.structure.StructureImportSettings; @@@ -398,7 -443,7 +444,7 @@@ public class JmolParser extends Structu * Not implemented - returns null */ @Override -- public String print() ++ public String print(SequenceI[] seqs, boolean jvSuffix) { return null; } diff --cc src/jalview/gui/AlignFrame.java index 1554631,f6268c0..38223c7 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@@ -1106,11 -1103,11 +1107,11 @@@ public class AlignFrame extends GAlignF @Override public void saveAs_actionPerformed(ActionEvent e) { -- JalviewFileChooser chooser = new JalviewFileChooser( - jalview.bin.Cache.getProperty("LAST_DIRECTORY"), - jalview.io.AppletFormatAdapter.WRITABLE_EXTENSIONS, - jalview.io.AppletFormatAdapter.WRITABLE_FNAMES, - currentFileFormat, false); ++ JalviewFileChooser chooser = JalviewFileChooser.forWrite( + Cache.getProperty("LAST_DIRECTORY"), + // AppletFormatAdapter.WRITABLE_EXTENSIONS, + // AppletFormatAdapter.WRITABLE_FNAMES, - currentFileFormat, false); ++ currentFileFormat.toString(), false); chooser.setFileView(new JalviewFileView()); chooser.setDialogTitle(MessageManager @@@ -1866,7 -1865,7 +1867,8 @@@ fileFormat omitHidden = viewport.getViewAsString(true); } -- String output = new FormatAdapter().formatSequences("Fasta", seqs, ++ String output = new FormatAdapter().formatSequences(FileFormat.Fasta, ++ seqs, omitHidden, null); StringSelection ss = new StringSelection(output); diff --cc src/jalview/gui/Desktop.java index 22a5203,7811e41..624054b --- a/src/jalview/gui/Desktop.java +++ b/src/jalview/gui/Desktop.java @@@ -446,12 -443,11 +446,11 @@@ public class Desktop extends jalview.jb public void run() { Cache.log.debug("Filechooser init thread started."); - FileFormat fileFormat = FileFormat.valueOf(Cache - .getProperty("DEFAULT_FILE_FORMAT")); - new JalviewFileChooser(Cache.getProperty("LAST_DIRECTORY"), - new JalviewFileChooser( - jalview.bin.Cache.getProperty("LAST_DIRECTORY"), - jalview.io.AppletFormatAdapter.READABLE_EXTENSIONS, - jalview.io.AppletFormatAdapter.READABLE_FNAMES, - jalview.bin.Cache.getProperty("DEFAULT_FILE_FORMAT")); ++ String fileFormat = Cache.getProperty("DEFAULT_FILE_FORMAT"); ++ JalviewFileChooser.forRead(Cache.getProperty("LAST_DIRECTORY"), + // jalview.io.AppletFormatAdapter.READABLE_EXTENSIONS, + // jalview.io.AppletFormatAdapter.READABLE_FNAMES, - fileFormat); ++ fileFormat, true); Cache.log.debug("Filechooser init thread finished."); } }).start(); @@@ -1011,13 -1007,11 +1010,12 @@@ @Override public void inputLocalFileMenuItem_actionPerformed(AlignViewport viewport) { - FileFormat fileFormat = FileFormat.valueOf(Cache - .getProperty("DEFAULT_FILE_FORMAT")); -- JalviewFileChooser chooser = new JalviewFileChooser( - jalview.bin.Cache.getProperty("LAST_DIRECTORY"), - jalview.io.AppletFormatAdapter.READABLE_EXTENSIONS, - jalview.io.AppletFormatAdapter.READABLE_FNAMES, - jalview.bin.Cache.getProperty("DEFAULT_FILE_FORMAT")); ++ String fileFormat = Cache.getProperty("DEFAULT_FILE_FORMAT"); ++ JalviewFileChooser chooser = JalviewFileChooser.forRead( + Cache.getProperty("LAST_DIRECTORY"), + // AppletFormatAdapter.READABLE_EXTENSIONS, + // AppletFormatAdapter.READABLE_FNAMES, - fileFormat); ++ fileFormat, true); chooser.setFileView(new JalviewFileView()); chooser.setDialogTitle(MessageManager @@@ -1070,7 -1057,6 +1068,7 @@@ */ @Override public void inputURLMenuItem_actionPerformed(AlignViewport viewport) - throws FileFormatException ++ // throws FileFormatException { // This construct allows us to have a wider textfield // for viewing @@@ -1125,10 -1110,9 +1123,17 @@@ } else { - FileFormatI format = new IdentifyFile().identify(url, - DataSourceType.URL); - String format = new IdentifyFile().identify(url, FormatAdapter.URL); ++ FileFormatI format = null; ++ try ++ { ++ format = new IdentifyFile().identify(url, DataSourceType.URL); ++ } catch (FileFormatException e) ++ { ++ // TODO revise error handling, distinguish between ++ // URL not found and response not valid ++ } -- if (format.equals("URL NOT FOUND")) ++ if (format == null) { JOptionPane.showInternalMessageDialog(Desktop.desktop, MessageManager.formatMessage("label.couldnt_locate", @@@ -1529,8 -1512,8 +1534,7 @@@ public void saveState_actionPerformed(ActionEvent e) { JalviewFileChooser chooser = new JalviewFileChooser( -- jalview.bin.Cache.getProperty("LAST_DIRECTORY"), -- new String[] { "jvp" }, new String[] { "Jalview Project" }, ++ Cache.getProperty("LAST_DIRECTORY"), "jvp", "Jalview Project", "Jalview Project"); chooser.setFileView(new JalviewFileView()); @@@ -1601,7 -1584,7 +1605,7 @@@ public void loadState_actionPerformed(ActionEvent e) { JalviewFileChooser chooser = new JalviewFileChooser( -- jalview.bin.Cache.getProperty("LAST_DIRECTORY"), new String[] { ++ Cache.getProperty("LAST_DIRECTORY"), new String[] { "jvp", "jar" }, new String[] { "Jalview Project", "Jalview Project (old)" }, "Jalview Project"); chooser.setFileView(new JalviewFileView()); @@@ -1614,7 -1597,7 +1618,7 @@@ final File selectedFile = chooser.getSelectedFile(); setProjectFile(selectedFile); final String choice = selectedFile.getAbsolutePath(); -- jalview.bin.Cache.setProperty("LAST_DIRECTORY", ++ Cache.setProperty("LAST_DIRECTORY", selectedFile.getParent()); new Thread(new Runnable() { @@@ -2185,9 -2168,9 +2189,8 @@@ if (v_client != null) { JalviewFileChooser chooser = new JalviewFileChooser( -- jalview.bin.Cache.getProperty("LAST_DIRECTORY"), new String[] -- { "vdj" }, // TODO: VAMSAS DOCUMENT EXTENSION is VDJ -- new String[] { "Vamsas Document" }, "Vamsas Document"); ++ Cache.getProperty("LAST_DIRECTORY"), "vdj", ++ "Vamsas Document", "Vamsas Document"); chooser.setFileView(new JalviewFileView()); chooser.setDialogTitle(MessageManager @@@ -2201,7 -2184,7 +2204,7 @@@ JPanel progpanel = addProgressPanel(MessageManager.formatMessage( "label.saving_vamsas_doc", new Object[] { choice.getName() })); -- jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice.getParent()); ++ Cache.setProperty("LAST_DIRECTORY", choice.getParent()); String warnmsg = null; String warnttl = null; try diff --cc src/jalview/gui/FeatureSettings.java index bfc14b5,3b8ce37..6dc5cb3 --- a/src/jalview/gui/FeatureSettings.java +++ b/src/jalview/gui/FeatureSettings.java @@@ -736,10 -750,10 +750,8 @@@ public class FeatureSettings extends JP void load() { JalviewFileChooser chooser = new JalviewFileChooser( -- jalview.bin.Cache.getProperty("LAST_DIRECTORY"), -- new String[] { "fc" }, -- new String[] { "Sequence Feature Colours" }, -- "Sequence Feature Colours"); ++ Cache.getProperty("LAST_DIRECTORY"), "fc", ++ "Sequence Feature Colours", "Sequence Feature Colours"); chooser.setFileView(new jalview.io.JalviewFileView()); chooser.setDialogTitle(MessageManager .getString("label.load_feature_colours")); @@@ -831,10 -845,10 +843,8 @@@ void save() { JalviewFileChooser chooser = new JalviewFileChooser( -- Cache.getProperty("LAST_DIRECTORY"), -- new String[] { "fc" }, -- new String[] { "Sequence Feature Colours" }, -- "Sequence Feature Colours"); ++ Cache.getProperty("LAST_DIRECTORY"), "fc", ++ "Sequence Feature Colours", "Sequence Feature Colours"); chooser.setFileView(new jalview.io.JalviewFileView()); chooser.setDialogTitle(MessageManager .getString("label.save_feature_colours")); diff --cc src/jalview/gui/Jalview2XML.java index 1c2bfa6,68245b6..35d4685 --- a/src/jalview/gui/Jalview2XML.java +++ b/src/jalview/gui/Jalview2XML.java @@@ -36,7 -36,6 +36,8 @@@ import jalview.datamodel.StructureViewe import jalview.datamodel.StructureViewerModel.StructureData; import jalview.ext.varna.RnaModel; import jalview.gui.StructureViewer.ViewerType; +import jalview.io.DataSourceType; ++import jalview.io.FileFormat; import jalview.schemabinding.version2.AlcodMap; import jalview.schemabinding.version2.AlcodonFrame; import jalview.schemabinding.version2.Annotation; @@@ -4104,7 -4260,7 +4261,7 @@@ public class Jalview2XM af = new AlignFrame(al, view.getWidth(), view.getHeight(), uniqueSeqSetId, viewId); -- af.setFileName(file, "Jalview"); ++ af.setFileName(file, FileFormat.Jalview); for (int i = 0; i < JSEQ.length; i++) { diff --cc src/jalview/gui/Jalview2XML_V1.java index 61e20fa,61e20fa..4a582de --- a/src/jalview/gui/Jalview2XML_V1.java +++ b/src/jalview/gui/Jalview2XML_V1.java @@@ -35,6 -35,6 +35,7 @@@ import jalview.binding.Tree import jalview.binding.UserColours; import jalview.binding.Viewport; import jalview.datamodel.PDBEntry; ++import jalview.io.FileFormat; import jalview.schemes.ColourSchemeI; import jalview.schemes.ColourSchemeProperty; import jalview.schemes.ResidueProperties; @@@ -305,7 -305,7 +306,7 @@@ public class Jalview2XML_V AlignFrame af = new AlignFrame(al, view.getWidth(), view.getHeight()); -- af.setFileName(file, "Jalview"); ++ af.setFileName(file, FileFormat.Jalview); for (int i = 0; i < JSEQ.length; i++) { diff --cc src/jalview/gui/PopupMenu.java index f0fdb9f,d28dc60..52a0d41 --- a/src/jalview/gui/PopupMenu.java +++ b/src/jalview/gui/PopupMenu.java @@@ -38,7 -38,6 +38,8 @@@ import jalview.datamodel.Sequence import jalview.datamodel.SequenceFeature; import jalview.datamodel.SequenceGroup; import jalview.datamodel.SequenceI; +import jalview.io.FileFormat; ++import jalview.io.FileFormatI; import jalview.io.FormatAdapter; import jalview.io.SequenceAnnotationReport; import jalview.schemes.AnnotationColourGradient; @@@ -2339,8 -2334,8 +2336,8 @@@ public class PopupMenu extends JPopupMe // or we simply trust the user wants // wysiwig behaviour - FileFormat fileFormat = FileFormat.forName(e.getActionCommand()); - cap.setText(new FormatAdapter(ap).formatSequences(e.getActionCommand(), - ap, true)); ++ FileFormatI fileFormat = FileFormat.forName(e.getActionCommand()); + cap.setText(new FormatAdapter(ap).formatSequences(fileFormat, ap, true)); } public void sequenceFeature_actionPerformed() diff --cc src/jalview/gui/Preferences.java index 80b1806,afc93e0..1ac17e4 --- a/src/jalview/gui/Preferences.java +++ b/src/jalview/gui/Preferences.java @@@ -684,14 -683,12 +683,14 @@@ public class Preferences extends GPrefe @Override public void startupFileTextfield_mouseClicked() { - FileFormat fileFormat = FileFormat.valueOf(Cache.getProperty("DEFAULT_FILE_FORMAT")); -- JalviewFileChooser chooser = new JalviewFileChooser( - // fixme push into enum - Cache.getProperty("LAST_DIRECTORY"), new String[] { - "fa, fasta, fastq", "aln", "pfam", "msf", "pir", "blc", - "jar" }, new String[] { "Fasta", "Clustal", "PFAM", "MSF", - "PIR", "BLC", "Jalview" }, - fileFormat); - jalview.bin.Cache.getProperty("LAST_DIRECTORY"), 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")); ++ String fileFormat = Cache.getProperty("DEFAULT_FILE_FORMAT"); ++ JalviewFileChooser chooser = JalviewFileChooser.forRead( ++ Cache.getProperty("LAST_DIRECTORY"), fileFormat, true); ++ // new String[] { ++ // "fa, fasta, fastq", "aln", "pfam", "msf", "pir", "blc", ++ // "jar" }, new String[] { "Fasta", "Clustal", "PFAM", "MSF", ++ // "PIR", "BLC", "Jalview" }, ++ // fileFormat); chooser.setFileView(new JalviewFileView()); chooser.setDialogTitle(MessageManager .getString("label.select_startup_file")); diff --cc src/jalview/gui/TreePanel.java index d78350d,fafa610..af84dbc --- a/src/jalview/gui/TreePanel.java +++ b/src/jalview/gui/TreePanel.java @@@ -42,6 -42,6 +42,7 @@@ import jalview.io.JalviewFileView import jalview.io.NewickFile; import jalview.jbgui.GTreePanel; import jalview.schemes.ResidueProperties; ++import jalview.util.ImageMaker; import jalview.util.MessageManager; import jalview.viewmodel.AlignmentViewport; @@@ -747,24 -747,24 +748,24 @@@ public class TreePanel extends GTreePan try { -- jalview.io.JalviewFileChooser chooser = new jalview.io.JalviewFileChooser( -- jalview.bin.Cache.getProperty("LAST_DIRECTORY"), new String[] -- { "eps" }, new String[] { "Encapsulated Postscript" }, -- "Encapsulated Postscript"); -- chooser.setFileView(new jalview.io.JalviewFileView()); ++ JalviewFileChooser chooser = new JalviewFileChooser( ++ Cache.getProperty("LAST_DIRECTORY"), ++ ImageMaker.EPS_EXTENSION, ImageMaker.EPS_EXTENSION, ++ ImageMaker.EPS_EXTENSION); ++ chooser.setFileView(new JalviewFileView()); chooser.setDialogTitle(MessageManager .getString("label.create_eps_from_tree")); chooser.setToolTipText(MessageManager.getString("action.save")); int value = chooser.showSaveDialog(this); -- if (value != jalview.io.JalviewFileChooser.APPROVE_OPTION) ++ if (value != JalviewFileChooser.APPROVE_OPTION) { return; } -- jalview.bin.Cache.setProperty("LAST_DIRECTORY", chooser -- .getSelectedFile().getParent()); ++ Cache.setProperty("LAST_DIRECTORY", chooser.getSelectedFile() ++ .getParent()); FileOutputStream out = new FileOutputStream(chooser.getSelectedFile()); EpsGraphics2D pg = new EpsGraphics2D("Tree", out, 0, 0, width, height); @@@ -795,10 -795,10 +796,10 @@@ try { -- jalview.io.JalviewFileChooser chooser = new jalview.io.JalviewFileChooser( -- jalview.bin.Cache.getProperty("LAST_DIRECTORY"), new String[] -- { "png" }, new String[] { "Portable network graphics" }, -- "Portable network graphics"); ++ JalviewFileChooser chooser = new JalviewFileChooser( ++ Cache.getProperty("LAST_DIRECTORY"), ++ ImageMaker.PNG_EXTENSION, ImageMaker.PNG_DESCRIPTION, ++ ImageMaker.PNG_DESCRIPTION); chooser.setFileView(new jalview.io.JalviewFileView()); chooser.setDialogTitle(MessageManager diff --cc src/jalview/gui/UserDefinedColours.java index c9c1531,c9c1531..80fd5f6 --- a/src/jalview/gui/UserDefinedColours.java +++ b/src/jalview/gui/UserDefinedColours.java @@@ -21,6 -21,6 +21,7 @@@ package jalview.gui; import jalview.api.structures.JalviewStructureDisplayI; ++import jalview.bin.Cache; import jalview.datamodel.SequenceGroup; import jalview.io.JalviewFileChooser; import jalview.jbgui.GUserDefinedColours; @@@ -597,9 -597,9 +598,8 @@@ public class UserDefinedColours extend lowerCaseButtons = new ArrayList(); JalviewFileChooser chooser = new JalviewFileChooser( -- jalview.bin.Cache.getProperty("LAST_DIRECTORY"), -- new String[] { "jc" }, new String[] { "Jalview User Colours" }, -- "Jalview User Colours"); ++ Cache.getProperty("LAST_DIRECTORY"), "jc", ++ "Jalview User Colours", "Jalview User Colours"); chooser.setFileView(new jalview.io.JalviewFileView()); chooser.setDialogTitle(MessageManager .getString("label.load_colour_scheme")); @@@ -833,9 -833,9 +833,8 @@@ userColourSchemes.remove(schemeName.getText()); } JalviewFileChooser chooser = new JalviewFileChooser( -- jalview.bin.Cache.getProperty("LAST_DIRECTORY"), -- new String[] { "jc" }, new String[] { "Jalview User Colours" }, -- "Jalview User Colours"); ++ Cache.getProperty("LAST_DIRECTORY"), "jc", ++ "Jalview User Colours", "Jalview User Colours"); chooser.setFileView(new jalview.io.JalviewFileView()); chooser.setDialogTitle(MessageManager diff --cc src/jalview/gui/WsParamSetManager.java index b6a7672,b6a7672..aec79e4 --- a/src/jalview/gui/WsParamSetManager.java +++ b/src/jalview/gui/WsParamSetManager.java @@@ -22,6 -22,6 +22,7 @@@ package jalview.gui import jalview.bin.Cache; import jalview.io.JalviewFileChooser; ++import jalview.io.JalviewFileView; import jalview.util.MessageManager; import jalview.ws.params.ParamDatastoreI; import jalview.ws.params.ParamManager; @@@ -185,11 -185,11 +186,9 @@@ public class WsParamSetManager implemen if (filename == null) { JalviewFileChooser chooser = new JalviewFileChooser( -- jalview.bin.Cache.getProperty("LAST_DIRECTORY"), new String[] -- { "wsparams" }, -- new String[] { "Web Service Parameter File" }, -- "Web Service Parameter File"); -- chooser.setFileView(new jalview.io.JalviewFileView()); ++ Cache.getProperty("LAST_DIRECTORY"), "wsparams", ++ "Web Service Parameter File", "Web Service Parameter File"); ++ chooser.setFileView(new JalviewFileView()); chooser.setDialogTitle(MessageManager .getString("label.choose_filename_for_param_file")); chooser.setToolTipText(MessageManager.getString("action.save")); diff --cc src/jalview/io/AlignFile.java index d36a588,5760fbe..d333c64 --- a/src/jalview/io/AlignFile.java +++ b/src/jalview/io/AlignFile.java @@@ -370,18 -371,16 +370,23 @@@ public abstract class AlignFile extend } /** -- * Creates the output id. Adds prefix Uniprot format source|id And suffix -- * Jalview /start-end ++ * Creates the output id. Adds prefix Uniprot format source|id and optionally ++ * suffix Jalview /start-end + * + * @param jvsuffix * * @String id Id to be parsed */ + String printId(SequenceI seq, boolean jvsuffix) + { + return seq.getDisplayId(jvsuffix); + } + + String printId(SequenceI seq) + { - return seq.getDisplayId(jvSuffix); ++ return printId(seq, true); + } + /** * vector of String[] treeName, newickString pairs */ diff --cc src/jalview/io/AppletFormatAdapter.java index 0c99d26,55bb03d..04d68e8 --- a/src/jalview/io/AppletFormatAdapter.java +++ b/src/jalview/io/AppletFormatAdapter.java @@@ -26,8 -26,9 +26,10 @@@ import jalview.datamodel.Alignment import jalview.datamodel.AlignmentAnnotation; import jalview.datamodel.AlignmentI; import jalview.datamodel.AlignmentView; + import jalview.datamodel.PDBEntry.Type; +import jalview.datamodel.SequenceI; ++import jalview.ext.jmol.JmolParser; import jalview.structure.StructureImportSettings; -import jalview.util.MessageManager; import java.io.File; import java.io.IOException; @@@ -177,45 -229,118 +179,68 @@@ public class AppletFormatAdapte * * @param inFile * data/data location - * @param type + * @param sourceType * type of datasource - * @param format - * File format of data provided by datasource + * @param fileFormat * - * @return DOCUMENT ME! + * @return */ - public AlignmentI readFile(String inFile, String type, String format) - throws java.io.IOException + public AlignmentI readFile(String file, DataSourceType sourceType, + FileFormatI fileFormat) throws IOException { - // TODO: generalise mapping between format string and io. class instances - // using Constructor.invoke reflection - this.inFile = inFile; + this.inFile = file; try { - if (format.equals("FASTA")) - { - alignFile = new FastaFile(inFile, type); - } - else if (format.equals("MSF")) - { - alignFile = new MSFfile(inFile, type); - } - else if (format.equals("PileUp")) - { - alignFile = new PileUpfile(inFile, type); - } - else if (format.equals("CLUSTAL")) - { - alignFile = new ClustalFile(inFile, type); - } - else if (format.equals("BLC")) - { - alignFile = new BLCFile(inFile, type); - } - else if (format.equals("PIR")) - { - alignFile = new PIRFile(inFile, type); - } - else if (format.equals("PFAM")) - { - alignFile = new PfamFile(inFile, type); - } - else if (format.equals("JnetFile")) - { - alignFile = new JPredFile(inFile, type); - ((JPredFile) alignFile).removeNonSequences(); - } - else if (format.equals("PDB")) + if (fileFormat == FileFormat.PDB || fileFormat == FileFormat.MMCif) { - StructureImportSettings.addSettings(annotFromStructure, - localSecondaryStruct, serviceSecondaryStruct); - alignFile = fileFormat.getAlignmentFile(inFile, sourceType); + // TODO obtain config value from preference settings. + // Set value to 'true' to test PDB processing with Jmol: JAL-1213 + boolean isParseWithJMOL = StructureImportSettings + .getDefaultPDBFileParser().equalsIgnoreCase( + StructureImportSettings.StructureParser.JMOL_PARSER + .toString()); + if (isParseWithJMOL) + { + StructureImportSettings.addSettings(annotFromStructure, + localSecondaryStruct, serviceSecondaryStruct); - alignFile = new jalview.ext.jmol.JmolParser(annotFromStructure, ++ alignFile = new JmolParser(annotFromStructure, + localSecondaryStruct, serviceSecondaryStruct, inFile, - type); ++ sourceType); + } + else + { + StructureImportSettings.addSettings(annotFromStructure, + localSecondaryStruct, serviceSecondaryStruct); + StructureImportSettings.setShowSeqFeatures(true); + alignFile = new MCview.PDBfile(annotFromStructure, + localSecondaryStruct, serviceSecondaryStruct, inFile, - type); ++ sourceType); + } - ((StructureFile) alignFile).setDbRefType(format); - } - else if (format.equalsIgnoreCase("mmCIF")) - { - StructureImportSettings.addSettings(annotFromStructure, - localSecondaryStruct, serviceSecondaryStruct); - alignFile = new jalview.ext.jmol.JmolParser(annotFromStructure, - localSecondaryStruct, serviceSecondaryStruct, inFile, type); - ((StructureFile) alignFile).setDbRefType(format); - } - else if (format.equals("STH")) - { - alignFile = new StockholmFile(inFile, type); ++ ((StructureFile) alignFile) ++ .setDbRefType(fileFormat == FileFormat.PDB ? Type.PDB ++ : Type.MMCIF); } - else if (format.equals("SimpleBLAST")) - { - alignFile = new SimpleBlastFile(inFile, type); - } - else if (format.equals(PhylipFile.FILE_DESC)) - { - alignFile = new PhylipFile(inFile, type); - } - else if (format.equals(JSONFile.FILE_DESC)) - { - alignFile = new JSONFile(inFile, type); - } - else if (format.equals(HtmlFile.FILE_DESC)) - { - alignFile = new HtmlFile(inFile, type); - } - else if (format.equals("RNAML")) - { - alignFile = new RnamlFile(inFile, type); - } - else if (format.equals(IdentifyFile.FeaturesFile)) + else { - alignFile = new FeaturesFile(true, inFile, type); - } - return buildAlignmentFrom(alignFile); + alignFile = fileFormat.getAlignmentFile(inFile, sourceType); + } + // new FastaFile(inFile, sourceType); + // new MSFfile(inFile, sourceType); + // new PileUpfile(inFile, sourceType); + // new ClustalFile(inFile, sourceType); + // new BLCFile(inFile, sourceType); + // new PIRFile(inFile, sourceType); + // new PfamFile(inFile, sourceType); + // alignFile = new JPredFile(inFile, sourceType); + // ((JPredFile) alignFile).removeNonSequences(); + // new StockholmFile(inFile, sourceType); + // new SimpleBlastFile(inFile, sourceType); + // new PhylipFile(inFile, sourceType); + // new JSONFile(inFile, sourceType); + // new HtmlFile(inFile, sourceType); + // new RnamlFile(inFile, sourceType); +// alignFile = new FeaturesFile(true, inFile, sourceType); + return buildAlignmentFromFile(); } catch (Exception e) { e.printStackTrace(); @@@ -265,27 -389,109 +290,40 @@@ * @param format * File format of data that will be provided by datasource * - * @return DOCUMENT ME! + * @return */ - public AlignmentI readFromFile(FileParse source, String format) - throws java.io.IOException + public AlignmentI readFromFile(FileParse source, FileFormatI format) + throws IOException { - // TODO: generalise mapping between format string and io. class instances - // using Constructor.invoke reflection - // This is exactly the same as the readFile method except we substitute - // 'inFile, type' with 'source' this.inFile = source.getInFile(); - String type = source.type; + DataSourceType type = source.dataSourceType; try { - if (format.equals("FASTA")) - { - alignFile = new FastaFile(source); - } - else if (format.equals("MSF")) - { - alignFile = new MSFfile(source); - } - else if (format.equals("PileUp")) - { - alignFile = new PileUpfile(source); - } - else if (format.equals("CLUSTAL")) - { - alignFile = new ClustalFile(source); - } - else if (format.equals("BLC")) - { - alignFile = new BLCFile(source); - } - else if (format.equals("PIR")) - { - alignFile = new PIRFile(source); - } - else if (format.equals("PFAM")) - { - alignFile = new PfamFile(source); - } - else if (format.equals("JnetFile")) - { - alignFile = new JPredFile(source); - ((JPredFile) alignFile).removeNonSequences(); - } - else if (format.equals("PDB")) + if (format == FileFormat.PDB || format == FileFormat.MMCif) { - StructureImportSettings.addSettings(annotFromStructure, - localSecondaryStruct, serviceSecondaryStruct); - alignFile = format.getAlignmentFile(source); + // TODO obtain config value from preference settings + boolean isParseWithJMOL = false; + if (isParseWithJMOL) + { + StructureImportSettings.addSettings(annotFromStructure, + localSecondaryStruct, serviceSecondaryStruct); - alignFile = new jalview.ext.jmol.JmolParser(annotFromStructure, ++ alignFile = new JmolParser(annotFromStructure, + localSecondaryStruct, serviceSecondaryStruct, source); + } + else + { + StructureImportSettings.setShowSeqFeatures(true); + alignFile = new MCview.PDBfile(annotFromStructure, + localSecondaryStruct, serviceSecondaryStruct, source); + } + ((StructureFile) alignFile).setDbRefType(Type.PDB); } - else if (format.equalsIgnoreCase("mmCIF")) - { - StructureImportSettings.addSettings(annotFromStructure, - localSecondaryStruct, serviceSecondaryStruct); - alignFile = new jalview.ext.jmol.JmolParser(annotFromStructure, - localSecondaryStruct, serviceSecondaryStruct, source); - ((StructureFile) alignFile).setDbRefType(Type.MMCIF); - } - else if (format.equals("STH")) - { - alignFile = new StockholmFile(source); - } - else if (format.equals("RNAML")) - { - alignFile = new RnamlFile(source); - } - else if (format.equals("SimpleBLAST")) - { - alignFile = new SimpleBlastFile(source); - } - else if (format.equals(PhylipFile.FILE_DESC)) - { - alignFile = new PhylipFile(source); - } - else if (format.equals(IdentifyFile.FeaturesFile)) - { - alignFile = new FeaturesFile(inFile, type); - } - else if (format.equals(JSONFile.FILE_DESC)) - { - alignFile = new JSONFile(source); - } - else if (format.equals(HtmlFile.FILE_DESC)) + else { - alignFile = new HtmlFile(source); + alignFile = format.getAlignmentFile(source); } - return buildAlignmentFrom(alignFile); + return buildAlignmentFromFile(); } catch (Exception e) { diff --cc src/jalview/io/BioJsHTMLOutput.java index 0ebebc2,f8fa1f5..80df097 --- a/src/jalview/io/BioJsHTMLOutput.java +++ b/src/jalview/io/BioJsHTMLOutput.java @@@ -22,13 -22,12 +22,15 @@@ package jalview.io import jalview.api.AlignExportSettingI; import jalview.api.AlignmentViewPanel; ++import jalview.bin.Cache; import jalview.datamodel.AlignmentExportData; import jalview.exceptions.NoFileSelectedException; +import jalview.gui.AlignFrame; import jalview.gui.IProgressIndicator; import jalview.gui.OOMWarning; import jalview.json.binding.biojs.BioJSReleasePojo; import jalview.json.binding.biojs.BioJSRepositoryPojo; ++import jalview.util.ImageMaker; import jalview.util.MessageManager; import java.io.BufferedInputStream; @@@ -177,9 -176,9 +179,8 @@@ public class BioJsHTMLOutpu } JalviewFileChooser jvFileChooser = new JalviewFileChooser( -- jalview.bin.Cache.getProperty("LAST_DIRECTORY"), -- new String[] { "html" }, new String[] { "HTML files" }, -- "HTML files"); ++ Cache.getProperty("LAST_DIRECTORY"), ImageMaker.HTML_EXTENSION, ++ ImageMaker.HTML_EXTENSION, ImageMaker.HTML_EXTENSION); jvFileChooser.setFileView(new JalviewFileView()); jvFileChooser.setDialogTitle(MessageManager @@@ -189,7 -188,7 +190,7 @@@ int fileChooserOpt = jvFileChooser.showSaveDialog(null); if (fileChooserOpt == JalviewFileChooser.APPROVE_OPTION) { -- jalview.bin.Cache.setProperty("LAST_DIRECTORY", jvFileChooser ++ Cache.setProperty("LAST_DIRECTORY", jvFileChooser .getSelectedFile().getParent()); selectedFile = jvFileChooser.getSelectedFile().getPath(); } diff --cc src/jalview/io/FileFormat.java index bca365f,0000000..a7113f6 mode 100644,000000..100644 --- a/src/jalview/io/FileFormat.java +++ b/src/jalview/io/FileFormat.java @@@ -1,529 -1,0 +1,530 @@@ +package jalview.io; + ++import jalview.datamodel.PDBEntry; +import jalview.ext.jmol.JmolParser; +import jalview.structure.StructureImportSettings; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +public enum FileFormat implements FileFormatI +{ + Fasta("FASTA", "fa, fasta, mfa, fastq", true, true) + { + @Override + public AlignmentFileI getAlignmentFile(String inFile, + DataSourceType sourceType) throws IOException + { + return new FastaFile(inFile, sourceType); + } + + @Override + public AlignmentFileI getAlignmentFile(FileParse source) + throws IOException + { + return new FastaFile(source); + } + + @Override + public AlignmentFileI getAlignmentFile() + { + return new FastaFile(); + } + }, + Pfam("PFAM", "pfam", true, true) + { + @Override + public AlignmentFileI getAlignmentFile(String inFile, + DataSourceType sourceType) throws IOException + { + return new PfamFile(inFile, sourceType); + } + + @Override + public AlignmentFileI getAlignmentFile(FileParse source) + throws IOException + { + return new PfamFile(source); + } + + @Override + public AlignmentFileI getAlignmentFile() + { + return new PfamFile(); + } + }, + Stockholm("STH", "sto,stk", true, true) + { + @Override + public AlignmentFileI getAlignmentFile(String inFile, + DataSourceType sourceType) throws IOException + { + return new StockholmFile(inFile, sourceType); + } + @Override + public AlignmentFileI getAlignmentFile(FileParse source) + throws IOException + { + return new StockholmFile(source); + } + + @Override + public AlignmentFileI getAlignmentFile() + { + return new StockholmFile(); + } + + }, + + PIR("PIR", "pir", true, true) + { + @Override + public AlignmentFileI getAlignmentFile(String inFile, + DataSourceType sourceType) throws IOException + { + return new PIRFile(inFile, sourceType); + } + @Override + public AlignmentFileI getAlignmentFile(FileParse source) + throws IOException + { + return new PIRFile(source); + } + + @Override + public AlignmentFileI getAlignmentFile() + { + return new PIRFile(); + } + }, + BLC("BLC", "BLC", true, true) + { + @Override + public AlignmentFileI getAlignmentFile(String inFile, + DataSourceType sourceType) throws IOException + { + return new BLCFile(inFile, sourceType); + } @Override + public AlignmentFileI getAlignmentFile(FileParse source) + throws IOException + { + return new BLCFile(source); + } + + @Override + public AlignmentFileI getAlignmentFile() + { + return new BLCFile(); + } + }, + Html("HTML", "html", true, false) + { + @Override + public AlignmentFileI getAlignmentFile(String inFile, + DataSourceType sourceType) throws IOException + { + return new HtmlFile(inFile, sourceType); + } @Override + public AlignmentFileI getAlignmentFile(FileParse source) + throws IOException + { + return new HtmlFile(source); + } + + @Override + public AlignmentFileI getAlignmentFile() + { + return new HtmlFile(); + } + + @Override + public boolean isComplexAlignFile() + { + return true; + } + + }, + Rnaml("RNAML", "xml,rnaml", true, false) + { + @Override + public AlignmentFileI getAlignmentFile(String inFile, + DataSourceType sourceType) throws IOException + { + return new RnamlFile(inFile, sourceType); + } @Override + public AlignmentFileI getAlignmentFile(FileParse source) + throws IOException + { + return new RnamlFile(source); + } + + @Override + public AlignmentFileI getAlignmentFile() + { + return new RnamlFile(); + } + + }, + Json("JSON","json", true, true) + { + @Override + public AlignmentFileI getAlignmentFile(String inFile, + DataSourceType sourceType) throws IOException + { + return new JSONFile(inFile, sourceType); + } @Override + public AlignmentFileI getAlignmentFile(FileParse source) + throws IOException + { + return new JSONFile(source); + } + + @Override + public AlignmentFileI getAlignmentFile() + { + return new JSONFile(); + } + + @Override + public boolean isComplexAlignFile() + { + return true; + } + + }, + Pileup("PileUp", "?", false, false) + { + @Override + public AlignmentFileI getAlignmentFile(String inFile, + DataSourceType sourceType) throws IOException + { + return new PileUpfile(inFile, sourceType); + } @Override + public AlignmentFileI getAlignmentFile(FileParse source) + throws IOException + { + return new PileUpfile(source); + } + + @Override + public AlignmentFileI getAlignmentFile() + { + return new PileUpfile(); + } + + }, + MSF("MSF", "msf", true, true) + { + @Override + public AlignmentFileI getAlignmentFile(String inFile, + DataSourceType sourceType) throws IOException + { + return new MSFfile(inFile, sourceType); + } @Override + public AlignmentFileI getAlignmentFile(FileParse source) + throws IOException + { + return new MSFfile(source); + } + + @Override + public AlignmentFileI getAlignmentFile() + { + return new MSFfile(); + } + + }, + Clustal("CLUSTAL", "aln", true, true) + { + @Override + public AlignmentFileI getAlignmentFile(String inFile, + DataSourceType sourceType) throws IOException + { + return new ClustalFile(inFile, sourceType); + } @Override + public AlignmentFileI getAlignmentFile(FileParse source) + throws IOException + { + return new ClustalFile(source); + } + + @Override + public AlignmentFileI getAlignmentFile() + { + return new ClustalFile(); + } + }, + Phylip("PHYLIP", "phy", true, true) + { + @Override + public AlignmentFileI getAlignmentFile(String inFile, + DataSourceType sourceType) throws IOException + { + return new PhylipFile(inFile, sourceType); + } + + @Override + public AlignmentFileI getAlignmentFile(FileParse source) + throws IOException + { + return new PhylipFile(source); + } + + @Override + public AlignmentFileI getAlignmentFile() + { + return new PhylipFile(); + } + }, + Jnet("JnetFile", "", false, false) + { + @Override + public AlignmentFileI getAlignmentFile(String inFile, + DataSourceType sourceType) throws IOException + { + JPredFile af = new JPredFile(inFile, sourceType); + af.removeNonSequences(); + return af; + } + + @Override + public AlignmentFileI getAlignmentFile(FileParse source) + throws IOException + { + JPredFile af = new JPredFile(source); + af.removeNonSequences(); + return af; + } + + @Override + public AlignmentFileI getAlignmentFile() + { + return null; // todo is this called? + } + + }, + Features("GFF or Jalview features", "gff2,gff3", false, false) + { + @Override + public AlignmentFileI getAlignmentFile(String inFile, + DataSourceType sourceType) throws IOException + { + return new FeaturesFile(true, inFile, sourceType); + } + + @Override + public AlignmentFileI getAlignmentFile(FileParse source) + throws IOException + { + return new FeaturesFile(source); + } + + @Override + public AlignmentFileI getAlignmentFile() + { + return new FeaturesFile(); + } + }, + PDB("PDB", "", false, false) + { + + @Override + public AlignmentFileI getAlignmentFile(String inFile, + DataSourceType sourceType) throws IOException + { + // TODO obtain config value from preference settings. + // Set value to 'true' to test PDB processing with Jmol: JAL-1213 - boolean isParseWithJMOL = !StructureImportSettings - .getCurrentDefaultFormat().equalsIgnoreCase("PDB"); ++ boolean isParseWithJMOL = StructureImportSettings ++ .getDefaultStructureFileFormat() != PDBEntry.Type.PDB; + if (isParseWithJMOL) + { + return new JmolParser( + StructureImportSettings.isVisibleChainAnnotation(), - StructureImportSettings.isPredictSecondaryStructure(), ++ StructureImportSettings.isProcessSecondaryStructure(), + StructureImportSettings.isExternalSecondaryStructure(), + inFile, + sourceType); + } + else + { + StructureImportSettings.setShowSeqFeatures(true); + return new MCview.PDBfile( + StructureImportSettings.isVisibleChainAnnotation(), - StructureImportSettings.isPredictSecondaryStructure(), ++ StructureImportSettings.isProcessSecondaryStructure(), + StructureImportSettings.isExternalSecondaryStructure(), + inFile, + sourceType); + } + } + + @Override + public AlignmentFileI getAlignmentFile(FileParse source) + throws IOException + { - boolean isParseWithJMOL = !StructureImportSettings - .getCurrentDefaultFormat().equalsIgnoreCase("PDB"); ++ boolean isParseWithJMOL = StructureImportSettings ++ .getDefaultStructureFileFormat() != PDBEntry.Type.PDB; + if (isParseWithJMOL) + { + return new JmolParser( + StructureImportSettings.isVisibleChainAnnotation(), - StructureImportSettings.isPredictSecondaryStructure(), ++ StructureImportSettings.isProcessSecondaryStructure(), + StructureImportSettings.isExternalSecondaryStructure(), + source); + } + else + { + StructureImportSettings.setShowSeqFeatures(true); + return new MCview.PDBfile( + StructureImportSettings.isVisibleChainAnnotation(), - StructureImportSettings.isPredictSecondaryStructure(), ++ StructureImportSettings.isProcessSecondaryStructure(), + StructureImportSettings.isExternalSecondaryStructure(), + source); + } + } + + @Override + public AlignmentFileI getAlignmentFile() + { + return new JmolParser(); // todo or null? + } + }, + MMCif("mmCIF", "cif", false, false) + { + + @Override + public AlignmentFileI getAlignmentFile(String inFile, + DataSourceType sourceType) throws IOException + { + return new JmolParser( + StructureImportSettings.isVisibleChainAnnotation(), - StructureImportSettings.isPredictSecondaryStructure(), ++ StructureImportSettings.isProcessSecondaryStructure(), + StructureImportSettings.isExternalSecondaryStructure(), + inFile, sourceType); + } + + @Override + public AlignmentFileI getAlignmentFile(FileParse source) + throws IOException + { + return new JmolParser( + StructureImportSettings.isVisibleChainAnnotation(), - StructureImportSettings.isPredictSecondaryStructure(), ++ StructureImportSettings.isProcessSecondaryStructure(), + StructureImportSettings.isExternalSecondaryStructure(), + source); + } + + @Override + public AlignmentFileI getAlignmentFile() + { + return new JmolParser(); // todo or null? + } + }, + Jalview("Jalview", "jar,jvp", true, false) + { + + @Override + public AlignmentFileI getAlignmentFile(String inFile, + DataSourceType sourceType) throws IOException + { + return null; + } + + @Override + public AlignmentFileI getAlignmentFile(FileParse source) + throws IOException + { + return null; + } + + @Override + public AlignmentFileI getAlignmentFile() + { + return null; + } + }; + + /** + * A lookup map of enums by upper-cased name + */ + private static Map names; + static + { + names = new HashMap(); + for (FileFormat format : FileFormat.values()) + { + names.put(format.toString().toUpperCase(), format); + } + } + + private boolean writable; + + private boolean readable; + + private String extensions; + + private String name; + + @Override + public boolean isComplexAlignFile() + { + return false; + } + + @Override + public String getShortDescription() + { + return toString(); + } + + /** + * Returns the file format with the given name, or null if format is null or + * invalid. Unlike valueOf(), this is not case-sensitive, to be kind to + * writers of javascript. + * + * @param format + * @return + */ + public static FileFormatI forName(String format) + { + // or could store format.getShortDescription().toUpperCase() + // in order to decouple 'given name' from enum name + return format == null ? null : names.get(format.toUpperCase()); + } + + @Override + public boolean isReadable() + { + return readable; + } + + @Override + public boolean isWritable() + { + return writable; + } + + /** + * Constructor + * + * @param shortName + * @param extensions + * comma-separated list of file extensions associated with the format + * @param isReadable + * @param isWritable + */ + private FileFormat(String shortName, String extensions, + boolean isReadable, boolean isWritable) + { + this.name = shortName; + this.extensions = extensions; + this.readable = isReadable; + this.writable = isWritable; + } + + @Override + public String getExtensions() + { + return extensions; + } +} diff --cc src/jalview/io/HTMLOutput.java index df0dc06,df0dc06..2e4a781 --- a/src/jalview/io/HTMLOutput.java +++ b/src/jalview/io/HTMLOutput.java @@@ -20,16 -20,16 +20,20 @@@ */ package jalview.io; ++import jalview.bin.Cache; import jalview.datamodel.AlignmentI; import jalview.datamodel.SequenceI; import jalview.gui.AlignViewport; import jalview.gui.AlignmentPanel; import jalview.gui.FeatureRenderer; import jalview.gui.SequenceRenderer; ++import jalview.util.BrowserLauncher; ++import jalview.util.ImageMaker; import jalview.util.MessageManager; import java.awt.Color; import java.awt.Font; ++import java.io.FileWriter; import java.io.PrintWriter; public class HTMLOutput @@@ -52,9 -52,9 +56,8 @@@ fr.transferSettings(fr1); JalviewFileChooser chooser = new JalviewFileChooser( -- jalview.bin.Cache.getProperty("LAST_DIRECTORY"), -- new String[] { "html" }, new String[] { "HTML files" }, -- "HTML files"); ++ Cache.getProperty("LAST_DIRECTORY"), ImageMaker.HTML_EXTENSION, ++ "HTML files", "HTML files"); chooser.setFileView(new JalviewFileView()); chooser.setDialogTitle(MessageManager.getString("label.save_as_html")); @@@ -65,13 -65,13 +68,12 @@@ if (value == JalviewFileChooser.APPROVE_OPTION) { String choice = chooser.getSelectedFile().getPath(); -- jalview.bin.Cache.setProperty("LAST_DIRECTORY", chooser ++ Cache.setProperty("LAST_DIRECTORY", chooser .getSelectedFile().getParent()); try { -- PrintWriter out = new java.io.PrintWriter(new java.io.FileWriter( -- choice)); ++ PrintWriter out = new PrintWriter(new FileWriter(choice)); out.println(""); out.println("