Skip to content

Package: EObjectSelectionStrategy

EObjectSelectionStrategy

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