Project

General

Profile

Download (2.81 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2018 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix;
10

    
11
import org.eclipse.nebula.widgets.nattable.copy.InternalCellClipboard;
12
import org.eclipse.nebula.widgets.nattable.copy.action.ClearClipboardAction;
13
import org.eclipse.nebula.widgets.nattable.copy.action.PasteDataAction;
14
import org.eclipse.nebula.widgets.nattable.copy.action.PasteOrMoveSelectionAction;
15
import org.eclipse.nebula.widgets.nattable.edit.action.DeleteSelectionAction;
16
import org.eclipse.nebula.widgets.nattable.edit.config.DefaultEditBindings;
17
import org.eclipse.nebula.widgets.nattable.selection.SelectionLayer;
18
import org.eclipse.nebula.widgets.nattable.ui.binding.UiBindingRegistry;
19
import org.eclipse.nebula.widgets.nattable.ui.matcher.KeyEventMatcher;
20
import org.eclipse.swt.SWT;
21

    
22
/**
23
 * @author pplitzner
24
 * @since Dec 20, 2018
25
 *
26
 */
27
public class CopyPasteEditBindings extends DefaultEditBindings {
28

    
29
    private SelectionLayer selectionLayer;
30

    
31
    private InternalCellClipboard clipboard;
32

    
33
    public CopyPasteEditBindings(SelectionLayer selectionLayer, InternalCellClipboard clipboard) {
34
        this.selectionLayer = selectionLayer;
35
        this.clipboard = clipboard;
36
    }
37

    
38
    @Override
39
    public void configureUiBindings(UiBindingRegistry uiBindingRegistry) {
40
        super.configureUiBindings(uiBindingRegistry);
41
        // ui binding for deleting a cell value on pressing DEL
42
        uiBindingRegistry.registerFirstKeyBinding(
43
                new KeyEventMatcher(SWT.DEL),
44
                new DeleteSelectionAction());
45

    
46
        // ui binding to perform a paste action on pressing CTRL+V
47
        uiBindingRegistry.registerFirstKeyBinding(
48
                new KeyEventMatcher(SWT.MOD1, 'v'),
49
                new PasteDataAction());
50

    
51
        // ui binding to perform paste or selection movement on ENTER
52
        uiBindingRegistry.registerFirstKeyBinding(
53
                new KeyEventMatcher(SWT.NONE, SWT.CR),
54
                new PasteOrMoveSelectionAction(this.clipboard));
55

    
56
        // ui binding to clear the InternalCellClipboard
57
        uiBindingRegistry.registerFirstKeyBinding(
58
                new KeyEventMatcher(SWT.NONE, SWT.ESC),
59
                new ClearClipboardAction(this.clipboard));
60

    
61
        // Mouse drag
62
        // trigger the handle drag operations
63
        // Note: we ensure a FillHandleLayerPainter is set in configureLayer
64
//        uiBindingRegistry.registerFirstMouseDragMode(
65
//                new FillHandleEventMatcher((FillHandleLayerPainter) this.selectionLayer.getLayerPainter()),
66
//                new FormulaFillHandleDragMode(this.selectionLayer, this.clipboard, this.dataProvider));
67
    }
68
}
(13-13/20)