Revision 4e400041
Added by Ben Stöver over 8 years ago
eu.etaxonomy.taxeditor.molecular/src/main/java/eu/etaxonomy/taxeditor/molecular/handler/AlignmentEditorCopyHandler.java | ||
---|---|---|
9 | 9 |
import info.bioinfweb.libralign.model.tokenset.AbstractTokenSet; |
10 | 10 |
|
11 | 11 |
import org.eclipse.core.commands.ExecutionEvent; |
12 |
import org.eclipse.core.commands.ExecutionException; |
|
13 | 12 |
import org.eclipse.swt.dnd.Clipboard; |
14 | 13 |
import org.eclipse.swt.dnd.TextTransfer; |
15 | 14 |
import org.eclipse.swt.dnd.Transfer; |
... | ... | |
34 | 33 |
* @author Ben Stöver |
35 | 34 |
* @date 25.08.2015 |
36 | 35 |
*/ |
37 |
public class AlignmentEditorCopyHandler extends AbstractAlignmentEditorHandler implements IElementUpdater { |
|
36 |
public class AlignmentEditorCopyHandler extends AbstractFocusedAlignmentAreaHandler implements IElementUpdater { |
|
37 |
@Override |
|
38 | 38 |
@SuppressWarnings("unchecked") |
39 |
public static void copySelectionAsString(AlignmentArea area) {
|
|
40 |
SelectionModel selection = area.getSelection();
|
|
39 |
protected void doExecute2(ExecutionEvent event, AlignmentEditor editor, AlignmentArea focusedArea) {
|
|
40 |
SelectionModel selection = focusedArea.getSelection();
|
|
41 | 41 |
if (!selection.isEmpty()) { |
42 | 42 |
StringBuilder selectedCharacters = new StringBuilder(); |
43 |
AlignmentModel<Character> alignmentModel = (AlignmentModel<Character>)area.getAlignmentModel();
|
|
43 |
AlignmentModel<Character> alignmentModel = (AlignmentModel<Character>)focusedArea.getAlignmentModel();
|
|
44 | 44 |
for (int row = selection.getFirstRow(); row <= selection.getLastRow(); row++) { |
45 |
int id = area.getSequenceOrder().idByIndex(row);
|
|
45 |
int id = focusedArea.getSequenceOrder().idByIndex(row);
|
|
46 | 46 |
for (int column = selection.getFirstColumn(); column <= selection.getLastColumn(); column++) { |
47 | 47 |
if (alignmentModel.getSequenceLength(id) > column) { |
48 | 48 |
selectedCharacters.append(alignmentModel.getTokenAt(id, column)); |
... | ... | |
58 | 58 |
new Clipboard(Display.getCurrent()).setContents(new Object[]{selectedCharacters.toString()}, |
59 | 59 |
new Transfer[]{TextTransfer.getInstance()}); |
60 | 60 |
} |
61 |
} |
|
62 |
|
|
63 |
|
|
64 |
@Override |
|
65 |
public void doExecute(ExecutionEvent event, AlignmentEditor editor) throws ExecutionException { |
|
66 |
AlignmentArea focusedArea = editor.getFocusedArea(); |
|
67 |
if (focusedArea != null) { |
|
68 |
copySelectionAsString(focusedArea); |
|
69 |
} |
|
70 | 61 |
} |
71 | 62 |
|
72 | 63 |
|
Also available in: Unified diff
AbstractFocusedAlignmentAreaHandler added.