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.AddRootBottomAction; 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 AddOutputRootAction extends AddRootBottomAction 36 { 37 40 public AddOutputRootAction() 41 { 42 super(); 43 } 44 45 50 protected Collection getBottomsToAdd() 51 { 52 Collection bottomsToAdd = new ArrayList (); 53 54 ResourceSelectionDialog resourceSelectionDialog = new ResourceSelectionDialog( 55 workbenchPart.getSite().getShell(), 56 ResourcesPlugin.getWorkspace().getRoot(), 57 Ecore2EcoreEditorPlugin.INSTANCE.getString("_UI_SelectOutputEcoreModels_label")); resourceSelectionDialog.open(); 59 60 Object [] result = resourceSelectionDialog.getResult(); 61 62 if (result != null) 63 { 64 65 for (int i = 0; i < result.length; i++) 66 { 67 IResource resource = (IResource)result[i]; 68 69 if (resource.getType() == IResource.FILE && "ecore".equals(resource.getFullPath().getFileExtension())) { 71 bottomsToAdd.addAll(((Ecore2EcoreEditor)workbenchPart).getEditingDomain().getResourceSet().getResource( 72 URI.createPlatformResourceURI(resource.getFullPath().toString()), 73 true).getContents()); 74 } 75 } 76 } 77 78 return bottomsToAdd; 79 } 80 } | Popular Tags |