Skip to content

Package: TableRendererAction

TableRendererAction

nameinstructionbranchcomplexitylinemethod
TableRendererAction(TableRendererViewerActionContext)
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
getActionContext()
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getVTableControl()
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
isTableDisabled()
M: 0 C: 10
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 1
100%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2018 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.swt.action;
15:
16: import org.eclipse.emf.ecp.view.spi.table.model.VTableControl;
17: import org.eclipse.emfforms.spi.swt.table.action.AbstractTableAction;
18: import org.eclipse.emfforms.spi.swt.table.action.ViewerActionContext;
19: import org.eclipse.jface.viewers.AbstractTableViewer;
20:
21: /**
22: * Common base class for table renderer actions.
23: *
24: * @author Mat Hansen <mhansen@eclipsesource.com>
25: * @since 1.18
26: *
27: */
28: public abstract class TableRendererAction extends AbstractTableAction<AbstractTableViewer> {
29:
30:         /**
31:          * The constructor.
32:          *
33:          * @param actionContext the {@link ViewerActionContext}
34:          */
35:         public TableRendererAction(TableRendererViewerActionContext actionContext) {
36:                 super(actionContext);
37:         }
38:
39:         /**
40:          * Returns true when the table is disabled.
41:          *
42:          * Note: EMF Forms distinguishes between read-only and enabled.
43:          * Read-only is a declarative state defined by the view model and cannot
44:          * be overwritten during runtime whereas the enabled state can.
45:          * Therefore we only have to check for the enabled state here.
46:          *
47:          * @return true when the table is disabled, false otherwise
48:          */
49:         @Override
50:         protected boolean isTableDisabled() {
51:                 final VTableControl vTableControl = getVTableControl();
52:•                return !vTableControl.isEffectivelyEnabled();
53:         }
54:
55:         @Override
56:         public TableRendererViewerActionContext getActionContext() {
57:                 return TableRendererViewerActionContext.class.cast(super.getActionContext());
58:         }
59:
60:         /**
61:          * Returns the table control VElement.
62:          *
63:          * @return the {@link VTableControl}
64:          */
65:         protected VTableControl getVTableControl() {
66:                 return VTableControl.class.cast(getActionContext().getVElement());
67:         }
68:
69: }