Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Get ElementType from containing feature and target EClass
Get ElementType from containing feature and target EClass [message #479187] Mon, 10 August 2009 07:56 Go to next message
Mickael Istria is currently offline Mickael IstriaFriend
Messages: 865
Registered: July 2009
Location: Grenoble, France
Senior Member

Hi all,

AFAIK, it is necessary to specify the ELementType (for example XXXElementTypes.NODE_2006) when one wants to programmatically create a node in the diagram. I'd like to find the way to deduce this ElementType from the EClass of the object I wish to create and the containing feature that should contain it. Some mapping model introspection at runtime would allow to do this kind of thing, but I am not aware of something like that existing...

Do you have any advices?

Mickael
Re: Get ElementType from containing feature and target EClass [message #481211 is a reply to message #479187] Thu, 20 August 2009 07:20 Go to previous messageGo to next message
Jevon  is currently offline Jevon Friend
Messages: 164
Registered: July 2009
Senior Member
Hi Mickael,

I wanted to do the exact same thing. In the end I implemented a dynamic
template to add that functionality to diagram.providers.XXXElementType:

private static Map<EClass, IElementType> elementsReverse;
public static IElementType getElementType(EClass hint) {
if (elementsReverse == null) {
elementsReverse = new IdentityHashMap<EClass, IElementType>();

elementsReverse.put(
ModelPackage.eINSTANCE.getInternetApplication(),
InternetApplication_1000);

...
}
return elementsReverse.get(hint);
}

The dynamic template is available at
http://code.google.com/p/iaml/source/browse/trunk/org.openia ml.model/templates/aspects/xpt/providers/ElementTypes.xpt?sp ec=svn1012&r=950

Hope this helps,

Jevon

Mickael Istria wrote:
> Hi all,
>
> AFAIK, it is necessary to specify the ELementType (for example
> XXXElementTypes.NODE_2006) when one wants to programmatically create a
> node in the diagram. I'd like to find the way to deduce this ElementType
> from the EClass of the object I wish to create and the containing
> feature that should contain it. Some mapping model introspection at
> runtime would allow to do this kind of thing, but I am not aware of
> something like that existing...
>
> Do you have any advices?
>
> Mickael
Re: Get ElementType from containing feature and target EClass [message #481739 is a reply to message #479187] Mon, 24 August 2009 07:39 Go to previous messageGo to next message
Mickael Istria is currently offline Mickael IstriaFriend
Messages: 865
Registered: July 2009
Location: Grenoble, France
Senior Member

Hello,

For those who are interested about a way to guess (before its is created) a node ElementType from its EClass and the EObject that is intended to contain it, here is an useful method that can be used: ModelingAssistantService.getTypeForPopupBar. It returns the list of ElementType that can be used on an object to create a child.

Hope that may help someone else one day...

Mickael


Mickael Istria a écrit :
> Hi all,
>
> AFAIK, it is necessary to specify the ELementType (for example
> XXXElementTypes.NODE_2006) when one wants to programmatically create a
> node in the diagram. I'd like to find the way to deduce this ElementType
> from the EClass of the object I wish to create and the containing
> feature that should contain it. Some mapping model introspection at
> runtime would allow to do this kind of thing, but I am not aware of
> something like that existing...
>
> Do you have any advices?
>
> Mickael
Re: Get ElementType from containing feature and target EClass [message #1495652 is a reply to message #481739] Tue, 02 December 2014 11:44 Go to previous message
Vitaly Savickas is currently offline Vitaly SavickasFriend
Messages: 62
Registered: March 2010
Member
ElementTypeRegistry.getInstance().getElementType(eObject);
Previous Topic:GMF/GEF Commands [documentation]
Next Topic:Drag and drop icon change
Goto Forum:
  


Current Time: Fri Apr 26 12:34:09 GMT 2024

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

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

Back to the top