Revision 14bbe452
Added by Ben Stöver over 8 years ago
eu.etaxonomy.taxeditor.molecular/src/main/java/eu/etaxonomy/taxeditor/molecular/handler/AlignmentEditorCopyHandler.java | ||
---|---|---|
5 | 5 |
|
6 | 6 |
import info.bioinfweb.libralign.alignmentarea.AlignmentArea; |
7 | 7 |
import info.bioinfweb.libralign.alignmentarea.selection.SelectionModel; |
8 |
import info.bioinfweb.libralign.model.AlignmentModel; |
|
9 |
import info.bioinfweb.libralign.model.tokenset.AbstractTokenSet; |
|
8 |
import info.bioinfweb.libralign.model.AlignmentModelUtils; |
|
10 | 9 |
|
11 | 10 |
import org.eclipse.core.commands.ExecutionEvent; |
12 | 11 |
import org.eclipse.swt.dnd.TextTransfer; |
... | ... | |
37 | 36 |
protected void doExecute2(ExecutionEvent event, AlignmentEditor editor, AlignmentArea focusedArea) { |
38 | 37 |
SelectionModel selection = focusedArea.getSelection(); |
39 | 38 |
if (!selection.isEmpty()) { |
40 |
StringBuilder selectedCharacters = new StringBuilder(); |
|
41 |
AlignmentModel<Character> alignmentModel = (AlignmentModel<Character>)focusedArea.getAlignmentModel(); |
|
42 |
for (int row = selection.getFirstRow(); row <= selection.getLastRow(); row++) { |
|
43 |
int id = focusedArea.getSequenceOrder().idByIndex(row); |
|
44 |
for (int column = selection.getFirstColumn(); column <= selection.getLastColumn(); column++) { |
|
45 |
if (alignmentModel.getSequenceLength(id) > column) { |
|
46 |
selectedCharacters.append(alignmentModel.getTokenAt(id, column)); |
|
47 |
} |
|
48 |
else { // Add gaps if selection is behind the end of the sequence. |
|
49 |
selectedCharacters.append(AbstractTokenSet.DEFAULT_GAP_REPRESENTATION); |
|
50 |
} |
|
51 |
} |
|
52 |
if (row < selection.getLastRow()) { |
|
53 |
selectedCharacters.append(System.getProperty("line.separator")); |
|
54 |
} |
|
55 |
} |
|
56 |
editor.CLIPBOARD.setContents(new Object[]{selectedCharacters.toString()}, |
|
39 |
editor.CLIPBOARD.setContents(new Object[]{AlignmentModelUtils.selectionAsString(focusedArea, false)}, |
|
57 | 40 |
new Transfer[]{TextTransfer.getInstance()}); |
58 | 41 |
} |
59 | 42 |
} |
Also available in: Unified diff
Shared functionality moved from AlignmentEditorCopyHandler to AlignmentModelUtils in LibrAlign.