Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
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 Go to next message
antonio guillen is currently offline antonio guillenFriend
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 Go to previous messageGo to next message
Jonas Helming is currently offline Jonas HelmingFriend
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 Go to previous messageGo to next message
antonio guillen is currently offline antonio guillenFriend
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 Go to previous messageGo to next message
Jonas Helming is currently offline Jonas HelmingFriend
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/
Re: [ECF] Pbs with EMF Client Platform and tree-explorer (Eclipse e4) [message #1691904 is a reply to message #1691850] Fri, 10 April 2015 11:46 Go to previous message
antonio guillen is currently offline antonio guillenFriend
Messages: 60
Registered: January 2014
Member
Hi Jonas,

Your workaround is OK, adding root object to a ressource is sufficient.

Thanks a lot for your help

Best regards

Antonio
Previous Topic:[Teneo] How can I persist java.util.Calendar as "timestamp with timezone"?
Next Topic:[ECP] Impossible to set in my application a customized view
Goto Forum:
  


Current Time: Tue Apr 23 14:43:01 GMT 2024

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

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

Back to the top