Skip to content

Package: BooleanCellEditorTester

BooleanCellEditorTester

nameinstructionbranchcomplexitylinemethod
BooleanCellEditorTester()
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: 18 C: 33
65%
M: 4 C: 6
60%
M: 4 C: 2
33%
M: 11 C: 9
45%
M: 0 C: 1
100%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2015 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: * jfaltermeier - initial API and implementation
13: ******************************************************************************/
14: package org.eclipse.emf.ecp.view.internal.table.celleditor.rcp;
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 {@link BooleanCellEditor}.
24: *
25: * @author jfaltermeier
26: *
27: */
28: public class BooleanCellEditorTester implements ECPCellEditorTester {
29:
30:         /**
31:          * {@inheritDoc}
32:          *
33:          * @see ECPCellEditorTester#isApplicable(EObject, EStructuralFeature, ViewModelContext)
34:          */
35:         @Override
36:         public int isApplicable(EObject eObject, EStructuralFeature feature, ViewModelContext viewModelContext) {
37:•                if (EAttribute.class.isInstance(feature)) {
38:                         final Class<?> instanceClass = ((EAttribute) feature).getEAttributeType().getInstanceClass();
39:•                        if (instanceClass == null) {
40:                                 return NOT_APPLICABLE;
41:                         }
42:•                        if (Boolean.class.isAssignableFrom(instanceClass)) {
43:                                 return 3;
44:                         }
45:•                        if (instanceClass.isPrimitive()) {
46:                                 try {
47:                                         final Class<?> primitive = (Class<?>) Boolean.class.getField("TYPE").get(null); //$NON-NLS-1$
48:•                                        if (primitive.equals(instanceClass)) {
49:                                                 return 3;
50:                                         }
51:                                         return NOT_APPLICABLE;
52:                                 } catch (final IllegalArgumentException e) {
53:                                         return NOT_APPLICABLE;
54:                                 } catch (final SecurityException e) {
55:                                         return NOT_APPLICABLE;
56:                                 } catch (final IllegalAccessException e) {
57:                                         return NOT_APPLICABLE;
58:                                 } catch (final NoSuchFieldException e) {
59:                                         return NOT_APPLICABLE;
60:                                 }
61:                         }
62:
63:                 }
64:                 return NOT_APPLICABLE;
65:         }
66: }