1 17 package org.eclipse.emf.mapping.action; 18 19 20 import java.util.Collection ; 21 22 import org.eclipse.jface.action.IAction; 23 import org.eclipse.jface.viewers.ISelection; 24 import org.eclipse.ui.IWorkbenchPart; 25 26 import org.eclipse.emf.edit.command.AddCommand; 27 import org.eclipse.emf.edit.ui.action.CommandAction; 28 import org.eclipse.emf.mapping.MappingPackage; 29 import org.eclipse.emf.mapping.MappingRoot; 30 import org.eclipse.emf.mapping.domain.MappingDomain; 31 32 33 36 public class AddRootTopAction extends CommandAction 37 { 38 42 protected Collection getTopsToAdd() 43 { 44 return null; 45 } 46 47 50 public void selectionChanged(IAction action, ISelection selection) 51 { 52 } 53 54 public void run(IAction action) 55 { 56 Collection additions = getTopsToAdd(); 57 MappingRoot mappingRoot = ((MappingDomain)editingDomain).getMappingRoot(); 58 command = AddCommand.create 59 (editingDomain, 60 mappingRoot, 61 mappingRoot.isTopToBottom() ? 62 MappingPackage.eINSTANCE.getMapping_Inputs() : 65 MappingPackage.eINSTANCE.getMapping_Outputs(), 66 additions); 67 68 super.run(action); 69 } 70 71 public void setActiveWorkbenchPart(IWorkbenchPart workbenchPart) 72 { 73 super.setActiveWorkbenchPart(workbenchPart); 74 action.setEnabled(true); 75 } 76 } 77 | Popular Tags |