0

I'm trying to draw diagram that contains a single entity which holds multiple elements inside.

My MVC structure looks something like this:
Model: contains EntityModel.java and ElementModel.java which represents my model objects.
View: EntityFigure.java and ElementFigure.java
Controller: EntityEditPart.java and ElementEditPart.java

I'm overriding getModelChildren() in EntityEditPart.java to return list of ElementModel.java so that is how GEF knows that an element "belongs" to an entity.

Since I would like to calculate my entity's figure size and include the embedded elements in this calculation, I cannot call entityFigure.getPreferredSize() during createFigure() in EntityEditPart.java since at this point - the elements figures do not exists (createFigure() in ElementEditPart.java is not invoked yet).

I'm looking for a place to set my entity figure after all child figures were created.
I though about overriding addNotify() in ElementEditPart.java, however, it is being called after creating a specific inner element and not after all elements created.

Any ideas?

Hope I was clear enough...

akaspi
  • 275
  • 1
  • 3
  • 12

1 Answers1

2

You can do it in an extension of

 refreshChildren()

method of an edit part, since all the child creation is done in refreshChildren() of superclass's (AbstractEditPart) refresh method:

public void refresh() {
    refreshVisuals();
    refreshChildren();
}

Or, you can just extend

refresh()
execc
  • 1,083
  • 12
  • 25