Hi Alexander,
Many thanks for you reply! I've solved this problem now. Unfortunately I forgot to mention that I'd needed to do the hit-testing on opening the editor. It is all too understandable that at this point (in refreshVisuals() of an arbitrary EditPart) not all EditParts will be in the registry
.
My (admittedly very hacky) solution involves getting a count of all model elements which are eligible for hit-testing in refreshVisuals(), and checking this count against the number of EditParts in the registry which are of a type which can "hold" these model elements. This way I can react to the registry being completed (for these types of elements) and perform a one-time re-layout of the whole diagram which is relatively performant as I can access the "complete" EditPartRegistry.
Below is some code for anyone who isn't clever enough to do this properly (like myself), but will ping this thread once s/he has found a better solution.
int nodes = 0;
nodes = nodes + superElement.getAllTypeOneElements().size();
nodes = nodes + superElement.getAllTypeTwoElements().size();
int partCounter = 0;
for (Object value : getViewer().getEditPartRegistry().values()) {
if (value instanceof TypeOneEditPart || value instanceof TypeTwoEditPart) {
partCounter++;
}
}
if (nodes == partCounter) {
System.out.println("This EditPart is the last one to be added to the registry, which is now complete!");
Layouter.pleaseLayoutTheDiagramProperlyJustThisOnce();
}
[Updated on: Mon, 08 September 2014 07:02] by Moderator