1 17 package org.eclipse.emf.mapping.ecore2ecore.action; 18 19 20 import java.util.ArrayList ; 21 import java.util.Collection ; 22 23 import org.eclipse.core.resources.IResource; 24 import org.eclipse.core.resources.ResourcesPlugin; 25 import org.eclipse.emf.common.util.URI; 26 import org.eclipse.emf.mapping.action.AddRootTopAction; 27 import org.eclipse.emf.mapping.ecore2ecore.presentation.Ecore2EcoreEditor; 28 import org.eclipse.emf.mapping.ecore2ecore.presentation.Ecore2EcoreEditorPlugin; 29 import org.eclipse.ui.dialogs.ResourceSelectionDialog; 30 31 32 35 public class AddInputRootAction extends AddRootTopAction 36 { 37 40 public AddInputRootAction() 41 { 42 super(); 43 } 44 45 50 protected Collection getTopsToAdd() 51 { 52 Collection topsToAdd = new ArrayList (); 53 54 ResourceSelectionDialog resourceSelectionDialog = new ResourceSelectionDialog( 55 workbenchPart.getSite().getShell(), 56 ResourcesPlugin.getWorkspace().getRoot(), 57 Ecore2EcoreEditorPlugin.INSTANCE.getString("_UI_SelectInputEcoreModels_label")); resourceSelectionDialog.open(); 59 60 Object [] result = resourceSelectionDialog.getResult(); 61 62 if (result != null) 63 { 64 for (int i = 0; i < result.length; i++) 65 { 66 IResource resource = (IResource)result[i]; 67 68 if (resource.getType() == IResource.FILE && "ecore".equals(resource.getFullPath().getFileExtension())) { 70 topsToAdd.addAll(((Ecore2EcoreEditor)workbenchPart).getEditingDomain().getResourceSet().getResource( 71 URI.createPlatformResourceURI(resource.getFullPath().toString()), 72 true).getContents()); 73 } 74 } 75 } 76 77 return topsToAdd; 78 } 79 } | Popular Tags |