Merge branch 'develop' into bug/JAL-2255_seq-fetcher-broken-on-linux
[jalview.git] / src / jalview / appletgui / CutAndPasteTransfer.java
index bbaeb68..c658734 100644 (file)
@@ -28,9 +28,11 @@ import jalview.datamodel.AlignmentI;
 import jalview.datamodel.ColumnSelection;
 import jalview.datamodel.PDBEntry;
 import jalview.datamodel.SequenceI;
+import jalview.io.AlignmentFileReaderI;
 import jalview.io.AnnotationFile;
 import jalview.io.AppletFormatAdapter;
-import jalview.io.FileParse;
+import jalview.io.DataSourceType;
+import jalview.io.FileFormatI;
 import jalview.io.IdentifyFile;
 import jalview.io.NewickFile;
 import jalview.io.TCoffeeScoreFile;
@@ -51,6 +53,7 @@ import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import java.awt.event.MouseEvent;
 import java.awt.event.MouseListener;
+import java.io.IOException;
 
 public class CutAndPasteTransfer extends Panel implements ActionListener,
         MouseListener
@@ -65,7 +68,7 @@ public class CutAndPasteTransfer extends Panel implements ActionListener,
 
   AlignFrame alignFrame;
 
-  FileParse source = null;
+  AlignmentFileReaderI source = null;
 
   public CutAndPasteTransfer(boolean forImport, AlignFrame alignFrame)
   {
@@ -194,7 +197,8 @@ public class CutAndPasteTransfer extends Panel implements ActionListener,
   {
     try
     {
-      NewickFile fin = new NewickFile(textarea.getText(), "Paste");
+      NewickFile fin = new NewickFile(textarea.getText(),
+              DataSourceType.PASTE);
 
       fin.parse();
       if (fin.getTree() != null)
@@ -225,17 +229,14 @@ public class CutAndPasteTransfer extends Panel implements ActionListener,
   {
     AlignmentI al = null;
 
-    String format = new IdentifyFile().identify(text,
-            AppletFormatAdapter.PASTE);
-    AppletFormatAdapter afa = new AppletFormatAdapter(alignFrame.alignPanel);
     try
     {
-      al = afa.readFile(text, AppletFormatAdapter.PASTE, format);
+      FileFormatI format = new IdentifyFile().identify(text,
+              DataSourceType.PASTE);
+      AppletFormatAdapter afa = new AppletFormatAdapter(
+              alignFrame.alignPanel);
+      al = afa.readFile(text, DataSourceType.PASTE, format);
       source = afa.getAlignFile();
-    } catch (java.io.IOException ex)
-    {
-      ex.printStackTrace();
-    }
 
     if (al != null)
     {
@@ -296,6 +297,10 @@ public class CutAndPasteTransfer extends Panel implements ActionListener,
                 .getString("label.successfully_pasted_alignment_file"));
       }
     }
+    } catch (IOException ex)
+    {
+      ex.printStackTrace();
+    }
   }
 
   /**
@@ -306,7 +311,7 @@ public class CutAndPasteTransfer extends Panel implements ActionListener,
    * @param al
    * @return
    */
-  protected boolean openSplitFrame(AlignmentI al, String format)
+  protected boolean openSplitFrame(AlignmentI al, FileFormatI format)
   {
     final AlignmentI thisAlignment = this.alignFrame.getAlignViewport()
             .getAlignment();
@@ -376,7 +381,7 @@ public class CutAndPasteTransfer extends Panel implements ActionListener,
     try
     {
       tcf = new TCoffeeScoreFile(textarea.getText(),
-              jalview.io.AppletFormatAdapter.PASTE);
+              jalview.io.DataSourceType.PASTE);
       if (tcf.isValid())
       {
         if (tcf.annotateAlignment(alignFrame.viewport.getAlignment(), true))
@@ -409,7 +414,7 @@ public class CutAndPasteTransfer extends Panel implements ActionListener,
     if (tcf == null)
     {
       if (new AnnotationFile().annotateAlignmentView(alignFrame.viewport,
-              textarea.getText(), jalview.io.AppletFormatAdapter.PASTE))
+              textarea.getText(), jalview.io.DataSourceType.PASTE))
       {
         alignFrame.alignPanel.fontChanged();
         alignFrame.alignPanel.setScrollValues(0, 0);
@@ -421,7 +426,7 @@ public class CutAndPasteTransfer extends Panel implements ActionListener,
       else
       {
         if (!alignFrame.parseFeaturesFile(textarea.getText(),
-                jalview.io.AppletFormatAdapter.PASTE))
+                jalview.io.DataSourceType.PASTE))
         {
           alignFrame.statusBar
                   .setText(MessageManager
@@ -445,12 +450,12 @@ public class CutAndPasteTransfer extends Panel implements ActionListener,
     if (alignFrame.alignPanel.av.applet.jmolAvailable)
     {
       new jalview.appletgui.AppletJmol(pdb, new SequenceI[] { seq }, null,
-              alignFrame.alignPanel, AppletFormatAdapter.PASTE);
+              alignFrame.alignPanel, DataSourceType.PASTE);
     }
     else
     {
       new MCview.AppletPDBViewer(pdb, new SequenceI[] { seq }, null,
-              alignFrame.alignPanel, AppletFormatAdapter.PASTE);
+              alignFrame.alignPanel, DataSourceType.PASTE);
     }
   }