Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Refresh node labels
Refresh node labels [message #103107] Mon, 12 February 2007 14:53 Go to next message
Eclipse UserFriend
Originally posted by: kalin.nakov.gmail.com

Hi,

In my diagram I have two nodes. The label of the first is composed as
<name>:<type> where <type> is the label of the second one. When I rename
the second one, the <type> field is not refreshed. The new value is only
visible when I close the diagram and load it again. How can I notify the
label of the first node when the label of the second one changes?

Thanks in advance,
Kalin
Re: Refresh node labels [message #103136 is a reply to message #103107] Mon, 12 February 2007 15:43 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: vcciubot.uwaterloo.ca

EditPart refresh by listening to the model, here are some methods in
GraphicalEditPart:

protected void addNotationalListeners() {
if (hasNotationView()){
addListenerFilter("View", this,(View)getModel()); //$NON-NLS-1$
}
}

The event is handled in handleNotificationEvent(), for instance
TextCompartmentEditPart does this:

protected void handleNotificationEvent(Notification event) {
Object feature = event.getFeature();
......................................................
if (getParser() != null) {

boolean sematicsAffected = getParser() instanceof ISemanticParser
&& ((ISemanticParser) getParser())
.areSemanticElementsAffected(null, event);

boolean parserAffected = getParser().isAffectingEvent(event,
getParserOptions().intValue());

if (sematicsAffected) {
removeSemanticListeners();

if (resolveSemanticElement() != null) {
addSemanticListeners();
}
}

if (sematicsAffected || parserAffected) {
refreshLabel();
}
}
super.handleNotificationEvent(event);
}


On Mon, 12 Feb 2007 16:53:31 +0200, Kalin Nakov wrote:

> Hi,
>
> In my diagram I have two nodes. The label of the first is composed as
> <name>:<type> where <type> is the label of the second one. When I rename
> the second one, the <type> field is not refreshed. The new value is only
> visible when I close the diagram and load it again. How can I notify the
> label of the first node when the label of the second one changes?
>
> Thanks in advance,
> Kalin
Re: Refresh node labels [message #103274 is a reply to message #103136] Mon, 12 February 2007 19:57 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: kalin.nakov.gmail.com

Hi,

Thank you for the suggestion. I have already tried that, but couldn't
find a way how to hook to the change events of the second node from the
first one. Actually what I did is to hook at the refreshLabel() method
and try to iterate through all top-level nodes in the diagram, then
through their children and refresh their labels. It was with no success,
because I was trying to guess what each method returns and I don't know
how to navigate through the available edit parts in the diagram. Is
there any example or documentation on how to iterate through the
different GraphicalEditPart instances in the diagram? Specifically the
best thing that will help me is to find a list of all GraphicalEditParts
in the current diagram.

Thanks,
Kalin

Vlad Ciubotariu wrote:
> EditPart refresh by listening to the model, here are some methods in
> GraphicalEditPart:
>
> protected void addNotationalListeners() {
> if (hasNotationView()){
> addListenerFilter("View", this,(View)getModel()); //$NON-NLS-1$
> }
> }
>
> The event is handled in handleNotificationEvent(), for instance
> TextCompartmentEditPart does this:
>
> protected void handleNotificationEvent(Notification event) {
> Object feature = event.getFeature();
> .....................................................
> if (getParser() != null) {
>
> boolean sematicsAffected = getParser() instanceof ISemanticParser
> && ((ISemanticParser) getParser())
> .areSemanticElementsAffected(null, event);
>
> boolean parserAffected = getParser().isAffectingEvent(event,
> getParserOptions().intValue());
>
> if (sematicsAffected) {
> removeSemanticListeners();
>
> if (resolveSemanticElement() != null) {
> addSemanticListeners();
> }
> }
>
> if (sematicsAffected || parserAffected) {
> refreshLabel();
> }
> }
> super.handleNotificationEvent(event);
> }
>
>
> On Mon, 12 Feb 2007 16:53:31 +0200, Kalin Nakov wrote:
>
>> Hi,
>>
>> In my diagram I have two nodes. The label of the first is composed as
>> <name>:<type> where <type> is the label of the second one. When I rename
>> the second one, the <type> field is not refreshed. The new value is only
>> visible when I close the diagram and load it again. How can I notify the
>> label of the first node when the label of the second one changes?
>>
>> Thanks in advance,
>> Kalin
>
Re: Refresh node labels [message #103289 is a reply to message #103274] Mon, 12 February 2007 20:06 Go to previous message
Mohammed Mostafa is currently offline Mohammed MostafaFriend
Messages: 143
Registered: July 2009
Senior Member
Hi ;
you need to make your edit part listen to the other node semantic
element, and respond to the change event by refreshing the label. I'm
assuming you can reach for the other semantic element somehow

to do that override addSemanticListeners

and add something like

addListenerFilter("SemanticElement",
this,theOtherNodeSemanticElement);//$NON-NLS-1$


then override the handleNotificationEvent method in your edit part and
add code their to handle the change by refreshing the label like :

Object feature = event.getFeature();
if (MyPackage.Literals.TheOtherElementFeature.equals(feature)){
refreshLabel();
}

this might do it for you


Kalin Nakov wrote:
}

> Hi,
>
> Thank you for the suggestion. I have already tried that, but couldn't
> find a way how to hook to the change events of the second node from the
> first one. Actually what I did is to hook at the refreshLabel() method
> and try to iterate through all top-level nodes in the diagram, then
> through their children and refresh their labels. It was with no success,
> because I was trying to guess what each method returns and I don't know
> how to navigate through the available edit parts in the diagram. Is
> there any example or documentation on how to iterate through the
> different GraphicalEditPart instances in the diagram? Specifically the
> best thing that will help me is to find a list of all GraphicalEditParts
> in the current diagram.
>
> Thanks,
> Kalin
>
> Vlad Ciubotariu wrote:
>> EditPart refresh by listening to the model, here are some methods in
>> GraphicalEditPart:
>>
>> protected void addNotationalListeners() {
>> if (hasNotationView()){
>> addListenerFilter("View", this,(View)getModel());
>> //$NON-NLS-1$
>> }
>> }
>>
>> The event is handled in handleNotificationEvent(), for instance
>> TextCompartmentEditPart does this:
>>
>> protected void handleNotificationEvent(Notification event) {
>> Object feature = event.getFeature();
>> .....................................................
>> if (getParser() != null) {
>>
>> boolean sematicsAffected = getParser() instanceof
>> ISemanticParser
>> && ((ISemanticParser) getParser())
>> .areSemanticElementsAffected(null, event);
>>
>> boolean parserAffected = getParser().isAffectingEvent(event,
>> getParserOptions().intValue());
>>
>> if (sematicsAffected) {
>> removeSemanticListeners();
>>
>> if (resolveSemanticElement() != null) {
>> addSemanticListeners();
>> }
>> }
>>
>> if (sematicsAffected || parserAffected) {
>> refreshLabel();
>> }
>> }
>> super.handleNotificationEvent(event);
>> }
>>
>>
>> On Mon, 12 Feb 2007 16:53:31 +0200, Kalin Nakov wrote:
>>
>>> Hi,
>>>
>>> In my diagram I have two nodes. The label of the first is composed as
>>> <name>:<type> where <type> is the label of the second one. When I
>>> rename the second one, the <type> field is not refreshed. The new
>>> value is only visible when I close the diagram and load it again. How
>>> can I notify the label of the first node when the label of the second
>>> one changes?
>>>
>>> Thanks in advance,
>>> Kalin
>>
Previous Topic:edit of label changes model, but label doesn't refresh
Next Topic:Only one file storing the model and many diagrams
Goto Forum:
  


Current Time: Wed Jul 17 10:23:42 GMT 2024

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

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

Back to the top