*/
package jalview.gui;
+import jalview.api.AlignmentViewPanel;
import jalview.bin.Cache;
import jalview.datamodel.Alignment;
import jalview.datamodel.AlignmentI;
}
/**
+ * @return true if added structures should be aligned to existing one(s)
+ */
+ @Override
+ public boolean isAlignAddedStructures()
+ {
+ return alignAddedStructures;
+ }
+
+ /**
+ *
+ * @param true
+ * if added structures should be aligned to existing one(s)
+ */
+ @Override
+ public void setAlignAddedStructures(boolean alignAdded)
+ {
+ alignAddedStructures = alignAdded;
+ }
+
+ /**
*
* @param ap2
* @return true if this Jmol instance is linked with the given alignPanel
*/
protected void addStructure(final PDBEntry pdbentry,
final SequenceI[] seqs, final String[] chains,
- final boolean align, final IProgressIndicator alignFrame)
+ final IProgressIndicator alignFrame)
{
if (pdbentry.getFile() == null)
{
}
}
// and call ourselves again.
- addStructure(pdbentry, seqs, chains, align, alignFrame);
+ addStructure(pdbentry, seqs, chains, alignFrame);
}
}).start();
return;
{ seqs }, new String[][] { chains });
addingStructures = true;
_started = false;
- alignAddedStructures = align;
worker = new Thread(this);
worker.start();
return;
}
- /**
- * Presents a dialog with the option to add an align a structure to an
- * existing structure view
- *
- * @param pdbId
- * @param view
- * @return YES, NO or CANCEL JvOptionPane code
- */
- protected int chooseAlignStructureToViewer(String pdbId,
- StructureViewerBase view)
+ protected boolean hasPdbId(String pdbId)
{
- int option = JvOptionPane.showInternalConfirmDialog(Desktop.desktop,
- MessageManager.formatMessage("label.add_pdbentry_to_view",
- new Object[]
- { pdbId, view.getTitle() }),
- MessageManager
- .getString("label.align_to_existing_structure_view"),
- JvOptionPane.YES_NO_CANCEL_OPTION);
- return option;
+ return getBinding().hasPdbId(pdbId);
}
- protected boolean hasPdbId(String pdbId)
+ /**
+ * Returns a list of any viewer of the instantiated type. The list is
+ * restricted to those linked to the given alignment panel if it is not null.
+ */
+ protected List<StructureViewerBase> getViewersFor(AlignmentPanel alp)
{
- return getBinding().hasPdbId(pdbId);
+ return Desktop.instance.getStructureViewers(alp, this.getClass());
}
- protected abstract List<StructureViewerBase> getViewersFor(
- AlignmentPanel alp);
/**
* Check for any existing views involving this alignment and give user the
* @param pdbId
* @return true if user adds to a view, or cancels entirely, else false
*/
- protected boolean addToExistingViewer(PDBEntry pdbentry, SequenceI[] seq,
- String[] chains, final AlignmentPanel apanel, String pdbId)
+ @Override
+ public boolean addToExistingViewer(PDBEntry pdbentry, SequenceI[] seq,
+ String[] chains, final AlignmentViewPanel apanel, String pdbId)
{
- for (StructureViewerBase view : getViewersFor(apanel))
- {
- // TODO: highlight the view somehow
- /*
- * JAL-1742 exclude view with this structure already mapped (don't offer
- * to align chain B to chain A of the same structure)
- */
- if (view.hasPdbId(pdbId))
- {
- continue;
- }
- int option = chooseAlignStructureToViewer(pdbId, view);
- if (option == JvOptionPane.CANCEL_OPTION)
- {
- return true;
- }
- else if (option == JvOptionPane.YES_OPTION)
- {
- view.useAlignmentPanelForSuperposition(apanel);
- view.addStructure(pdbentry, seq, chains, true, apanel.alignFrame);
- return true;
- }
- else
- {
- // NO_OPTION - offer the next viewer if any
- }
- }
-
/*
- * nothing offered and selected
+ * JAL-1742 exclude view with this structure already mapped (don't offer
+ * to align chain B to chain A of the same structure)
*/
- return false;
+ if (hasPdbId(pdbId))
+ {
+ return false;
+ }
+ AlignmentPanel ap = (AlignmentPanel) apanel; // Implementation error if this
+ // cast fails
+ useAlignmentPanelForSuperposition(ap);
+ addStructure(pdbentry, seq, chains, ap.alignFrame);
+ return true;
}
/**
* @param apanel
* @param pdbFilename
*/
- protected void addSequenceMappingsToStructure(SequenceI[] seq,
- String[] chains, final AlignmentPanel apanel, String pdbFilename)
+ public void addSequenceMappingsToStructure(SequenceI[] seq,
+ String[] chains, final AlignmentViewPanel alpanel,
+ String pdbFilename)
{
+ AlignmentPanel apanel = (AlignmentPanel) alpanel;
+
// TODO : Fix multiple seq to one chain issue here.
/*
* create the mappings
* @param pdbId
* @return true if the user chooses to add to a viewer, or to cancel entirely
*/
- protected boolean addAlreadyLoadedFile(SequenceI[] seq, String[] chains,
- final AlignmentPanel apanel, String pdbId)
+ @Override
+ public boolean addAlreadyLoadedFile(SequenceI[] seq, String[] chains,
+ final AlignmentViewPanel apanel, String pdbId)
{
boolean finished = false;
String alreadyMapped = apanel.getStructureSelectionManager()
/*
* the PDB file is already loaded
*/
- int option = JvOptionPane.showInternalConfirmDialog(Desktop.desktop,
- MessageManager.formatMessage(
- "label.pdb_entry_is_already_displayed", new Object[]
- { pdbId }),
- MessageManager.formatMessage(
- "label.map_sequences_to_visible_window", new Object[]
- { pdbId }),
- JvOptionPane.YES_NO_CANCEL_OPTION);
- if (option == JvOptionPane.CANCEL_OPTION)
- {
- finished = true;
- }
- else if (option == JvOptionPane.YES_OPTION)
- {
- addSequenceMappingsToStructure(seq, chains, apanel, alreadyMapped);
- finished = true;
- }
+ addSequenceMappingsToStructure(seq, chains, apanel, alreadyMapped);
+ finished = true;
}
return finished;
}
/**
* Configures the title and menu items of the viewer panel.
*/
+ @Override
public void updateTitleAndMenus()
{
AAStructureBindingModel binding = getBinding();
}
@Override
+ public String toString()
+ {
+ return getTitle();
+ }
+
+ @Override
public boolean hasMapping()
{
if (worker != null && (addingStructures || _started))