Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 13:42 Go to next message
Boel NFriend
Messages: 4
Registered: July 2013
Junior Member
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 14:22 Go to previous messageGo to next message
Camille Letavernier is currently offline Camille LetavernierFriend
Messages: 932
Registered: February 2011
Senior Member
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


Camille Letavernier
Re: Class equivalent to ModelElementItem [message #1073596 is a reply to message #1073324] Thu, 25 July 2013 06:17 Go to previous messageGo to next message
Boel NFriend
Messages: 4
Registered: July 2013
Junior Member
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 15:04 Go to previous message
Remi Schnekenburger is currently offline Remi SchnekenburgerFriend
Messages: 168
Registered: July 2009
Location: Palaiseau, France
Senior Member
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


Remi Schnekenburger

Get professional Eclipse developer support:
http://eclipsesource.com/en/services/developer-support/
Previous Topic:validation warning in an IBD (bug or wrong use?)
Next Topic:Extending the properties view
Goto Forum:
  


Current Time: Fri Dec 04 08:55:22 GMT 2020

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

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

Back to the top