1 17 package org.eclipse.emf.edit.ui.action; 18 19 20 import java.util.Collection ; 21 22 import org.eclipse.ui.IEditorPart; 23 import org.eclipse.ui.IWorkbenchPart; 24 25 import org.eclipse.emf.common.command.Command; 26 import org.eclipse.emf.common.command.UnexecutableCommand; 27 import org.eclipse.emf.edit.command.PasteFromClipboardCommand; 28 import org.eclipse.emf.edit.domain.EditingDomain; 29 import org.eclipse.emf.edit.domain.IEditingDomainProvider; 30 import org.eclipse.emf.edit.ui.EMFEditUIPlugin; 31 32 33 36 public class PasteAction extends CommandActionHandler 37 { 38 public PasteAction(EditingDomain domain) 39 { 40 super(domain, EMFEditUIPlugin.INSTANCE.getString("_UI_Paste_menu_item")); 41 } 42 43 public PasteAction() 44 { 45 super(null, EMFEditUIPlugin.INSTANCE.getString("_UI_Paste_menu_item")); 46 } 47 48 public Command createCommand(Collection selection) 49 { 50 if (selection.size() == 1) 51 { 52 return PasteFromClipboardCommand.create(domain, selection.iterator().next(), null); 53 } 54 else 55 { 56 return UnexecutableCommand.INSTANCE; 57 } 58 } 59 60 63 public void setActiveEditor(IEditorPart editorPart) 64 { 65 setActiveWorkbenchPart(editorPart); 66 } 67 68 71 public void setActiveWorkbenchPart(IWorkbenchPart workbenchPart) 72 { 73 if (workbenchPart instanceof IEditingDomainProvider) 74 { 75 domain = ((IEditingDomainProvider)workbenchPart).getEditingDomain(); 76 } 77 } 78 } 79 | Popular Tags |