Skip to content

Package: UnsetRootEClass

UnsetRootEClass

nameinstructionbranchcomplexitylinemethod
UnsetRootEClass()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
execute(ExecutionEvent)
M: 24 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 7 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: * Eugen - initial API and implementation
13: ******************************************************************************/
14: package org.eclipse.emf.ecp.ui.view.internal.editor.controls.legacy.handler;
15:
16: import org.eclipse.core.commands.AbstractHandler;
17: import org.eclipse.core.commands.ExecutionEvent;
18: import org.eclipse.core.commands.ExecutionException;
19: import org.eclipse.emf.ecp.core.util.ECPUtil;
20: import org.eclipse.emf.ecp.view.spi.model.VView;
21: import org.eclipse.jface.viewers.IStructuredSelection;
22: import org.eclipse.ui.handlers.HandlerUtil;
23:
24: /**
25: * @author Eugen
26: *
27: */
28: public class UnsetRootEClass extends AbstractHandler {
29:
30:         /**
31:          * {@inheritDoc}
32:          *
33:          * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
34:          */
35:         @Override
36:         public Object execute(ExecutionEvent event) throws ExecutionException {
37:                 final Object selection = ((IStructuredSelection) HandlerUtil.getActiveMenuSelection(event)).getFirstElement();
38:•                if (selection == null || !(selection instanceof VView)) {
39:                         return null;
40:                 }
41:
42:                 final VView view = (VView) selection;
43:                 view.setRootEClass(null);
44:
45:                 ECPUtil.getECPProjectManager().getProject(view).saveContents();
46:
47:                 return null;
48:         }
49:
50: }