Set backgound color depending on model elements propertyhttps://www.eclipse.org/forums/index.php/mv/msg/69951/219037/#msg_219037
I have a class ClassA with an attribute color:String in my domain
model. Now I'd like to update the background color of the nodes
representing instances of ClassA based on the color property. I did not
find anything in the graph/mapping models, so I guess I need to code it
manually. Can anyone give me a hint at what classes I need to look and
how I could possibly achieve what I want?

Many thanks!

Best regards,
Marc Moser]]>Marc Moser2009-02-16T22:46:26-00:00[solved] Re: Set backgound color depending on model elements propertyhttps://www.eclipse.org/forums/index.php/mv/msg/69951/219097/#msg_219097
A short description how I solved the problem, in case anyone is interested.

> Hi,
>
> I have a class ClassA with an attribute color:String in my domain
> model. Now I'd like to update the background color of the nodes
> representing instances of ClassA based on the color property. I did not
> find anything in the graph/mapping models, so I guess I need to code it
> manually. Can anyone give me a hint at what classes I need to look and
> how I could possibly achieve what I want?
>
> Many thanks!
>
> Best regards,
> Marc Moser]]>Marc Moser2009-02-17T14:45:19-00:00Re: [solved] Re: Set backgound color depending on model elements propertyhttps://www.eclipse.org/forums/index.php/mv/msg/69951/676106/#msg_676106
Does anyone know if this is the "right" way to do it?

Best
Ivar

Marc Moser wrote, on 02/17/2009 03:45 PM:
> Hi,
>
> A short description how I solved the problem, in case anyone is interested.
>
> In the generated class *.diagram.edit.parts.ClassAEditPart, I've
> overridden method refreshBackgroundColor() something like this:
>
> protected void refreshBackgroundColor() {
> Color backgroundColor = THIS_BACK; // THIS_BACK is created by setting
> background color in figure
> View notationView = getNotationView();
> EObject element = notationView.getElement();
> if (element instanceof ClassA) {
> ClassA a = (ClassA) element;
> backgroundColor = a.getColor();
> }
>
> setBackgroundColor(backgroundColor);
> }
>
> Best,
> Marc
>
> On 2009-02-16 23:46:26 +0100, Marc Moser <moser@montages.com> said:
>
>> Hi,
>>
>> I have a class ClassA with an attribute color:String in my domain
>> model. Now I'd like to update the background color of the nodes
>> representing instances of ClassA based on the color property. I did
>> not find anything in the graph/mapping models, so I guess I need to
>> code it manually. Can anyone give me a hint at what classes I need to
>> look and how I could possibly achieve what I want?
>>
>> Many thanks!
>>
>> Best regards,
>> Marc Moser
>
>]]>Ivar Refsdal2011-06-02T20:32:49-00:00Re: [solved] Re: Set backgound color depending on model elements propertyhttps://www.eclipse.org/forums/index.php/mv/msg/69951/687841/#msg_687841
Best Regards,
Vincent ]]>vincent9889232011-06-23T11:17:22-00:00Re: [solved] Re: Set backgound color depending on model elements propertyhttps://www.eclipse.org/forums/index.php/mv/msg/69951/687849/#msg_687849
What does
> If I only want to change some of them according to there contribute
> respectively, do you have any ideas?
mean? Can you be more precise?

> View notationView = getNotationView();
> EObject element = notationView.getElement();
With those you have access to the view and your domain element/model if
you want to base the color on those...

Best,
Ivar

forums-noreply@eclipse.org wrote, on 06/23/2011 01:17 PM:
> Hi, Marc. I have tried your solution. It works for me. Thank you very
> much. But when I do that, it will change the color of all the nodes. If
> I only want to change some of them according to there contribute
> respectively, do you have any ideas? Thanks
>
> Best Regards,
> Vincent]]>Ivar Refsdal2011-06-23T11:44:33-00:00Re: [solved] Re: Set backgound color depending on model elements propertyhttps://www.eclipse.org/forums/index.php/mv/msg/69951/687937/#msg_687937

In my model, there is an int attribute called TIRER, the background color of the NODE will be changed dynamically according the value of TIRER (0: balck; 1: red).
In XXXEditPart.java, I write a new function called ChangeColor

regards,]]>Aurelien Pupier2011-07-24T17:45:06-00:00Re: [solved] Re: Set backgound color depending on model elements propertyhttps://www.eclipse.org/forums/index.php/mv/msg/69951/908861/#msg_908861
Iqbal Hossain2012-09-06T06:11:43-00:00Re: [solved] Re: Set backgound color depending on model elements propertyhttps://www.eclipse.org/forums/index.php/mv/msg/69951/908871/#msg_908871
please read again the pointing article.
it is in PortEditPart, so in all XXXEditPart. The method might not be generated. You can add it to override the super behavior.

Regards,]]>Aurelien Pupier2012-09-06T06:37:12-00:00Re: [solved] Re: Set backgound color depending on model elements propertyhttps://www.eclipse.org/forums/index.php/mv/msg/69951/909515/#msg_909515
int tirer = this.tirer;
tirer is a attribute of ur model. but i cant get my attribute is my code.
My attribute name is packetSize. but when i write,
int packetSize = this.packetSize.... packetSize is unknown.
that means i cant access my attribute list....

any help will be appreciable...]]>Iqbal Hossain2012-09-07T09:07:30-00:00Re: [solved] Re: Set backgound color depending on model elements propertyhttps://www.eclipse.org/forums/index.php/mv/msg/69951/909518/#msg_909518
Aurelien Pupier2012-09-07T09:10:16-00:00Re: [solved] Re: Set backgound color depending on model elements propertyhttps://www.eclipse.org/forums/index.php/mv/msg/69951/909525/#msg_909525
Iqbal Hossain2012-09-07T09:17:47-00:00Re: [solved] Re: Set backgound color depending on model elements propertyhttps://www.eclipse.org/forums/index.php/mv/msg/69951/909528/#msg_909528
on which class did you add the packetSize attribute?

Regards,]]>Aurelien Pupier2012-09-07T09:19:58-00:00Re: [solved] Re: Set backgound color depending on model elements propertyhttps://www.eclipse.org/forums/index.php/mv/msg/69951/909531/#msg_909531
actually when i design in XXX.ecorediag i have a node CBQ and I added some attribute like name, packetSize, Priority etc.
Then step by step i made XXX.diagram and other generates other code and it runs perfectly.
Now what i am trying to do is: In the editor I will put some value and the node will change its color according to it. suppose if Priority is 1 then the node becomes red. thats y i am using the function ChangeColor().