| How do I change color in programmatic way [message #859692] |
Fri, 27 April 2012 15:15  |
Johnny Qin Messages: 40 Registered: April 2012 |
Member |
|
|
Hi there,
I created my ChangeStateColorFeature which extends AbstractCustomFeature, registered it in feature provider. It all works well.
Right now I am trying to change color of state (a rectangle in diagram) in programmatic way, in other words, change its color without clicking any button. Firstly I was trying to get access to the context object which seems to have control of everything. Later I thought there should be some event system going on. Neither worked for me.
Could anyone give a brief idea of how to achieve this? Thanks in advance.
Sincerely,
Johnny
|
|
|
|
|
| Re: How do I change color in programmatic way [message #868183 is a reply to message #865745] |
Tue, 01 May 2012 13:34  |
Johnny Qin Messages: 40 Registered: April 2012 |
Member |
|
|
Finally it works (I believe there must be a better way)
load pictogram model in ecore
update color in object hierarchy
save the pictogram model
// till now the diagram file is updated, the next is to update editor to present the color change visually
find the diagram editor from eclipse platform ui
find its resource
call unload() method on the pictogram model resource
// now color change is visual
what unload() does is
Clears the contents, errors, and warnings of the resource and marks it as unloaded.
It walks the content tree, and sets each content object to be a proxy. The resource will remain in the resource set,
and can be subsequently reloaded.
If anyone find a better solution, please shoot me a message. Thanks in advance!
Sincerely,
Johnny
|
|
|
Powered by
FUDForum. Page generated in 0.01552 seconds