summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-12-19 07:54:52 (EST)
committerEike Stepper2007-12-19 07:54:52 (EST)
commitc2485924e9781add057687cbd7ffa419df31b471 (patch)
tree73904f5b7c14147b5728128df22e8c75d5c0c58c
parente1ec52f74c8cbfb72c17c26bbacd5e4d74938a19 (diff)
downloadcdo-c2485924e9781add057687cbd7ffa419df31b471.zip
cdo-c2485924e9781add057687cbd7ffa419df31b471.tar.gz
cdo-c2485924e9781add057687cbd7ffa419df31b471.tar.bz2
[213417] Provide action to import resources
https://bugs.eclipse.org/bugs/show_bug.cgi?id=213417
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ImportResourceAction.java25
-rw-r--r--plugins/org.eclipse.emf.cdo/META-INF/MANIFEST.MF2
2 files changed, 22 insertions, 5 deletions
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ImportResourceAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ImportResourceAction.java
index 6fada30..ab0a1f4 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ImportResourceAction.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ImportResourceAction.java
@@ -4,9 +4,13 @@ import org.eclipse.emf.cdo.CDOTransaction;
import org.eclipse.emf.cdo.CDOView;
import org.eclipse.emf.common.ui.dialogs.ResourceDialog;
+import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.SWT;
@@ -23,6 +27,7 @@ import org.eclipse.ui.IWorkbenchPage;
import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
/**
* @author Eike Stepper
@@ -71,13 +76,25 @@ public class ImportResourceAction extends ViewAction
protected void doRun() throws Exception
{
CDOTransaction transaction = getTransaction();
- Resource source = transaction.getResourceSet().getResource(sourceURI, true);
+
+ // Source ResourceSet
+ ResourceSet sourceSet = new ResourceSetImpl();
+ Map<String, Object> map = sourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap();
+ map.put("*", new XMIResourceFactoryImpl());
+ sourceSet.setPackageRegistry(transaction.getSession().getPackageRegistry());
+
+ // Source Resource
+ Resource source = sourceSet.getResource(sourceURI, true);
+ List<EObject> sourceContents = new ArrayList<EObject>(source.getContents());
+
+ // Target Resource
Resource target = transaction.createResource(targetPath);
+ EList<EObject> targetContents = target.getContents();
- List<EObject> contents = new ArrayList<EObject>(source.getContents());
- for (EObject root : contents)
+ // Move contents over
+ for (EObject root : sourceContents)
{
- target.getContents().add(root);
+ targetContents.add(root);
}
}
diff --git a/plugins/org.eclipse.emf.cdo/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo/META-INF/MANIFEST.MF
index 8386dcf..11d89f8 100644
--- a/plugins/org.eclipse.emf.cdo/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.emf.cdo/META-INF/MANIFEST.MF
@@ -10,7 +10,7 @@ Bundle-Activator: org.eclipse.emf.internal.cdo.bundle.Activator$Implementation
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.3.0,4.0.0)",
org.eclipse.emf.ecore;bundle-version="[2.3.0,3.0.0)";visibility:=reexport,
- org.eclipse.emf.ecore.xmi;bundle-version="[2.3.0,3.0.0)",
+ org.eclipse.emf.ecore.xmi;bundle-version="[2.3.0,3.0.0)";visibility:=reexport,
org.eclipse.emf.cdo.protocol;bundle-version="[0.8.0,0.9.0)";visibility:=reexport
Export-Package: org.eclipse.emf.cdo;version="0.8.0",
org.eclipse.emf.cdo.analyzer;version="0.8.0",