Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Showing an icon on property change
Showing an icon on property change [message #197312] Wed, 16 July 2008 10:04 Go to next message
Eclipse UserFriend
Originally posted by: marcello.larosa.iinet.net.au

Hi all,

I would like to show a small icon on a side of a given diagram element when
it's property x (of type boolean) changes from false (default value) to
true. The property can be changed from the property view. Anyone knows how
to show icons on demand? Of course, if the property is set back to "false",
the icon needs to disappear.

Thanks in advance,
Marcello
Re: Showing an icon on property change [message #197337 is a reply to message #197312] Wed, 16 July 2008 10:09 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: tobk42.gmx.de

Hi Marcello,

without going too much into detail, you should override the
notifyChanged method in the element's EditPart, calling a specific
method on the element's figure when the property is changed, e.g. adding
an embedded figure to the figure or setting a flag, affecting the
paintFigure method.

Hope this helps,
tobias



Marcello schrieb:
> Hi all,
>
> I would like to show a small icon on a side of a given diagram element when
> it's property x (of type boolean) changes from false (default value) to
> true. The property can be changed from the property view. Anyone knows how
> to show icons on demand? Of course, if the property is set back to "false",
> the icon needs to disappear.
>
> Thanks in advance,
> Marcello
>
>
Re: Showing an icon on property change [message #198866 is a reply to message #197337] Fri, 25 July 2008 01:10 Go to previous message
Eclipse UserFriend
Originally posted by: marcello.larosa.iinet.net.au

Thanks Tobias. I tried your method but had some problems with the refresh.

In the end I preferred to follow the approach used by the Shortcut /
Validation Decorator in GMF. I created a new decorator extending
AbstractDecorator and implementing NotificationListener, as a subclass of a
new decorator provider extending AbstractProvider and implementing
IDecoratorProvider. Then I registered this provider as an extension of
"org.eclipse.gmf.runtime.diagram.ui.decoratorProviders" in plugin.xml.

The decorator needs to be registered as a listener of a specific editpart
(the one whose property needs to be checked) in its constructor, and the
refresh() method builds an icon only if the property changed its value to
the desired one (e.g. to "true"). The icon is added with the following
method invoked in refresh():

setDecoration(getDecoratorTarget().addShapeDecoration(image,
IDecoratorTarget.Direction.EAST, -5, false));

where getDecoratorTarget() is the shape of the editpart. The method
notifyChanged() of the decorator simply recalls the refresh(). I found a
presentation on the topic at
http://eclipsezilla.eclipsecon.org/php/attachment.php?bugid= 3624

It works fine!

Cheers,
Marcello

"Tobias" <tobk42@gmx.de> ha scritto nel messaggio
news:g5khc0$q2g$1@build.eclipse.org...
> Hi Marcello,
>
> without going too much into detail, you should override the notifyChanged
> method in the element's EditPart, calling a specific method on the
> element's figure when the property is changed, e.g. adding an embedded
> figure to the figure or setting a flag, affecting the paintFigure method.
>
> Hope this helps,
> tobias
>
>
>
> Marcello schrieb:
>> Hi all,
>>
>> I would like to show a small icon on a side of a given diagram element
>> when it's property x (of type boolean) changes from false (default value)
>> to true. The property can be changed from the property view. Anyone knows
>> how to show icons on demand? Of course, if the property is set back to
>> "false", the icon needs to disappear.
>>
>> Thanks in advance,
>> Marcello
Previous Topic:GMF not freeing JVM memory after an editor is closed
Next Topic:Set Node Visible when initialized
Goto Forum:
  


Current Time: Sat Jun 06 12:14:02 GMT 2020

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

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

Back to the top