How to refresh model source/target connection “children” of GEF NodeEditParts

My blog has moved to a new home. Please go to for the Brand New Code on the Block! And – like they said in the nineties – “don’t forget to update your bookmarks”. Link to this post on the new site:

I am currently developing a GEF-based editor for an EMF-based model with the help of the GEF Book, and vainolo’s incredibly helpful blog posts.

I had implemented connection creation, following vainolo’s post about connections, but in my editor, the added connection figures never showed up, although the respective model objects had been instantiated (I’ve checked!). It was only after I had saved the graph, and re-opened the editor that the connection figures became visible. The respective code bits looked like this:

Read more (opens the full post at the new blog location…

2 thoughts on “How to refresh model source/target connection “children” of GEF NodeEditParts

  1. While your solution surely works, it breaks the MVC pattern, creating a dependency from the commands to the controller, which is not encouraged.
    The solution I would implement is making MyGraph and Adapter and calling refresh() when the graph changes. Since the links are stored in MyGraph, it surely changes when a new link is added. I have also found that you should call refresh() instead of refreshSourceConnections() and others. It refreshes everything, so you never forget anything.

    • Hi vainolo,
      Funny that your comment came in just today, and thanks a lot. I’m in the process of re-implementing the editor (the original one was a hacky proof-of-concept affair), and have just stumbled over the same issue again, thinking that the above solution is not clean at all.
      I had made MyGraph an Adapter already, but that wouldn’t solve the issue, until I’ve found that I’ve never added the model objects (it wasn’t links I was working on, but annotations in today’s case) to the children List in getModelChildren()… D’uh! Well better find a bug late than never. All part of the GEF learning experience.
      Now I can just call getParent().refresh() in the Adapter’s notifyChanged() method and everything works just fine. I’ll update the post with the better implementation.
      Thanks also for your hint about not using refreshSourceConnections(), I’ll keep that in mind.

Leave a Comment

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s