Skip to content

Package: TypedElementBoundsRevealProvider

TypedElementBoundsRevealProvider

nameinstructionbranchcomplexitylinemethod
TypedElementBoundsRevealProvider()
M: 0 C: 23
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 6
100%
M: 0 C: 1
100%
canReveal(VControl, EStructuralFeature)
M: 14 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
lambda$0(TypedElementBoundsRenderer, EStructuralFeature)
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
reveal(TypedElementBoundsRenderer, EObject, EStructuralFeature)
M: 9 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2019 Christian W. Damus 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: * Christian W. Damus - initial API and implementation
13: ******************************************************************************/
14: package org.eclipse.emfforms.internal.editor.ecore.helpers;
15:
16: import static java.util.Arrays.asList;
17:
18: import java.util.HashSet;
19: import java.util.Set;
20:
21: import org.eclipse.emf.ecore.EObject;
22: import org.eclipse.emf.ecore.EStructuralFeature;
23: import org.eclipse.emf.ecore.EcorePackage;
24: import org.eclipse.emf.ecp.view.model.common.di.annotations.Renderer;
25: import org.eclipse.emf.ecp.view.spi.model.VControl;
26: import org.eclipse.emf.ecp.view.spi.model.VViewPackage;
27: import org.eclipse.emfforms.bazaar.Bid;
28: import org.eclipse.emfforms.bazaar.Create;
29: import org.eclipse.emfforms.internal.editor.ecore.controls.TypedElementBoundsRenderer;
30: import org.eclipse.emfforms.spi.core.services.reveal.EMFFormsRevealProvider;
31: import org.eclipse.emfforms.spi.core.services.reveal.RevealStep;
32: import org.osgi.service.component.annotations.Component;
33:
34: /**
35: * Specific reveal provider for the bounds control of typed elements, which accounts
36: * for the fact that this control edits two features, one of which (the lower bound)
37: * is not mapped in the settings mapper service.
38: *
39: * @since 1.22
40: */
41: @Component(name = "typedElementBoundsRevealProvider")
42: public class TypedElementBoundsRevealProvider implements EMFFormsRevealProvider {
43:
44:         private final Set<EStructuralFeature> features = new HashSet<>(asList(
45:                 EcorePackage.Literals.ETYPED_ELEMENT__LOWER_BOUND,
46:                 EcorePackage.Literals.ETYPED_ELEMENT__UPPER_BOUND));
47:
48:         private final Double bid = 20.0;
49:
50:         /**
51:          * Initializes me.
52:          */
53:         public TypedElementBoundsRevealProvider() {
54:                 super();
55:         }
56:
57:         /**
58:          * I can reveal a control that renders the upper or lower bound of an Ecore typed element.
59:          *
60:          * @param control the control
61:          * @param feature the feature to be revealed
62:          * @return my bid
63:          */
64:         @Bid
65:         public Double canReveal(VControl control, EStructuralFeature feature) {
66:•                return control.eClass() == VViewPackage.Literals.CONTROL && features.contains(feature)
67:                         ? bid
68:                         : null;
69:         }
70:
71:         /**
72:          * Reveal the given {@code feature} of an {@code owner} in the bounds {@code renderer}.
73:          *
74:          * @param renderer the bounds renderer
75:          * @param owner the typed element
76:          * @param feature the bounds feature to reveal
77:          * @return the reveal step
78:          */
79:         @Create
80:         public RevealStep reveal(@Renderer TypedElementBoundsRenderer renderer, EObject owner,
81:                 EStructuralFeature feature) {
82:
83:                 return RevealStep.reveal(renderer.getVElement(), owner, feature, () -> renderer.reveal(feature));
84:         }
85:
86: }