Skip to main content



      Home
Home » Modeling » Papyrus » Class equivalent to ModelElementItem(Is there a class (or interface) that is equivalent to ModelElementItem?)
Class equivalent to ModelElementItem [message #1073300] Wed, 24 July 2013 09:42 Go to next message
Eclipse UserFriend
I have been trying to create a context menu whenever a Papyrus model is selected. So far I have been using the class ModelElementItem (org.eclipse.emf.facet.infra.browser.uicore.internal.model.ModelElementItem), which works fine. I would, however, like to change it since I would prefer not to use an internal class. Does anyone know of a class or an interface that is equivalent to the ModelElementItem that I could use instead?

Thanks in advance!
Regards,
Boel
Re: Class equivalent to ModelElementItem [message #1073324 is a reply to message #1073300] Wed, 24 July 2013 10:22 Go to previous messageGo to next message
Eclipse UserFriend
Hi,


You should use EMFHelper.getEObject(selection), which will work for the ModelExplorer, as well as GMF EditParts (Diagram elements).

The EMFHelper class is available in the org.eclipse.papyrus.infra.emf plug-in.

Object selectedElement = ...; //ModelElementItem, EditPart, ...
EObject selectedEObject = EMFHelper.getEObject(selectedElement);
if (selectedEObject != null){
    //do something
}


This method relies on the Eclipse IAdaptable interface: IAdaptable.getAdapter(EObject.class)


Regards,
Camille
Re: Class equivalent to ModelElementItem [message #1073596 is a reply to message #1073324] Thu, 25 July 2013 02:17 Go to previous messageGo to next message
Eclipse UserFriend
Hi Camille,

Thank you! Using the EMFHelper solved my problem.

Regards,
Boel
Re: Class equivalent to ModelElementItem [message #1321877 is a reply to message #1073596] Tue, 29 April 2014 11:04 Go to previous message
Eclipse UserFriend
Hi,

For next version of Luna, Papyrus will no longer depend on this ModelElementItem in the model explorer. The best way to get the Semantic Element is the EMFHelper#getEObject(Object) as indicated in the previous messages.

quote from mailing list:
Quote:
Hi,
The usage of EMF-Facet 0.2 has been integrated into Papyrus.
This usage involves one major change.

In the context of old framewok, to obtain the UML element from the model explorer, it was only needed to adapt it into an EObject.
Now this approach does not run. In fact all elements in the model explorer that are directly displayed with EMF- Facet are EObjects. See org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.internal.treeproxy

It implies that the test with IAdaptable does not un.

Now , I advise you to use

import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
...
obj = EMFHelper.getEObject(obj);
...




Regards
Rémi
Previous Topic:validation warning in an IBD (bug or wrong use?)
Next Topic:Extending the properties view
Goto Forum:
  


Current Time: Thu Jul 03 10:27:04 EDT 2025

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

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

Back to the top