Skip to main content



      Home
Home » Modeling » GMF (Graphical Modeling Framework) » Retrieve graphical element from model element
Retrieve graphical element from model element [message #218274] Wed, 11 February 2009 08:48
Eclipse UserFriend
Originally posted by: c.c.es

Hi all!

I have a problem when trying to retrieve the graphical representation
associated to a model element. Let me briefly explain the context:

- My metamodel:
- Root contains 0..* Group
- Root contains 0..* Element
- Group refers (association without containment) to 1..* Elements.

- What I want my GMF model editor to achieve: when a Group is selected,
all the Elements it refers to must be highlighted (e.g. changing their
background color).

- What I have already achieved:

1) I have added the "selectedStateChanged" method in my GroupEditPart.java
=> This method is executed whenever I select a Group with the mouse.

2) I have retrieved the model element associated with the selected Group:

Group g = (Group)((View)GroupEditPart.this.getModel()).getElement();

3) I have retrieved the Elements refered by the Group.

List<Element> elements = g.getElements();

4) I am able to iterate over the "elements" List to show, for instance,
their names:

System.out.println ("The group refers the following elements");
for (Element e: elements){
System.out.println (e.getElementName());
}

- Problem description: I don't know how to access the graphical
representation associated to each Element e in the previous iteration, in
order to change their background.

Any help will be very wellcome!

Thanks in advance!

C
Previous Topic:Alas, GMF still unusable after all these years...
Next Topic:Creating views without a running Platform
Goto Forum:
  


Current Time: Thu Jul 03 12:58:21 EDT 2025

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

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

Back to the top