Skip to content

Package: GridAction

GridAction

nameinstructionbranchcomplexitylinemethod
GridAction(GridTableViewerComposite, String)
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
GridAction(GridTableViewerComposite, String, int)
M: 0 C: 8
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
getGrid()
M: 0 C: 5
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getGridTableViewer()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
isEnabled()
M: 2 C: 5
71%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 0 C: 1
100%
M: 0 C: 1
100%

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: * Christian W. Damus - bug 534829
14: ******************************************************************************/
15: package org.eclipse.emf.ecp.view.spi.table.nebula.grid.menu;
16:
17: import org.eclipse.emf.ecp.view.spi.table.nebula.grid.GridTableViewerComposite;
18: import org.eclipse.emfforms.spi.swt.table.AbstractTableViewerComposite;
19: import org.eclipse.jface.action.Action;
20: import org.eclipse.nebula.jface.gridviewer.GridTableViewer;
21: import org.eclipse.nebula.widgets.grid.Grid;
22:
23: /**
24: * Helper class for Nebula Grid context menu actions.
25: *
26: * @author Mat Hansen <mhansen@eclipsesource.com>
27: *
28: */
29: class GridAction extends Action {
30:
31:         private final GridTableViewerComposite gridTableViewerComposite;
32:
33:         /**
34:          * The constructor.
35:          *
36:          * @param gridTableViewerComposite the {@link GridTableViewerComposite}
37:          * @param actionLabel the label text for the menu action
38:          *
39:          */
40:         GridAction(GridTableViewerComposite gridTableViewerComposite, String actionLabel) {
41:                 this(gridTableViewerComposite, actionLabel, AS_PUSH_BUTTON);
42:         }
43:
44:         /**
45:          * Initializes me with my grid composite, label, and style.
46:          *
47:          * @param gridTableViewerComposite the {@link GridTableViewerComposite}
48:          * @param actionLabel the label text for the menu action
49:          * @param style my presentation style
50:          *
51:          */
52:         GridAction(GridTableViewerComposite gridTableViewerComposite, String actionLabel, int style) {
53:                 super(actionLabel, style);
54:
55:                 this.gridTableViewerComposite = gridTableViewerComposite;
56:         }
57:
58:         /**
59:          * Returns the current grid instance.
60:          *
61:          * @return the {@link Grid}
62:          */
63:         public Grid getGrid() {
64:                 return gridTableViewerComposite.getTableViewer().getGrid();
65:         }
66:
67:         /**
68:          * Returns the table viewer instance.
69:          *
70:          * @return the table viewer
71:          */
72:         public AbstractTableViewerComposite<GridTableViewer> getGridTableViewer() {
73:                 return gridTableViewerComposite;
74:         }
75:
76:         @Override
77:         public boolean isEnabled() {
78:•                return getGrid() != null;
79:         }
80:
81: }