Skip to content

Package: NumberCellEditorTester

NumberCellEditorTester

nameinstructionbranchcomplexitylinemethod
NumberCellEditorTester()
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%
isApplicable(EObject, EStructuralFeature, ViewModelContext)
M: 8 C: 49
86%
M: 4 C: 16
80%
M: 4 C: 7
64%
M: 4 C: 14
78%
M: 0 C: 1
100%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2013 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: * Eugen Neufeld - initial API and implementation
13: *******************************************************************************/
14: package org.eclipse.emf.ecp.edit.internal.swt.table;
15:
16: import org.eclipse.emf.ecore.EAttribute;
17: import org.eclipse.emf.ecore.EObject;
18: import org.eclipse.emf.ecore.EStructuralFeature;
19: import org.eclipse.emf.ecp.edit.spi.swt.table.ECPCellEditorTester;
20: import org.eclipse.emf.ecp.view.spi.context.ViewModelContext;
21:
22: /**
23: * Tester for number cell editor.
24: *
25: * @author Eugen Neufeld
26: *
27: */
28: public class NumberCellEditorTester implements ECPCellEditorTester {
29:
30:         /**
31:          * {@inheritDoc}
32:          *
33:          * @see ECPCellEditorTester#isApplicable(EObject, EStructuralFeature,
34:          * org.eclipse.emf.ecp.view.spi.context.ViewModelContext)
35:          */
36:         @Override
37:         public int isApplicable(EObject eObject, EStructuralFeature feature, ViewModelContext viewModelContext) {
38:•                if (EAttribute.class.isInstance(feature) && !feature.isMany()) {
39:                         final Class<?> instanceClass = ((EAttribute) feature).getEAttributeType().getInstanceClass();
40:•                        if (instanceClass == null) {
41:                                 return NOT_APPLICABLE;
42:                         }
43:•                        if (Number.class.isAssignableFrom(instanceClass)) {
44:                                 return 1;
45:                         }
46:
47:                         // if the attribute class is an primitive test the primitive types
48:•                        if (instanceClass.isPrimitive()) {
49:•                                if (int.class.equals(instanceClass)) {
50:                                         return 1;
51:•                                } else if (float.class.equals(instanceClass)) {
52:                                         return 1;
53:•                                } else if (long.class.equals(instanceClass)) {
54:                                         return 1;
55:•                                } else if (double.class.equals(instanceClass)) {
56:                                         return 1;
57:•                                } else if (short.class.equals(instanceClass)) {
58:                                         return 1;
59:                                 }
60:                         }
61:
62:                 }
63:                 return NOT_APPLICABLE;
64:         }
65:
66: }