+ * @param al
+ * @param title
+ */
+ protected boolean openLinkedAlignment(AlignmentI al, String title)
+ {
+ String[] options = new String[] {
+ MessageManager.getString("action.no"),
+ MessageManager.getString("label.split_window"),
+ MessageManager.getString("label.new_window"), };
+ final String question = JvSwingUtils.wrapTooltip(true,
+ MessageManager.getString("label.open_split_window?"));
+ int response = JvOptionPane.showOptionDialog(Desktop.desktop, question,
+ MessageManager.getString("label.open_split_window"),
+ JvOptionPane.DEFAULT_OPTION, JvOptionPane.PLAIN_MESSAGE, null,
+ options, options[0]);
+
+ if (response != 1 && response != 2)
+ {
+ return false;
+ }
+ final boolean openSplitPane = (response == 1);
+ final boolean openInNewWindow = (response == 2);
+
+ /*
+ * 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();
+ AlignmentI protein = al.isNucleotide() ? thisAlignment : al;
+ final AlignmentI cdna = al.isNucleotide() ? al : thisAlignment;
+
+ /*
+ * Map sequences. At least one should get mapped as we have already passed
+ * the test for 'mappability'. Any mappings made will be added to the
+ * protein alignment. Note creating dataset sequences on the new alignment
+ * is a pre-requisite for building mappings.
+ */
+ al.setDataset(null);
+ AlignmentUtils.mapProteinAlignmentToCdna(protein, cdna);
+
+ /*
+ * Create the AlignFrame for the added alignment. If it is protein, mappings
+ * are registered with StructureSelectionManager as a side-effect.
+ */
+ AlignFrame newAlignFrame = new AlignFrame(al, AlignFrame.DEFAULT_WIDTH,
+ AlignFrame.DEFAULT_HEIGHT);
+ newAlignFrame.setTitle(title);
+ newAlignFrame.statusBar.setText(MessageManager.formatMessage(
+ "label.successfully_loaded_file", new Object[] { title }));
+
+ // TODO if we want this (e.g. to enable reload of the alignment from file),
+ // we will need to add parameters to the stack.
+ // if (!protocol.equals(DataSourceType.PASTE))
+ // {
+ // alignFrame.setFileName(file, format);
+ // }
+
+ if (openInNewWindow)
+ {
+ Desktop.addInternalFrame(newAlignFrame, title,
+ AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT);
+ }