summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-08-03 18:14:24 (EDT)
committerEike Stepper2007-08-03 18:14:24 (EDT)
commitb5ed745b45320f38f25d86432188c06c51bbe691 (patch)
treeaa7398892385afe73f37d07d9d8ea7c8d1a6dd45
parentf5abb9a9b32e8eda188dbea2fc1d2f6023acf9ec (diff)
downloadcdo-b5ed745b45320f38f25d86432188c06c51bbe691.zip
cdo-b5ed745b45320f38f25d86432188c06c51bbe691.tar.gz
cdo-b5ed745b45320f38f25d86432188c06c51bbe691.tar.bz2
*** empty log message ***
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOUtil.java27
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/EMFUtil.java1
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStateMachine.java4
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/FSMUtil.java14
4 files changed, 39 insertions, 7 deletions
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOUtil.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOUtil.java
index 5a06137..9ebfe6d 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOUtil.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOUtil.java
@@ -28,6 +28,8 @@ import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EAttribute;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EGenericType;
+import org.eclipse.emf.ecore.EModelElement;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.EReference;
@@ -37,13 +39,18 @@ import org.eclipse.emf.ecore.resource.Resource.Factory.Registry;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.ecore.util.EcoreUtil.Copier;
import org.eclipse.emf.internal.cdo.CDOSessionImpl;
+import org.eclipse.emf.internal.cdo.CDOStateMachine;
+import org.eclipse.emf.internal.cdo.CDOViewImpl;
+import org.eclipse.emf.internal.cdo.InternalCDOObject;
import org.eclipse.emf.internal.cdo.bundle.OM;
+import org.eclipse.emf.internal.cdo.util.FSMUtil;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.Platform;
import java.util.HashSet;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -227,6 +234,7 @@ public final class CDOUtil
* @return the copy.
* @see EcoreUtil#copy(EObject)
*/
+ @Deprecated
public static EObject copy(EObject eObject, CDOView view)
{
Copier copier = new CDOCopier(view);
@@ -235,9 +243,28 @@ public final class CDOUtil
return result;
}
+ public static void load(EObject eObject)
+ {
+ if (eObject instanceof EModelElement || eObject instanceof EGenericType)
+ {
+ return;
+ }
+
+ InternalCDOObject cdoObject = FSMUtil.adapt(eObject, null);
+ CDOStateMachine.INSTANCE.read(cdoObject);
+
+ CDOViewImpl view = (CDOViewImpl)cdoObject.cdoView();
+ for (Iterator<InternalCDOObject> it = FSMUtil.iterator(cdoObject.eContents(), view); it.hasNext();)
+ {
+ InternalCDOObject content = it.next();
+ load(content);
+ }
+ }
+
/**
* @author Eike Stepper
*/
+ @Deprecated
public static final class CDOCopier extends Copier
{
private static final long serialVersionUID = 1L;
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/EMFUtil.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/EMFUtil.java
index 1e5ad62..2625065 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/EMFUtil.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/EMFUtil.java
@@ -72,6 +72,7 @@ public final class EMFUtil
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("*", new XMIResourceFactoryImpl());
Resource resource = resourceSet.createResource(URI.createFileURI(fileName));
+ CDOUtil.load(root);
EObject copy = EcoreUtil.copy(root);
resource.getContents().add(copy);
try
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStateMachine.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStateMachine.java
index 6b544db..70f61b1 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStateMachine.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStateMachine.java
@@ -201,9 +201,9 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent
transaction.registerNew(object);
// Attach content tree
- for (Iterator it = FSMUtil.iterator(object.eContents(), transaction); it.hasNext();)
+ for (Iterator<InternalCDOObject> it = FSMUtil.iterator(object.eContents(), transaction); it.hasNext();)
{
- InternalCDOObject content = (InternalCDOObject)it.next();
+ InternalCDOObject content = it.next();
INSTANCE.process(content, CDOEvent.ATTACH, data);
}
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/FSMUtil.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/FSMUtil.java
index aaba0d0..c9cae66 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/FSMUtil.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/FSMUtil.java
@@ -50,6 +50,10 @@ public final class FSMUtil
return state == CDOState.TRANSIENT || state == CDOState.PREPARED_ATTACH;
}
+ /**
+ * @param view
+ * Only needed if object is a meta instance.
+ */
public static InternalCDOObject adapt(Object object, CDOView view)
{
if (object == null)
@@ -57,11 +61,6 @@ public final class FSMUtil
throw new IllegalArgumentException("object == null");
}
- if (view == null)
- {
- throw new IllegalArgumentException("view == null");
- }
-
if (object instanceof InternalCDOObject)
{
return (InternalCDOObject)object;
@@ -70,6 +69,11 @@ public final class FSMUtil
if (object instanceof EModelElement || object instanceof EGenericType)
{
InternalEObject eObject = (InternalEObject)object;
+ if (view == null)
+ {
+ throw new IllegalArgumentException("view == null");
+ }
+
if (eObject.eIsProxy())
{
EcoreUtil.resolve(eObject, view.getResourceSet());