Skip to main content



      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
Eclipse UserFriend
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 1315 times)
  • Attachment: incorrect.PNG
    (Size: 1.50KB, Downloaded 1288 times)
  • Attachment: expected.PNG
    (Size: 1.84KB, Downloaded 1258 times)

[Updated on: Wed, 04 December 2013 18:53] by 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
Eclipse UserFriend
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
Eclipse UserFriend
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: Sat Jul 05 05:29:51 EDT 2025

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

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

Back to the top