Debian Codegraph @

plugins/org.eclipse.emf.edit.ui/src/org/eclipse/emf/edit/ui/action/CopyAction.java

raw
1 /**
2 * Copyright (c) 2002-2006 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v2.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v20.html
7 *
8 * Contributors:
9 * IBM - Initial API and implementation
10 */
11 package org.eclipse.emf.edit.ui.action;
12
13
14 import java.util.Collection;
15
16 import org.eclipse.ui.IEditorPart;
17 import org.eclipse.ui.IWorkbenchPart;
18
19 import org.eclipse.emf.common.command.Command;
20 import org.eclipse.emf.edit.command.CopyToClipboardCommand;
21 import org.eclipse.emf.edit.domain.EditingDomain;
22 import org.eclipse.emf.edit.domain.IEditingDomainProvider;
23 import org.eclipse.emf.edit.ui.EMFEditUIPlugin;
24
25
26 /**
27 * A copy action is implemented by creating a {@link CopyToClipboardCommand}.
28 */
29 public class CopyAction extends CommandActionHandler
30 {
31 public CopyAction(EditingDomain domain)
32 {
33 super(domain, EMFEditUIPlugin.INSTANCE.getString("_UI_Copy_menu_item"));
34 }
35
36 public CopyAction()
37 {
38 super(null, EMFEditUIPlugin.INSTANCE.getString("_UI_Copy_menu_item"));
39 }
40
41 @Override
42 public Command createCommand(Collection<?> selection)
43 {
44 return CopyToClipboardCommand.create(domain, selection);
45 }
46
47 /**
48 * @deprecated As of EMF 2.1.0, replaced by {@link #setActiveWorkbenchPart}.
49 */
50 @Deprecated
51 public void setActiveEditor(IEditorPart editorPart)
52 {
53 setActiveWorkbenchPart(editorPart);
54 }
55
56 /**
57 * @since 2.1.0
58 */
59 public void setActiveWorkbenchPart(IWorkbenchPart workbenchPart)
60 {
61 if (workbenchPart instanceof IEditingDomainProvider)
62 {
63 domain = ((IEditingDomainProvider)workbenchPart).getEditingDomain();
64 }
65 }
66 }