|
Re: How to have multidecorators [message #631604 is a reply to message #631552] |
Fri, 08 October 2010 07:41 |
Michael Wenz Messages: 1931 Registered: July 2009 Location: Walldorf, Germany |
Senior Member |
|
|
I'm not really sure if I understood your problem correctly. What I tried is
the following: I added your code snippet to the toturial
ToolBehaviorProvider and tried to return first a digfferent decorator, then
two decorators at once. That worked, also the location of the second
decorator changed as expected. This change was triggered via direct editing,
external changes and via the properties view.
A gues what could be wrong (without knowing your coding) is that there is
something going wrong within the notification process: it could be that the
wrong editing domain is used for doing the change or that the diagram
objects are not correctly linked to the domain objects. The root
PictogramElement for your "thing" needs to be linked to the "Thing"
instance.
Besides I not really sure if the decorator is the best solution for your
scenario. Did you think about adding the icons directly to the diagram in
your add feature? My impression is that the icons are rather static and
directly depend on the value of one attribute. An example for this would be
a class object displaying the attributes with an icon for the visibility
state (green circle for public, red for private). Maybe that would be an
alternative as well.
Michael
"Daniele" <barone.daniele@gmail.com> wrote in message
news:i8lh61$tk3$1@news.eclipse.org...
> Hi there, I need to have different decorators on my PE depending on values
> in the properties panel. I am starting to implement it using the following
> code:
>
> @Override
> public IDecorator[] getDecorators(PictogramElement pe) {
> IFeatureProvider featureProvider = getFeatureProvider();
> Object bo = featureProvider.getBusinessObjectForPictogramElement(pe);
>
> if (bo instanceof Thing) {
> Thing thing = (Thing) bo;
> String name = thing.getName();
> if (name != null && name.length() > 0 && !(name.charAt(0) >= 'A' &&
> name.charAt(0) <= 'Z')) {
>
> //Image: imageWarning
> ImageDecorator imageWarning=new
> ImageDecorator(IPlatformImageConstants.IMG_ECLIPSE_WARNING_T SK);
>
> return new ImageDecorator[] {imageWarning};
>
> }
>
> else if (name.equals("Vision")) {
> //Image: imageWarning
> ImageDecorator imageVision=new ImageDecorator(ImageProvider.IMG_VISION);
> imageVision.setX(30);
> imageVision.setY(30);
>
> return new ImageDecorator[] {imageVision};
>
> }
>
> }
>
> return super.getDecorators(pe);
> }
>
> But I have the following problem:
>
>
> when I add a PE into the diagram it remains stucked at the same location
> altough I am able to visualize the different decorators by setting
> different values for the attribute NAME in the properties panel.
>
> I noticed that if I eliminate the "else if" part, it works perfectly but
> obviously (in this case) I have just one kind of decorator.
>
> Indeed, my final goal is to have a PE that have three decorators each one
> associated to a different attribute of the BO linked to the PE. These 3
> decorators can change their images depending on a specific set of values
> defined for the three attributes, e.g.:
>
>
> Attribute 1 --> Decorator 1:
> ----------------------------------
> (Value ---> Image)
>
> "A"---> "ImgA"
> "B"---> "ImgB"
> "C"---> "ImgC"
>
> Attribute 2 --> Decorator 2:
> ----------------------------------
> (Value ---> Image)
>
> "X"---> "ImgX"
> "Y"---> "ImgY"
> "Z"---> "ImgZ"
>
> Attribute 3 --> Decorator 3:
> ----------------------------------
> (Value ---> Image)
>
> "K"---> "ImgK"
> "L"---> "ImgL"
> "M"---> "ImgM"
>
>
> Thank you in adnvance for any suggestions or help :)
> Daniele
>
>
>
|
|
|
|
|
|
Re: How to have multidecorators [message #632103 is a reply to message #631997] |
Mon, 11 October 2010 15:08 |
Daniele Messages: 45 Registered: August 2010 |
Member |
|
|
Hi Micheal,
I just noticed that when I change the value in the properties panel the PE is not automatically refreshed. Only when I move the PE the decorator change reflecting the value in the properties panel.
In the EClass example there is not this issue since (I suppose) the name of the EClass is directly linked to the PE, therefore some event is triggered when its value changes.
But when the attribute appears just in the properties panel (and it is not visualized on the PE), how can I force the refreshing of the PE element?
Thanks
---- this is my actual code for the ELSE part in which the typeIntention is a value that I can change in the properties panel; when this value changes a different image for the Decorator appears on the PE----
else if (typeIntention != null && typeIntention.equals("Vision")) {
ImageDecorator imageVision=new ImageDecorator(ImageProvider.IMG_VISION);
imageVision.setMessage("This is our Vision"); //$NON-NLS-1$
return new ImageDecorator[] {imageVision};
}
[Updated on: Mon, 11 October 2010 15:47] Report message to a moderator
|
|
|
|
Re: How to have multidecorators [message #632427 is a reply to message #632214] |
Tue, 12 October 2010 20:38 |
Daniele Messages: 45 Registered: August 2010 |
Member |
|
|
Hi Michael,
(again thank you for your help and support)
--> "Is the object which name you change linked to any PE?"
Yes it is linked. The PE is connected to a BO which has two attributes, namely NAME and TYPE (that is an enumeration attribute). The NAME is visualized on the PE and it can be modified with direct editing or trough the properties panel; instead, the TYPE is not part of the PE definition (i.e., not in the addXFeature.java) but appears in the properties panel(using a Combo widget). The user can change the TYPE's value and the decorator's image on the PE changes in accordance.
Anyway, for now I am using your suggestion where each time I change the TYPE 's value in the properties panel I am forcing the refresh of the diagram (in the listener associated to the combo TYPE widget) with the following code:
private ModifyListener listenerIntentionTypeWidget = new ModifyListener(){
public void modifyText (ModifyEvent arg0){
...
IDiagramEditor digramEditor = getDiagramEditor();
digramEditor.refresh();
...
}
Now it seems work
Thank you again for your support
Daniele
[Updated on: Tue, 12 October 2010 20:43] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.04029 seconds