Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [EMF Forms] Generic Custom Control(Generic custom control used with multiple ecore models)
[EMF Forms] Generic Custom Control [message #1716274] Wed, 02 December 2015 15:57 Go to next message
Teohari Simona is currently offline Teohari SimonaFriend
Messages: 40
Registered: September 2015
Member
Hello,

I have 4 ecore models and I want to implement a generic custom control to apply to some of the attributes or references from all 4 models, but without causing a dependency of the project with the models.

I thought about creating a file plugin.properties that would contain some information like the canonical name of the class and the name of the attribute/reference that I want to be rendered.
For example:

com.company.model1.model.AType=ATypeAttribute
com.company.model2.model.BType=BTypeAttribute
com.company.model3.model.CType=CTypeReference
...

And in the renderer service to have something like this:

public class CustomControlSWTRendererService implements EMFFormsDIRendererService<VControl> {

@Override
public double isApplicable(VElement vElement, ViewModelContext viewModelContext) {
...
List<EStructuralFeature> listOfObjectsToBeRendered = getElementsToBeRendered();
for (EStructuralFeature feature : listOfObjectsToBeRendered) {
if (feature.equals(eStructuralFeature))
{
return 10;
}
}
return NOT_APPLICABLE;
}

public List<EStructuralFeature> getElementsToBeRendered(){

// parse plugin.properties

// instead of calling the Model1Package.eINSTANCE.getAType_ATypeAttribute() use EMF reflective API
}

My question is how do I use the EMF reflective API to do this? Or do you have another idea on how can I accomplish this generic control?

Best regards,
S.
Re: [EMF Forms] Generic Custom Control [message #1716350 is a reply to message #1716274] Thu, 03 December 2015 08:01 Go to previous messageGo to next message
Eugen Neufeld is currently offline Eugen NeufeldFriend
Messages: 174
Registered: May 2015
Senior Member
Hi Simona,
You can use org.eclipse.emf.ecore.EPackage.Registry.getEPackage(String) to retrieve the epackage. Then use org.eclipse.emf.ecore.EPackage.getEClassifier(String) to get the EClass and org.eclipse.emf.ecore.EClass.getEStructuralFeature(String) to get the feature. So you would need to have the nsuri, the classname and the feature name available.
Another alternative would be to use simple string matching.

Cheers,
Eugen


--
Eugen Neufeld

Get professional Eclipse developer support:
http://eclipsesource.com/en/services/developer-support/
Re: [EMF Forms] Generic Custom Control [message #1716413 is a reply to message #1716350] Thu, 03 December 2015 14:53 Go to previous message
Teohari Simona is currently offline Teohari SimonaFriend
Messages: 40
Registered: September 2015
Member
Hi Eugen,

Thank you! It worked!

Best regards,
Simona
Previous Topic:[EMF Forms] Custom Control Area Questions
Next Topic:org.eclipse.emf.edapt.history.reconstruction.EcoreForwardReconstructor$EcoreReconstructorSwitch 124
Goto Forum:
  


Current Time: Thu Apr 25 17:29:44 GMT 2024

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

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

Back to the top