Skip to content

Package: EMFFormsSettingToControlMapper

EMFFormsSettingToControlMapper

nameinstructionbranchcomplexitylinemethod
hasMapping(UniqueSetting, VElement)
M: 0 C: 15
100%
M: 1 C: 3
75%
M: 1 C: 2
67%
M: 0 C: 2
100%
M: 0 C: 1
100%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2019 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: * Lucas Koehler - initial API and implementation
13: * Christian W. Damus - bug 527686
14: ******************************************************************************/
15: package org.eclipse.emfforms.spi.core.services.controlmapper;
16:
17: import java.util.Collection;
18: import java.util.Set;
19:
20: import org.eclipse.emf.ecore.EObject;
21: import org.eclipse.emf.ecore.EStructuralFeature.Setting;
22: import org.eclipse.emf.ecp.common.spi.UniqueSetting;
23: import org.eclipse.emf.ecp.view.spi.model.VControl;
24: import org.eclipse.emf.ecp.view.spi.model.VElement;
25:
26: /**
27: * A mapping between {@link UniqueSetting UniqueSettings} and Sets of {@link VControl VControls}.
28: *
29: * @author Lucas Koehler
30: * @since 1.8
31: *
32: */
33: // TODO move to another bundle
34: public interface EMFFormsSettingToControlMapper {
35:
36:         /**
37:          * Returns all controls which are associated with the provided {@link Setting}. The {@link Setting} is converted to
38:          * a {@link UniqueSetting}.
39:          *
40:          * @param setting the {@link Setting} to search controls for
41:          * @return the Set of all controls associated with the provided setting or null if no controls can be found
42:          */
43:         Set<VControl> getControlsFor(Setting setting);
44:
45:         /**
46:          * Returns all controls which are associated with the provided {@link UniqueSetting}.
47:          *
48:          * @param setting the {@link UniqueSetting} to search controls for
49:          * @return the Set of all controls associated with the provided setting or null if no controls can be found
50:          */
51:         Set<VElement> getControlsFor(UniqueSetting setting);
52:
53:         /**
54:          * Updates the setting to control mapping for the given {@link VControl}.
55:          *
56:          * @param vControl The {@link VControl}
57:          */
58:         void updateControlMapping(VControl vControl);
59:
60:         /**
61:          * Removes a {@link VControl} from the setting to control mapping.
62:          *
63:          * @param vControl The {@link VControl} to remove
64:          */
65:         void vControlRemoved(VControl vControl);
66:
67:         /**
68:          * Adds a {@link VControl} to the setting to control mapping.
69:          *
70:          * @param vControl The {@link VControl} to add
71:          */
72:         void vControlAdded(VControl vControl);
73:
74:         /**
75:          * Checks and updates the mapping for the given {@link EObject}.
76:          *
77:          * @param eObject The {@link EObject}
78:          */
79:         void checkAndUpdateSettingToControlMapping(EObject eObject);
80:
81:         /**
82:          * Checks whether any feature of this EObject has a registered control.
83:          *
84:          * @param eObject the EObject to check
85:          * @return <code>true</code> if there is at least one control for any feature of the given EObject,
86:          * <code>false</code> otherwise
87:          * @since 1.9
88:          */
89:         boolean hasControlsFor(EObject eObject);
90:
91:         /**
92:          * Returns a collection of all EObjects which have a mapped setting.
93:          *
94:          * @return the EObjects
95:          * @since 1.9
96:          */
97:         Collection<EObject> getEObjectsWithSettings();
98:
99:         /**
100:          * Returns a collection of all settings for the given control.
101:          *
102:          * @param control the control to get the settings for
103:          * @return the unique settings for the given control
104:          */
105:         Set<UniqueSetting> getSettingsForControl(VControl control);
106:
107:         /**
108:          * Query whether I have mapped the given {@code control} for the the a {@code setting}.
109:          *
110:          * @param setting an unique setting of some feature of some domain model object
111:          * @param control a control in the view model
112:          * @return {@code true} if I have mapped the {@code setting} to the {@code control};
113:          * {@code false}, otherwise
114:          *
115:          * @since 1.22
116:          */
117:         default boolean hasMapping(UniqueSetting setting, VElement control) {
118:•                return hasControlsFor(setting.getEObject())
119:•                        && getControlsFor(setting).contains(control);
120:         }
121:
122: }