summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-12-20 03:53:34 (EST)
committerEike Stepper2007-12-20 03:53:34 (EST)
commitcfc6948f35e94947b461b830025f7c7a022a01b9 (patch)
treede4be5942870fe8700269e6ebd36de77cdc72add
parent1d9cda8de09d5e10af9b361f5d36c647c2edd413 (diff)
downloadcdo-cfc6948f35e94947b461b830025f7c7a022a01b9.zip
cdo-cfc6948f35e94947b461b830025f7c7a022a01b9.tar.gz
cdo-cfc6948f35e94947b461b830025f7c7a022a01b9.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/src/org/eclipse/emf/internal/cdo/CDOCallbackImpl.java29
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/FSMUtil.java67
2 files changed, 62 insertions, 34 deletions
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOCallbackImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOCallbackImpl.java
index 0a4d805..8c1620d 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOCallbackImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOCallbackImpl.java
@@ -10,11 +10,15 @@
**************************************************************************/
package org.eclipse.emf.internal.cdo;
+import org.eclipse.emf.cdo.CDOView;
+
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.InternalEObject;
+import org.eclipse.emf.ecore.impl.CDOAware;
import org.eclipse.emf.ecore.impl.CDOCallback;
import org.eclipse.emf.ecore.impl.EObjectImpl;
+import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.internal.cdo.bundle.OM;
import org.eclipse.emf.internal.cdo.util.FSMUtil;
@@ -141,4 +145,29 @@ public class CDOCallbackImpl extends CDOLegacyImpl implements CDOCallback
}
}
}
+
+ public static InternalCDOObject adapt(Object object, CDOView view) throws Throwable
+ {
+ if (object instanceof CDOAware)
+ {
+ CDOAware aware = (CDOAware)object;
+ CDOCallbackImpl callback = (CDOCallbackImpl)aware.getCDOCallback();
+ if (callback == null)
+ {
+ InternalEObject instance = (InternalEObject)aware;
+ if (instance.eIsProxy())
+ {
+ instance = (InternalEObject)EcoreUtil.resolve(instance, view.getResourceSet());
+ }
+
+ callback = new CDOCallbackImpl(instance);
+ aware.setCDOCallback(callback);
+ instance.eAdapters().add(callback);
+ }
+
+ return callback;
+ }
+
+ return null;
+ }
}
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 baddc47..40b9347 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
@@ -27,6 +27,7 @@ import org.eclipse.emf.internal.cdo.CDOViewImpl;
import org.eclipse.emf.internal.cdo.InternalCDOObject;
import org.eclipse.emf.internal.cdo.bundle.OM;
+import java.lang.reflect.Method;
import java.util.Collection;
import java.util.Iterator;
@@ -35,10 +36,35 @@ import java.util.Iterator;
*/
public final class FSMUtil
{
+ private static Method adaptLegacyMethod = initAdaptLegacyMethod();
+
private FSMUtil()
{
}
+ private static Method initAdaptLegacyMethod()
+ {
+ try
+ {
+ Class<?> c = Class.forName("org.eclipse.emf.internal.cdo.CDOCallbackImpl");
+ if (c != null)
+ {
+ final Class<?>[] params = { Object.class, CDOView.class };
+ Method method = c.getDeclaredMethod("adapt", params);
+ if (method != null)
+ {
+ return method;
+ }
+ }
+ }
+ catch (Throwable ignore)
+ {
+ }
+
+ OM.LOG.info("Legacy system not available");
+ return null;
+ }
+
public static boolean isTransient(CDOObject object)
{
CDOState state = object.cdoState();
@@ -82,17 +108,16 @@ public final class FSMUtil
}
}
- try
+ if (adaptLegacyMethod != null)
{
- InternalCDOObject callback = adaptLegacy(object, view);
- if (callback != null)
+ try
{
- return callback;
+ return (InternalCDOObject)adaptLegacyMethod.invoke(null, object, view);
+ }
+ catch (Throwable t)
+ {
+ OM.LOG.info(t);
}
- }
- catch (Throwable t)
- {
- OM.LOG.info(t);
}
if (object instanceof InternalEObject)
@@ -111,32 +136,6 @@ public final class FSMUtil
return null;
}
- public static InternalCDOObject adaptLegacy(Object object, CDOView view) throws Throwable
- {
- if (object instanceof org.eclipse.emf.ecore.impl.CDOAware)
- {
- org.eclipse.emf.ecore.impl.CDOAware aware = (org.eclipse.emf.ecore.impl.CDOAware)object;
- org.eclipse.emf.internal.cdo.CDOCallbackImpl callback = (org.eclipse.emf.internal.cdo.CDOCallbackImpl)aware
- .getCDOCallback();
- if (callback == null)
- {
- InternalEObject instance = (InternalEObject)aware;
- if (instance.eIsProxy())
- {
- instance = (InternalEObject)EcoreUtil.resolve(instance, view.getResourceSet());
- }
-
- callback = new org.eclipse.emf.internal.cdo.CDOCallbackImpl(instance);
- aware.setCDOCallback(callback);
- instance.eAdapters().add(callback);
- }
-
- return callback;
- }
-
- return null;
- }
-
public static Iterator<InternalCDOObject> iterator(Collection<?> instances, final CDOViewImpl view)
{
final Iterator<?> delegate = instances.iterator();