FileLoader replaces paste when Dropping files
authoramwaterhouse <Andrew Waterhouse>
Tue, 25 Jul 2006 09:38:52 +0000 (09:38 +0000)
committeramwaterhouse <Andrew Waterhouse>
Tue, 25 Jul 2006 09:38:52 +0000 (09:38 +0000)
src/jalview/gui/AlignFrame.java

index 2ce8f06..5036a0b 100755 (executable)
@@ -37,7 +37,6 @@ import jalview.ws.*;
 import java.awt.dnd.*;\r
 import org.biojava.dasobert.eventmodel.*;\r
 \r
-\r
 /**\r
  * DOCUMENT ME!\r
  *\r
@@ -479,6 +478,7 @@ public class AlignFrame
     new AnnotationExporter().exportFeatures(alignPanel);\r
   }\r
 \r
+\r
   public void exportAnnotations_actionPerformed(ActionEvent e)\r
   {\r
     new AnnotationExporter().exportAnnotations(\r
@@ -767,6 +767,7 @@ public class AlignFrame
       String format = new IdentifyFile().Identify(str, "Paste");\r
       SequenceI[] sequences;\r
 \r
+\r
      if(Desktop.jalviewClipboard!=null)\r
      {\r
        // The clipboard was filled from within Jalview, we must use the sequences\r
@@ -782,32 +783,40 @@ public class AlignFrame
 \r
       if (newAlignment)\r
       {\r
+        System.out.println(format +" 2");\r
         alignment = new Alignment(sequences);\r
 \r
         if(Desktop.jalviewClipboard!=null)\r
            alignment.setDataset( (Alignment)Desktop.jalviewClipboard[1] );\r
         else\r
            alignment.setDataset( null );\r
+\r
       }\r
       else\r
       {\r
+        System.out.println(format +" 24");\r
         alignment = viewport.getAlignment();\r
 \r
         //!newAlignment\r
         for (int i = 0; i < sequences.length; i++)\r
         {\r
-\r
           Sequence newseq = new Sequence(sequences[i].getName(),\r
               sequences[i].getSequence(), sequences[i].getStart(),\r
               sequences[i].getEnd());\r
 \r
           alignment.addSequence(newseq);\r
         }\r
+\r
+\r
         viewport.setEndSeq(alignment.getHeight());\r
         alignment.getWidth();\r
         viewport.firePropertyChange("alignment", null, alignment.getSequences());\r
       }\r
 \r
+\r
+\r
+\r
+\r
       // Add any annotations attached to sequences\r
       for (int i = 0; i < sequences.length; i++)\r
      {\r
@@ -1422,7 +1431,7 @@ public class AlignFrame
     {\r
       viewport.hideSequence(seqs[i]);\r
     }\r
-    repaint();\r
+    alignPanel.repaint();\r
   }\r
 \r
   public void hideSelColumns_actionPerformed(ActionEvent e)\r
@@ -2842,16 +2851,8 @@ public void drop(DropTargetDropEvent evt)
                                                 AppletFormatAdapter.FILE);\r
         if (!isGroupsFile)\r
         {\r
-          String protocol = "File";\r
-          String format = new IdentifyFile().Identify(file, protocol);\r
-          SequenceI[] sequences = new FormatAdapter().readFile(file, protocol,\r
-              format);\r
-\r
-          FastaFile ff = new FastaFile();\r
-          Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard();\r
-          c.setContents(new StringSelection(ff.print(sequences)), Desktop.instance);\r
-\r
-          this.paste(false);\r
+          String format = new IdentifyFile().Identify(file, FormatAdapter.FILE);\r
+          new FileLoader().LoadFile(viewport, file, FormatAdapter.FILE, format);\r
         }\r
       }\r
       else\r