Skip to content

Package: ValidationViewToEditorBridge

ValidationViewToEditorBridge

nameinstructionbranchcomplexitylinemethod
ValidationViewToEditorBridge()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
doubleClick(DoubleClickEvent)
M: 39 C: 0
0%
M: 6 C: 0
0%
M: 4 C: 0
0%
M: 11 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2014 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: * Johannes Faltermeier - initial API and implementation
13: ******************************************************************************/
14: package org.eclipse.emf.ecp.internal.validationvieweditorbridge;
15:
16: import org.eclipse.emf.common.util.Diagnostic;
17: import org.eclipse.emf.ecore.EObject;
18: import org.eclipse.emf.ecp.core.ECPProject;
19: import org.eclipse.emf.ecp.core.util.ECPUtil;
20: import org.eclipse.emf.ecp.spi.ui.util.ECPHandlerHelper;
21: import org.eclipse.jface.viewers.DoubleClickEvent;
22: import org.eclipse.jface.viewers.IDoubleClickListener;
23: import org.eclipse.jface.viewers.IStructuredSelection;
24:
25: /**
26: * Double click listener for the validation view which opens the model editor for the {@link EObject} associated with
27: * the double clicked {@link Diagnostic}.
28: *
29: * @author jfaltermeier
30: *
31: */
32: public class ValidationViewToEditorBridge implements IDoubleClickListener {
33:
34:         /**
35:          * {@inheritDoc}
36:          *
37:          * @see org.eclipse.jface.viewers.IDoubleClickListener#doubleClick(org.eclipse.jface.viewers.DoubleClickEvent)
38:          */
39:         @Override
40:         public void doubleClick(DoubleClickEvent event) {
41:                 final IStructuredSelection thisSelection = (IStructuredSelection) event.getSelection();
42:                 final Object selection = thisSelection.getFirstElement();
43:•                if (!(selection instanceof Diagnostic)) {
44:                         return;
45:                 }
46:                 final Diagnostic diagnostic = (Diagnostic) selection;
47:•                if (diagnostic.getData().isEmpty() || !(diagnostic.getData().get(0) instanceof EObject)) {
48:                         return;
49:                 }
50:                 final EObject eObject = (EObject) diagnostic.getData().get(0);
51:                 final ECPProject project = ECPUtil.getECPProjectManager().getProject(eObject);
52:                 ECPHandlerHelper.openModelElement(eObject, project);
53:         }
54: }