Skip to content

Package: EClassSelectionStrategy

EClassSelectionStrategy

nameinstructionbranchcomplexitylinemethod
static {...}
M: 0 C: 5
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2018 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.Collection;
17:
18: import org.eclipse.emf.ecore.EClass;
19: import org.eclipse.emf.ecore.EObject;
20: import org.eclipse.emf.ecore.EReference;
21: import org.eclipse.emfforms.bazaar.Vendor;
22:
23: /**
24: * A <em>customization strategy</em> for accumulating {@link EClass}es for instantiation to create a new
25: * object in a reference. Used by the {@link DefaultCreateNewModelElementStrategyProvider}.
26: *
27: * @since 1.16
28: *
29: * @see org.eclipse.emf.ecp.ui.view.swt.DefaultReferenceService DefaultReferenceService
30: */
31: public interface EClassSelectionStrategy {
32:         /** An idempotent strategy (does not modify the selection). */
33:         EClassSelectionStrategy NULL = new EClassSelectionStrategy() {
34:                 @Override
35:                 public Collection<EClass> collectEClasses(EObject owner, EReference reference, Collection<EClass> eclasses) {
36:                         return eclasses;
37:                 }
38:         };
39:
40:         /**
41:          * Update a collection of {@link EClass}es that are eligible for creation of
42:          * a new object in the reference.
43:          *
44:          * @param owner the proposed owner of a new reference
45:          * @param reference the {@code owner}'s reference in which to add a new object
46:          * @param eclasses a mutable collection of classes. Implementors may add and remove
47:          * elements in this collection as needed
48:          *
49:          * @return a mutable filtered collection of classes that can be passed into the
50:          * next strategy. A suggested pattern is to modify the {@code eclasses} in place
51:          * and return that collection
52:          */
53:         Collection<EClass> collectEClasses(EObject owner, EReference reference, Collection<EClass> eclasses);
54:
55:         //
56:         // Nested types
57:         //
58:
59:         /**
60:          * Specific Bazaar vendor interface for {@code EClass} selection strategies.
61:          *
62:          * @since 1.16
63:          */
64:         public interface Provider extends Vendor<EClassSelectionStrategy> {
65:                 // Nothing to add to the superinterface
66:         }
67:
68: }