Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2008-06-13 15:21:46 +0000
committerEike Stepper2008-06-13 15:21:46 +0000
commit94ad0c7cf2c2807ce80217687ce907d8839bbc79 (patch)
treecb87c2785eb9dd53dcbdc6817850a9cf4fdc5556 /plugins
parent2c592fa6dcf28ed07d71563506f66be70bd7e803 (diff)
downloadcdo-94ad0c7cf2c2807ce80217687ce907d8839bbc79.tar.gz
cdo-94ad0c7cf2c2807ce80217687ce907d8839bbc79.tar.xz
cdo-94ad0c7cf2c2807ce80217687ce907d8839bbc79.zip
[237093] [UI] Persisting dynamic models fails
https://bugs.eclipse.org/bugs/show_bug.cgi?id=237093
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/model1.ecore30
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/PackageRegistryTest.java44
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterPackagesAction.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java7
4 files changed, 61 insertions, 23 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests/model1.ecore b/plugins/org.eclipse.emf.cdo.tests/model1.ecore
index 9c39d345f6..716968f5d2 100644
--- a/plugins/org.eclipse.emf.cdo.tests/model1.ecore
+++ b/plugins/org.eclipse.emf.cdo.tests/model1.ecore
@@ -3,11 +3,12 @@
xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="model1"
nsURI="http://www.eclipse.org/emf/CDO/tests/model1/1.0.0" nsPrefix="model1">
- <eClassifiers xsi:type="ecore:EClass" name="Company">
- <eStructuralFeatures xsi:type="ecore:EReference" name="test" eType="ecore:EClass http://www.eclipse.org/emf/2002/Ecore#//EClass"/>
+ <eClassifiers xsi:type="ecore:EClass" name="Address">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="street" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="city" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+ </eClassifiers>
+ <eClassifiers xsi:type="ecore:EClass" name="Company" eSuperTypes="#//Address">
<eStructuralFeatures xsi:type="ecore:EReference" name="categories" upperBound="-1"
eType="#//Category" containment="true"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="suppliers" upperBound="-1"
@@ -19,19 +20,15 @@
<eStructuralFeatures xsi:type="ecore:EReference" name="salesOrders" upperBound="-1"
eType="#//SalesOrder" containment="true"/>
</eClassifiers>
- <eClassifiers xsi:type="ecore:EClass" name="Supplier">
- <eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
- <eStructuralFeatures xsi:type="ecore:EAttribute" name="street" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
- <eStructuralFeatures xsi:type="ecore:EAttribute" name="city" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+ <eClassifiers xsi:type="ecore:EClass" name="Supplier" eSuperTypes="#//Address">
<eStructuralFeatures xsi:type="ecore:EReference" name="purchaseOrders" upperBound="-1"
eType="#//PurchaseOrder" eOpposite="#//PurchaseOrder/supplier"/>
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="preferred" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EBoolean"
+ defaultValueLiteral="true"/>
</eClassifiers>
- <eClassifiers xsi:type="ecore:EClass" name="Customer">
- <eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
- <eStructuralFeatures xsi:type="ecore:EAttribute" name="street" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
- <eStructuralFeatures xsi:type="ecore:EAttribute" name="city" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
- <eStructuralFeatures xsi:type="ecore:EReference" name="salesOrders" upperBound="-1"
- eType="#//SalesOrder" eOpposite="#//SalesOrder/customer"/>
+ <eClassifiers xsi:type="ecore:EClass" name="Customer" eSuperTypes="#//Address">
+ <eStructuralFeatures xsi:type="ecore:EReference" name="salesOrders" unique="false"
+ upperBound="-1" eType="#//SalesOrder" eOpposite="#//SalesOrder/customer"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Order">
<eStructuralFeatures xsi:type="ecore:EReference" name="orderDetails" upperBound="-1"
@@ -65,5 +62,14 @@
<eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="orderDetails" upperBound="-1"
eType="#//OrderDetail" eOpposite="#//OrderDetail/product"/>
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="vat" eType="#//VAT" defaultValueLiteral="vat15"/>
+ </eClassifiers>
+ <eClassifiers xsi:type="ecore:EEnum" name="VAT">
+ <eLiterals name="vat0"/>
+ <eLiterals name="vat7" value="7"/>
+ <eLiterals name="vat15" value="15"/>
+ </eClassifiers>
+ <eClassifiers xsi:type="ecore:EClass" name="OrderAddress" eSuperTypes="#//Address #//Order #//OrderDetail">
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="testAttribute" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EBoolean"/>
</eClassifiers>
</ecore:EPackage>
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/PackageRegistryTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/PackageRegistryTest.java
index 29d3405339..bce17fc097 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/PackageRegistryTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/PackageRegistryTest.java
@@ -38,6 +38,8 @@ import org.eclipse.emf.cdo.util.CDOUtil;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EAttribute;
import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EFactory;
+import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
@@ -308,18 +310,44 @@ public class PackageRegistryTest extends AbstractCDOTest
}
}
- /**
- * TODO Fix testDynamicPackage()
- */
- public void _testDynamicPackage() throws Exception
+ public void testDynamicPackageFactory() throws Exception
{
{
- // Obtain model
EPackage model1 = loadModel("model1.ecore");
- // EClass supplierClass = (EClass)model1.getEClassifier("Supplier");
- // EStructuralFeature firstFeature =
- // supplierClass.getEStructuralFeatures().get(0);
+ EClass companyClass = (EClass)model1.getEClassifier("Company");
+ EAttribute nameAttribute = (EAttribute)companyClass.getEStructuralFeature("name");
+
+ // Create resource in session 1
+ CDOSession session = openSession();
+ session.getPackageRegistry().putEPackage(model1);
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource res = transaction.createResource("/res");
+
+ EFactory factory = model1.getEFactoryInstance();
+ EObject company = factory.create(companyClass);
+ company.eSet(nameAttribute, "Eike");
+ res.getContents().add(company);
+ transaction.commit();
+ }
+
+ {
+ // Load resource in session 2
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource res = transaction.getResource("/res");
+ CDOObject company = (CDOObject)res.getContents().get(0);
+ EClass companyClass = company.eClass();
+ EAttribute nameAttribute = (EAttribute)companyClass.getEStructuralFeature("name");
+ String name = (String)company.eGet(nameAttribute);
+ assertEquals("Eike", name);
+ }
+ }
+
+ public void testDynamicPackageNewInstance() throws Exception
+ {
+ {
+ EPackage model1 = loadModel("model1.ecore");
EClass companyClass = (EClass)model1.getEClassifier("Company");
EAttribute nameAttribute = (EAttribute)companyClass.getEStructuralFeature("name");
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterPackagesAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterPackagesAction.java
index 84d8e9d0e2..27cfe941c6 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterPackagesAction.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterPackagesAction.java
@@ -103,6 +103,9 @@ public abstract class RegisterPackagesAction extends SessionAction
protected abstract List<EPackage> getEPackages(IWorkbenchPage page, CDOSession session);
+ /**
+ * @see https://bugs.eclipse.org/237093
+ */
private void fixEPackage(EPackage ePackage)
{
for (EClassifier classifier : ePackage.getEClassifiers())
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java
index e2c2657c2e..0fc8889282 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java
@@ -61,7 +61,6 @@ import org.eclipse.emf.edit.domain.IEditingDomainProvider;
import org.eclipse.emf.edit.provider.AdapterFactoryItemDelegator;
import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
import org.eclipse.emf.edit.provider.ReflectiveItemProviderAdapterFactory;
-import org.eclipse.emf.edit.provider.ComposedAdapterFactory.Descriptor.Registry;
import org.eclipse.emf.edit.provider.resource.ResourceItemProviderAdapterFactory;
import org.eclipse.emf.edit.ui.action.EditingDomainActionBarContributor;
import org.eclipse.emf.edit.ui.celleditor.AdapterFactoryTreeEditor;
@@ -745,8 +744,10 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
*/
protected void initializeEditingDomain()
{
- Registry registry = EMFEditPlugin.getComposedAdapterFactoryDescriptorRegistry();
+ ComposedAdapterFactory.Descriptor.Registry registry = EMFEditPlugin.getComposedAdapterFactoryDescriptorRegistry();
adapterFactory = new ComposedAdapterFactory(registry);
+ adapterFactory.addAdapterFactory(new ResourceItemProviderAdapterFactory());
+ adapterFactory.addAdapterFactory(new ReflectiveItemProviderAdapterFactory());
}
/**
@@ -1911,7 +1912,7 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
*/
public void menuAboutToShow(IMenuManager menuManager)
{
- ((IMenuListener)getEditorSite().getActionBarContributor()).menuAboutToShow(menuManager);
+ menuAboutToShowGen(menuManager);
MenuManager submenuManager = new MenuManager("New Root");
if (populateNewRoot(submenuManager))
{

Back to the top