PDB implementation updated
authoramwaterhouse <Andrew Waterhouse>
Thu, 10 Nov 2005 11:05:24 +0000 (11:05 +0000)
committeramwaterhouse <Andrew Waterhouse>
Thu, 10 Nov 2005 11:05:24 +0000 (11:05 +0000)
src/jalview/gui/PopupMenu.java

index 6055230..b9d379c 100755 (executable)
@@ -63,7 +63,6 @@ public class PopupMenu extends JPopupMenu
     JMenuItem sequenceName = new JMenuItem();\r
     Sequence sequence;\r
     JMenuItem unGroupMenuItem = new JMenuItem();\r
-    JMenuItem pdbMenuItem = new JMenuItem();\r
     JMenuItem outline = new JMenuItem();\r
     JRadioButtonMenuItem nucleotideMenuItem = new JRadioButtonMenuItem();\r
     JMenu colourMenu = new JMenu();\r
@@ -77,7 +76,7 @@ public class PopupMenu extends JPopupMenu
      * @param ap DOCUMENT ME!\r
      * @param seq DOCUMENT ME!\r
      */\r
-    public PopupMenu(AlignmentPanel ap, Sequence seq)\r
+    public PopupMenu(final AlignmentPanel ap, Sequence seq)\r
     {\r
         ///////////////////////////////////////////////////////////\r
         // If this is activated from the sequence panel, the user may want to\r
@@ -112,9 +111,27 @@ public class PopupMenu extends JPopupMenu
             e.printStackTrace();\r
         }\r
 \r
-        if ((seq == null) || (seq.getPDBId() == null))\r
+\r
+        if ((seq != null)\r
+            && seq.getDatasetSequence().getPDBId() != null)\r
         {\r
-            pdbMenuItem.setVisible(false);\r
+          java.util.Enumeration e = seq.getDatasetSequence().getPDBId().elements();\r
+          while(e.hasMoreElements())\r
+          {\r
+\r
+            final PDBEntry pdb = (PDBEntry)e.nextElement();\r
+            JMenuItem pdbMenuItem = new JMenuItem();\r
+            pdbMenuItem.setText("View PDB entry: "+pdb.getId());\r
+            pdbMenuItem.addActionListener(new java.awt.event.ActionListener()\r
+            {\r
+                public void actionPerformed(ActionEvent e)\r
+                {\r
+                  PDBViewer viewer = new PDBViewer(pdb, sequence, ap.seqPanel.seqCanvas);\r
+                }\r
+            });\r
+            sequenceMenu.add(pdbMenuItem);\r
+          }\r
+\r
         }\r
 \r
         SequenceGroup sg = ap.av.getSelectionGroup();\r
@@ -261,14 +278,7 @@ public class PopupMenu extends JPopupMenu
                     unGroupMenuItem_actionPerformed(e);\r
                 }\r
             });\r
-        pdbMenuItem.setText("View PDB structure");\r
-        pdbMenuItem.addActionListener(new java.awt.event.ActionListener()\r
-            {\r
-                public void actionPerformed(ActionEvent e)\r
-                {\r
-                    pdbMenuItem_actionPerformed(e);\r
-                }\r
-            });\r
+\r
         outline.setText("Border colour");\r
         outline.addActionListener(new java.awt.event.ActionListener()\r
             {\r
@@ -325,7 +335,6 @@ public class PopupMenu extends JPopupMenu
         groupMenu.addSeparator();\r
         groupMenu.add(outline);\r
         sequenceMenu.add(sequenceName);\r
-        sequenceMenu.add(pdbMenuItem);\r
         colourMenu.add(noColourmenuItem);\r
         colourMenu.add(clustalColour);\r
         colourMenu.add(BLOSUM62Colour);\r
@@ -830,37 +839,6 @@ public class PopupMenu extends JPopupMenu
         refresh();\r
     }\r
 \r
-    /**\r
-     * DOCUMENT ME!\r
-     *\r
-     * @param e DOCUMENT ME!\r
-     */\r
-    void pdbMenuItem_actionPerformed(ActionEvent e)\r
-    {\r
-        if (sequence.getPDBId() == null)\r
-        {\r
-            return;\r
-        }\r
-\r
-        try\r
-        {\r
-            EBIFetchClient ebi = new EBIFetchClient();\r
-            String[] result = ebi.fetchData("pdb:" + sequence.getPDBId(), null,\r
-                    null);\r
-\r
-            PDBfile pdb = new PDBfile(result);\r
-\r
-            rotCanvas rc = new rotCanvas(pdb, sequence, ap.av);\r
-            JInternalFrame frame = new JInternalFrame();\r
-            frame.setContentPane(rc);\r
-            Desktop.addInternalFrame(frame,\r
-                sequence.getName() + " " + sequence.getPDBId(), 400, 400);\r
-        }\r
-        catch (Exception ex)\r
-        {\r
-            ex.printStackTrace();\r
-        }\r
-    }\r
 \r
     /**\r
      * DOCUMENT ME!\r