JAL-1477 first implementation of 'View all representative structures' option.
authorJim Procter <jprocter@dundee.ac.uk>
Fri, 18 Apr 2014 09:50:15 +0000 (10:50 +0100)
committerJim Procter <jprocter@dundee.ac.uk>
Mon, 21 Apr 2014 13:09:18 +0000 (14:09 +0100)
resources/lang/Messages.properties
src/jalview/gui/PopupMenu.java

index ce534e1..329eb8d 100644 (file)
@@ -617,6 +617,7 @@ label.2d_rna_sequence_name = 2D RNA - {0}
 label.edit_name_and_description_current_group = Edit name and description of current group.\r
 label.view_structure_for = View structure for {0}\r
 label.view_all_structures = View all {0} structures.\r
+label.view_all_representative_structures = View all {0} representative structures.\r
 label.associate_structure_with_sequence = Associate Structure with Sequence\r
 label.from_file = from file\r
 label.enter_pdb_id = Enter PDB Id\r
index 0e39f34..66cafc5 100644 (file)
@@ -472,7 +472,7 @@ public class PopupMenu extends JPopupMenu
         buildGroupURLMenu(sg, groupLinks);
       }
       // Add a 'show all structures' for the current selection
-      Hashtable<String, PDBEntry> pdbe = new Hashtable<String, PDBEntry>();
+      Hashtable<String, PDBEntry> pdbe = new Hashtable<String, PDBEntry>(),reppdb=new Hashtable<String,PDBEntry>();
       SequenceI sqass = null;
       for (SequenceI sq : ap.av.getSequenceSelection())
       {
@@ -480,6 +480,7 @@ public class PopupMenu extends JPopupMenu
                 .getPDBId();
         if (pes != null)
         {
+          reppdb.put(pes.get(0).getId(),pes.get(0));
           for (PDBEntry pe : pes)
           {
             pdbe.put(pe.getId(), pe);
@@ -493,15 +494,16 @@ public class PopupMenu extends JPopupMenu
       if (pdbe.size() > 0)
       {
         final PDBEntry[] pe = pdbe.values().toArray(
-                new PDBEntry[pdbe.size()]);
-        final JMenuItem gpdbview;
+                new PDBEntry[pdbe.size()]),pr = reppdb.values().toArray(
+                        new PDBEntry[reppdb.size()]);
+        final JMenuItem gpdbview,rpdbview;
         if (pdbe.size() == 1)
         {
           structureMenu.add(gpdbview = new JMenuItem(MessageManager.formatMessage("label.view_structure_for", new String[]{sqass.getDisplayId(false)})));\r
         }
         else
         {
-          structureMenu.add(gpdbview = new JMenuItem(MessageManager.formatMessage("label.view_all_structures", new String[]{new Integer(pdbe.size()).toString()})));\r
+          structureMenu.add(gpdbview = new JMenuItem(MessageManager.formatMessage("label.view_all_structures", new String[]{new Integer(pdbe.size()).toString()})));          \r
         }
         gpdbview.setToolTipText(MessageManager.getString("label.open_new_jmol_view_with_all_structures_associated_current_selection_superimpose_using_alignment"));\r
         gpdbview.addActionListener(new ActionListener()
@@ -513,6 +515,20 @@ public class PopupMenu extends JPopupMenu
             new AppJmol(ap, pe, ap.av.collateForPDB(pe));
           }
         });
+        if (reppdb.size()>1 && reppdb.size()<pdbe.size())
+        {
+          structureMenu.add(rpdbview = new JMenuItem(MessageManager.formatMessage("label.view_all_representative_structures", new String[]{new Integer(reppdb.size()).toString()})));
+          rpdbview.setToolTipText(MessageManager.getString("label.open_new_jmol_view_with_all_representative_structures_associated_current_selection_superimpose_using_alignment"));
+          rpdbview.addActionListener(new ActionListener()
+          {
+
+            @Override
+            public void actionPerformed(ActionEvent e)
+            {
+              new AppJmol(ap, pr, ap.av.collateForPDB(pr));
+            }
+          });
+        }
       }
     }
     else