Retrieve graphical element from model element [message #218274] |
Wed, 11 February 2009 08:48 |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.03521 seconds