import jalview.api.AlignViewportI;
import jalview.bin.Cache;
import jalview.commands.CommandI;
-import jalview.commands.EditCommand;
+import jalview.datamodel.Alignment;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.ColumnSelection;
import jalview.datamodel.PDBEntry;
import java.util.ArrayList;
import java.util.Deque;
import java.util.Hashtable;
-import java.util.List;
import java.util.Set;
import java.util.Vector;
import javax.swing.JInternalFrame;
import javax.swing.JOptionPane;
-import javax.swing.JSplitPane;
/**
* DOCUMENT ME!
boolean showSeqFeaturesHeight;
+ /**
+ * Send the current selection to be broadcast to any selection listeners.
+ */
public void sendSelection()
{
jalview.structure.StructureSelectionManager
*/
@Override
public void mirrorCommand(CommandI command, boolean undo,
- StructureSelectionManager ssm)
+ StructureSelectionManager ssm, VamsasSource source)
{
/*
- * Only EditCommand is currently handled by listeners.
+ * ...work in progress... do nothing unless we are a 'slave' of the source
+ * May replace this with direct calls not via SSM.
*/
- if (!(command instanceof EditCommand))
+ if (source instanceof AlignViewportI
+ && ((AlignViewportI) source).getSlave() == this)
+ {
+ // ok to continue;
+ }
+ else
{
return;
}
- EditCommand edit = (EditCommand) command;
- List<SequenceI> seqs = getAlignment().getSequences();
- EditCommand mappedCommand = ssm.mapEditCommand(edit, undo, seqs,
+ CommandI mappedCommand = ssm.mapCommand(command, undo, getAlignment(),
getGapCharacter());
- AlignmentI[] views = getAlignPanel().alignFrame.getViewAlignments();
- mappedCommand.performEdit(0, views);
- getAlignPanel().alignmentChanged();
+ if (mappedCommand != null)
+ {
+ AlignmentI[] views = getAlignPanel().alignFrame.getViewAlignments();
+ mappedCommand.doCommand(views);
+ getAlignPanel().alignmentChanged();
+ }
}
@Override
/**
* Add the sequences from the given alignment to this viewport. Optionally,
- * may give the user the option to open a new frame or panel linking cDNA and
- * protein.
+ * may give the user the option to open a new frame, or split panel, with cDNA
+ * and protein linked.
*
* @param al
* @param title
/**
* Show a dialog with the option to open and link (cDNA <-> protein) as a new
- * alignment. Returns true if the new alignment was opened, false if not -
- * either because the user declined the offer, or because no mapping could be
- * made.
+ * alignment. Returns true if the new alignment was opened, false if not,
+ * because the user declined the offer.
*
* @param title
*/
MessageManager.getString("label.open_linked_alignment"),
JOptionPane.DEFAULT_OPTION, JOptionPane.PLAIN_MESSAGE, null,
options, options[0]);
- // int reply = JOptionPane.showInternalConfirmDialog(Desktop.desktop,
- // question,
- // MessageManager.getString("label.open_linked_alignment"),
- // JOptionPane.YES_NO_OPTION,
- // JOptionPane.QUESTION_MESSAGE);
if (response != 1 && response != 2)
{
* Create the AlignFrame first (which creates the new alignment's datasets),
* before attempting sequence mapping.
*/
- AlignFrame alignFrame = new AlignFrame(al, AlignFrame.DEFAULT_WIDTH,
+ AlignFrame newAlignFrame = new AlignFrame(al, AlignFrame.DEFAULT_WIDTH,
AlignFrame.DEFAULT_HEIGHT);
- final AlignmentI protein = al.isNucleotide() ? getAlignment() : al;
- final AlignmentI cdna = al.isNucleotide() ? al : getAlignment();
+ /*
+ * Identify protein and dna alignments. Make a copy of this one if opening
+ * in a new split pane.
+ */
+ AlignmentI thisAlignment = openSplitPane ? new Alignment(getAlignment())
+ : getAlignment();
+ final AlignmentI protein = al.isNucleotide() ? thisAlignment : al;
+ final AlignmentI cdna = al.isNucleotide() ? al : thisAlignment;
- alignFrame.statusBar.setText(MessageManager.formatMessage(
+ newAlignFrame.statusBar.setText(MessageManager.formatMessage(
"label.successfully_loaded_file", new Object[]
{ title }));
// {
// alignFrame.setFileName(file, format);
// }
+
if (openInNewWindow)
{
- /*
- * open in new window
- */
- Desktop.addInternalFrame(alignFrame, title, AlignFrame.DEFAULT_WIDTH,
+ Desktop.addInternalFrame(newAlignFrame, title,
+ AlignFrame.DEFAULT_WIDTH,
AlignFrame.DEFAULT_HEIGHT);
}
* Try to find mappings for at least one sequence.
*/
MappingResult mapped = AlignmentUtils.mapProteinToCdna(protein, cdna);
+ final StructureSelectionManager ssm = StructureSelectionManager
+ .getStructureSelectionManager(Desktop.instance);
if (mapped == MappingResult.Mapped)
{
* Register the mappings (held on the protein alignment) with the
* StructureSelectionManager (for mouseover linking).
*/
- final StructureSelectionManager ssm = StructureSelectionManager
- .getStructureSelectionManager(Desktop.instance);
ssm.addMappings(protein.getCodonFrames());
-
- /*
- * Set the cDNA to listen for edits on the protein.
- */
- ssm.addCommandListener(al.isNucleotide() ? alignFrame.getViewport()
- : this);
}
else
{
try
{
- alignFrame.setMaximum(jalview.bin.Cache.getDefault("SHOW_FULLSCREEN",
+ newAlignFrame.setMaximum(jalview.bin.Cache.getDefault(
+ "SHOW_FULLSCREEN",
false));
} catch (java.beans.PropertyVetoException ex)
{
if (openSplitPane)
{
/*
- * Open in split pane. Original sequence above, new one below.
+ * Open in split pane. DNA sequence above, protein below.
*/
- JInternalFrame splitFrame = new JInternalFrame();
- splitFrame.setSize(AlignFrame.DEFAULT_WIDTH,
- AlignFrame.DEFAULT_HEIGHT);
- // TODO not quite right to 'move' AlignPanel from 'this' to the split
- // pane
- // TODO probably want linked editing set up here
- JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
- getAlignPanel(), alignFrame.alignPanel);
- splitPane.setDividerLocation(0.5d);
- splitFrame.setSize(AlignFrame.DEFAULT_WIDTH,
- AlignFrame.DEFAULT_HEIGHT);
- splitFrame.add(splitPane);
+ AlignFrame copyMe = new AlignFrame(thisAlignment,
+ AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT);
+ copyMe.setTitle(""); // TODO would like this AlignFrame.title here
+ final AlignFrame proteinFrame = al.isNucleotide() ? copyMe
+ : newAlignFrame;
+ final AlignFrame cdnaFrame = al.isNucleotide() ? newAlignFrame
+ : copyMe;
+ newAlignFrame.setTitle(title);
+
+ cdnaFrame.setVisible(true);
+ proteinFrame.setVisible(true);
+ JInternalFrame splitFrame = new SplitFrame(cdnaFrame, proteinFrame);
Desktop.addInternalFrame(splitFrame, title, AlignFrame.DEFAULT_WIDTH,
AlignFrame.DEFAULT_HEIGHT);
+
+ /*
+ * Set the cDNA to list for edits on the protein.
+ */
+ ssm.addCommandListener(cdnaFrame.getViewport());
+
+ /*
+ * cDNA is 'slaved' to edits, selection, sorting, show/hide on protein
+ */
+ proteinFrame.getViewport().setSlave(cdnaFrame.getViewport());
}
return true;