Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Change EditPart figure dynamically
Change EditPart figure dynamically [message #1219616] Wed, 04 December 2013 18:51 Go to next message
pbartosz   is currently offline pbartosz
Messages: 11
Registered: March 2012
Junior Member
Hi, I'm currently working on some GEF editor and can't find a way to dynamically change EditPart figure. Sad
I have an
org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeNodeEditPart
object. While org.eclipse.emf.common.notify.Notification event come, then
org.eclipse.gef.editparts.AbstractGraphicalEditPart.refreshSourceConnections()
method is invoked on my ShapeNodeEditPart object. It means that my node on diagram was connected to some other node. In this moment I would like to change my node figure.
I was trying to invoke
unregisterVisuals();
IFigure figure = customEditPart.createNodeFigure();
figure.setBounds(getFigure().getBounds());
setFigure(figure);
registerVisuals();

It doesn't seem to work. There is the same figure displayed but little bit shifted depending on bounds.
What is the correct way to do this?
I would be grateful for any tips.

Node figure before event came:
index.php/fa/16935/0/

Node figure after event came (above changes):
index.php/fa/16936/0/

Node figure after event came (expected):
index.php/fa/16937/0/
  • Attachment: normal.PNG
    (Size: 1.46KB, Downloaded 187 times)
  • Attachment: incorrect.PNG
    (Size: 1.50KB, Downloaded 184 times)
  • Attachment: expected.PNG
    (Size: 1.84KB, Downloaded 181 times)

[Updated on: Wed, 04 December 2013 18:53]

Report message to a moderator

Re: Change EditPart figure dynamically [message #1220360 is a reply to message #1219616] Wed, 11 December 2013 05:06 Go to previous messageGo to next message
Jan Krakora is currently offline Jan Krakora
Messages: 477
Registered: December 2009
Location: Prague
Senior Member
Hi, you should update your part's visual representation in AbstractEditPart.refreshVisuals().

If you need to remove an existing part and replace it with a new one, then I think it's its parent responsibility to do that.
You have to change the list returned from parent's getModelChildren() method and call refreshChildren()
or call removeChild(EditPart child) and addChild(EditPart child) for more efficient way.
Re: Change EditPart figure dynamically [message #1224462 is a reply to message #1220360] Thu, 26 December 2013 15:37 Go to previous message
pbartosz   is currently offline pbartosz
Messages: 11
Registered: March 2012
Junior Member
Thank you for reply. I found out to invoke
AbstractEditPart.removeChild(...)
and
AbstractEditPart.refreshChildren(...)
next.
Previous Topic:Save gef diagram or view as xml file
Next Topic:Figure move border
Goto Forum:
  


Current Time: Fri Apr 18 19:29:44 EDT 2014

Powered by FUDForum. Page generated in 0.01614 seconds