Skip to content

Package: ReferenceStrategy$Provider

ReferenceStrategy$Provider

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2018-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.emf.ecp.ui.view.swt.reference;
15:
16: import java.util.Set;
17:
18: import org.eclipse.emf.ecore.EObject;
19: import org.eclipse.emf.ecore.EReference;
20: import org.eclipse.emf.ecp.internal.edit.ECPControlHelper;
21: import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
22: import org.eclipse.emf.edit.domain.EditingDomain;
23: import org.eclipse.emfforms.bazaar.Vendor;
24:
25: /**
26: * A {@link org.eclipse.emf.ecp.ui.view.swt.DefaultReferenceService DefaultReferenceService}
27: * <em>customization strategy</em> for adding an object to a reference of another.
28: *
29: * @since 1.16
30: *
31: * @see org.eclipse.emf.ecp.ui.view.swt.DefaultReferenceService DefaultReferenceService
32: */
33: @SuppressWarnings("restriction")
34: public interface ReferenceStrategy {
35:         /**
36:          * The default strategy. Just executes a simple command to add the reference.
37:          */
38:         ReferenceStrategy DEFAULT = new ReferenceStrategy() {
39:                 @Override
40:                 public boolean addElementsToReference(EObject owner, EReference reference, Set<? extends EObject> objects) {
41:                         final EditingDomain domain = AdapterFactoryEditingDomain.getEditingDomainFor(owner);
42:
43:                         ECPControlHelper.addModelElementsInReference(owner, objects, reference, domain);
44:
45:                         return true;
46:                 }
47:         };
48:
49:         /**
50:          * Add a set of new {@code objects} to a {@code reference}.
51:          *
52:          * @param owner an existing object to which the given {@code objects} are to be added in the {@code reference}
53:          * @param reference the reference of the {@code owner} to which the {@code objects} are to be added
54:          * @param objects the new objects to be added to the {@code reference} of the {@code owner}
55:          *
56:          * @return {@code true} if the {@code objects} were added to the {@code reference} by this
57:          * strategy; {@code false}, otherwise
58:          */
59:         boolean addElementsToReference(EObject owner, EReference reference, Set<? extends EObject> objects);
60:
61:         //
62:         // Nested types
63:         //
64:
65:         /**
66:          * Specific Bazaar vendor interface for reference strategies.
67:          *
68:          * @since 1.16
69:          */
70:         public interface Provider extends Vendor<ReferenceStrategy> {
71:                 // Nothing to add to the superinterface
72:         }
73: }