file format enum wip changes
[jalview.git] / src / jalview / gui / CutAndPasteTransfer.java
index 8665320..7b3e438 100644 (file)
@@ -23,12 +23,16 @@ package jalview.gui;
 import jalview.api.AlignViewportI;
 import jalview.api.AlignmentViewPanel;
 import jalview.api.ComplexAlignFile;
+import jalview.api.FeatureSettingsModelI;
 import jalview.api.FeaturesDisplayedI;
+import jalview.api.FeaturesSourceI;
 import jalview.bin.Jalview;
 import jalview.datamodel.AlignmentI;
 import jalview.datamodel.ColumnSelection;
 import jalview.datamodel.SequenceI;
 import jalview.io.AppletFormatAdapter;
+import jalview.io.DataSourceType;
+import jalview.io.FileFormatI;
 import jalview.io.FileParse;
 import jalview.io.FormatAdapter;
 import jalview.io.IdentifyFile;
@@ -211,14 +215,15 @@ public class CutAndPasteTransfer extends GCutAndPasteTransfer
       return;
     }
 
-    String format = new IdentifyFile().identify(text, "Paste");
-    if (format == null || format.equalsIgnoreCase("EMPTY DATA FILE"))
+    FileFormatI format = new IdentifyFile().identify(text,
+            DataSourceType.PASTE);
+    if (format == null)
     {
       System.err.println(MessageManager
               .getString("label.couldnt_read_data"));
       if (!Jalview.isHeadlessMode())
       {
-        javax.swing.JOptionPane.showInternalMessageDialog(Desktop.desktop,
+        JOptionPane.showInternalMessageDialog(Desktop.desktop,
                 AppletFormatAdapter.SUPPORTED_FORMATS,
                 MessageManager.getString("label.couldnt_read_data"),
                 JOptionPane.WARNING_MESSAGE);
@@ -234,7 +239,7 @@ public class CutAndPasteTransfer extends GCutAndPasteTransfer
       try
       {
         FormatAdapter fa = new FormatAdapter(alignpanel);
-        al = fa.readFile(getText(), "Paste", format);
+        al = fa.readFile(getText(), DataSourceType.PASTE, format);
         source = fa.getAlignFile();
 
       } catch (java.io.IOException ex)
@@ -252,12 +257,19 @@ public class CutAndPasteTransfer extends GCutAndPasteTransfer
     {
       String title = MessageManager.formatMessage(
               "label.input_cut_paste_params", new String[] { format });
+      FeatureSettingsModelI proxyColourScheme = source
+              .getFeatureColourScheme();
+
       /*
        * if the view panel was closed its alignment is nulled
        * and this is an orphaned cut and paste window
        */
       if (viewport != null && viewport.getAlignment() != null)
       {
+        if (proxyColourScheme != null)
+        {
+          viewport.applyFeaturesStyle(proxyColourScheme);
+        }
         ((AlignViewport) viewport).addAlignment(al, title);
       }
       else
@@ -291,8 +303,15 @@ public class CutAndPasteTransfer extends GCutAndPasteTransfer
         {
           af = new AlignFrame(al, AlignFrame.DEFAULT_WIDTH,
                   AlignFrame.DEFAULT_HEIGHT);
+          if (source instanceof FeaturesSourceI)
+          {
+            af.getViewport().setShowSequenceFeatures(true);
+          }
+        }
+        if (proxyColourScheme != null)
+        {
+          af.getViewport().applyFeaturesStyle(proxyColourScheme);
         }
-
         af.currentFileFormat = format;
         Desktop.addInternalFrame(af, title, AlignFrame.DEFAULT_WIDTH,
                 AlignFrame.DEFAULT_HEIGHT);
@@ -342,7 +361,7 @@ public class CutAndPasteTransfer extends GCutAndPasteTransfer
   @Override
   public void textarea_mousePressed(MouseEvent e)
   {
-    if (SwingUtilities.isRightMouseButton(e))
+    if (e.isPopupTrigger())
     {
       JPopupMenu popup = new JPopupMenu(
               MessageManager.getString("action.edit"));