first approximation for JAL-782 - hint that opaque groupName is actually the name
[jalview.git] / src / jalview / gui / PopupMenu.java
index a952d29..07fdeea 100755 (executable)
@@ -1,5 +1,5 @@
 /*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.5)
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.6)
  * Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle
  * 
  * This file is part of Jalview.
@@ -341,7 +341,8 @@ public class PopupMenu extends JPopupMenu
 
     if (sg != null)
     {
-      groupName.setText(sg.getName());
+      groupName.setText("Name: "+sg.getName());
+      groupName.setText("Edit name and description of current group.");
 
       if (sg.cs instanceof ZappoColourScheme)
       {
@@ -452,9 +453,9 @@ public class PopupMenu extends JPopupMenu
         {
 
           // collect matching db-refs
-          DBRefEntry[] dbr = jalview.util.DBRefUtils.selectRefs(seq
-                  .getDBRef(), new String[]
-          { urlLink.getTarget() });
+          DBRefEntry[] dbr = jalview.util.DBRefUtils.selectRefs(
+                  seq.getDBRef(), new String[]
+                  { urlLink.getTarget() });
           // collect id string too
           String id = seq.getName();
           String descr = seq.getDescription();
@@ -658,8 +659,8 @@ public class PopupMenu extends JPopupMenu
       Object[] urlset = null;
       try
       {
-        urlset = urlLink.makeUrlStubs(ids, seqstr, "FromJalview"
-                + System.currentTimeMillis(), false);
+        urlset = urlLink.makeUrlStubs(ids, seqstr,
+                "FromJalview" + System.currentTimeMillis(), false);
       } catch (UrlStringTooLongException e)
       {
       }
@@ -1175,9 +1176,9 @@ public class PopupMenu extends JPopupMenu
   protected void clustalColour_actionPerformed()
   {
     SequenceGroup sg = getGroup();
-    sg.cs = new ClustalxColourScheme(sg
-            .getSequences(ap.av.hiddenRepSequences), ap.av.alignment
-            .getWidth());
+    sg.cs = new ClustalxColourScheme(
+            sg.getSequences(ap.av.hiddenRepSequences),
+            ap.av.alignment.getWidth());
     refresh();
   }
 
@@ -1293,9 +1294,9 @@ public class PopupMenu extends JPopupMenu
 
     if (abovePIDColour.isSelected())
     {
-      sg.cs.setConsensus(AAFrequency.calculate(sg
-              .getSequences(ap.av.hiddenRepSequences), sg.getStartRes(), sg
-              .getEndRes() + 1));
+      sg.cs.setConsensus(AAFrequency.calculate(
+              sg.getSequences(ap.av.hiddenRepSequences), sg.getStartRes(),
+              sg.getEndRes() + 1));
 
       int threshold = SliderPanel.setPIDSliderSource(ap, sg.cs, getGroup()
               .getName());
@@ -1347,9 +1348,9 @@ public class PopupMenu extends JPopupMenu
   {
     SequenceGroup sg = getGroup();
     sg.cs = new PIDColourScheme();
-    sg.cs.setConsensus(AAFrequency.calculate(sg
-            .getSequences(ap.av.hiddenRepSequences), sg.getStartRes(), sg
-            .getEndRes() + 1));
+    sg.cs.setConsensus(AAFrequency.calculate(
+            sg.getSequences(ap.av.hiddenRepSequences), sg.getStartRes(),
+            sg.getEndRes() + 1));
     refresh();
   }
 
@@ -1365,9 +1366,9 @@ public class PopupMenu extends JPopupMenu
 
     sg.cs = new Blosum62ColourScheme();
 
-    sg.cs.setConsensus(AAFrequency.calculate(sg
-            .getSequences(ap.av.hiddenRepSequences), sg.getStartRes(), sg
-            .getEndRes() + 1));
+    sg.cs.setConsensus(AAFrequency.calculate(
+            sg.getSequences(ap.av.hiddenRepSequences), sg.getStartRes(),
+            sg.getEndRes() + 1));
 
     refresh();
   }
@@ -1401,9 +1402,9 @@ public class PopupMenu extends JPopupMenu
     if (conservationMenuItem.isSelected())
     {
       Conservation c = new Conservation("Group",
-              ResidueProperties.propHash, 3, sg
-                      .getSequences(ap.av.hiddenRepSequences), sg
-                      .getStartRes(), sg.getEndRes() + 1);
+              ResidueProperties.propHash, 3,
+              sg.getSequences(ap.av.hiddenRepSequences), sg.getStartRes(),
+              sg.getEndRes() + 1);
 
       c.calculate();
       c.verdict(false, ap.av.ConsPercGaps);
@@ -1430,8 +1431,8 @@ public class PopupMenu extends JPopupMenu
       return;
     }
 
-    AnnotationColourGradient acg = new AnnotationColourGradient(sequence
-            .getAnnotation()[0], null,
+    AnnotationColourGradient acg = new AnnotationColourGradient(
+            sequence.getAnnotation()[0], null,
             AnnotationColourGradient.NO_THRESHOLD);
 
     acg.predefinedColours = true;
@@ -1450,9 +1451,10 @@ public class PopupMenu extends JPopupMenu
   {
 
     SequenceGroup sg = getGroup();
-    EditNameDialog dialog = new EditNameDialog(sg.getName(), sg
-            .getDescription(), "       Group Name ", "Group Description ",
-            "Edit Group Name/Description", ap.alignFrame);
+    EditNameDialog dialog = new EditNameDialog(sg.getName(),
+            sg.getDescription(), "       Group Name ",
+            "Group Description ", "Edit Group Name/Description",
+            ap.alignFrame);
 
     if (!dialog.accept)
     {
@@ -1489,9 +1491,10 @@ public class PopupMenu extends JPopupMenu
    */
   void sequenceName_actionPerformed()
   {
-    EditNameDialog dialog = new EditNameDialog(sequence.getName(), sequence
-            .getDescription(), "       Sequence Name ",
-            "Sequence Description ", "Edit Sequence Name/Description", ap.alignFrame);
+    EditNameDialog dialog = new EditNameDialog(sequence.getName(),
+            sequence.getDescription(), "       Sequence Name ",
+            "Sequence Description ", "Edit Sequence Name/Description",
+            ap.alignFrame);
 
     if (!dialog.accept)
     {
@@ -1681,8 +1684,8 @@ public class PopupMenu extends JPopupMenu
         caseChange = ChangeCaseCommand.TO_LOWER;
       }
 
-      ChangeCaseCommand caseCommand = new ChangeCaseCommand(description, sg
-              .getSequencesAsArray(ap.av.hiddenRepSequences), startEnd,
+      ChangeCaseCommand caseCommand = new ChangeCaseCommand(description,
+              sg.getSequencesAsArray(ap.av.hiddenRepSequences), startEnd,
               caseChange);
 
       ap.alignFrame.addHistoryItem(caseCommand);
@@ -1697,8 +1700,8 @@ public class PopupMenu extends JPopupMenu
   {
     CutAndPasteTransfer cap = new CutAndPasteTransfer();
     cap.setForInput(null);
-    Desktop.addInternalFrame(cap, "Alignment output - "
-            + e.getActionCommand(), 600, 500);
+    Desktop.addInternalFrame(cap,
+            "Alignment output - " + e.getActionCommand(), 600, 500);
 
     String[] omitHidden = null;
 
@@ -1710,7 +1713,8 @@ public class PopupMenu extends JPopupMenu
     omitHidden = ap.av.getViewAsString(true);
     Alignment oal = new Alignment(ap.av.getSequenceSelection());
     AlignmentAnnotation[] nala = ap.av.alignment.getAlignmentAnnotation();
-    if (nala!=null) {
+    if (nala != null)
+    {
       for (int i = 0; i < nala.length; i++)
       {
         AlignmentAnnotation na = nala[i];
@@ -1727,47 +1731,16 @@ public class PopupMenu extends JPopupMenu
     jalview.io.JalviewFileChooser chooser = new jalview.io.JalviewFileChooser(
             jalview.bin.Cache.getProperty("LAST_DIRECTORY"));
     chooser.setFileView(new jalview.io.JalviewFileView());
-    chooser.setDialogTitle("Select a PDB file");
-    chooser.setToolTipText("Load a PDB file");
+    chooser.setDialogTitle("Select a PDB file for "+sequence.getDisplayId(false));
+    chooser.setToolTipText("Load a PDB file and associate it with sequence '"+sequence.getDisplayId(false)+"'");
 
     int value = chooser.showOpenDialog(null);
 
     if (value == jalview.io.JalviewFileChooser.APPROVE_OPTION)
     {
-      PDBEntry entry = new PDBEntry();
       String choice = chooser.getSelectedFile().getPath();
       jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice);
-      try
-      {
-        MCview.PDBfile pdbfile = new MCview.PDBfile(choice,
-                jalview.io.AppletFormatAdapter.FILE);
-
-        if (pdbfile.id == null)
-        {
-          String reply = JOptionPane
-                  .showInternalInputDialog(
-                          Desktop.desktop,
-                          "Couldn't find a PDB id in the file supplied."
-                                  + "Please enter an Id to identify this structure.",
-                          "No PDB Id in File", JOptionPane.QUESTION_MESSAGE);
-          if (reply == null)
-          {
-            return;
-          }
-
-          entry.setId(reply);
-        }
-        else
-        {
-          entry.setId(pdbfile.id);
-        }
-      } catch (java.io.IOException ex)
-      {
-        ex.printStackTrace();
-      }
-
-      entry.setFile(choice);
-      sequence.getDatasetSequence().addPDBId(entry);
+      new AssociatePdbFileWithSeq().associatePdbWithSeq(choice, jalview.io.AppletFormatAdapter.FILE, sequence, true);
     }
 
   }
@@ -1880,17 +1853,18 @@ public class PopupMenu extends JPopupMenu
       if (sequence == null)
         sequence = (Sequence) sg.getSequenceAt(0);
 
-      EditNameDialog dialog = new EditNameDialog(sequence
-              .getSequenceAsString(sg.getStartRes(), sg.getEndRes() + 1),
-              null, "Edit Sequence ", null, "Edit Sequence", ap.alignFrame);
+      EditNameDialog dialog = new EditNameDialog(
+              sequence.getSequenceAsString(sg.getStartRes(),
+                      sg.getEndRes() + 1), null, "Edit Sequence ", null,
+              "Edit Sequence", ap.alignFrame);
 
       if (dialog.accept)
       {
         EditCommand editCommand = new EditCommand("Edit Sequences",
                 EditCommand.REPLACE, dialog.getName().replace(' ',
-                        ap.av.getGapCharacter()), sg
-                        .getSequencesAsArray(ap.av.hiddenRepSequences), sg
-                        .getStartRes(), sg.getEndRes() + 1, ap.av.alignment);
+                        ap.av.getGapCharacter()),
+                sg.getSequencesAsArray(ap.av.hiddenRepSequences),
+                sg.getStartRes(), sg.getEndRes() + 1, ap.av.alignment);
 
         ap.alignFrame.addHistoryItem(editCommand);