From 32a259190463ee06a81886db9d7843b565dea6df Mon Sep 17 00:00:00 2001 From: amwaterhouse Date: Tue, 15 Aug 2006 10:02:12 +0000 Subject: [PATCH] WRITEABLE_FORMATS and READABLE_FORMATS string [] --- src/jalview/appletgui/APopupMenu.java | 7 +++--- src/jalview/appletgui/AlignFrame.java | 7 +++--- src/jalview/bin/JalviewLite.java | 1 + src/jalview/gui/CutAndPasteTransfer.java | 2 +- src/jalview/gui/PopupMenu.java | 7 +++--- src/jalview/gui/SequenceFetcher.java | 2 +- src/jalview/io/AppletFormatAdapter.java | 34 ++++++++++++++++++------------ src/jalview/io/FileLoader.java | 2 +- src/jalview/jbgui/GAlignFrame.java | 7 +++--- src/jalview/ws/JPredClient.java | 2 +- 10 files changed, 37 insertions(+), 34 deletions(-) diff --git a/src/jalview/appletgui/APopupMenu.java b/src/jalview/appletgui/APopupMenu.java index b26bd74..449b83a 100755 --- a/src/jalview/appletgui/APopupMenu.java +++ b/src/jalview/appletgui/APopupMenu.java @@ -89,11 +89,10 @@ public class APopupMenu e.printStackTrace(); } - for (int i = 0; i < jalview.io.AppletFormatAdapter.formats.size()-2; i++) + for (int i = 0; i < jalview.io.AppletFormatAdapter.WRITEABLE_FORMATS.length; i++) { - MenuItem item = new MenuItem( (String) jalview.io.AppletFormatAdapter.formats. - elementAt( - i)); + MenuItem item = new MenuItem( jalview.io.AppletFormatAdapter.WRITEABLE_FORMATS[i] ); + item.addActionListener(this); outputmenu.add(item); } diff --git a/src/jalview/appletgui/AlignFrame.java b/src/jalview/appletgui/AlignFrame.java index 1ff729d..eb6fe49 100755 --- a/src/jalview/appletgui/AlignFrame.java +++ b/src/jalview/appletgui/AlignFrame.java @@ -1937,12 +1937,11 @@ public void itemStateChanged(ItemEvent evt) MenuItem item; // dynamically fill save as menu with available formats - for (int i = 0; i < jalview.io.AppletFormatAdapter.formats.size()-2; i++) + for (int i = 0; i < jalview.io.AppletFormatAdapter.WRITEABLE_FORMATS.length; i++) { - item = new MenuItem( (String) jalview.io.AppletFormatAdapter.formats. - elementAt( - i)); + item = new MenuItem( jalview.io.AppletFormatAdapter.WRITEABLE_FORMATS[i]); + item.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) diff --git a/src/jalview/bin/JalviewLite.java b/src/jalview/bin/JalviewLite.java index 53d55f3..10efeeb 100755 --- a/src/jalview/bin/JalviewLite.java +++ b/src/jalview/bin/JalviewLite.java @@ -337,6 +337,7 @@ public class JalviewLite extends Applet param = getParameter("showFeatureSettings"); if(param !=null && param.equalsIgnoreCase("true")) { + currentAlignFrame.viewport.showSequenceFeatures(true); currentAlignFrame.featureSettings_actionPerformed(); } diff --git a/src/jalview/gui/CutAndPasteTransfer.java b/src/jalview/gui/CutAndPasteTransfer.java index 2bb456b..5c9c941 100755 --- a/src/jalview/gui/CutAndPasteTransfer.java +++ b/src/jalview/gui/CutAndPasteTransfer.java @@ -169,7 +169,7 @@ public class CutAndPasteTransfer extends GCutAndPasteTransfer String format = new IdentifyFile().Identify(getText(), "Paste"); SequenceI[] sequences = null; - if (FormatAdapter.formats.contains(format)) + if (FormatAdapter.isValidFormat(format)) { try{ sequences = new FormatAdapter().readFile(getText(), "Paste", format); diff --git a/src/jalview/gui/PopupMenu.java b/src/jalview/gui/PopupMenu.java index 9764f4a..e89eb28 100755 --- a/src/jalview/gui/PopupMenu.java +++ b/src/jalview/gui/PopupMenu.java @@ -115,11 +115,10 @@ public class PopupMenu extends JPopupMenu colours.add(PIDColour); colours.add(BLOSUM62Colour); - for (int i = 0; i < jalview.io.FormatAdapter.formats.size()-2; i++) + for (int i = 0; i < jalview.io.FormatAdapter.WRITEABLE_FORMATS.length; i++) { - JMenuItem item = new JMenuItem( (String) jalview.io.FormatAdapter.formats. - elementAt( - i)); + JMenuItem item = new JMenuItem( jalview.io.FormatAdapter.WRITEABLE_FORMATS[i] ); + item.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) diff --git a/src/jalview/gui/SequenceFetcher.java b/src/jalview/gui/SequenceFetcher.java index 99c1d5e..f3d8e29 100755 --- a/src/jalview/gui/SequenceFetcher.java +++ b/src/jalview/gui/SequenceFetcher.java @@ -364,7 +364,7 @@ public class SequenceFetcher String format = new IdentifyFile().Identify(result, "Paste"); SequenceI[] sequences = null; - if (FormatAdapter.formats.contains(format)) + if (FormatAdapter.isValidFormat(format)) { sequences = null; try{ sequences = new FormatAdapter().readFile(result.toString(), "Paste", diff --git a/src/jalview/io/AppletFormatAdapter.java b/src/jalview/io/AppletFormatAdapter.java index ba5b8a0..1de01e6 100755 --- a/src/jalview/io/AppletFormatAdapter.java +++ b/src/jalview/io/AppletFormatAdapter.java @@ -32,26 +32,22 @@ public class AppletFormatAdapter { /** DOCUMENT ME!! */ - public static final Vector formats = new Vector(); + public static final String [] READABLE_FORMATS = new String[] + { + "BLC", "CLUSTAL", "FASTA", "MSF", "PileUp", "PIR", "PFAM", "STH", "PDB" + }; + + public static final String [] WRITEABLE_FORMATS = new String[] + { + "BLC", "CLUSTAL", "FASTA", "MSF", "PileUp", "PIR", "PFAM" + }; + public static String INVALID_CHARACTERS = "Contains invalid characters"; public static String SUPPORTED_FORMATS = "Formats currently supported are\n" + "Fasta, MSF, Clustal, BLC, PIR, MSP, and PFAM"; - static - { - formats.addElement("BLC"); - formats.addElement("CLUSTAL"); - formats.addElement("FASTA"); - formats.addElement("MSF"); - formats.addElement("PileUp"); - formats.addElement("PIR"); - formats.addElement("PFAM"); - formats.addElement("STH"); - formats.addElement("PDB"); - } - public static String FILE = "File"; public static String URL = "URL"; @@ -62,6 +58,16 @@ AlignFile afile = null; String inFile; + public static final boolean isValidFormat(String format) + { + boolean valid = false; + for(int i=0; i