JAL-1641 Further refactoring of JSON export option, introduction of Viewport to the...
[jalview.git] / src / jalview / gui / CutAndPasteTransfer.java
index 6511cd8..3f4aa71 100644 (file)
@@ -21,7 +21,9 @@
 package jalview.gui;
 
 import jalview.datamodel.Alignment;
+import jalview.io.FileParse;
 import jalview.io.FormatAdapter;
+import jalview.io.HtmlFile;
 import jalview.io.IdentifyFile;
 import jalview.io.JSONFile;
 import jalview.io.JalviewFileChooser;
@@ -54,6 +56,7 @@ public class CutAndPasteTransfer extends GCutAndPasteTransfer
 
   AlignViewport viewport;
 
+  FileParse source = null;
   public CutAndPasteTransfer()
   {
     SwingUtilities.invokeLater(new Runnable()
@@ -189,7 +192,10 @@ public class CutAndPasteTransfer extends GCutAndPasteTransfer
     {
       try
       {
-        al = new FormatAdapter().readFile(getText(), "Paste", format);
+        FormatAdapter fa = new FormatAdapter(viewport);
+        al = fa.readFile(getText(), "Paste", format);
+        source = fa.getAlignFile();
+
       } catch (java.io.IOException ex)
       {
         JOptionPane.showInternalMessageDialog(Desktop.desktop,
@@ -220,10 +226,15 @@ public class CutAndPasteTransfer extends GCutAndPasteTransfer
         af.statusBar.setText(MessageManager
                 .getString("label.successfully_pasted_alignment_file"));
 
-        af.setShowSeqFeatures(JSONFile.isSeqFeaturesEnabled());
+        if (source instanceof HtmlFile)
+        {
+          ((HtmlFile) source).LoadAlignmentFeatures(af);
+        }
+        else if (source instanceof JSONFile)
+        {
+          ((JSONFile) source).LoadAlignmentFeatures(af);
+        }
 
-        af.changeColour(JSONFile.getColourScheme());
-        af.setMenusForViewport();
 
         try
         {