need to change diagram and business model on save - how? [message #658712] |
Wed, 09 March 2011 10:15  |
Eclipse User |
|
|
|
Hi,
for the state machine diagram editor of the eTrice project I need to drop empty sub state graphs of states including the
corresponding visual elements.
Of course I have to wrap that in a write transaction.
I'm doing this:
public void doSave(IProgressMonitor monitor) {
getEditingDomain().getCommandStack().execute(new RecordingCommand(getEditingDomain()) {
protected void doExecute() {
removeEmptySubgraphs();
}
});
super.doSave(monitor);
}
In removeEmptySubgraphs() I'm removing unused business object as well as diagram elements (ContainerShapes).
After that the diagram files received an error marker showing a "Dangling HREF exception: ...PictogramLinkImpl is not contained in
a resource".
How can I leave the diagram model in a valid state?
Thanks,
Henrik
|
|
|
|
Re: need to change diagram and business model on save - how? [message #658724 is a reply to message #658715] |
Wed, 09 March 2011 10:48  |
Eclipse User |
|
|
|
Hi Tim,
thanks for your reply.
Yes, my problem is solved now.
I use EcoreUtil.delete() to delete unused business objects and collect the shapes that are to be removed.
Finally
for (Shape shape : toBeRemoved) {
EcoreUtil.delete(shape, true);
}
does the job (it is important to use the recursive variant!).
Thanks,
Henrik
Am 09.03.2011 16:31, schrieb Tim Kaiser:
> Hi Henrik,
>
> probably some references to the deleted objects
> still exist in your diagram.
> Example. If i have a Font without eContainer and it is referenced by a Shape via a non-containment reference, this results in a
> Dangling HREF exception on serialization; this can be solved by setting the reference to null, after the Font was detached from
> the model
> As far as i know EMF's EcoreUtil.delete() does this job for you.
>
> Does it solve your problem?
>
> Best, Tim
|
|
|
Powered by
FUDForum. Page generated in 0.03085 seconds