Skip to content

Package: CheckoutHandler

CheckoutHandler

nameinstructionbranchcomplexitylinemethod
CheckoutHandler()
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: 36 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 10 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 java.util.ArrayList;
19: import java.util.Iterator;
20: import java.util.List;
21:
22: import org.eclipse.core.commands.AbstractHandler;
23: import org.eclipse.core.commands.ExecutionEvent;
24: import org.eclipse.core.commands.ExecutionException;
25: import org.eclipse.emf.ecp.core.util.ECPCheckoutSource;
26: import org.eclipse.emf.ecp.spi.ui.util.ECPHandlerHelper;
27: import org.eclipse.jface.viewers.ISelection;
28: import org.eclipse.jface.viewers.IStructuredSelection;
29: import org.eclipse.ui.handlers.HandlerUtil;
30:
31: /**
32: * This Handler uses the {@link ECPHandlerHelper#checkout(List, org.eclipse.swt.widgets.Shell)} method
33: * to checkout a project.
34: *
35: * @author Eugen Neufeld
36: */
37: public class CheckoutHandler extends AbstractHandler {
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<ECPCheckoutSource> checkouts = new ArrayList<ECPCheckoutSource>();
45:•                for (final Iterator<?> it = ssel.iterator(); it.hasNext();) {
46:                         final Object element = it.next();
47:•                        if (element instanceof ECPCheckoutSource) {
48:                                 final ECPCheckoutSource checkoutSource = (ECPCheckoutSource) element;
49:                                 checkouts.add(checkoutSource);
50:                         }
51:                 }
52:                 ECPHandlerHelper.checkout(checkouts, HandlerUtil.getActiveShell(event));
53:
54:                 return null;
55:         }
56:
57: }