FileFormat enum wip changes
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Tue, 12 Jul 2016 20:54:35 +0000 (21:54 +0100)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Tue, 12 Jul 2016 20:54:35 +0000 (21:54 +0100)
23 files changed:
src/MCview/PDBCanvas.java
src/MCview/PDBViewer.java
src/jalview/appletgui/APopupMenu.java
src/jalview/appletgui/AlignFrame.java
src/jalview/appletgui/ExtJmol.java
src/jalview/bin/JalviewLite.java
src/jalview/controller/AlignViewController.java
src/jalview/ext/rbvi/chimera/JalviewChimeraBinding.java
src/jalview/gui/AlignFrame.java
src/jalview/gui/AppJmolBinding.java
src/jalview/gui/AssociatePdbFileWithSeq.java
src/jalview/gui/CutAndPasteTransfer.java
src/jalview/gui/Desktop.java
src/jalview/gui/JalviewChimeraBindingModel.java
src/jalview/gui/Preferences.java
src/jalview/gui/SequenceFetcher.java
src/jalview/gui/StructureChooser.java
src/jalview/io/FileLoader.java
src/jalview/io/FormatAdapter.java
src/jalview/io/JalviewFileChooser.java
src/jalview/ws/dbsources/Pfam.java
src/jalview/ws/dbsources/Xfam.java
src/jalview/ws/rest/params/Alignment.java

index 2905a3e..7b4e0f0 100644 (file)
@@ -26,6 +26,7 @@ import jalview.datamodel.SequenceI;
 import jalview.gui.AlignmentPanel;
 import jalview.gui.FeatureRenderer;
 import jalview.gui.SequenceRenderer;
+import jalview.io.DataSourceType;
 import jalview.io.StructureFile;
 import jalview.structure.AtomSpec;
 import jalview.structure.StructureListener;
@@ -141,7 +142,7 @@ public class PDBCanvas extends JPanel implements MouseListener,
   String errorMessage;
 
   void init(PDBEntry pdbentry, SequenceI[] seq, String[] chains,
-          AlignmentPanel ap, String protocol)
+          AlignmentPanel ap, DataSourceType protocol)
   {
     this.ap = ap;
     this.pdbentry = pdbentry;
index cbe2332..39bc4ef 100755 (executable)
@@ -80,12 +80,12 @@ public class PDBViewer extends JInternalFrame implements Runnable
 
   AlignmentPanel ap;
 
-  String protocol;
+  DataSourceType protocol;
 
   String tmpPDBFile;
 
   public PDBViewer(PDBEntry pdbentry, SequenceI[] seq, String[] chains,
-          AlignmentPanel ap, String protocol)
+          AlignmentPanel ap, DataSourceType protocol)
   {
     this.pdbentry = pdbentry;
     this.seq = seq;
index 948c8e5..71f126b 100644 (file)
@@ -24,6 +24,7 @@ import jalview.analysis.AAFrequency;
 import jalview.analysis.AlignmentAnnotationUtils;
 import jalview.analysis.AlignmentUtils;
 import jalview.analysis.Conservation;
+import jalview.bin.JalviewLite;
 import jalview.commands.ChangeCaseCommand;
 import jalview.commands.EditCommand;
 import jalview.commands.EditCommand.Action;
@@ -35,6 +36,8 @@ import jalview.datamodel.SequenceFeature;
 import jalview.datamodel.SequenceGroup;
 import jalview.datamodel.SequenceI;
 import jalview.io.AppletFormatAdapter;
+import jalview.io.DataSourceType;
+import jalview.io.FileFormat;
 import jalview.io.SequenceAnnotationReport;
 import jalview.schemes.Blosum62ColourScheme;
 import jalview.schemes.BuriedColourScheme;
@@ -826,15 +829,16 @@ public class APopupMenu extends java.awt.PopupMenu implements
 
     Frame frame = new Frame();
     frame.add(cap);
-    jalview.bin.JalviewLite.addFrame(frame, MessageManager.formatMessage(
+    JalviewLite.addFrame(frame, MessageManager.formatMessage(
             "label.selection_output_command",
             new Object[] { e.getActionCommand() }), 600, 500);
     // JBPNote: getSelectionAsNewSequence behaviour has changed - this method
     // now returns a full copy of sequence data
     // TODO consider using getSequenceSelection instead here
 
-    cap.setText(new jalview.io.AppletFormatAdapter().formatSequences(
-            e.getActionCommand(), ap.av.getShowJVSuffix(), ap, true));
+    FileFormat fileFormat = FileFormat.valueOf(e.getActionCommand());
+    cap.setText(new AppletFormatAdapter().formatSequences(fileFormat,
+            ap.av.getShowJVSuffix(), ap, true));
 
   }
 
@@ -902,12 +906,12 @@ public class APopupMenu extends java.awt.PopupMenu implements
       if (ap.av.applet.jmolAvailable)
       {
         new jalview.appletgui.AppletJmol(entry, new SequenceI[] { seq },
-                null, ap, AppletFormatAdapter.URL);
+                null, ap, DataSourceType.URL);
       }
       else
       {
         new MCview.AppletPDBViewer(entry, new SequenceI[] { seq }, null,
-                ap, AppletFormatAdapter.URL);
+                ap, DataSourceType.URL);
       }
 
     }
