Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Delete Shapes inside Containershape
Delete Shapes inside Containershape [message #1786648] Tue, 08 May 2018 22:05 Go to next message
Markus Gamperle is currently offline Markus GamperleFriend
Messages: 7
Registered: April 2018
Junior Member
Hey Guys,

I want to update the Graphical Representation of my model.

Therefore, i need to delete all contained shapes/texts/polylines.

When i try
public boolean update(IUpdateContext context) {
		PictogramElement pictogramElement = context.getPictogramElement();
        if (pictogramElement instanceof ContainerShape) {

            ContainerShape cs = (ContainerShape) pictogramElement;
            cs.getChildren().clear();


I can't save the diagram any more. So how is it possible to remove shapes without errors?

It throws this exception:
org.eclipse.emf.ecore.resource.Resource$IOWrappedException: The object 'org.eclipse.graphiti.mm.pictograms.impl.PictogramLinkImpl@2bb60439' is not contained in a resource.
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.endSave(XMLSaveImpl.java:301)

I want to clear the containershape to fill it with new Texts. Is this possible?

Thanks in advance

Markus
Re: Delete Shapes inside Containershape [message #1786668 is a reply to message #1786648] Wed, 09 May 2018 07:39 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1931
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Markus,

the call to cs.getChildren().clear() will only remove the children from the aggregation in the container shape, it will actually not delete them. This means that you will end up with dangling objects that do not have a parent and are not associated to any EMF resource (this is what the error message is about). You will need to really delete the children shapes to get rid of this.

Michael
Re: Delete Shapes inside Containershape [message #1786722 is a reply to message #1786668] Wed, 09 May 2018 20:21 Go to previous messageGo to next message
Markus Gamperle is currently offline Markus GamperleFriend
Messages: 7
Registered: April 2018
Junior Member
Michael,

thank you for the quick answer. But how can i delete the shapes/ the texts inside the shapes?
I tried calling ECoreUtil.deleteFeature() on them, it didn't work.

Markus
Re: Delete Shapes inside Containershape [message #1786775 is a reply to message #1786722] Fri, 11 May 2018 07:34 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1931
Registered: July 2009
Location: Walldorf, Germany
Senior Member
ECoreUtil.delete() should be the method to call for this. What was the error you were getting when you tried to call that?

Michael
Re: Delete Shapes inside Containershape [message #1786803 is a reply to message #1786775] Sat, 12 May 2018 11:53 Go to previous messageGo to next message
Markus Gamperle is currently offline Markus GamperleFriend
Messages: 7
Registered: April 2018
Junior Member
No Message Body

[Updated on: Sat, 12 May 2018 11:55]

Report message to a moderator

Re: Delete Shapes inside Containershape [message #1786804 is a reply to message #1786775] Sat, 12 May 2018 11:53 Go to previous messageGo to next message
Markus Gamperle is currently offline Markus GamperleFriend
Messages: 7
Registered: April 2018
Junior Member
the same as before,

the Link of the shape with the business-object still existed.

So I had to first delete the link of the shape and then the shape itself.
Now it works fine and i'm able to safe.

Markus
Re: Delete Shapes inside Containershape [message #1786805 is a reply to message #1786775] Sat, 12 May 2018 11:53 Go to previous message
Markus Gamperle is currently offline Markus GamperleFriend
Messages: 7
Registered: April 2018
Junior Member
No Message Body

[Updated on: Sat, 12 May 2018 11:54]

Report message to a moderator

Previous Topic:Double Post
Next Topic:Remove Zoom Levels
Goto Forum:
  


Current Time: Sat Oct 05 19:52:04 GMT 2024

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

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

Back to the top