Skip to content

Package: SWTDiffMergeAdditionTester

SWTDiffMergeAdditionTester

nameinstructionbranchcomplexitylinemethod
SWTDiffMergeAdditionTester()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
isApplicable(VElement, ViewModelContext)
M: 56 C: 0
0%
M: 8 C: 0
0%
M: 5 C: 0
0%
M: 16 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2014 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 - initial API and implementation
13: ******************************************************************************/
14: package org.eclipse.emf.ecp.diffmerge.internal.renderer.swt;
15:
16: import org.eclipse.core.databinding.property.value.IValueProperty;
17: import org.eclipse.emf.ecore.EStructuralFeature;
18: import org.eclipse.emf.ecp.diffmerge.spi.context.DiffMergeModelContext;
19: import org.eclipse.emf.ecp.view.spi.context.ViewModelContext;
20: import org.eclipse.emf.ecp.view.spi.model.VControl;
21: import org.eclipse.emf.ecp.view.spi.model.VElement;
22: import org.eclipse.emf.ecp.view.spi.swt.ECPAdditionalRendererTester;
23: import org.eclipse.emfforms.spi.common.report.ReportService;
24: import org.eclipse.emfforms.spi.core.services.databinding.DatabindingFailedException;
25: import org.eclipse.emfforms.spi.core.services.databinding.DatabindingFailedReport;
26: import org.eclipse.emfforms.spi.core.services.databinding.EMFFormsDatabinding;
27:
28: /**
29: * The tester for {@link SWTDiffMergeAddition}.
30: *
31: * @author Eugen Neufeld
32: *
33: */
34: public class SWTDiffMergeAdditionTester implements ECPAdditionalRendererTester {
35:
36:         /**
37:          * {@inheritDoc}
38:          *
39:          * @see org.eclipse.emf.ecp.view.spi.swt.ECPAdditionalRendererTester#isApplicable(org.eclipse.emf.ecp.view.spi.model.VElement,
40:          * org.eclipse.emf.ecp.view.spi.context.ViewModelContext)
41:          */
42:         @Override
43:         public boolean isApplicable(VElement vElement, ViewModelContext viewModelContext) {
44:•                if (!DiffMergeModelContext.class.isInstance(viewModelContext)) {
45:                         return false;
46:                 }
47:•                if (!VControl.class.isInstance(vElement)) {
48:                         return false;
49:                 }
50:                 final VControl control = (VControl) vElement;
51:                 @SuppressWarnings("rawtypes")
52:                 IValueProperty valueProperty;
53:                 try {
54:                         valueProperty = viewModelContext.getService(EMFFormsDatabinding.class)
55:                                 .getValueProperty(control.getDomainModelReference(), viewModelContext.getDomainModel());
56:                 } catch (final DatabindingFailedException ex) {
57:                         viewModelContext.getService(ReportService.class).report(new DatabindingFailedReport(ex));
58:                         return false;
59:                 }
60:                 final EStructuralFeature feature = (EStructuralFeature) valueProperty.getValueType();
61:•                if (!feature.isChangeable()) {
62:                         return false;
63:                 }
64:•                if (!((DiffMergeModelContext) viewModelContext).hasDiff(control)) {
65:                         return false;
66:                 }
67:                 return true;
68:         }
69:
70: }