Skip to content

Package: TemplateProvider

TemplateProvider

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: * Mat Hansen - initial API and implementation
13: * Christian W. Damus - bug 529138
14: ******************************************************************************/
15: package org.eclipse.emfforms.core.services.datatemplate;
16:
17: import java.util.Set;
18:
19: import org.eclipse.emf.ecore.EObject;
20: import org.eclipse.emf.ecore.EReference;
21: import org.eclipse.emfforms.datatemplate.Template;
22:
23: /**
24: * Template provider interface.
25: *
26: * @author Mat Hansen <mhansen@eclipsesource.com>
27: * @since 1.17
28: */
29: public interface TemplateProvider {
30:
31:         /**
32:          * Queries whether the provider can provide templates that may be assigned
33:          * to the given {@code reference} of the given {@code owner} object.
34:          *
35:          * @param owner the object owning a {@code reference} to be assigned from a template
36:          * @param reference a reference feature of the {@code owner} that is to be assigned from a template.
37:          * If the {@code reference} is a {@link EReference#isContainment() containment} then
38:          * the {@code owner} would be the {@link EObject#eContainer() container} of the template
39:          *
40:          * @return whether I have any templates to offer
41:          */
42:         boolean canProvideTemplates(EObject owner, EReference reference);
43:
44:         /**
45:          * Obtains templates wrapping objects that can be assigned to the given
46:          * {@code reference} of the given {@code owner} object. This will only
47:          * be called for an {@code owner} and {@code reference} for which the
48:          * receiver previously answered {@code true} to an invocation of the
49:          * {@link #canProvideTemplates(EObject, EReference)} query.
50:          *
51:          * @param owner the object owning a {@code reference} to be assigned from a template
52:          * @param reference a reference feature of the {@code owner} that is to be assigned from a template.
53:          * If the {@code reference} is a {@link EReference#isContainment() containment} then
54:          * the {@code owner} would be the {@link EObject#eContainer() container} of the template
55:          *
56:          * @return my available templates, or an empty set if none (never {@code null})
57:          */
58:         Set<Template> provideTemplates(EObject owner, EReference reference);
59:
60: }