Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » need to change diagram and business model on save - how?
need to change diagram and business model on save - how? [message #658712] Wed, 09 March 2011 15:15 Go to next message
Henrik Rentz-Reichert is currently offline Henrik Rentz-Reichert
Messages: 220
Registered: July 2009
Senior Member
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 #658715 is a reply to message #658712] Wed, 09 March 2011 15:31 Go to previous messageGo to next message
Tim Kaiser is currently offline Tim Kaiser
Messages: 118
Registered: July 2009
Senior Member
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
Re: need to change diagram and business model on save - how? [message #658724 is a reply to message #658715] Wed, 09 March 2011 15:48 Go to previous message
Henrik Rentz-Reichert is currently offline Henrik Rentz-Reichert
Messages: 220
Registered: July 2009
Senior Member
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
Previous Topic:Create Automatically a model from EMF
Next Topic:Bordere items
Goto Forum:
  


Current Time: Tue Oct 21 12:06:44 GMT 2014

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

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