Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Display property as icon
Display property as icon [message #182238] Thu, 10 April 2008 12:59 Go to next message
Eclipse UserFriend
Originally posted by: news.wartmal.de

Hi,

I have this usecase: My model object is currently displayed as
rectangle. Now I want to show an icon in that figure to represent a
property of the model object. On double click on the icon I want to edit
the property in a modal dialog.

Now I'm not sure about the right approach.
I want to avoid changes to the generated code, because the whole thing
is still under heavy development, so I regenerate the code quite often.

My first try uses decorations. I have a DecoratorProvider, and the
Decorator adds an ImageFigure with
DecoratorTarget.addShapeDecoration(..). Editing is done with a custom
EditPolicyProvider, which installs a edit policy for OPEN_ROLE to open
the modal dialog. This works fine, until the user has edited the
property. Now the icon should be updated to represents the changed
value, but the decorator it not called again. I have to save and close
the editor and reopen it to see the new icon.
Perhaps decorators are not the right way to do this.

Currently I think about the following solutions:
1. Use decorations and force the figure to be refreshed. But how?

2. Edit the generated code to add an ImageFigure the rectangle figure
and update it manually. But how to handle further changes in the
generated code?

3. Use a custom editpartProvider and let the custom editPart extend the
generated editPart. Then try to do it like in 2.


Before I implement the other dead-end solutions, perhaps you may point
me to the right direction. Or are there any other, better solutions?


Thanks in advance,
tobi
Re: Display property as icon [message #182274 is a reply to message #182238] Thu, 10 April 2008 14:01 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: 5d5.mail.ru

One more option is to define a label and tweak generated ???IconProvider
to return different icons.

Tobias Vogele wrote:
> Hi,
>
> I have this usecase: My model object is currently displayed as
> rectangle. Now I want to show an icon in that figure to represent a
> property of the model object. On double click on the icon I want to edit
> the property in a modal dialog.
>
> Now I'm not sure about the right approach.
> I want to avoid changes to the generated code, because the whole thing
> is still under heavy development, so I regenerate the code quite often.
>
> My first try uses decorations. I have a DecoratorProvider, and the
> Decorator adds an ImageFigure with
> DecoratorTarget.addShapeDecoration(..). Editing is done with a custom
> EditPolicyProvider, which installs a edit policy for OPEN_ROLE to open
> the modal dialog. This works fine, until the user has edited the
> property. Now the icon should be updated to represents the changed
> value, but the decorator it not called again. I have to save and close
> the editor and reopen it to see the new icon.
> Perhaps decorators are not the right way to do this.
>
> Currently I think about the following solutions:
> 1. Use decorations and force the figure to be refreshed. But how?
>
> 2. Edit the generated code to add an ImageFigure the rectangle figure
> and update it manually. But how to handle further changes in the
> generated code?
>
> 3. Use a custom editpartProvider and let the custom editPart extend the
> generated editPart. Then try to do it like in 2.
>
>
> Before I implement the other dead-end solutions, perhaps you may point
> me to the right direction. Or are there any other, better solutions?
>
>
> Thanks in advance,
> tobi
Re: Display property as icon [message #182392 is a reply to message #182274] Fri, 11 April 2008 07:00 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: news.wartmal.de

Hi,

Dmitry Stadnik schrieb:
> One more option is to define a label and tweak generated ???IconProvider
> to return different icons.

How can I use a IconProvider for a label? I have tried to use the
extension point org.eclipse.gmf.runtime.common.ui.services.iconProviders
and set the "object" parameter to the class of my model object.
Unfortunately my IconProvider is only called for the Outline View.

My label always shows the text of the property and I didn't find a way
to bind it to the IconProvider. Setting the parameter "ElementIcon" in
the gmfgraph to true just displays the default icon.
Is there a way to display icons in a label?

bye,
tobi
Re: Display property as icon [message #182765 is a reply to message #182238] Sat, 12 April 2008 08:57 Go to previous message
Eclipse UserFriend
Originally posted by: jan.herriger.gmx.de

Hi Tobias,


> Currently I think about the following solutions:
> 1. Use decorations and force the figure to be refreshed. But how?

just "refresh()" it inside handleNotificationEvent() of the decorated
editpart. This should result in refreshing decorators:

if (MyPackage.eINSTANCE
.getMyClass_MyFeature()
.equals(event.getFeature())) {
refresh();
}

> 2. Edit the generated code to add an ImageFigure the rectangle figure
> and update it manually. But how to handle further changes in the
> generated code?

I would prefer this solution. You could write your own class which
extends ImageFigure. This ImageFigure could have a method which takes an
EObject (lets call it 'setElement'), choses a proper Image and calls
ImageFigure#setImage() with the chosen Image instance.

Now, every time you call myImageFigure#setElement() inside
handleNotificationEvent(), the displayed image should be updated.

> 3. Use a custom editpartProvider and let the custom editPart extend the
> generated editPart. Then try to do it like in 2.
>
>
> Before I implement the other dead-end solutions, perhaps you may point
> me to the right direction. Or are there any other, better solutions?
>
>
> Thanks in advance,
> tobi
Previous Topic:[Announce] GMF GMF 2.1.0M6a is available
Next Topic:Distinguish empty and non-empty collection-type nodes (which have diagram paritiniong feature)
Goto Forum:
  


Current Time: Fri Sep 20 13:58:12 GMT 2024

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

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

Back to the top