Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [EMF Forms]Reference feature is not supported when using Dynamic EMF
icon4.gif  [EMF Forms]Reference feature is not supported when using Dynamic EMF [message #1486722] Tue, 25 November 2014 08:39 Go to next message
Yan Zhang is currently offline Yan ZhangFriend
Messages: 4
Registered: November 2014
Junior Member
First I create EMF Model dynamiclly
But when using the default ViewProvider (in package org.eclipse.emf.ecp.view.model.generator) to get View Model, the attribute faeture will be contained in the new view model ,while the reference feature can not.


Then I try to implement a ViewProvider myself, I use new CustomReflectiveItemProviderAdapterFactory() to construct the ComposedAdapterFactory instead of ReflectiveItemProviderAdapterFactory()
, then the reference feature will be contained in the new view model.

waiting for help, thanks!






Re: [EMF Forms]Reference feature is not supported when using Dynamic EMF [message #1488135 is a reply to message #1486722] Wed, 26 November 2014 10:41 Go to previous messageGo to next message
Jonas Helming is currently offline Jonas HelmingFriend
Messages: 699
Registered: July 2009
Senior Member
Hi,

I am not sure, whether I understand you issue, could you kindly
elaborate a bit more on what you are currently stuck with?

Best regards

Jonas

Am 25.11.2014 15:21, schrieb yan zhang:
> First I create EMF Model dynamiclly
> But when using the default ViewProvider (in package
> org.eclipse.emf.ecp.view.model.generator) to get View Model, the
> attribute faeture will be contained in the new view model ,while the
> reference feature can not.
>
>
> Then I try to implement a ViewProvider myself, I use new
> CustomReflectiveItemProviderAdapterFactory() to construct the
> ComposedAdapterFactory instead of ReflectiveItemProviderAdapterFactory()
> , then the reference feature will be contained in the new view model.
>
> waiting for help, thanks!
>
>
>
>
>
>
>


--
Get professional Eclipse developer support:
http://eclipsesource.com/en/services/developer-support/
Re: [EMF Forms]Reference feature is not supported when using Dynamic EMF [message #1489186 is a reply to message #1488135] Thu, 27 November 2014 06:52 Go to previous messageGo to next message
Yan Zhang is currently offline Yan ZhangFriend
Messages: 4
Registered: November 2014
Junior Member
Ok , you can see the following code.
First, I can get a EClass dynamically
public static EClass getEClass() {
		/*
		 * Instantiate EcoreFactory
		 */
		final EcoreFactory theCoreFactory = EcoreFactory.eINSTANCE;

		/*
		 * Create EClass instance to model BookStore class
		 */
		final EClass bookStoreEClass = theCoreFactory.createEClass();
		bookStoreEClass.setName("BookStore");

		/*
		 * Create EClass instance to model Book class
		 */
		final EClass bookEClass = theCoreFactory.createEClass();
		bookEClass.setName("Book");

		/*
		 * Instantiate EPackage and provide unique URI
		 * to identify this package
		 */
		final EPackage bookStoreEPackage = theCoreFactory.createEPackage();
		bookStoreEPackage.setName("BookStorePackage");
		bookStoreEPackage.setNsPrefix("bookStore");
		bookStoreEPackage.setNsURI("http:///com.ibm.dynamic.example.bookstore.ecore");
		/*
		 * Instantiate EcorePackage
		 */
		final EcorePackage theCorePackage = EcorePackage.eINSTANCE;

		/*
		 * Create attributes for BookStore class as specified in the model
		 */
		final EAttribute bookStoreOwner = theCoreFactory.createEAttribute();
		bookStoreOwner.setName("owner");
		bookStoreOwner.setEType(theCorePackage.getEString());
		final EAttribute bookStoreLocation = theCoreFactory.createEAttribute();
		bookStoreLocation.setName("location");
		bookStoreLocation.setEType(theCorePackage.getEString());
		final EReference bookStore_Books = theCoreFactory.createEReference();
		bookStore_Books.setName("books");
		bookStore_Books.setEType(bookEClass);
		bookStore_Books.setUpperBound(ETypedElement.UNBOUNDED_MULTIPLICITY);
		bookStore_Books.setContainment(true);
		bookStore_Books.setLowerBound(0);
		bookStore_Books.setUnique(true);
		bookStore_Books.setChangeable(true);
		/*
		 * Create attributes for Book class as defined in the model
		 */
		final EAttribute bookName = theCoreFactory.createEAttribute();
		bookName.setName("name");
		bookName.setEType(theCorePackage.getEString());
		final EAttribute bookISBN = theCoreFactory.createEAttribute();
		bookISBN.setName("isbn");
		bookISBN.setEType(theCorePackage.getEInt());
		/*
		 * final Add owner, location and final books attributes/references
		 * to BookStore class
		 */
		bookStoreEClass.getEStructuralFeatures().add(bookStoreOwner);
		bookStoreEClass.getEStructuralFeatures().add(bookStoreLocation);
		bookStoreEClass.getEStructuralFeatures().add(bookStore_Books);

		/*
		 * Add name and isbn attributes to Book class
		 */
		bookEClass.getEStructuralFeatures().add(bookName);
		bookEClass.getEStructuralFeatures().add(bookISBN);

		/*
		 * Place BookStore and Book classes in bookStoreEPackage
		 */
		bookStoreEPackage.getEClassifiers().add(bookStoreEClass);
		bookStoreEPackage.getEClassifiers().add(bookEClass);
		return bookStoreEClass;

	}


Then I use the returned EClass to get a UI component by EMF Forms.
EObject dummObject = EcoreUtil.create(bookStoreEClass);
			final ViewModelContext vmc = ViewModelContextFactory.INSTANCE.createViewModelContext(
				ViewProviderHelper.getView(dummyObject, null), dummyObject, new DefaultReferenceService());

			render = ECPSWTViewRenderer.INSTANCE.render(content, vmc);


The generated UI component should contain three kind of controls for three feature of bookstore, but it only contains two (owner and location, but not books), you can see screenshot (result.png), but the expected result should be like expected.png.
  • Attachment: result.png
    (Size: 27.46KB, Downloaded 143 times)
  • Attachment: expected.png
    (Size: 27.44KB, Downloaded 134 times)

[Updated on: Thu, 27 November 2014 06:59]

Report message to a moderator

Re: [EMF Forms]Reference feature is not supported when using Dynamic EMF [message #1489395 is a reply to message #1489186] Thu, 27 November 2014 10:28 Go to previous message
Jonas Helming is currently offline Jonas HelmingFriend
Messages: 699
Registered: July 2009
Senior Member
Hi,

the property type of containment references is by default "None". In
static EMF, this is set in the gen model. It has to be editable to be
shown in the UI.

Best regards

Jonas

Am 27.11.2014 07:52, schrieb yan zhang:
> Ok , you can see the following code.
> First, I can a EClass dynamically
> public static EClass getEClass() {
> /*
> * Instantiate EcoreFactory
> */
> final EcoreFactory theCoreFactory = EcoreFactory.eINSTANCE;
>
> /*
> * Create EClass instance to model BookStore class
> */
> final EClass bookStoreEClass = theCoreFactory.createEClass();
> bookStoreEClass.setName("BookStore");
>
> /*
> * Create EClass instance to model Book class
> */
> final EClass bookEClass = theCoreFactory.createEClass();
> bookEClass.setName("Book");
>
> /*
> * Instantiate EPackage and provide unique URI
> * to identify this package
> */
> final EPackage bookStoreEPackage = theCoreFactory.createEPackage();
> bookStoreEPackage.setName("BookStorePackage");
> bookStoreEPackage.setNsPrefix("bookStore");
>
> bookStoreEPackage.setNsURI("http:///com.ibm.dynamic.example.bookstore.ecore");
>
> /*
> * Instantiate EcorePackage
> */
> final EcorePackage theCorePackage = EcorePackage.eINSTANCE;
>
> /*
> * Create attributes for BookStore class as specified in the model
> */
> final EAttribute bookStoreOwner =
> theCoreFactory.createEAttribute();
> bookStoreOwner.setName("owner");
> bookStoreOwner.setEType(theCorePackage.getEString());
> final EAttribute bookStoreLocation =
> theCoreFactory.createEAttribute();
> bookStoreLocation.setName("location");
> bookStoreLocation.setEType(theCorePackage.getEString());
> final EReference bookStore_Books =
> theCoreFactory.createEReference();
> bookStore_Books.setName("books");
> bookStore_Books.setEType(bookEClass);
>
> bookStore_Books.setUpperBound(ETypedElement.UNBOUNDED_MULTIPLICITY);
> bookStore_Books.setContainment(true);
> bookStore_Books.setLowerBound(0);
> bookStore_Books.setUnique(true);
> bookStore_Books.setChangeable(true);
> /*
> * Create attributes for Book class as defined in the model
> */
> final EAttribute bookName = theCoreFactory.createEAttribute();
> bookName.setName("name");
> bookName.setEType(theCorePackage.getEString());
> final EAttribute bookISBN = theCoreFactory.createEAttribute();
> bookISBN.setName("isbn");
> bookISBN.setEType(theCorePackage.getEInt());
> /*
> * final Add owner, location and final books attributes/references
> * to BookStore class
> */
> bookStoreEClass.getEStructuralFeatures().add(bookStoreOwner);
> bookStoreEClass.getEStructuralFeatures().add(bookStoreLocation);
> bookStoreEClass.getEStructuralFeatures().add(bookStore_Books);
>
> /*
> * Add name and isbn attributes to Book class
> */
> bookEClass.getEStructuralFeatures().add(bookName);
> bookEClass.getEStructuralFeatures().add(bookISBN);
>
> /*
> * Place BookStore and Book classes in bookStoreEPackage
> */
> bookStoreEPackage.getEClassifiers().add(bookStoreEClass);
> bookStoreEPackage.getEClassifiers().add(bookEClass);
> return bookStoreEClass;
>
> }
>
> Then I use the returned EClass to do the following things.
> EObject dummObject = EcoreUtil.create(bookStoreEClass);
> final ViewModelContext vmc =
> ViewModelContextFactory.INSTANCE.createViewModelContext(
> ViewProviderHelper.getView(dummyObject, null),
> dummyObject, new DefaultReferenceService());
>
> render = ECPSWTViewRenderer.INSTANCE.render(content, vmc);
> The generated UI component should contain three kind of controls for
> three feature of bookstore, but it only contains two (owner and
> location, but not books)
>


--
Get professional Eclipse developer support:
http://eclipsesource.com/en/services/developer-support/
Previous Topic:[ECP] Difficulties with using an XCore model
Next Topic:Set Version of Plugins Generated from Ecore
Goto Forum:
  


Current Time: Sat Apr 20 02:20:54 GMT 2024

Powered by FUDForum. Page generated in 0.02964 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top