Skip to content

Package: EditorModelElementOpener

EditorModelElementOpener

nameinstructionbranchcomplexitylinemethod
EditorModelElementOpener()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
canOpen(EObject)
M: 2 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
openModelElement(Object, ECPProject)
M: 23 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 6 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2012 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: * Eugen Neufeld - initial API and implementation
13: *
14: *******************************************************************************/
15: package org.eclipse.emf.ecp.explorereditorbridge.internal;
16:
17: import org.eclipse.emf.ecore.EObject;
18: import org.eclipse.emf.ecp.core.ECPProject;
19: import org.eclipse.emf.ecp.editor.e3.MEEditorInput;
20: import org.eclipse.emf.ecp.ui.util.ECPModelElementOpener;
21: import org.eclipse.ui.PartInitException;
22: import org.eclipse.ui.PlatformUI;
23:
24: /**
25: * ECP Class to open the default ECP Editor.
26: *
27: * @author Eugen Neufeld
28: *
29: */
30: public class EditorModelElementOpener implements ECPModelElementOpener {
31:
32:         private static final String ECP_EDITOR_ID = "org.eclipse.emf.ecp.editor"; //$NON-NLS-1$
33:
34:         /**
35:          * Convenient constructor.
36:          */
37:         public EditorModelElementOpener() {
38:         }
39:
40:         /**
41:          * The default editor can open every {@link EObject}, but has the lowest value.
42:          *
43:          * @param modelElement {@link EObject} to test
44:          * @return 0
45:          */
46:         public int canOpen(EObject modelElement) {
47:                 return 0;
48:         }
49:
50:         /**
51:          * Opens the default ECP Editor for an {@link EObject} and the corresponding {@link ECPProject}.
52:          *
53:          * @param modelElement the {@link EObject} to open the Editor for
54:          * @param ecpProject the {@link ECPProject} to open the Editor for
55:          */
56:         @Override
57:         public void openModelElement(Object modelElement, ECPProject ecpProject) {
58:                 final MEEditorInput input = new MEEditorInput(new EditorContext((EObject) modelElement, ecpProject));
59:                 try {
60:                         PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
61:                                 .openEditor(input, ECP_EDITOR_ID, true);
62:                 } catch (final PartInitException e) {
63:                         Activator.logException(e);
64:                 }
65:         }
66: }