Skip to content

Package: DomainModelReferenceSegmentConverterEMF

DomainModelReferenceSegmentConverterEMF

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2017 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: ******************************************************************************/
14: package org.eclipse.emfforms.spi.core.services.databinding.emf;
15:
16: import org.eclipse.core.databinding.property.list.IListProperty;
17: import org.eclipse.core.databinding.property.value.IValueProperty;
18: import org.eclipse.emf.databinding.IEMFListProperty;
19: import org.eclipse.emf.databinding.IEMFValueProperty;
20: import org.eclipse.emf.ecore.EClass;
21: import org.eclipse.emf.ecore.EObject;
22: import org.eclipse.emf.ecore.EStructuralFeature;
23: import org.eclipse.emf.ecore.EStructuralFeature.Setting;
24: import org.eclipse.emf.ecp.view.spi.model.VDomainModelReferenceSegment;
25: import org.eclipse.emf.edit.domain.EditingDomain;
26: import org.eclipse.emfforms.spi.core.services.databinding.DatabindingFailedException;
27:
28: /**
29: * Converts a {@link VDomainModelReferenceSegment} to an {@link IEMFValueProperty} or an {@link IEMFListProperty}.
30: *
31: * @author Lucas Koehler
32: * @since 1.19
33: *
34: */
35: public interface DomainModelReferenceSegmentConverterEMF {
36:
37:         /**
38:          * The constant defining the priority that a {@link DomainModelReferenceSegmentConverterEMF} is not suitable for a
39:          * {@link VDomainModelReferenceSegment}.
40:          */
41:         double NOT_APPLICABLE = Double.NEGATIVE_INFINITY;
42:
43:         /**
44:          * Checks whether the given {@link VDomainModelReferenceSegment} can be converted by this
45:          * {@link DomainModelReferenceSegmentConverterEMF} to an {@link IValueProperty} or an {@link IListProperty}. The
46:          * return value is the priority of this converter. The higher the priority, the better the converter suits the given
47:          * {@link VDomainModelReferenceSegment}.
48:          *
49:          * @param segment The {@link VDomainModelReferenceSegment} whose priority is wanted.
50:          * @return The priority of the given {@link VDomainModelReferenceSegment}; negative infinity if this converter is
51:          * not applicable.
52:          */
53:         double isApplicable(VDomainModelReferenceSegment segment);
54:
55:         /**
56:          * Converts a {@link VDomainModelReferenceSegment} to an {@link IValueProperty}.
57:          *
58:          * @param segment The {@link VDomainModelReferenceSegment} that will be converted to an {@link IValueProperty}
59:          * @param segmentRoot The root {@link EClass} of the {@link VDomainModelReferenceSegment segment} used to resolve
60:          * the segment to an {@link EStructuralFeature}. This means the {@link EClass} has to contain the feature
61:          * used in the segment
62:          * @param editingDomain The {@link EditingDomain} in which the {@link IEMFValueProperty} is created
63:          * @return The {@link SegmentConverterValueResultEMF} with the created {@link IEMFValueProperty}, does not return
64:          * <code>null</code>
65:          * @throws DatabindingFailedException if no value property could be created
66:          */
67:         SegmentConverterValueResultEMF convertToValueProperty(VDomainModelReferenceSegment segment, EClass segmentRoot,
68:                 EditingDomain editingDomain) throws DatabindingFailedException;
69:
70:         /**
71:          * Converts a {@link VDomainModelReferenceSegment} to an {@link IListProperty}.
72:          *
73:          * @param segment The {@link VDomainModelReferenceSegment} that will be converted to an {@link IValueProperty}
74:          * @param segmentRoot The root {@link EClass} of the {@link VDomainModelReferenceSegment segment} used to resolve
75:          * the segment to an {@link EStructuralFeature}. This means the {@link EClass} has to contain the feature
76:          * used in the segment
77:          * @param editingDomain The {@link EditingDomain} in which the {@link IEMFValueProperty} is created
78:          * @return The {@link SegmentConverterListResultEMF} with the created {@link IEMFListProperty}, does not return
79:          * <code>null</code>
80:          * @throws DatabindingFailedException if no value property could be created
81:          */
82:         SegmentConverterListResultEMF convertToListProperty(VDomainModelReferenceSegment segment, EClass segmentRoot,
83:                 EditingDomain editingDomain) throws DatabindingFailedException;
84:
85:         /**
86:          * Retrieve the Setting which is described by the provided {@link VDomainModelReferenceSegment} and the provided
87:          * {@link EObject}.
88:          *
89:          * @param segment The {@link VDomainModelReferenceSegment} to use to retrieve the setting
90:          * @param eObject The {@link EObject} to use to retrieve the setting. This {@link EObject} must have the same
91:          * {@link EClass} as the feature used in the segment
92:          * @return The Setting being described by the {@link VDomainModelReferenceSegment segment} and {@link EObject}
93:          * @throws DatabindingFailedException if the databinding could not be executed successfully.
94:          */
95:         Setting getSetting(VDomainModelReferenceSegment segment, EObject eObject) throws DatabindingFailedException;
96: }