Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc) » [ECF] Pbs with EMF Client Platform and tree-explorer (Eclipse e4)(When I show in EMF Form an object selected in my Tree explorer it's deleted from the tree!!!)
[ECF] Pbs with EMF Client Platform and tree-explorer (Eclipse e4) [message #1691622] |
Wed, 08 April 2015 14:06 |
antonio guillen Messages: 60 Registered: January 2014 |
Member |
|
|
Hi,
I use ecp to build UI from my ecore model. To visualize an EObject, I select it in a Tree explorer. When it's visualized in the form UI, the object selected is deleted from my Tree explorer. I don't understand why!!!
Here after the code used.
/**
* Example Part for displaying a Forms Editor for an EObject.
*/
public class ObjectView {
private Composite content;
/**
* Render the editor.
*
* @param parent the {@link Composite} to render to
*/
@PostConstruct
public void createComposite(Composite parent) {
content = new Composite(parent, SWT.NONE);
content.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WHITE));
content.setLayout(GridLayoutFactory.fillDefaults().margins(10, 10).create());
content.setLayoutData(GridDataFactory.fillDefaults().create());
parent.layout();
}
@SuppressWarnings("restriction")
@Inject
public void receiveSelection(@Optional @Named(IServiceConstants.ACTIVE_SELECTION) Object o) {
if(o != null) {
EObject objectToView = ((EObject) (o));
if(objectToView instanceof GeologicalEntity || objectToView instanceof Support) {
for (Control kid : content.getChildren()) {
kid.dispose();
}
{
try {
final ViewModelContext vmc = ViewModelContextFactory.INSTANCE.createViewModelContext(ViewProviderHelper.getView(objectToView, null), objectToView, new DefaultReferenceService());
ECPSWTViewRenderer.INSTANCE.render(content, vmc);
content.layout();
} catch (final ECPRendererException e) {
e.printStackTrace();
}
}
content.getParent().layout();
}
}
}
|
|
|
Re: [ECF] Pbs with EMF Client Platform and tree-explorer (Eclipse e4) [message #1691695 is a reply to message #1691622] |
Thu, 09 April 2015 06:12 |
Jonas Helming Messages: 699 Registered: July 2009 |
Senior Member |
|
|
Hi,
that indeed sounds strange! Is the element also deleted from the model
or only made invisible in the TreeViewer? Can you share some details
about the model structure? I would set a break point on the containment
reference of the parent containing the element to see, where it is removed.
Best regards
Jonas
Am 08.04.2015 um 16:06 schrieb antonio guillen:
> Hi,
>
> I use ecp to build UI from my ecore model. To visualize an EObject, I
> select it in a Tree explorer. When it's visualized in the form UI, the
> object selected is deleted from my Tree explorer. I don't understand why!!!
>
> Here after the code used.
>
> /**
> * Example Part for displaying a Forms Editor for an EObject.
> */
> public class ObjectView {
>
> private Composite content;
>
> /**
> * Render the editor.
> * * @param parent the {@link Composite} to render to
> */
> @PostConstruct
> public void createComposite(Composite parent) {
> content = new Composite(parent, SWT.NONE);
>
> content.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WHITE));
>
> content.setLayout(GridLayoutFactory.fillDefaults().margins(10,
> 10).create());
> content.setLayoutData(GridDataFactory.fillDefaults().create());
> parent.layout();
> }
>
> @SuppressWarnings("restriction")
> @Inject
> public void receiveSelection(@Optional
> @Named(IServiceConstants.ACTIVE_SELECTION) Object o) {
> if(o != null) {
> EObject objectToView = ((EObject) (o));
> if(objectToView instanceof GeologicalEntity || objectToView
> instanceof Support) {
> for (Control kid : content.getChildren()) {
> kid.dispose();
> }
> {
> try {
> final ViewModelContext vmc =
> ViewModelContextFactory.INSTANCE.createViewModelContext(ViewProviderHelper.getView(objectToView,
> null), objectToView, new DefaultReferenceService());
> ECPSWTViewRenderer.INSTANCE.render(content, vmc);
> content.layout();
> } catch (final ECPRendererException e) {
> e.printStackTrace();
> }
> }
> content.getParent().layout();
> }
> }
> }
>
--
Get professional Eclipse developer support:
http://eclipsesource.com/en/services/developer-support/
|
|
|
Re: [ECF] Pbs with EMF Client Platform and tree-explorer (Eclipse e4) [message #1691702 is a reply to message #1691695] |
Thu, 09 April 2015 07:58 |
antonio guillen Messages: 60 Registered: January 2014 |
Member |
|
|
Hi Jonas,
I have set some breaks in my code and I found the following when I select an object (a Formation) in my tree I call receive Selection and when I build the viewmodelcontext I have the following stack:
GroupImpl.eInverseRemove(InternalEObject, int, NotificationChain) line: 307
GroupImpl(BasicEObjectImpl).eInverseRemove(InternalEObject, int, Class<?>, NotificationChain) line: 1437
FormationImpl(BasicEObjectImpl).eBasicRemoveFromContainer(NotificationChain) line: 1386
FormationImpl(BasicEObjectImpl).eSetResource(Resource$Internal, NotificationChain) line: 981
ResourceImpl$ContentsEList<E>.inverseAdd(E, NotificationChain) line: 410
ResourceImpl$ContentsEList<E>(NotifyingListImpl<E>).addUnique(E) line: 312
ResourceImpl$ContentsEList<E>(AbstractEList<E>).add(E) line: 303
ViewModelContextImpl.addResourceIfNecessary() line: 234
ViewModelContextImpl.instantiate() line: 200
ViewModelContextImpl.<init>(VElement, EObject, ViewModelService...) line: 173
ViewModelContextFactory.createViewModelContext(VElement, EObject, ViewModelService...) line: 55
ObjectView.receiveSelection(EObject) line: 104
GroupImpl contains Formations so it remove from my Group the selected formation.
Strange strange!!!!
If it's necessary I will try to isolate this part, but it will be a big job!!!
Thanks a lot for your help
Antonio
|
|
|
Re: [ECF] Pbs with EMF Client Platform and tree-explorer (Eclipse e4) [message #1691850 is a reply to message #1691702] |
Fri, 10 April 2015 07:15 |
Jonas Helming Messages: 699 Registered: July 2009 |
Senior Member |
|
|
Hi,
OK, I found the reason, interesting case.
Your root object is not contained in any resource and the containment
feature has "containment proxies" turned off. In this case, the view
model context will add a resource and this will indeed remove the child
from the tree (standard EMF behavior).
I have reopened https://bugs.eclipse.org/bugs/show_bug.cgi?id=436553
to find a good solution mid-term
as a quick fix, could you either add your objects to a resource (root is
enough) or turn containment proxies on.
Please let me know, if this helps.
Best regards
Jonas
Am 09.04.2015 um 09:58 schrieb antonio guillen:
> Hi Jonas,
>
> I have set some breaks in my code and I found the following when I
> select an object (a Formation) in my tree I call receive Selection and
> when I build the viewmodelcontext I have the following stack:
>
>
>
> GroupImpl.eInverseRemove(InternalEObject, int, NotificationChain) line:
> 307
> GroupImpl(BasicEObjectImpl).eInverseRemove(InternalEObject, int,
> Class<?>, NotificationChain) line: 1437
> FormationImpl(BasicEObjectImpl).eBasicRemoveFromContainer(NotificationChain)
> line: 1386
> FormationImpl(BasicEObjectImpl).eSetResource(Resource$Internal,
> NotificationChain) line: 981
> ResourceImpl$ContentsEList<E>.inverseAdd(E, NotificationChain) line: 410
> ResourceImpl$ContentsEList<E>(NotifyingListImpl<E>).addUnique(E) line:
> 312
> ResourceImpl$ContentsEList<E>(AbstractEList<E>).add(E) line: 303
> ViewModelContextImpl.addResourceIfNecessary() line: 234
> ViewModelContextImpl.instantiate() line: 200
> ViewModelContextImpl.<init>(VElement, EObject, ViewModelService...)
> line: 173
> ViewModelContextFactory.createViewModelContext(VElement, EObject,
> ViewModelService...) line: 55
> ObjectView.receiveSelection(EObject) line: 104
>
>
> GroupImpl contains Formations so it remove from my Group the selected
> formation.
>
> Strange strange!!!!
>
> If it's necessary I will try to isolate this part, but it will be a big
> job!!!
>
> Thanks a lot for your help
>
> Antonio
--
Get professional Eclipse developer support:
http://eclipsesource.com/en/services/developer-support/
|
|
| |
Goto Forum:
Current Time: Tue Sep 24 17:36:41 GMT 2024
Powered by FUDForum. Page generated in 0.03245 seconds
|