Skip to content

Package: CloseableHandler

CloseableHandler

nameinstructionbranchcomplexitylinemethod
CloseableHandler()
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: 37 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 9 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:
16: package org.eclipse.emf.ecp.ui.commands;
17:
18: import org.eclipse.core.commands.AbstractHandler;
19: import org.eclipse.core.commands.ExecutionEvent;
20: import org.eclipse.core.commands.ExecutionException;
21: import org.eclipse.emf.ecp.core.ECPProject;
22: import org.eclipse.emf.ecp.spi.ui.util.ECPHandlerHelper;
23: import org.eclipse.jface.viewers.ISelection;
24: import org.eclipse.jface.viewers.IStructuredSelection;
25: import org.eclipse.ui.handlers.HandlerUtil;
26:
27: /**
28: * This Handler uses the {@link ECPHandlerHelper#changeCloseState(ECPProject[], String)} method
29: * to close selected projects.
30: *
31: * @author Eugen Neufeld
32: */
33: public class CloseableHandler extends AbstractHandler {
34:
35:         /** {@inheritDoc} */
36:         @Override
37:         public Object execute(ExecutionEvent event) throws ExecutionException {
38:                 final ISelection selection = HandlerUtil.getActiveMenuSelection(event);
39:                 final IStructuredSelection ssel = (IStructuredSelection) selection;
40:                 final String currentType = event.getParameter("org.eclipse.emf.ecp.project.type"); //$NON-NLS-1$
41:                 final Object[] selectionArray = ssel.toArray();
42:                 final ECPProject[] closeable = new ECPProject[selectionArray.length];
43:
44:•                for (int i = 0; i < selectionArray.length; i++) {
45:                         closeable[i] = (ECPProject) selectionArray[i];
46:                 }
47:
48:                 ECPHandlerHelper.changeCloseState(closeable, currentType);
49:
50:                 return null;
51:         }
52:
53: }