Skip to content

Package: DeleteHandler

DeleteHandler

nameinstructionbranchcomplexitylinemethod
DeleteHandler()
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: 34 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 9 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2013 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.ui.commands;
16:
17: import java.util.ArrayList;
18: import java.util.Iterator;
19: import java.util.List;
20:
21: import org.eclipse.core.commands.AbstractHandler;
22: import org.eclipse.core.commands.ExecutionEvent;
23: import org.eclipse.core.commands.ExecutionException;
24: import org.eclipse.emf.ecp.core.util.ECPContainer;
25: import org.eclipse.emf.ecp.spi.ui.util.ECPHandlerHelper;
26: import org.eclipse.jface.viewers.ISelection;
27: import org.eclipse.jface.viewers.IStructuredSelection;
28: import org.eclipse.ui.handlers.HandlerUtil;
29:
30: /**
31: * This Handler uses the {@link ECPHandlerHelper#deleteHandlerHelper(List, org.eclipse.swt.widgets.Shell)} method
32: * to delete {@link ECPContainer}.
33: *
34: * @author Eugen Neufeld
35: */
36: public class DeleteHandler extends AbstractHandler {
37:
38:         /** {@inheritDoc} */
39:         @Override
40:         public Object execute(ExecutionEvent event) throws ExecutionException {
41:                 final ISelection selection = HandlerUtil.getActiveMenuSelection(event);
42:                 final IStructuredSelection ssel = (IStructuredSelection) selection;
43:
44:                 final List<ECPContainer> deletables = new ArrayList<ECPContainer>();
45:•                for (final Iterator<?> it = ssel.iterator(); it.hasNext();) {
46:                         final Object element = it.next();
47:•                        if (element instanceof ECPContainer) {
48:                                 deletables.add((ECPContainer) element);
49:                         }
50:                 }
51:                 ECPHandlerHelper.deleteHandlerHelper(deletables, HandlerUtil.getActiveShell(event));
52:                 return null;
53:         }
54: }