1 package eu
.etaxonomy
.taxeditor
.molecular
.handler
;
4 import info
.bioinfweb
.libralign
.alignmentarea
.AlignmentArea
;
5 import info
.bioinfweb
.libralign
.alignmentarea
.selection
.SelectionModel
;
6 import info
.bioinfweb
.libralign
.model
.utils
.AlignmentModelUtils
;
10 import org
.eclipse
.core
.commands
.ExecutionEvent
;
11 import org
.eclipse
.swt
.dnd
.TextTransfer
;
12 import org
.eclipse
.swt
.dnd
.Transfer
;
13 import org
.eclipse
.ui
.commands
.IElementUpdater
;
14 import org
.eclipse
.ui
.menus
.UIElement
;
16 import eu
.etaxonomy
.taxeditor
.molecular
.editor
.AlignmentEditor
;
21 * Handler that copies the currently selected nucleotides from an alignment editor to the clipboard.
23 * The copied contents either come from the single reads or the consensus sequence alignment area,
24 * depending on which component currently has the focus. If none of these components has the focus,
25 * nothing will be copied, even if nucleotides are currently selected.
27 * If the selection contains parts of multiple sequence, these are separated by the line separator
28 * of the current operating system.
33 public class AlignmentEditorCopyHandler
extends AbstractFocusedAlignmentAreaHandler
implements IElementUpdater
{
35 @SuppressWarnings("unchecked")
36 protected void doExecute2(ExecutionEvent event
, AlignmentEditor editor
, AlignmentArea focusedArea
) {
37 SelectionModel selection
= focusedArea
.getSelection();
38 if (!selection
.isEmpty()) {
39 editor
.CLIPBOARD
.setContents(new Object
[]{AlignmentModelUtils
.selectionAsString(focusedArea
, false)},
40 new Transfer
[]{TextTransfer
.getInstance()});
46 public boolean isEnabled() {
47 AlignmentEditor editor
= getActiveAlignmentEditor();
49 AlignmentArea focusedArea
= editor
.getFocusedArea();
50 if (focusedArea
!= null) {
51 return !focusedArea
.getSelection().isEmpty();
59 public void updateElement(UIElement element
, @SuppressWarnings("rawtypes") Map parameters
) {
60 setBaseEnabled(isEnabled());