Skip to content

Package: ECPEnumCellEditor

ECPEnumCellEditor

nameinstructionbranchcomplexitylinemethod
ECPEnumCellEditor(Composite)
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%
ECPEnumCellEditor(Composite, int)
M: 0 C: 5
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
getELiterals()
M: 3 C: 32
91%
M: 3 C: 3
50%
M: 2 C: 2
50%
M: 0 C: 9
100%
M: 0 C: 1
100%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2017 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: * Edgar Mueller - initial API and implementation
13: *******************************************************************************/
14: package org.eclipse.emf.ecp.edit.spi.swt.table;
15:
16: import java.util.ArrayList;
17: import java.util.List;
18:
19: import org.eclipse.emf.common.util.EList;
20: import org.eclipse.emf.ecore.EEnum;
21: import org.eclipse.emf.ecore.EEnumLiteral;
22: import org.eclipse.emf.ecore.util.EcoreUtil;
23: import org.eclipse.emf.ecp.view.spi.model.VViewPackage;
24: import org.eclipse.jface.viewers.CellEditor;
25: import org.eclipse.swt.widgets.Composite;
26:
27: /**
28: * Common base class for combo-based enum cell editors.
29: *
30: * @since 1.13
31: */
32: public abstract class ECPEnumCellEditor extends CellEditor implements ECPCellEditor {
33:
34:         /**
35:          * Constructor.
36:          *
37:          * @param parent the parent {@link Composite}
38:          */
39:         public ECPEnumCellEditor(Composite parent) {
40:                 super(parent);
41:         }
42:
43:         /**
44:          * Constructor.
45:          *
46:          * @param parent the parent {@link Composite}
47:          * @param style SWT style bits
48:          */
49:         public ECPEnumCellEditor(Composite parent, int style) {
50:                 super(parent, style);
51:         }
52:
53:         /**
54:          * Returns the {@link EEnum} is cell editor responsible for.
55:          *
56:          * @return the enum
57:          */
58:         public abstract EEnum getEEnum();
59:
60:         /**
61:          * Returns the list of literals of the enum.
62:          *
63:          * @return a list of literals
64:          *
65:          * @see #getEEnum
66:          */
67:         public List<EEnumLiteral> getELiterals() {
68:                 final List<EEnumLiteral> filtered = new ArrayList<EEnumLiteral>();
69:                 final EList<EEnumLiteral> eLiterals = getEEnum().getELiterals();
70:•                for (final EEnumLiteral literal : eLiterals) {
71:
72:                         final String isInputtable = EcoreUtil.getAnnotation(literal,
73:                                 VViewPackage.NS_URI_170,
74:                                 "isInputtable"); //$NON-NLS-1$
75:
76:•                        if (isInputtable == null || Boolean.getBoolean(isInputtable)) {
77:                                 filtered.add(literal);
78:                         }
79:                 }
80:                 return filtered;
81:         }
82: }