index c2e9038..8e69134 100644 (file)
@@ -1361,13 +1361,13 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
     CutAndPasteTransfer cap = new CutAndPasteTransfer(true, this);
     Frame frame = new Frame();
     frame.add(cap);
-    jalview.bin.JalviewLite.addFrame(frame, MessageManager.formatMessage(
+    JalviewLite.addFrame(frame, MessageManager.formatMessage(
             "label.alignment_output_command",
             new Object[] { e.getActionCommand() }), 600, 500);
 
-    FeatureRenderer fr = this.alignPanel.cloneFeatureRenderer();
+    FileFormat fileFormat = FileFormat.valueOf(e.getActionCommand());
     cap.setText(new AppletFormatAdapter(alignPanel).formatSequences(
-            e.getActionCommand(), viewport.getAlignment(),
+            fileFormat, viewport.getAlignment(),
             viewport.getShowJVSuffix()));
   }
 
index 929a871..a402ae0 100644 (file)
@@ -26,6 +26,7 @@ import jalview.api.SequenceRenderer;
 import jalview.datamodel.PDBEntry;
 import jalview.datamodel.SequenceI;
 import jalview.ext.jmol.JalviewJmolBinding;
+import jalview.io.DataSourceType;
 
 import java.awt.Container;
 import java.util.ArrayList;
@@ -48,9 +49,9 @@ public class ExtJmol extends JalviewJmolBinding
 
   private AlignmentPanel ap;
 
-  protected ExtJmol(jalview.appletgui.AlignFrame alframe,
+  protected ExtJmol(AlignFrame alframe,
           PDBEntry[] pdbentry, SequenceI[][] seq, String[][] chains,
-          String protocol)
+          DataSourceType protocol)
   {
     super(alframe.alignPanel.getStructureSelectionManager(), pdbentry, seq,
             chains, protocol);
@@ -64,6 +65,7 @@ public class ExtJmol extends JalviewJmolBinding
     notifyFileLoaded(null, null, null, null, 0);
   }
 
+  @Override
   public void updateColours(Object source)
   {
 
@@ -71,6 +73,7 @@ public class ExtJmol extends JalviewJmolBinding
 
   }
 
+  @Override
   public void showUrl(String arg0)
   {
     showUrl(arg0, "jmol");
@@ -126,6 +129,7 @@ public class ExtJmol extends JalviewJmolBinding
     // ignore
   }
 
+  @Override
   public void selectionChanged(BS arg0)
   {
     System.out.println(arg0);
index 96c8a97..0f3feb2 100644 (file)
@@ -518,7 +518,7 @@ public class JalviewLite extends Applet implements
    */
   @Override
   public String getSelectedSequencesAsAlignmentFrom(AlignFrame alf,
-          String format, String suffix)
+          FileFormatI format, String suffix)
   {
     try
     {
index 24439ca..e1fdbfc 100644 (file)
@@ -33,6 +33,7 @@ import jalview.datamodel.SequenceCollectionI;
 import jalview.datamodel.SequenceFeature;
 import jalview.datamodel.SequenceGroup;
 import jalview.datamodel.SequenceI;
+import jalview.io.DataSourceType;
 import jalview.io.FeaturesFile;
 import jalview.util.MessageManager;
 
@@ -370,7 +371,7 @@ public class AlignViewController implements AlignViewControllerI
   }
 
   @Override
-  public boolean parseFeaturesFile(String file, String protocol,
+  public boolean parseFeaturesFile(String file, DataSourceType protocol,
           boolean relaxedIdMatching)
   {
     boolean featuresFile = false;
index 944ef52..dca7038 100644 (file)
@@ -29,6 +29,7 @@ import jalview.datamodel.ColumnSelection;
 import jalview.datamodel.PDBEntry;
 import jalview.datamodel.SequenceI;
 import jalview.httpserver.AbstractRequestHandler;
+import jalview.io.DataSourceType;
 import jalview.schemes.ColourSchemeI;
 import jalview.schemes.ResidueProperties;
 import jalview.structure.AtomSpec;
@@ -197,7 +198,7 @@ public abstract class JalviewChimeraBinding extends AAStructureBindingModel
    */
   public JalviewChimeraBinding(StructureSelectionManager ssm,
           PDBEntry[] pdbentry, SequenceI[][] sequenceIs, String[][] chains,
-          String protocol)
+          DataSourceType protocol)
   {
     super(ssm, pdbentry, sequenceIs, chains, protocol);
     viewer = new ChimeraManager(
index cf5766f..1554631 100644 (file)
@@ -1010,7 +1010,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
       // originating file's format
       // TODO: work out how to recover feature settings for correct view(s) when
       // file is reloaded.
-      if (currentFileFormat.equals("Jalview"))
+      if (currentFileFormat == FileFormat.Jalview)
       {
         JInternalFrame[] frames = Desktop.desktop.getAllFrames();
         for (int i = 0; i < frames.length; i++)
@@ -1032,7 +1032,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
         Desktop.instance.closeAssociatedWindows();
 
         FileLoader loader = new FileLoader();
-        String protocol = fileName.startsWith("http:") ? "URL" : "File";
+        DataSourceType protocol = fileName.startsWith("http:") ? DataSourceType.URL
+                : DataSourceType.FILE;
         loader.LoadFile(viewport, fileName, protocol, currentFileFormat);
       }
       else
@@ -1040,7 +1041,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
         Rectangle bounds = this.getBounds();
 
         FileLoader loader = new FileLoader();
-        String protocol = fileName.startsWith("http:") ? "URL" : "File";
+        DataSourceType protocol = fileName.startsWith("http:") ? DataSourceType.URL
+                : DataSourceType.FILE;
         AlignFrame newframe = loader.LoadFileWaitTillLoaded(fileName,
                 protocol, currentFileFormat);
 
@@ -1084,9 +1086,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
   @Override
   public void save_actionPerformed(ActionEvent e)
   {
-    if (fileName == null
-            || (currentFileFormat == null || !jalview.io.FormatAdapter
-                    .isValidIOFormat(currentFileFormat, true))
+    if (fileName == null || (currentFileFormat == null)
             || fileName.startsWith("http"))
     {
       saveAs_actionPerformed(null);
@@ -1107,9 +1107,9 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
   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,
+            Cache.getProperty("LAST_DIRECTORY"),
+            // AppletFormatAdapter.WRITABLE_EXTENSIONS,
+            // AppletFormatAdapter.WRITABLE_FNAMES,
             currentFileFormat, false);
 
     chooser.setFileView(new JalviewFileView());
@@ -1146,11 +1146,6 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
               currentFileFormat.toString());
 
       Cache.setProperty("LAST_DIRECTORY", fileName);
-      if (currentFileFormat.indexOf(" ") > -1)
-      {
-        currentFileFormat = currentFileFormat.substring(0,
-                currentFileFormat.indexOf(" "));
-      }
       saveAlignment(fileName, currentFileFormat);
     }
   }
@@ -1178,16 +1173,16 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     }
     else
     {
-      if (!jalview.io.AppletFormatAdapter.isValidFormat(format, true))
-      {
-        warningMessage("Cannot save file " + fileName + " using format "
-                + format, "Alignment output format not supported");
-        if (!Jalview.isHeadlessMode())
-        {
-          saveAs_actionPerformed(null);
-        }
-        return false;
-      }
+      // if (!jalview.io.AppletFormatAdapter.isValidFormat(format, true))
+      // {
+      // warningMessage("Cannot save file " + fileName + " using format "
+      // + format, "Alignment output format not supported");
+      // if (!Jalview.isHeadlessMode())
+      // {
+      // saveAs_actionPerformed(null);
+      // }
+      // return false;
+      // }
 
       AlignmentExportData exportData = getAlignmentForExport(format,
               viewport, null);
@@ -1267,8 +1262,10 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
   protected void outputText_actionPerformed(ActionEvent e)
   {
 
+    FileFormat fileFormat = FileFormat.valueOf(e.getActionCommand());
     AlignmentExportData exportData = getAlignmentForExport(
-            e.getActionCommand(), viewport, null);
+fileFormat,
+            viewport, null);
     if (exportData.getSettings().isCancelled())
     {
       return;
@@ -1277,7 +1274,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     cap.setForInput(null);
     try
     {
-      FileFormatI format = FileFormat.valueOf(e.getActionCommand());
+      FileFormatI format = fileFormat;
       cap.setText(new FormatAdapter(alignPanel, exportData.getSettings())
               .formatSequences(format,
                       exportData.getAlignment(),
@@ -1956,7 +1953,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
         return;
       }
 
-      String str, format;
+      String str;
+      FileFormatI format;
       try
       {
         str = (String) contents.getTransferData(DataFlavor.stringFlavor);
@@ -1965,7 +1963,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
           return;
         }
 
-        format = new IdentifyFile().identify(str, "Paste");
+        format = new IdentifyFile().identify(str, DataSourceType.PASTE);
 
       } catch (OutOfMemoryError er)
       {
@@ -1995,7 +1993,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
       else
       {
         // parse the clipboard as an alignment.
-        alignment = new FormatAdapter().readFile(str, "Paste", format);
+        alignment = new FormatAdapter().readFile(str, DataSourceType.PASTE,
+                format);
         sequences = alignment.getSequencesArray();
       }
 
@@ -5102,7 +5101,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
             }
             if (mtch != null)
             {
-              String type = null;
+              FileFormatI type = null;
               try
               {
                 type = new IdentifyFile().identify(file, protocol);
@@ -5112,7 +5111,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
               }
               if (type != null)
               {
-                if (type.equalsIgnoreCase("PDB"))
+                if (type == FileFormat.PDB)
                 {
                   filesmatched.add(new Object[] { file, protocol, mtch });
                   continue;
@@ -5152,7 +5151,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
               {
                 PDBEntry pe = new AssociatePdbFileWithSeq()
                         .associatePdbWithSeq((String) fm[0],
-                                (String) fm[1], toassoc, false,
+                                (DataSourceType) fm[1], toassoc, false,
                                 Desktop.instance);
                 if (pe != null)
                 {
index 1c54a5e..6e520e5 100644 (file)
@@ -25,6 +25,7 @@ import jalview.bin.Cache;
 import jalview.datamodel.PDBEntry;
 import jalview.datamodel.SequenceI;
 import jalview.ext.jmol.JalviewJmolBinding;
+import jalview.io.DataSourceType;
 import jalview.structure.StructureSelectionManager;
 
 import java.awt.Container;
@@ -42,7 +43,7 @@ public class AppJmolBinding extends JalviewJmolBinding
 
   public AppJmolBinding(AppJmol appJmol, StructureSelectionManager sSm,
           PDBEntry[] pdbentry, SequenceI[][] sequenceIs, String[][] chains,
-          String protocol)
+          DataSourceType protocol)
   {
     super(sSm, pdbentry, sequenceIs, chains, protocol);
     appJmolWindow = appJmol;
@@ -113,6 +114,7 @@ public class AppJmolBinding extends JalviewJmolBinding
     // appJmolWindow.repaint();
     javax.swing.SwingUtilities.invokeLater(new Runnable()
     {
+      @Override
       public void run()
       {
         appJmolWindow.updateTitleAndMenus();
@@ -121,6 +123,7 @@ public class AppJmolBinding extends JalviewJmolBinding
     });
   }
 
+  @Override
   public void updateColours(Object source)
   {
     AlignmentPanel ap = (AlignmentPanel) source;
@@ -144,6 +147,7 @@ public class AppJmolBinding extends JalviewJmolBinding
     // msWalltime);
   }
 
+  @Override
   public void showUrl(String url)
   {
     showUrl(url, "jmol");
index e2637a9..c380e2f 100644 (file)
@@ -23,6 +23,7 @@ package jalview.gui;
 import jalview.api.StructureSelectionManagerProvider;
 import jalview.datamodel.PDBEntry;
 import jalview.datamodel.SequenceI;
+import jalview.io.DataSourceType;
 import jalview.io.StructureFile;
 import jalview.structure.StructureSelectionManager;
 import jalview.util.MessageManager;
@@ -44,7 +45,7 @@ public class AssociatePdbFileWithSeq
    * @param choice
    * @param sequence
    */
-  public PDBEntry associatePdbWithSeq(String choice, String protocol,
+  public PDBEntry associatePdbWithSeq(String choice, DataSourceType file,
           SequenceI sequence, boolean prompt,
           StructureSelectionManagerProvider ssmp)
   {
@@ -52,7 +53,7 @@ public class AssociatePdbFileWithSeq
     StructureFile pdbfile = null;
     pdbfile = StructureSelectionManager.getStructureSelectionManager(ssmp)
             .setMapping(false, new SequenceI[] { sequence }, null, choice,
-                    protocol);
+                    file);
     if (pdbfile == null)
     {
       // stacktrace already thrown so just return
index 7b3e438..4e5ef40 100644 (file)
@@ -30,10 +30,11 @@ import jalview.bin.Jalview;
 import jalview.datamodel.AlignmentI;
 import jalview.datamodel.ColumnSelection;
 import jalview.datamodel.SequenceI;
+import jalview.io.AlignmentFileI;
 import jalview.io.AppletFormatAdapter;
 import jalview.io.DataSourceType;
+import jalview.io.FileFormatException;
 import jalview.io.FileFormatI;
-import jalview.io.FileParse;
 import jalview.io.FormatAdapter;
 import jalview.io.IdentifyFile;
 import jalview.io.JalviewFileChooser;
@@ -70,7 +71,7 @@ public class CutAndPasteTransfer extends GCutAndPasteTransfer
 
   AlignViewportI viewport;
 
-  FileParse source = null;
+  AlignmentFileI source = null;
 
   public CutAndPasteTransfer()
   {
@@ -215,8 +216,14 @@ public class CutAndPasteTransfer extends GCutAndPasteTransfer
       return;
     }
 
-    FileFormatI format = new IdentifyFile().identify(text,
-            DataSourceType.PASTE);
+    FileFormatI format = null;
+    try
+    {
+      format = new IdentifyFile().identify(text, DataSourceType.PASTE);
+    } catch (FileFormatException e1)
+    {
+      // leave as null
+    }
     if (format == null)
     {
       System.err.println(MessageManager
@@ -234,29 +241,26 @@ public class CutAndPasteTransfer extends GCutAndPasteTransfer
     // TODO: identify feature, annotation or tree file and parse appropriately.
     AlignmentI al = null;
 
-    if (FormatAdapter.isValidFormat(format))
+    try
     {
-      try
-      {
-        FormatAdapter fa = new FormatAdapter(alignpanel);
-        al = fa.readFile(getText(), DataSourceType.PASTE, format);
-        source = fa.getAlignFile();
+      FormatAdapter fa = new FormatAdapter(alignpanel);
+      al = fa.readFile(getText(), DataSourceType.PASTE, format);
+      source = fa.getAlignFile();
 
-      } catch (java.io.IOException ex)
-      {
-        JOptionPane.showInternalMessageDialog(Desktop.desktop,
-                MessageManager.formatMessage(
-                        "label.couldnt_read_pasted_text",
-                        new String[] { ex.toString() }), MessageManager
-                        .getString("label.error_parsing_text"),
-                JOptionPane.WARNING_MESSAGE);
-      }
+    } catch (java.io.IOException ex)
+    {
+      JOptionPane.showInternalMessageDialog(Desktop.desktop, MessageManager
+              .formatMessage("label.couldnt_read_pasted_text", new String[]
+              { ex.toString() }), MessageManager
+              .getString("label.error_parsing_text"),
+              JOptionPane.WARNING_MESSAGE);
     }
 
     if (al != null && al.hasValidSequence())
     {
       String title = MessageManager.formatMessage(
-              "label.input_cut_paste_params", new String[] { format });
+              "label.input_cut_paste_params",
+              new String[] { format.getShortDescription() });
       FeatureSettingsModelI proxyColourScheme = source
               .getFeatureColourScheme();
 
index 7810099..22a5203 100644 (file)
@@ -24,7 +24,6 @@ import jalview.api.AlignViewportI;
 import jalview.api.AlignmentViewPanel;
 import jalview.bin.Cache;
 import jalview.bin.Jalview;
-import jalview.io.AppletFormatAdapter;
 import jalview.io.DataSourceType;
 import jalview.io.FileFormat;
 import jalview.io.FileFormatException;
@@ -447,11 +446,12 @@ public class Desktop extends jalview.jbgui.GDesktop implements
       public void run()
       {
         Cache.log.debug("Filechooser init thread started.");
-        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"));
+        FileFormat fileFormat = FileFormat.valueOf(Cache
+                .getProperty("DEFAULT_FILE_FORMAT"));
+        new JalviewFileChooser(Cache.getProperty("LAST_DIRECTORY"),
+        // jalview.io.AppletFormatAdapter.READABLE_EXTENSIONS,
+        // jalview.io.AppletFormatAdapter.READABLE_FNAMES,
+                fileFormat);
         Cache.log.debug("Filechooser init thread finished.");
       }
     }).start();
@@ -1011,11 +1011,13 @@ public class Desktop extends jalview.jbgui.GDesktop implements
   @Override
   public void inputLocalFileMenuItem_actionPerformed(AlignViewport viewport)
   {
+    FileFormat fileFormat = FileFormat.valueOf(Cache
+            .getProperty("DEFAULT_FILE_FORMAT"));
     JalviewFileChooser chooser = new JalviewFileChooser(
             Cache.getProperty("LAST_DIRECTORY"),
-            AppletFormatAdapter.READABLE_EXTENSIONS,
-            AppletFormatAdapter.READABLE_FNAMES,
-            Cache.getProperty("DEFAULT_FILE_FORMAT"));
+            // AppletFormatAdapter.READABLE_EXTENSIONS,
+            // AppletFormatAdapter.READABLE_FNAMES,
+            fileFormat);
 
     chooser.setFileView(new JalviewFileView());
     chooser.setDialogTitle(MessageManager
index 7a54732..76d2703 100644 (file)
@@ -24,6 +24,7 @@ import jalview.api.AlignmentViewPanel;
 import jalview.datamodel.PDBEntry;
 import jalview.datamodel.SequenceI;
 import jalview.ext.rbvi.chimera.JalviewChimeraBinding;
+import jalview.io.DataSourceType;
 import jalview.structure.StructureSelectionManager;
 
 public class JalviewChimeraBindingModel extends JalviewChimeraBinding
@@ -34,7 +35,8 @@ public class JalviewChimeraBindingModel extends JalviewChimeraBinding
 
   public JalviewChimeraBindingModel(ChimeraViewFrame chimeraViewFrame,
           StructureSelectionManager ssm, PDBEntry[] pdbentry,
-          SequenceI[][] sequenceIs, String[][] chains, String protocol)
+          SequenceI[][] sequenceIs, String[][] chains,
+          DataSourceType protocol)
   {
     super(ssm, pdbentry, sequenceIs, chains, protocol);
     cvf = chimeraViewFrame;
@@ -72,6 +74,7 @@ public class JalviewChimeraBindingModel extends JalviewChimeraBinding
   {
     javax.swing.SwingUtilities.invokeLater(new Runnable()
     {
+      @Override
       public void run()
       {
         cvf.updateTitleAndMenus();
@@ -80,6 +83,7 @@ public class JalviewChimeraBindingModel extends JalviewChimeraBinding
     });
   }
 
+  @Override
   public void updateColours(Object source)
   {
     AlignmentPanel ap = (AlignmentPanel) source;
@@ -113,6 +117,7 @@ public class JalviewChimeraBindingModel extends JalviewChimeraBinding
    * Send an asynchronous command to Chimera, in a new thread, optionally with
    * an 'in progress' message in a progress bar somewhere
    */
+  @Override
   protected void sendAsynchronousCommand(final String command,
           final String progressMsg)
   {
index 5b48e2d..80b1806 100755 (executable)
@@ -24,6 +24,7 @@ import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder;
 import jalview.bin.Cache;
 import jalview.gui.Help.HelpId;
 import jalview.gui.StructureViewer.ViewerType;
+import jalview.io.FileFormat;
 import jalview.io.JalviewFileChooser;
 import jalview.io.JalviewFileView;
 import jalview.jbgui.GPreferences;
@@ -683,12 +684,14 @@ public class Preferences extends GPreferences
   @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" },
-            Cache.getProperty("DEFAULT_FILE_FORMAT"));
+            fileFormat);
     chooser.setFileView(new JalviewFileView());
     chooser.setDialogTitle(MessageManager
             .getString("label.select_startup_file"));
index 03bb375..3a77c6c 100755 (executable)
@@ -28,6 +28,7 @@ import jalview.datamodel.SequenceFeature;
 import jalview.datamodel.SequenceI;
 import jalview.fts.service.pdb.PDBFTSPanel;
 import jalview.fts.service.uniprot.UniprotFTSPanel;
+import jalview.io.FileFormatI;
 import jalview.io.gff.SequenceOntologyI;
 import jalview.util.DBRefUtils;
 import jalview.util.MessageManager;
@@ -896,7 +897,7 @@ public class SequenceFetcher extends JPanel implements Runnable
   }
 
   AlignmentI parseResult(AlignmentI al, String title,
-          String currentFileFormat,
+          FileFormatI currentFileFormat,
           FeatureSettingsModelI preferredFeatureColours)
   {
 
index 76cb71d..3581cf9 100644 (file)
@@ -32,6 +32,7 @@ import jalview.fts.api.FTSRestClientI;
 import jalview.fts.core.FTSRestRequest;
 import jalview.fts.core.FTSRestResponse;
 import jalview.fts.service.pdb.PDBFTSRestClient;
+import jalview.io.DataSourceType;
 import jalview.jbgui.GStructureChooser;
 import jalview.structure.StructureSelectionManager;
 import jalview.util.MessageManager;
@@ -828,7 +829,7 @@ public class StructureChooser extends GStructureChooser implements
       }
       PDBEntry fileEntry = new AssociatePdbFileWithSeq()
               .associatePdbWithSeq(selectedPdbFileName,
-                      jalview.io.DataSourceType.FILE,
+                          DataSourceType.FILE,
                       selectedSequence, true, Desktop.instance);
 
           launchStructureViewer(ssm, new PDBEntry[] { fileEntry }, ap,
index bbc753b..88f9ae5 100755 (executable)
@@ -258,10 +258,8 @@ public class FileLoader implements Runnable
         // just in case the caller didn't identify the file for us
         if (source != null)
         {
-          format = new IdentifyFile().identify(source, false); // identify
-          // stream and
-          // rewind rather
-          // than close
+          format = new IdentifyFile().identify(source, false);
+          // identify stream and rewind rather than close
         }
         else
         {
index eac1041..7f8b007 100755 (executable)
@@ -230,12 +230,7 @@ public class FormatAdapter extends AppletFormatAdapter
 
   public boolean getCacheSuffixDefault(FileFormatI format)
   {
-    if (isValidFormat(format))
-    {
-      return Cache.getDefault(format.toUpperCase()
-              + "_JVSUFFIX", true);
-    }
-    return false;
+    return Cache.getDefault(format.toString() + "_JVSUFFIX", true);
   }
 
   public String formatSequences(FileFormatI format, AlignmentI alignment,
index 9ac6a35..cad69ed 100755 (executable)
@@ -88,6 +88,13 @@ public class JalviewFileChooser extends JFileChooser
     init(suffix, desc, selected, true);
   }
 
+  public JalviewFileChooser(String property, FileFormatI currentFileFormat,
+          boolean b)
+  {
+    todo write this
+    // TODO Auto-generated constructor stub
+  }
+
   void init(String[] suffix, String[] desc, String selected,
           boolean selectAll)
   {
index 4f081ee..5b8a3ae 100644 (file)
@@ -23,6 +23,8 @@ package jalview.ws.dbsources;
 import jalview.datamodel.AlignmentI;
 import jalview.datamodel.DBRefEntry;
 import jalview.datamodel.DBRefSource;
+import jalview.io.DataSourceType;
+import jalview.io.FileFormat;
 import jalview.io.FormatAdapter;
 
 import com.stevesoft.pat.Regex;
@@ -119,8 +121,8 @@ abstract public class Pfam extends Xfam
     // retrieved.
     startQuery();
     AlignmentI rcds = new FormatAdapter().readFile(getXFAMURL()
-            + queries.trim().toUpperCase(), jalview.io.FormatAdapter.URL,
-            "STH");
+            + queries.trim().toUpperCase(), DataSourceType.URL,
+            FileFormat.Stockholm);
     for (int s = 0, sNum = rcds.getHeight(); s < sNum; s++)
     {
       rcds.getSequenceAt(s).addDBRef(
index 508047d..3554f01 100644 (file)
@@ -22,6 +22,8 @@ package jalview.ws.dbsources;
 
 import jalview.datamodel.AlignmentI;
 import jalview.datamodel.DBRefEntry;
+import jalview.io.DataSourceType;
+import jalview.io.FileFormat;
 import jalview.io.FormatAdapter;
 import jalview.ws.seqfetcher.DbSourceProxyImpl;
 
@@ -56,8 +58,7 @@ public abstract class Xfam extends DbSourceProxyImpl
     // TODO: trap HTTP 404 exceptions and return null
     AlignmentI rcds = new FormatAdapter().readFile(getXFAMURL()
             + queries.trim().toUpperCase() + getXFAMURLSUFFIX(),
-            jalview.io.FormatAdapter.URL,
-            "STH");
+            DataSourceType.URL, FileFormat.Stockholm);
     for (int s = 0, sNum = rcds.getHeight(); s < sNum; s++)
     {
       rcds.getSequenceAt(s).addDBRef(new DBRefEntry(getXfamSource(),
index 18c1ad0..306c40d 100644 (file)
@@ -21,6 +21,9 @@
 package jalview.ws.rest.params;
 
 import jalview.datamodel.AlignmentI;
+import jalview.io.FileFormat;
+import jalview.io.FileFormatI;
+import jalview.io.FormatAdapter;
 import jalview.ws.params.OptionI;
 import jalview.ws.params.simple.BooleanOption;
 import jalview.ws.params.simple.Option;
@@ -55,7 +58,7 @@ public class Alignment extends InputType
     super(new Class[] { AlignmentI.class });
   }
 
-  String format = "FASTA";
+  FileFormatI format = FileFormat.Fasta;
 
   molType type;
 
@@ -79,7 +82,7 @@ public class Alignment extends InputType
         PrintWriter pw = new PrintWriter(
                 new OutputStreamWriter(new BufferedOutputStream(
                         new FileOutputStream(fa)), "UTF-8"));
-        pw.append(new jalview.io.FormatAdapter().formatSequences(format,
+        pw.append(new FormatAdapter().formatSequences(format,
                 alignment, jvsuffix));
         pw.close();
         return new FileBody(fa, "text/plain");
@@ -91,7 +94,7 @@ public class Alignment extends InputType
     }
     else
     {
-      jalview.io.FormatAdapter fa = new jalview.io.FormatAdapter();
+      FormatAdapter fa = new FormatAdapter();
       fa.setNewlineString("\r\n");
       return new StringBody(
               (fa.formatSequences(format, alignment, jvsuffix)));
@@ -115,12 +118,10 @@ public class Alignment extends InputType
     {
       prms.add("jvsuffix");
     }
-    ;
     if (writeAsFile)
     {
       prms.add("writeasfile");
     }
-    ;
     return prms;
   }