Project

General

Profile

Download (1.88 KB) Statistics
| Branch: | Tag: | Revision:
1
package eu.etaxonomy.taxeditor.molecular.editor.e4.handler;
2

    
3

    
4
import javax.inject.Named;
5

    
6
import org.eclipse.e4.core.di.annotations.CanExecute;
7
import org.eclipse.e4.core.di.annotations.Execute;
8
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
9
import org.eclipse.e4.ui.services.IServiceConstants;
10

    
11
import eu.etaxonomy.taxeditor.molecular.editor.e4.AlignmentEditorE4;
12
import info.bioinfweb.libralign.alignmentarea.AlignmentArea;
13

    
14

    
15

    
16
/**
17
 * Handler that cuts the currently selected nucleotides from an alignment editor to the clipboard.
18
 * <p>
19
 * The cut contents either come from the single reads or the consensus sequence alignment area,
20
 * depending on which component currently has the focus. If none of these components has the focus,
21
 * nothing will be cut, even if nucleotides are currently selected.
22
 * <p>
23
 * If the selection contains parts of multiple sequence, these are separated by the line separator
24
 * of the current operating system.
25
 *
26
 * @author Ben Stöver
27
 * @date 25.08.2015
28
 */
29
public class AlignmentEditorCutHandlerE4 extends AlignmentEditorCopyHandlerE4 {
30

    
31
    @Override
32
    @Execute
33
    protected void doExecute2(@Named(IServiceConstants.ACTIVE_PART)MPart activePart) {
34
        super.doExecute2(activePart);  // Copy selected contents.
35
        AlignmentEditorE4 editor = (AlignmentEditorE4) activePart.getObject();
36
        AlignmentArea focusedArea = editor.getFocusedArea();
37
        focusedArea.getActionProvider().deleteSelection();
38
    }
39

    
40

    
41
    @Override
42
    @CanExecute
43
    public boolean isEnabled(@Named(IServiceConstants.ACTIVE_PART)MPart activePart) {
44
        AlignmentEditorE4 editor = (AlignmentEditorE4) activePart.getObject();
45
        if (editor != null) {
46
            AlignmentArea focusedArea = editor.getFocusedArea();
47
            if (focusedArea != null) {
48
                return !focusedArea.getSelection().isEmpty();
49
            }
50
        }
51
        return false;
52
    }
53

    
54
}
(2-2/17)