1 17 package org.eclipse.emf.codegen.ecore.genmodel.action; 18 19 20 import java.util.Collection ; 21 22 import org.eclipse.jface.resource.ImageDescriptor; 23 import org.eclipse.jface.viewers.ISelection; 24 import org.eclipse.ui.IEditorPart; 25 26 import org.eclipse.emf.codegen.ecore.genmodel.provider.GenModelEditPlugin; 27 import org.eclipse.emf.common.command.Command; 28 import org.eclipse.emf.common.command.UnexecutableCommand; 29 import org.eclipse.emf.edit.command.CommandParameter; 30 import org.eclipse.emf.edit.command.CreateChildCommand; 31 import org.eclipse.emf.edit.domain.EditingDomain; 32 import org.eclipse.emf.edit.ui.action.StaticSelectionCommandAction; 33 import org.eclipse.emf.edit.ui.provider.ExtendedImageRegistry; 34 35 36 39 public class CreateChildAction extends StaticSelectionCommandAction 40 { 41 44 protected CommandParameter newChildDescriptor; 45 46 50 public CreateChildAction(IEditorPart editorPart, ISelection selection, CommandParameter newChildDescriptor) 51 { 52 super(editorPart); 53 this.newChildDescriptor = newChildDescriptor; 54 configureAction(selection); 55 } 56 57 61 protected ImageDescriptor getDefaultImageDescriptor() 62 { 63 return ExtendedImageRegistry.INSTANCE.getImageDescriptor(GenModelEditPlugin.INSTANCE.getImage("CreateChild")); 64 } 65 66 70 protected Command createActionCommand(EditingDomain editingDomain, Collection collection) 71 { 72 if (collection.size() == 1) 73 { 74 return CreateChildCommand.create(editingDomain, collection.iterator().next(), newChildDescriptor, collection); 75 } 76 else 77 { 78 return UnexecutableCommand.INSTANCE; 79 } 80 } 81 } 82 | Popular Tags |