Skip to content

Package: GridColumnAction

GridColumnAction

nameinstructionbranchcomplexitylinemethod
GridColumnAction(GridTableViewerComposite, String)
M: 5 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
isEnabled()
M: 35 C: 0
0%
M: 6 C: 0
0%
M: 4 C: 0
0%
M: 9 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /**
2: * Copyright (c) 2011-2019 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: * Mat Hansen - initial API and implementation
13: ******************************************************************************/
14: package org.eclipse.emf.ecp.view.spi.table.nebula.grid.rap.menu;
15:
16: import org.eclipse.emf.ecp.view.spi.table.nebula.grid.rap.GridTableViewerComposite;
17: import org.eclipse.emfforms.spi.swt.table.ColumnConfiguration;
18: import org.eclipse.nebula.widgets.grid.GridColumn;
19: import org.eclipse.swt.graphics.Point;
20: import org.eclipse.swt.widgets.Display;
21:
22: /**
23: * Helper class for Nebula Grid column-based context menu actions.
24: *
25: * @author Mat Hansen <mhansen@eclipsesource.com>
26: *
27: */
28: public class GridColumnAction extends GridAction {
29:
30:         /**
31:          * The constructor.
32:          *
33:          * @param gridTableViewerComposite the {@link GridTableViewerComposite}
34:          * @param actionLabel the label text for the menu action
35:          *
36:          */
37:         public GridColumnAction(GridTableViewerComposite gridTableViewerComposite, String actionLabel) {
38:                 super(gridTableViewerComposite, actionLabel);
39:         }
40:
41:         @Override
42:         public boolean isEnabled() {
43:•                if (!super.isEnabled()) {
44:                         return false;
45:                 }
46:
47:                 final Display currentDisplay = getGrid().getDisplay();
48:                 final Point cursorLocation = currentDisplay.getCursorLocation();
49:                 final GridColumn column = getGrid().getColumn(getGrid().toControl(cursorLocation));
50:
51:•                if (column == null) {
52:                         return false;
53:                 }
54:                 final ColumnConfiguration columnConfig = getGridTableViewer().getColumnConfiguration(column);
55:
56:•                return columnConfig != null;
57:         }
58:
59: }