pasted file contents should never be added to the recent URL or recent file list.
[jalview.git] / src / jalview / appletgui / CutAndPasteTransfer.java
index 7c9d421..d13bb7e 100755 (executable)
@@ -1,6 +1,6 @@
 /*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4)
- * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4.0.b2)
+ * Copyright (C) 2009 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
  * 
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -24,13 +24,17 @@ import java.awt.event.*;
 import jalview.datamodel.*;
 import jalview.io.*;
 
-public class CutAndPasteTransfer
-    extends Panel implements ActionListener, MouseListener
+public class CutAndPasteTransfer extends Panel implements ActionListener,
+        MouseListener
 {
   boolean pdbImport = false;
+
   boolean treeImport = false;
+
   boolean annotationImport = false;
-  Sequence  seq;
+
+  Sequence seq;
+
   AlignFrame alignFrame;
 
   public CutAndPasteTransfer(boolean forImport, AlignFrame alignFrame)
@@ -38,8 +42,7 @@ public class CutAndPasteTransfer
     try
     {
       jbInit();
-    }
-    catch (Exception e)
+    } catch (Exception e)
     {
       e.printStackTrace();
     }
@@ -107,15 +110,14 @@ public class CutAndPasteTransfer
     textarea.append("\n");
     if (textarea.getText().length() == length)
     {
-      String warning =
-          "\n\n#################################################\n"
-          + "WARNING!! THIS IS THE MAXIMUM SIZE OF TEXTAREA!!\n"
-          + "\nCAN'T INPUT FULL ALIGNMENT"
-          + "\n\nYOU MUST DELETE THIS WARNING TO CONTINUE"
-          + "\n\nMAKE SURE LAST SEQUENCE PASTED IS COMPLETE"
-          + "\n#################################################\n";
+      String warning = "\n\n#################################################\n"
+              + "WARNING!! THIS IS THE MAXIMUM SIZE OF TEXTAREA!!\n"
+              + "\nCAN'T INPUT FULL ALIGNMENT"
+              + "\n\nYOU MUST DELETE THIS WARNING TO CONTINUE"
+              + "\n\nMAKE SURE LAST SEQUENCE PASTED IS COMPLETE"
+              + "\n#################################################\n";
       textarea.setText(text.substring(0, text.length() - warning.length())
-                       + warning);
+              + warning);
 
       textarea.setCaretPosition(text.length());
     }
@@ -125,27 +127,21 @@ public class CutAndPasteTransfer
       PDBEntry pdb = new PDBEntry();
       pdb.setFile(text);
 
-      if ( alignFrame.alignPanel.av.applet.jmolAvailable )
-        new jalview.appletgui.AppletJmol(pdb,
-                                         new Sequence[]{seq},
-                                         null,
-                                         alignFrame.alignPanel,
-                                         AppletFormatAdapter.PASTE);
+      if (alignFrame.alignPanel.av.applet.jmolAvailable)
+        new jalview.appletgui.AppletJmol(pdb, new Sequence[]
+        { seq }, null, alignFrame.alignPanel, AppletFormatAdapter.PASTE);
       else
 
-        new MCview.AppletPDBViewer(pdb,
-                                   new Sequence[]{seq},
-                                   null,
-                                   alignFrame.alignPanel,
-                                   AppletFormatAdapter.PASTE);
+        new MCview.AppletPDBViewer(pdb, new Sequence[]
+        { seq }, null, alignFrame.alignPanel, AppletFormatAdapter.PASTE);
 
     }
     else if (treeImport)
     {
       try
       {
-        jalview.io.NewickFile fin = new jalview.io.NewickFile(textarea.getText(),
-            "Paste");
+        jalview.io.NewickFile fin = new jalview.io.NewickFile(textarea
+                .getText(), "Paste");
 
         fin.parse();
         if (fin.getTree() != null)
@@ -153,8 +149,7 @@ public class CutAndPasteTransfer
           alignFrame.loadTree(fin, "Pasted tree file");
         }
 
-      }
-      catch (Exception ex)
+      } catch (Exception ex)
       {
         textarea.setText("Could not parse Newick file!\n" + ex);
         return;
@@ -163,8 +158,8 @@ public class CutAndPasteTransfer
     else if (annotationImport)
     {
       if (new AnnotationFile().readAnnotationFile(
-          alignFrame.viewport.alignment, textarea.getText(),
-          jalview.io.AppletFormatAdapter.PASTE))
+              alignFrame.viewport.alignment, textarea.getText(),
+              jalview.io.AppletFormatAdapter.PASTE))
       {
         alignFrame.alignPanel.fontChanged();
         alignFrame.alignPanel.setScrollValues(0, 0);
@@ -173,7 +168,7 @@ public class CutAndPasteTransfer
       else
       {
         alignFrame.parseFeaturesFile(textarea.getText(),
-                                     jalview.io.AppletFormatAdapter.PASTE);
+                jalview.io.AppletFormatAdapter.PASTE);
       }
     }
     else if (alignFrame != null)
@@ -181,13 +176,12 @@ public class CutAndPasteTransfer
       Alignment al = null;
 
       String format = new IdentifyFile().Identify(text,
-                                                  AppletFormatAdapter.PASTE);
+              AppletFormatAdapter.PASTE);
       try
       {
-        al = new AppletFormatAdapter().readFile(text, AppletFormatAdapter.PASTE,
-                                                format);
-      }
-      catch (java.io.IOException ex)
+        al = new AppletFormatAdapter().readFile(text,
+                AppletFormatAdapter.PASTE, format);
+      } catch (java.io.IOException ex)
       {
         ex.printStackTrace();
       }
@@ -197,8 +191,7 @@ public class CutAndPasteTransfer
         if (newWindow)
         {
           AlignFrame af = new AlignFrame(al, alignFrame.viewport.applet,
-                                         "Cut & Paste input - " + format,
-                                         false);
+                  "Cut & Paste input - " + format, false);
           af.statusBar.setText("Successfully pasted alignment file");
         }
         else
@@ -210,11 +203,11 @@ public class CutAndPasteTransfer
 
     if (this.getParent() instanceof Frame)
     {
-      ( (Frame)this.getParent()).setVisible(false);
+      ((Frame) this.getParent()).setVisible(false);
     }
     else
     {
-      ( (Dialog)this.getParent()).setVisible(false);
+      ((Dialog) this.getParent()).setVisible(false);
     }
   }
 
@@ -223,24 +216,27 @@ public class CutAndPasteTransfer
     textarea.setText("");
     if (this.getParent() instanceof Frame)
     {
-      ( (Frame)this.getParent()).setVisible(false);
+      ((Frame) this.getParent()).setVisible(false);
     }
     else
     {
-      ( (Dialog)this.getParent()).setVisible(false);
+      ((Dialog) this.getParent()).setVisible(false);
     }
   }
 
   protected TextArea textarea = new TextArea();
+
   Button accept = new Button("New Window");
+
   Button addSequences = new Button("Add to Current Alignment");
+
   Button cancel = new Button("Close");
 
   protected Panel buttonPanel = new Panel();
+
   BorderLayout borderLayout1 = new BorderLayout();
 
-  private void jbInit()
-      throws Exception
+  private void jbInit() throws Exception
   {
     textarea.setFont(new java.awt.Font("Monospaced", Font.PLAIN, 10));
     textarea.setText("Paste your alignment file here");
@@ -265,14 +261,18 @@ public class CutAndPasteTransfer
   }
 
   public void mouseReleased(MouseEvent evt)
-  {}
+  {
+  }
 
   public void mouseClicked(MouseEvent evt)
-  {}
+  {
+  }
 
   public void mouseEntered(MouseEvent evt)
-  {}
+  {
+  }
 
   public void mouseExited(MouseEvent evt)
-  {}
+  {
+  }
 }