import info.bioinfweb.libralign.alignmentarea.AlignmentArea;
import info.bioinfweb.libralign.alignmentarea.selection.SelectionModel;
-import info.bioinfweb.libralign.model.AlignmentModel;
-import info.bioinfweb.libralign.model.tokenset.AbstractTokenSet;
+import info.bioinfweb.libralign.model.AlignmentModelUtils;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.swt.dnd.TextTransfer;
protected void doExecute2(ExecutionEvent event, AlignmentEditor editor, AlignmentArea focusedArea) {
SelectionModel selection = focusedArea.getSelection();
if (!selection.isEmpty()) {
- StringBuilder selectedCharacters = new StringBuilder();
- AlignmentModel<Character> alignmentModel = (AlignmentModel<Character>)focusedArea.getAlignmentModel();
- for (int row = selection.getFirstRow(); row <= selection.getLastRow(); row++) {
- int id = focusedArea.getSequenceOrder().idByIndex(row);
- for (int column = selection.getFirstColumn(); column <= selection.getLastColumn(); column++) {
- if (alignmentModel.getSequenceLength(id) > column) {
- selectedCharacters.append(alignmentModel.getTokenAt(id, column));
- }
- else { // Add gaps if selection is behind the end of the sequence.
- selectedCharacters.append(AbstractTokenSet.DEFAULT_GAP_REPRESENTATION);
- }
- }
- if (row < selection.getLastRow()) {
- selectedCharacters.append(System.getProperty("line.separator"));
- }
- }
- editor.CLIPBOARD.setContents(new Object[]{selectedCharacters.toString()},
+ editor.CLIPBOARD.setContents(new Object[]{AlignmentModelUtils.selectionAsString(focusedArea, false)},
new Transfer[]{TextTransfer.getInstance()});
}
}