summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-08-06 02:31:28 (EDT)
committerEike Stepper2007-08-06 02:31:28 (EDT)
commitf3ae66f9e99e25249b5b5ac9e6e30508c2e3e2a6 (patch)
treedd747f225198ca1a1ccc2edbb7d38baac5441669
parentc58cae84c4b595eb675c85cdac885be4ec82dad5 (diff)
downloadcdo-f3ae66f9e99e25249b5b5ac9e6e30508c2e3e2a6.zip
cdo-f3ae66f9e99e25249b5b5ac9e6e30508c2e3e2a6.tar.gz
cdo-f3ae66f9e99e25249b5b5ac9e6e30508c2e3e2a6.tar.bz2
*** empty log message ***
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/PackageManagerDialog.java8
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOPackageType.java44
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOUtil.java54
3 files changed, 91 insertions, 15 deletions
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/PackageManagerDialog.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/PackageManagerDialog.java
index b0dd3f4..88be437 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/PackageManagerDialog.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/PackageManagerDialog.java
@@ -15,6 +15,7 @@ import org.eclipse.emf.cdo.internal.ui.SharedIcons;
import org.eclipse.emf.cdo.internal.ui.actions.RegisterCDOPackageAction;
import org.eclipse.emf.cdo.internal.ui.views.CDOItemProvider;
import org.eclipse.emf.cdo.protocol.model.CDOPackage;
+import org.eclipse.emf.cdo.util.CDOPackageType;
import org.eclipse.emf.cdo.util.CDOUtil;
import org.eclipse.net4j.util.ObjectUtil;
@@ -44,7 +45,6 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
-import java.util.Set;
import java.util.Map.Entry;
/**
@@ -58,8 +58,6 @@ public class PackageManagerDialog extends TitleAreaDialog
private static final String EMPTY = "";
- private final Set<String> persistentPackageURIs = CDOUtil.getPersistentPackageURIs();
-
private IWorkbenchPage page;
private CDOSession session;
@@ -170,7 +168,9 @@ public class PackageManagerDialog extends TitleAreaDialog
return "ECORE";
}
- return persistentPackageURIs.contains(((EPackage)ePackage).getNsURI()) ? "CDO" : "EMF";
+ String uri = ((EPackage)ePackage).getNsURI();
+ CDOPackageType packageType = CDOUtil.getPackageTypes().get(uri);
+ return packageType.toString();
}
protected String getCDOPackageText(CDOPackage cdoPackage)
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOPackageType.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOPackageType.java
new file mode 100644
index 0000000..f502220
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOPackageType.java
@@ -0,0 +1,44 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2007 Eike Stepper, Germany.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ **************************************************************************/
+package org.eclipse.emf.cdo.util;
+
+import org.eclipse.emf.internal.cdo.CDOAdapterImpl;
+import org.eclipse.emf.internal.cdo.CDOCallbackImpl;
+import org.eclipse.emf.internal.cdo.CDOObjectImpl;
+import org.eclipse.emf.internal.cdo.CDOStateMachine;
+
+/**
+ * @author Eike Stepper
+ */
+public enum CDOPackageType
+{
+ /**
+ * The type of <code>EPackages</code> that have been dedicatedly generated
+ * for CDO. Instances of <code>EClasses</code> of these packages are
+ * represented by {@link CDOObjectImpl} to the {@link CDOStateMachine}.
+ */
+ NATIVE,
+
+ /**
+ * The type of <code>EPackages</code> that have been normally generated for
+ * EMF. Instances of <code>EClasses</code> of these packages are represented
+ * by {@link CDOAdapterImpl} to the {@link CDOStateMachine}.
+ */
+ LEGACY,
+
+ /**
+ * The type of <code>EPackages</code> that have been normally generated for
+ * EMF and later converted to CDO. Instances of <code>EClasses</code> of
+ * these packages are represented by {@link CDOCallbackImpl} to the
+ * {@link CDOStateMachine}.
+ */
+ CONVERTED
+}
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 499b425..7bcf3fb 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
@@ -32,6 +32,7 @@ import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.EcoreFactory;
+import org.eclipse.emf.ecore.plugin.EcorePlugin;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.Resource.Factory.Registry;
import org.eclipse.emf.ecore.util.EcoreUtil;
@@ -47,11 +48,13 @@ import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.Platform;
-import java.util.HashSet;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.Constants;
+
+import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import java.util.Set;
/**
* @author Eike Stepper
@@ -60,6 +63,10 @@ public final class CDOUtil
{
public static final String EXT_POINT_NAME = "persistent_package";
+ private static Map<String, CDOPackageType> packageTypes;
+
+ public static final String CDO_VERSION_SUFFIX = "-CDO";
+
private CDOUtil()
{
}
@@ -67,21 +74,46 @@ public final class CDOUtil
/**
* Can only be used with Eclipse running!
*/
- public static Set<String> getPersistentPackageURIs()
+ public static synchronized Map<String, CDOPackageType> getPackageTypes()
{
- Set<String> result = new HashSet();
- IExtensionRegistry registry = Platform.getExtensionRegistry();
- IConfigurationElement[] elements = registry.getConfigurationElementsFor(OM.BUNDLE_ID, EXT_POINT_NAME);
- for (IConfigurationElement element : elements)
+ if (packageTypes == null)
{
- String uri = element.getAttribute("uri");
- if (!StringUtil.isEmpty(uri))
+ packageTypes = new HashMap();
+ IExtensionRegistry registry = Platform.getExtensionRegistry();
+
+ // Collect native packages
+ for (IConfigurationElement element : registry.getConfigurationElementsFor(OM.BUNDLE_ID, EXT_POINT_NAME))
+ {
+ String uri = element.getAttribute("uri");
+ if (!StringUtil.isEmpty(uri))
+ {
+ packageTypes.put(uri, CDOPackageType.NATIVE);
+ }
+ }
+
+ // Collect legacy and converted packages
+ for (IConfigurationElement element : registry.getConfigurationElementsFor(EcorePlugin.getPlugin().getBundle()
+ .getSymbolicName(), EcorePlugin.GENERATED_PACKAGE_PPID))
{
- result.add(uri);
+ String uri = element.getAttribute("uri");
+ if (!StringUtil.isEmpty(uri) && !packageTypes.containsKey(uri))
+ {
+ String bundleName = element.getContributor().getName();
+ Bundle bundle = Platform.getBundle(bundleName);
+ String version = (String)bundle.getHeaders().get(Constants.BUNDLE_VERSION);
+ if (version.endsWith(CDOUtil.CDO_VERSION_SUFFIX))
+ {
+ packageTypes.put(uri, CDOPackageType.CONVERTED);
+ }
+ else
+ {
+ packageTypes.put(uri, CDOPackageType.LEGACY);
+ }
+ }
}
}
- return result;
+ return packageTypes;
}
public static CDOSession openSession(IConnector connector, String repositoryName, EPackage.Registry delegate)