Skip to content

Package: DefaultDeleteActionBuilder$1

DefaultDeleteActionBuilder$1

nameinstructionbranchcomplexitylinemethod
run()
M: 9 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
{...}
M: 0 C: 12
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2015 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.emfforms.internal.swt.treemasterdetail.defaultprovider;
15:
16: import org.eclipse.emf.common.command.Command;
17: import org.eclipse.emf.edit.command.DeleteCommand;
18: import org.eclipse.emf.edit.domain.EditingDomain;
19: import org.eclipse.emfforms.spi.swt.treemasterdetail.DeleteActionBuilder;
20: import org.eclipse.emfforms.spi.swt.treemasterdetail.TreeMasterDetailComposite;
21: import org.eclipse.jface.action.Action;
22: import org.eclipse.jface.resource.ImageDescriptor;
23: import org.eclipse.jface.viewers.IStructuredSelection;
24: import org.osgi.framework.FrameworkUtil;
25:
26: /**
27: * The default delete action creates a remove command and wraps it's execution in the {@link Action#run() run} method.
28: *
29: * @author Johannes Faltermeier
30: *
31: */
32: public class DefaultDeleteActionBuilder implements DeleteActionBuilder {
33:
34:         @Override
35:         public Action createDeleteAction(IStructuredSelection selection, final EditingDomain editingDomain) {
36:                 final Command deleteCommand = DeleteCommand.create(editingDomain, selection.toList());
37:
38:                 final Action deleteAction = new Action() {
39:                         @Override
40:                         public void run() {
41:                                 super.run();
42:                                 editingDomain.getCommandStack().execute(deleteCommand);
43:                         }
44:                 };
45:
46:                 if (!deleteCommand.canExecute()) {
47:                         deleteAction.setEnabled(false);
48:                 }
49:
50:                 final String deleteImagePath = "icons/delete.png";//$NON-NLS-1$
51:                 deleteAction.setImageDescriptor(ImageDescriptor
52:                         .createFromURL(FrameworkUtil.getBundle(TreeMasterDetailComposite.class).getResource(deleteImagePath)));
53:                 deleteAction.setText("Delete"); //$NON-NLS-1$
54:
55:                 return deleteAction;
56:         }
57:
58: }