1 17 package org.eclipse.emf.edit.ui.action; 18 19 20 import java.util.Collection ; 21 22 import org.eclipse.jface.viewers.ISelection; 23 import org.eclipse.ui.IEditorPart; 24 import org.eclipse.ui.IWorkbenchPart; 25 26 import org.eclipse.emf.common.command.Command; 27 import org.eclipse.emf.common.command.UnexecutableCommand; 28 import org.eclipse.emf.edit.command.CreateChildCommand; 29 import org.eclipse.emf.edit.domain.EditingDomain; 30 31 32 36 public class CreateChildAction extends StaticSelectionCommandAction 37 { 38 41 protected Object descriptor; 42 43 49 public CreateChildAction(IWorkbenchPart workbenchPart, ISelection selection, 50 Object descriptor) 51 { 52 super(workbenchPart); 53 this.descriptor = descriptor; 54 configureAction(selection); 55 } 56 57 62 public CreateChildAction(IEditorPart editorPart, ISelection selection, 63 Object descriptor) 64 { 65 this((IWorkbenchPart)editorPart, selection, descriptor); 66 } 67 68 72 protected Command createActionCommand(EditingDomain editingDomain, 73 Collection collection) 74 { 75 if (collection.size() == 1) 76 { 77 Object owner = collection.iterator().next(); 78 return CreateChildCommand.create(editingDomain, owner, 79 descriptor, collection); 80 } 81 return UnexecutableCommand.INSTANCE; 82 } 83 } 84 | Popular Tags |