import java.awt.*;
import java.awt.event.*;
+
import javax.swing.*;
import MCview.*;
* DOCUMENT ME!
*
* @author $author$
- * @version $Revision$
+ * @version $Revision: 1.118 $
*/
public class PopupMenu extends JPopupMenu
{
e.printStackTrace();
}
+ JMenuItem menuItem;
if (seq != null)
{
sequenceMenu.setText(sequence.getName());
- JMenuItem menuItem;
if (seq.getDatasetSequence().getPDBId() != null
&& seq.getDatasetSequence().getPDBId().size() > 0)
{
{
public void actionPerformed(ActionEvent e)
{
- Vector seqs = new Vector();
- for (int i = 0; i < ap.av.alignment.getHeight(); i++)
- {
- Vector pdbs = ap.av.alignment.getSequenceAt(i)
- .getDatasetSequence().getPDBId();
- if (pdbs == null)
- continue;
-
- for (int p = 0; p < pdbs.size(); p++)
- {
- PDBEntry p1 = (PDBEntry) pdbs.elementAt(p);
- if (p1.getId().equals(pdb.getId()))
- {
- if (!seqs.contains(ap.av.alignment.getSequenceAt(i)))
- seqs.addElement(ap.av.alignment.getSequenceAt(i));
-
- continue;
- }
- }
- }
-
- SequenceI[] seqs2 = new SequenceI[seqs.size()];
- seqs.toArray(seqs2);
-
- new AppJmol(pdb, seqs2, null, ap);
+ // TODO re JAL-860: optionally open dialog or provide a menu entry allowing user to open just one structure per sequence
+ new AppJmol(pdb, ap.av.collateForPDB(new PDBEntry[] { pdb })[0], null, ap);
// new PDBViewer(pdb, seqs2, null, ap, AppletFormatAdapter.FILE);
}
+
});
viewStructureMenu.add(menuItem);
});
add(menuItem);
}
-
+ }
+ }
+ // for the case when no sequences are even visible
+ if (ap.av.hasHiddenRows) {
+ {
menuItem = new JMenuItem("Reveal All");
menuItem.addActionListener(new ActionListener()
{
SequenceGroup sg = ap.av.getSelectionGroup();
- if (sg != null)
+ if (sg != null&& sg.getSize()>0)
{
- groupName.setText(sg.getName());
+ groupName.setText("Name: "+sg.getName());
+ groupName.setText("Edit name and description of current group.");
if (sg.cs instanceof ZappoColourScheme)
{
{
buildGroupURLMenu(sg, groupLinks);
}
+ // Add a 'show all structures' for the current selection
+ Hashtable<String, PDBEntry> pdbe=new Hashtable<String,PDBEntry>();
+ SequenceI sqass=null;
+ for (SequenceI sq: ap.av.getSequenceSelection())
+ {
+ Vector<PDBEntry> pes = (Vector<PDBEntry>) sq.getDatasetSequence().getPDBId();
+ if (pes!=null) {
+ for (PDBEntry pe: pes)
+ {
+ pdbe.put(pe.getId(), pe);
+ if (sqass==null)
+ {
+ sqass = sq;
+ }
+ }
+ }
+ }
+ if (pdbe.size()>0)
+ {
+ final PDBEntry[] pe = pdbe.values().toArray(new PDBEntry[pdbe.size()]);
+ final JMenuItem gpdbview;
+ if (pdbe.size()==1)
+ {
+ structureMenu.add(gpdbview=new JMenuItem("View structure for "+sqass.getDisplayId(false)));
+ } else {
+ structureMenu.add(gpdbview=new JMenuItem("View all "+pdbe.size()+" structures."));
+ }
+ gpdbview.setToolTipText("Open a new Jmol view with all structures associated with the current selection and superimpose them using the alignment.");
+ gpdbview.addActionListener(new ActionListener()
+ {
+
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ new AppJmol(ap, pe, ap.av.collateForPDB(pe));
+ }
+ });
+ }
}
else
{
structureMenu.setVisible(false);
}
- if (links != null && links.size() > 0)
+ if (seq !=null && links != null && links.size() > 0)
{
JMenu linkMenu = new JMenu("Link");
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);
}
}
public void colourByStructure(String pdbid)
{
- Annotation[] anots = jalview.structure.StructureSelectionManager
- .getStructureSelectionManager().colourSequenceFromStructure(
+ Annotation[] anots = ap.av.getStructureSelectionManager().colourSequenceFromStructure(
sequence, pdbid);
AlignmentAnnotation an = new AlignmentAnnotation("Structure",