Skip to content

Package: OpenInNewContextStrategy

OpenInNewContextStrategy

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 org.eclipse.emf.ecore.EObject;
17: import org.eclipse.emf.ecore.EReference;
18: import org.eclipse.emf.ecp.edit.spi.swt.util.ECPDialogExecutor;
19: import org.eclipse.emfforms.bazaar.Vendor;
20: import org.eclipse.jface.dialogs.Dialog;
21: import org.eclipse.swt.widgets.Display;
22:
23: /**
24: * A {@link org.eclipse.emf.ecp.ui.view.swt.DefaultReferenceService DefaultReferenceService}
25: * <em>customization strategy</em> for opening a newly created object for editing its details.
26: *
27: * @since 1.16
28: *
29: * @see org.eclipse.emf.ecp.ui.view.swt.DefaultReferenceService DefaultReferenceService
30: */
31: public interface OpenInNewContextStrategy {
32:         /**
33:          * The default strategy. It opens the new object in a dialog for focused editing.
34:          */
35:         OpenInNewContextStrategy DEFAULT = new OpenInNewContextStrategy() {
36:                 @Override
37:                 public boolean openInNewContext(EObject owner, EReference reference, EObject object) {
38:                         final Dialog dialog = new EditNewObjectDialog(Display.getDefault().getActiveShell(), object);
39:
40:                         new ECPDialogExecutor(dialog) {
41:                                 @Override
42:                                 public void handleResult(int codeResult) {
43:                                         // Nothing to do
44:                                 }
45:                         }.execute();
46:
47:                         return true;
48:                 }
49:         };
50:
51:         /**
52:          * Open a new {@code object} for editing its details in its own context.
53:          *
54:          * @param owner the container of the {@code object}, or {@code null} if it is contained in a resource
55:          * @param reference the reference of the {@code owner} in which the {@code object} is contained,
56:          * or {@code null} if it is contained in a resource
57:          * @param object the new object to be opened for editing
58:          *
59:          * @return {@code true} if the {@code object} was opened for editing by this
60:          * strategy; {@code false}, otherwise
61:          */
62:         boolean openInNewContext(EObject owner, EReference reference, EObject object);
63:
64:         //
65:         // Nested types
66:         //
67:
68:         /**
69:          * Specific Bazaar vendor interface for open strategies.
70:          *
71:          * @since 1.16
72:          */
73:         public interface Provider extends Vendor<OpenInNewContextStrategy> {
74:                 // Nothing to add to the superinterface
75:         }
76:
77: }