Skip to content

Package: FcoreResourcePasteAction

FcoreResourcePasteAction

nameinstructionbranchcomplexitylinemethod
FcoreResourcePasteAction()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
createCommand(Collection)
M: 16 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
setActiveWorkbenchPart(IWorkbenchPart)
M: 15 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 5 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /**
2: * <copyright>
3: * </copyright>
4: *
5: * $Id$
6: */
7: package org.eclipse.egf.model.editor.actions;
8:
9: import java.util.Collection;
10:
11: import org.eclipse.egf.model.fcore.commands.resource.FcoreResourcePasteFromClipboardCommand;
12: import org.eclipse.emf.common.command.Command;
13: import org.eclipse.emf.common.command.UnexecutableCommand;
14: import org.eclipse.emf.edit.domain.IEditingDomainProvider;
15: import org.eclipse.emf.edit.ui.action.PasteAction;
16: import org.eclipse.ui.IWorkbenchPart;
17:
18: /**
19: * Multi-rooted resources support.
20: * This action allows the user to paste a valid element at the resource level.
21: */
22: public class FcoreResourcePasteAction extends PasteAction {
23:
24: /**
25: * Constructor
26: */
27: public FcoreResourcePasteAction() {
28: super();
29: }
30:
31: /**
32: * @since 2.1.0
33: */
34: @Override
35: public void setActiveWorkbenchPart(IWorkbenchPart workbenchPart) {
36: super.setActiveWorkbenchPart(workbenchPart);
37: domain = null;
38:• if (workbenchPart instanceof IEditingDomainProvider) {
39: domain = ((IEditingDomainProvider) workbenchPart).getEditingDomain();
40: }
41: }
42:
43: /**
44: * @see org.eclipse.emf.edit.ui.action.CommandActionHandler#createCommand(java.util.Collection)
45: */
46: @Override
47: public Command createCommand(Collection<?> selection) {
48:• if (selection == null || selection.size() != 1) {
49: return UnexecutableCommand.INSTANCE;
50: }
51: return FcoreResourcePasteFromClipboardCommand.create(domain, selection.iterator().next(), null);
52: }
53:
54: }