Skip to content

Package: DataTemplateEClassSelectionStrategyProvider

DataTemplateEClassSelectionStrategyProvider

nameinstructionbranchcomplexitylinemethod
DataTemplateEClassSelectionStrategyProvider()
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%
bid(EReference)
M: 0 C: 9
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
create()
M: 0 C: 5
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
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: * Eugen Neufeld - initial API and implementation
13: ******************************************************************************/
14: package org.eclipse.emfforms.internal.datatemplate.tooling.editor;
15:
16: import java.util.Collection;
17:
18: import org.eclipse.emf.ecore.EClass;
19: import org.eclipse.emf.ecore.EObject;
20: import org.eclipse.emf.ecore.EReference;
21: import org.eclipse.emf.ecp.common.spi.EMFUtils;
22: import org.eclipse.emf.ecp.ui.view.swt.reference.EClassSelectionStrategy;
23: import org.eclipse.emfforms.bazaar.Bid;
24: import org.eclipse.emfforms.bazaar.Create;
25: import org.eclipse.emfforms.datatemplate.DataTemplatePackage;
26: import org.osgi.service.component.annotations.Component;
27:
28: /**
29: * An {@link org.eclipse.emf.ecp.ui.view.swt.reference.EClassSelectionStrategy.Provider
30: * EClassSelectionStrategy.Provider} for
31: * DataTemplate EClass Selection.
32: *
33: * @author Eugen Neufeld
34: *
35: */
36: @Component
37: public class DataTemplateEClassSelectionStrategyProvider implements EClassSelectionStrategy.Provider {
38:
39:         /**
40:          * This is the {@link Bid} for the EClassSelectionStrategy.
41:          *
42:          * @param eReference The {@link EReference} to check
43:          * @return 10 if the reference is the Template_Instance, null otherwise
44:          * @see Bid
45:          */
46:         @Bid
47:         public Double bid(EReference eReference) {
48:•                if (DataTemplatePackage.eINSTANCE.getTemplate_Instance() == eReference) {
49:                         return 10d;
50:                 }
51:                 return null;
52:         }
53:
54:         /**
55:          * This actually creates the EClassSelectionStrategy.
56:          *
57:          * @return The {@link EClassSelectionStrategy}
58:          */
59:         @Create
60:         public EClassSelectionStrategy create() {
61:                 return new EClassSelectionStrategy() {
62:
63:                         @Override
64:                         public Collection<EClass> collectEClasses(EObject owner, EReference reference,
65:                                 Collection<EClass> eclasses) {
66:                                 return EMFUtils.getSubClasses(reference.getEReferenceType());
67:                         }
68:                 };
69:         }
70: }