Skip to content

Package: GridCutKeyListener

GridCutKeyListener

nameinstructionbranchcomplexitylinemethod
GridCutKeyListener(Display, VControl, EMFFormsDatabindingEMF)
M: 0 C: 10
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
keyPressed(KeyEvent)
M: 15 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
keyReleased(KeyEvent)
M: 17 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 5 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2016 EclipseSource Muenchen GmbH and others.
3: *
4: * All rights reserved. This program and the accompanying materials
5: * are made available under the terms of the Eclipse Public License 2.0
6: * which accompanies this distribution, and is available at
7: * https://www.eclipse.org/legal/epl-2.0/
8: *
9: * SPDX-License-Identifier: EPL-2.0
10: *
11: * Contributors:
12: * Stefan Dirix - initial API and implementation
13: ******************************************************************************/
14: package org.eclipse.emf.ecp.view.internal.table.nebula.grid;
15:
16: import org.eclipse.emf.ecp.view.spi.model.VControl;
17: import org.eclipse.emfforms.spi.core.services.databinding.emf.EMFFormsDatabindingEMF;
18: import org.eclipse.nebula.widgets.grid.Grid;
19: import org.eclipse.swt.SWT;
20: import org.eclipse.swt.events.KeyEvent;
21: import org.eclipse.swt.widgets.Display;
22:
23: /**
24: * @author Stefan Dirix
25: * @since 1.11
26: *
27: */
28: public class GridCutKeyListener extends GridCopyKeyListener {
29:
30:         private final EMFFormsDatabindingEMF dataBinding;
31:         private final VControl vControl;
32:
33:         /**
34:          * Constructor.
35:          *
36:          * @param display the {@link Display} on which to allocate this command's {@link org.eclipse.swt.dnd.Clipboard}.
37:          * @param vControl the {@link VControl}.
38:          * @param dataBinding the {@link EMFFormsDatabindingEMF}.
39:          */
40:         public GridCutKeyListener(Display display, VControl vControl, EMFFormsDatabindingEMF dataBinding) {
41:                 super(display);
42:                 this.vControl = vControl;
43:                 this.dataBinding = dataBinding;
44:         }
45:
46:         @Override
47:         public void keyPressed(KeyEvent e) {
48:•                setTriggerActive((e.stateMask & SWT.CTRL) != 0 && e.keyCode == 'x');
49:         }
50:
51:         @Override
52:         public void keyReleased(KeyEvent e) {
53:•                if (isTriggerActive()) {
54:                         final Grid grid = (Grid) e.widget;
55:                         copySelectionToClipboard(grid);
56:                         KeyListenerUtil.clearSelection(grid, vControl, dataBinding);
57:                 }
58:         }
59:
60: }