Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » Binding Ecore model object to ECP form custom control(Can't have two objects opened in two instances of ECP form with custom control. )
Binding Ecore model object to ECP form custom control [message #1713131] Sun, 01 November 2015 05:11 Go to next message
Francine Mising name is currently offline Francine Mising nameFriend
Messages: 21
Registered: July 2009
Junior Member
I am using Ecore modeled objects with forms that contain ECP custom controls. I open the first object in my ECP form. While it is still active, I open a second object in a second instance of the same ECP form. Viewing the second object, when I click on the custom control, it now has the first object. The call to retrieve the object from the modelRef, getValue(modelRef), seems to return the lastRerencedObject? How do I get the object that the form was opened with? What am I doing wrong?

Here is my custom control Editor class:

public class PrivilegesEditor extends ECPAbstractCustomControlSWT {

private FormToolkit toolkit;
private Composite privilegeArea;

/**
* The constructor.
*/
public PrivilegesEditor() {
}

@Override
protected void disposeCustomControl() {
if (!privilegeArea.isDisposed()) {
privilegeArea.dispose();
}

}

@Override
protected void handleContentValidation() {
// TODO Auto-generated method stub

}

@Override
public SWTGridDescription getGridDescription() {
return GridDescriptionFactory.INSTANCE.createSimpleGrid(1, 1, null);
}

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

VDomainModelReference modelRef = getResolvedDomainModelReference(SqladminPackage.eINSTANCE
.getSQLObjectWithPrivileges_Privileges());
EObjectContainmentWithInverseEList<Privilege> value = (EObjectContainmentWithInverseEList<Privilege>) getValue(modelRef);
SQLObjectWithPrivileges eobject = (SQLObjectWithPrivileges) value
.getEObject();

toolkit = new FormToolkit(parent.getDisplay());

privilegeArea = toolkit.createComposite(parent);
toolkit.adapt(privilegeArea);
privilegeArea.setLayout(new GridLayout(1, false));
privilegeArea
.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

boolean onlyShowRoles = false;
PrivilegesComposite privComp = new PrivilegesComposite(privilegeArea,
SWT.NONE, eobject, onlyShowRoles);
privComp.setLayoutData(new GridData(GridData.FILL_BOTH));
privilegeArea.layout();

return privilegeArea;
}

}

------------

-thanks,

Re: Binding Ecore model object to ECP form custom control [message #1713219 is a reply to message #1713131] Mon, 02 November 2015 13:27 Go to previous messageGo to next message
Eugen Neufeld is currently offline Eugen NeufeldFriend
Messages: 161
Registered: May 2015
Senior Member
Hi,
I don't get whats going on. You write:
"I open the first object in my ECP form. While it is still active, I open a second object in a second instance of the same ECP form. "
So you have called:
ECPSWTViewRenderer.INSTANCE.render() once or twice?
Did you reuse your View Model for both render steps?

Cheers,
Eugen


--
Eugen Neufeld

Get professional Eclipse developer support:
http://eclipsesource.com/en/services/developer-support/
Re: Binding Ecore model object to ECP form custom control [message #1713245 is a reply to message #1713219] Mon, 02 November 2015 18:11 Go to previous messageGo to next message
Francine Mising name is currently offline Francine Mising nameFriend
Messages: 21
Registered: July 2009
Junior Member
It invokes the ECPSWTViewRenderer.INSTANCE.render() twice, once for each domain object, theObject, passing the same viewModel.

ECPSWTViewRenderer.INSTANCE.render(parent, theObject, viewModel);

Yes, using the same viewModel but different domain objects.

-francine
Re: Binding Ecore model object to ECP form custom control [message #1713279 is a reply to message #1713245] Tue, 03 November 2015 00:43 Go to previous messageGo to next message
Francine Mising name is currently offline Francine Mising nameFriend
Messages: 21
Registered: July 2009
Junior Member
It isn't until I invoke our ECP Custom Control and the renderControl() is called and it goes to return the domain object that it seems to get confused and the wrong one is returned.

[Updated on: Tue, 03 November 2015 00:44]

Report message to a moderator

Re: Binding Ecore model object to ECP form custom control [message #1713372 is a reply to message #1713279] Tue, 03 November 2015 16:03 Go to previous messageGo to next message
Eugen Neufeld is currently offline Eugen NeufeldFriend
Messages: 161
Registered: May 2015
Senior Member
Hi Francine,
The problem is the reuse of the view model. EMFForms stores some information during rendering in the view model. This is especially the case for the resolved EObjects (so the concrete EObject reachable by the DomainModelReference).
You need to use a second ViewModel for the second render step.

Is there a reason you reused the ViewModel?

Cheers,
Eugen


--
Eugen Neufeld

Get professional Eclipse developer support:
http://eclipsesource.com/en/services/developer-support/
Re: Binding Ecore model object to ECP form custom control [message #1713388 is a reply to message #1713372] Tue, 03 November 2015 18:16 Go to previous messageGo to next message
Francine Mising name is currently offline Francine Mising nameFriend
Messages: 21
Registered: July 2009
Junior Member
Thank you for the reply.
At start up, we create a Hashmap of the various view models. We have one for "create" and one for "display" for each of our forms. Then when we want to render a form, we get the model for the associated object, either the "create" or the "display" version. We are trying to show two different objects in two separate instances of the same form that use the same "display" view model? How is this done?
Re: Binding Ecore model object to ECP form custom control [message #1713445 is a reply to message #1713388] Wed, 04 November 2015 09:03 Go to previous messageGo to next message
Eugen Neufeld is currently offline Eugen NeufeldFriend
Messages: 161
Registered: May 2015
Senior Member
Hi Francine,
you can always return a copy of the view model you need using EcoreUtil.copy(myViewModel) .

Take a look at XMIViewModelProvider .

Why don't you use the XMIViewModelProvider directly?

Cheers,
Eugen


--
Eugen Neufeld

Get professional Eclipse developer support:
http://eclipsesource.com/en/services/developer-support/
Re: Binding Ecore model object to ECP form custom control [message #1713549 is a reply to message #1713445] Thu, 05 November 2015 05:02 Go to previous message
Francine Mising name is currently offline Francine Mising nameFriend
Messages: 21
Registered: July 2009
Junior Member
Eugen,
Thanks! That seems to work.

-francine
Previous Topic:[EMF4Net] Proposal
Next Topic:[ECP] Support for other file extension for import/export project/child
Goto Forum:
  


Current Time: Wed Jul 08 06:11:29 GMT 2020

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

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

Back to the top