Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [EMF Forms] Custom Control Area Questions(Deprecated code + java.lang.IllegalArgumentException: The feature '<some feature>' is not a valid feature)
[EMF Forms] Custom Control Area Questions [message #1715532] Tue, 24 November 2015 09:47 Go to next message
Teohari Simona is currently offline Teohari SimonaFriend
Messages: 40
Registered: September 2015
Member
Hello,

I am trying to create a simple custom control area with one label and 2 textfields (on the same row), by following your tutorial from http://eclipsesource.com/blogs/tutorials/emf-forms-custom-control-areas/.
I have an EClass in the ecore model called MinimumDurationType which has a "days" attribute and a "seconds" attribute, which numbers I want to display in the textfields.

Label <textfield with nr of days> <textfield with nr of seconds>

I created a class that implements the ECPHardcodedReferences interface for the needed domain model references and now I have a problem in creating the class that actually renders the custom control area by extending the ECPAbstractCustomControlSWT.

@Override
public Control renderControl(SWTGridCell cell, Composite parent)
throws NoRendererFoundException, NoPropertyDescriptorFoundExeption {

Composite mainComposite = new Composite(parent, SWT.NONE);
mainComposite.setLayout(new FillLayout(SWT.VERTICAL));

Label durationAttributes=new Label(mainComposite, SWT.NONE);
durationAttributes.setText("Minimum Duration [d/s]");
durationAttributes.setAlignment(SWT.CENTER);
VDomainModelReference domainModelRefMinDurationDays = getResolvedDomainModelReference(MyPackage.eINSTANCE.getMinimumDurationType_Days());
VDomainModelReference domainModelRefMinDurationSec = getResolvedDomainModelReference(MyPackage.eINSTANCE.getMinimumDurationType_Seconds());

getControl(SWTControl.class, domainModelRefMinDurationDays).createControl(mainComposite);
getControl(SWTControl.class, domainModelRefMinDurationSec).createControl(mainComposite);
return parent;

}

I saw that this code is deprecated. Can you please tell me what class should I use instead of the SWTControl? Or what mechanism? I did not found any information about this till now.

Below I have also an error when I try to run this.

!ENTRY org.eclipse.e4.ui.workbench 4 0 2015-11-24 11:29:40.240
!MESSAGE
!STACK 0
java.lang.IllegalArgumentException: The feature 'days' is not a valid feature
at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eSetting(BasicEObjectImpl.java:1595)
at org.eclipse.emf.ecp.edit.spi.ECPAbstractControl.getFirstSetting(ECPAbstractControl.java:213)
at org.eclipse.emf.ecp.edit.internal.swt.controls.StringControl.getTextWidgetStyle(StringControl.java:45)
at org.eclipse.emf.ecp.edit.internal.swt.controls.AbstractTextControl.createTextWidget(AbstractTextControl.java:64)


Thank you,
S.
Re: [EMF Forms] Custom Control Area Questions [message #1715671 is a reply to message #1715532] Wed, 25 November 2015 08:04 Go to previous messageGo to next message
Eugen Neufeld is currently offline Eugen NeufeldFriend
Messages: 174
Registered: May 2015
Senior Member
Hi Simona,
The code looks ok. But currently you simple have a custom control for a vertical Layout. Wink
So the Problem is here:
java.lang.IllegalArgumentException: The feature 'days' is not a valid feature
at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eSetting(BasicEObjectImpl.java:1595)

This means, that the EObject the Feature MyPackage.eINSTANCE.getMinimumDurationType_Days() is retrieved from doesn't contain such a feature.
So probably you have something like this as a model: a -> b -> days
You pass in a in the root render call, and the custom control now cannot handle this. You have to provide a full path just like with any other DomainModelReference.
If your model is indeed MinimumDurationType -> Days then check whether you have regenerated you model.

Cheers,
Eugen


--
Eugen Neufeld

Get professional Eclipse developer support:
http://eclipsesource.com/en/services/developer-support/
Re: [EMF Forms] Custom Control Area Questions [message #1715782 is a reply to message #1715671] Thu, 26 November 2015 08:27 Go to previous messageGo to next message
Teohari Simona is currently offline Teohari SimonaFriend
Messages: 40
Registered: September 2015
Member
Hi Eugen,

Can you please tell me how exactly should I create this full path for the domain model reference?

Actually, for this custom control the path should be like this:

AType->BType->CType->MinimumDurationType which has the attributes "days" and "seconds".

I just add the references and attributes to the features list in getNeededDomainModelReferences()?

@Override
public Set<VDomainModelReference> getNeededDomainModelReferences() {
Set<VDomainModelReference> features = new LinkedHashSet<VDomainModelReference>();

VFeaturePathDomainModelReference feature1 = VViewFactory.eINSTANCE
.createFeaturePathDomainModelReference();
feature1.setDomainModelEFeature(MyPackage.eINSTANCE.getAType_BTypeRef());
features.add(feature1);

VFeaturePathDomainModelReference feature2= VViewFactory.eINSTANCE
.createFeaturePathDomainModelReference();
feature2.setDomainModelEFeature(MyPackage.eINSTANCE.getBType_CTypeRef);
features.add(feature2);

VFeaturePathDomainModelReference feature3 = VViewFactory.eINSTANCE
.createFeaturePathDomainModelReference();
feature3.setDomainModelEFeature(MyPackage.eINSTANCE.getCType_MinimumDurationType);
features.add(feature3);

VFeaturePathDomainModelReference feature4 = VViewFactory.eINSTANCE
.createFeaturePathDomainModelReference();
feature4.setDomainModelEFeature(MyPackage.eINSTANCE.getMinimumDurationType_Days());
features.add(feature4);

VFeaturePathDomainModelReference feature5 = VViewFactory.eINSTANCE
.createFeaturePathDomainModelReference();
feature5.setDomainModelEFeature(MyPackage.eINSTANCE.getMinimumDurationType_Seconds());
features.add(feature5);

return features;
}

It did not work also.

Thank you,
S.
Re: [EMF Forms] Custom Control Area Questions [message #1715833 is a reply to message #1715782] Thu, 26 November 2015 13:41 Go to previous messageGo to next message
Eugen Neufeld is currently offline Eugen NeufeldFriend
Messages: 174
Registered: May 2015
Senior Member
Hi Simona,
The path must be added to the feature itself.
This should work:
@Override
public Set<VDomainModelReference> getNeededDomainModelReferences() {
Set<VDomainModelReference> features = new LinkedHashSet<VDomainModelReference>();

VFeaturePathDomainModelReference featureDays = VViewFactory.eINSTANCE.createFeaturePathDomainModelReference();
featureDays.setDomainModelEFeature(MyPackage.eINSTANCE.getMinimumDurationType_Days());
featureDays.getDomainModelEReferencePath().add(MyPackage.eINSTANCE.getAType_BTypeRef());
featureDays.getDomainModelEReferencePath().add(MyPackage.eINSTANCE.getBType_CTypeRef());
featureDays.getDomainModelEReferencePath().add(MyPackage.eINSTANCE.getCType_MinimumDurationType());
features.add(featureDays);

VFeaturePathDomainModelReference featureSeconds = VViewFactory.eINSTANCE.createFeaturePathDomainModelReference();
featureSeconds.setDomainModelEFeature(MyPackage.eINSTANCE.getMinimumDurationType_Seconds());
featureSeconds.getDomainModelEReferencePath().add(MyPackage.eINSTANCE.getAType_BTypeRef());
featureSeconds.getDomainModelEReferencePath().add(MyPackage.eINSTANCE.getBType_CTypeRef());
featureSeconds.getDomainModelEReferencePath().add(MyPackage.eINSTANCE.getCType_MinimumDurationType());
features.add(featureSeconds);

return features;
}

Cheers,
Eugen


--
Eugen Neufeld

Get professional Eclipse developer support:
http://eclipsesource.com/en/services/developer-support/
Re: [EMF Forms] Custom Control Area Questions [message #1715852 is a reply to message #1715833] Thu, 26 November 2015 16:03 Go to previous messageGo to next message
Teohari Simona is currently offline Teohari SimonaFriend
Messages: 40
Registered: September 2015
Member
Hi,

Yes, that makes sense now Smile . I have to change also the code from renderControl method? Unfortunately, now I have a NullPointerException.

!ENTRY org.eclipse.e4.ui.workbench 4 0 2015-11-26 17:17:27.720
!MESSAGE
!STACK 0
java.lang.NullPointerException
at org.eclipse.emf.ecp.view.internal.editor.controls.TableDomainModelReferenceTester.isApplicable(TableDomainModelReferenceTester.java:56)
at org.eclipse.emf.ecp.internal.edit.ControlFactoryImpl.getControlCandidate(ControlFactoryImpl.java:241)
at org.eclipse.emf.ecp.internal.edit.ControlFactoryImpl.createControl(ControlFactoryImpl.java:151)
at org.eclipse.emf.ecp.view.spi.custom.swt.ECPAbstractCustomControlSWT.getControl(ECPAbstractCustomControlSWT.java:493)
at com.siemens.vixe.customarea.twotextfields.TwoTextfieldsCustomArea.renderControl(TwoTextfieldsCustomArea.java:58)
at org.eclipse.emf.ecp.view.spi.custom.swt.CustomControlSWTRenderer.renderControl(CustomControlSWTRenderer.java:155)
at org.eclipse.emfforms.spi.swt.core.AbstractSWTRenderer.render(AbstractSWTRenderer.java:198)
at org.eclipse.emf.ecp.view.spi.horizontal.swt.HorizontalLayoutSWTRenderer.renderControl(HorizontalLayoutSWTRenderer.java:144)
at org.eclipse.emfforms.spi.swt.core.AbstractSWTRenderer.render(AbstractSWTRenderer.java:198)

Best regards,
S.
Re: [EMF Forms] Custom Control Area Questions [message #1716054 is a reply to message #1715852] Mon, 30 November 2015 21:46 Go to previous messageGo to next message
Eugen Neufeld is currently offline Eugen NeufeldFriend
Messages: 174
Registered: May 2015
Senior Member
Hi,
As I don't know what you changed in the render method, I cannot say why you have a NPE.
Can you share your renderControl code?

Cheers,
Eugen


--
Eugen Neufeld

Get professional Eclipse developer support:
http://eclipsesource.com/en/services/developer-support/
Re: [EMF Forms] Custom Control Area Questions [message #1716197 is a reply to message #1715852] Wed, 02 December 2015 07:56 Go to previous messageGo to next message
Teohari Simona is currently offline Teohari SimonaFriend
Messages: 40
Registered: September 2015
Member
Hi Eugen,

I did not changed anything.
I only asked if I should change something in there also.

The method is described in my initial post.

Tx,
Simona
Re: [EMF Forms] Custom Control Area Questions [message #1716216 is a reply to message #1716197] Wed, 02 December 2015 09:27 Go to previous messageGo to next message
Eugen Neufeld is currently offline Eugen NeufeldFriend
Messages: 174
Registered: May 2015
Senior Member
Hi Simona,
I see.
Can you check whether org.eclipse.emf.ecp.view.spi.custom.model.impl.VCustomDomainModelReferenceImpl.resolve(EObject) is called and the result is true.
It looks like the domain model is not fully resolved.

Cheers,
Eugen


--
Eugen Neufeld

Get professional Eclipse developer support:
http://eclipsesource.com/en/services/developer-support/
Re: [EMF Forms] Custom Control Area Questions [message #1716236 is a reply to message #1716216] Wed, 02 December 2015 12:00 Go to previous message
Teohari Simona is currently offline Teohari SimonaFriend
Messages: 40
Registered: September 2015
Member
Hi,

Yes you are right, before this NPE, it appeard five times this error:

!ENTRY org.eclipse.emf.ecp.view.model 2 0 2015-12-02 13:37:21.746
!MESSAGE Not resolved: org.eclipse.emf.ecp.view.spi.custom.model.impl.VCustomDomainModelReferenceImpl@16a6dc21 (changeListener: null, bundleName: com.customarea.twotextfields.renderer, className: com.customarea.twotextfields.TwoTextfieldsDomainModelReference, controlChecked: true) on control org.eclipse.emf.ecp.view.spi.custom.model.impl.VCustomControlImpl@baa9ce4 (name: Minimum Constraint, label: null, visible: true, enabled: true, readonly: false) (labelAlignment: None) (bundleName: com.customarea.twotextfields.renderer, className: com.customarea.twotextfields.TwoTextfieldsCustomArea)

I still had one stupid error in getNeededDomainModelReferences() caused by the old copy/paste Sad.. I solved it now, sorry about that.
Now it works like a charm!

Thank you very much!
Simona
Previous Topic:[EMF Forms] opening a view model hangs for very long time
Next Topic:[EMF Forms] Generic Custom Control
Goto Forum:
  


Current Time: Thu Mar 28 15:24:25 GMT 2024

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

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

Back to the top