[EMF Forms] Custom Control Area Questions [message #1715532] |
Tue, 24 November 2015 09:47 |
Teohari Simona 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 #1716236 is a reply to message #1716216] |
Wed, 02 December 2015 12:00 |
Teohari Simona 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 .. I solved it now, sorry about that.
Now it works like a charm!
Thank you very much!
Simona
|
|
|
Powered by
FUDForum. Page generated in 0.04294 seconds