Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » delete with deletion of connections to nested shapes
delete with deletion of connections to nested shapes [message #664307] Fri, 08 April 2011 10:28 Go to next message
Henrik Rentz-Reichert is currently offline Henrik Rentz-ReichertFriend
Messages: 261
Registered: July 2009
Senior Member
Hi all,

the default delete behavior is to remove also connections of the deleted shape.
Are the business objects linked with those connections also deleted?

I also have the situation that my shape has child shapes with connections attached.
I'm treating this with

public void preDelete(IDeleteContext context) {
super.preDelete(context);

if (!(context.getPictogramElement() instanceof ContainerShape))
return;

ContainerShape container = (ContainerShape) context.getPictogramElement();
for (Shape child : container.getChildren()) {
for (Iterator<Anchor> iter = child.getAnchors().iterator(); iter.hasNext();) {
Anchor anchor = iter.next();
for (Iterator<Connection> iterator = Graphiti.getPeService().getAllConnections(anchor).iterator() ; iterator.hasNext();) {
Connection connection = iterator.next();
DeleteContext ctx = new DeleteContext(connection);
ctx.setMultiDeleteInfo(new MultiDeleteInfo(false, false, 1));
IDeleteFeature deleteFeature = getFeatureProvider().getDeleteFeature(ctx);
if (deleteFeature!=null)
deleteFeature.delete(ctx);
}
}
}
}

I use the MultiDeleteInfo to suppress the user question for each connection.
But MultiDeleteInfo is marked @noinstantiate.
Is there a better way to achieve this?
And do I have to care about the connection decorators?

Thanks,
Henrik
Re: delete with deletion of connections to nested shapes [message #664312 is a reply to message #664307] Fri, 08 April 2011 11:06 Go to previous messageGo to next message
Jos Warmer is currently offline Jos WarmerFriend
Messages: 114
Registered: October 2010
Senior Member
Deleting shapes or connection do not remove any business objects.

Jos
Re: delete with deletion of connections to nested shapes [message #664322 is a reply to message #664312] Fri, 08 April 2011 11:38 Go to previous messageGo to next message
Henrik Rentz-Reichert is currently offline Henrik Rentz-ReichertFriend
Messages: 261
Registered: July 2009
Senior Member
Yes, not in general.

But it does for EObjects, cf.
org.eclipse.graphiti.ui.features.DefaultDeleteFeature.delete BusinessObject(Object)

-Henrik

Am 08.04.2011 13:06, schrieb Jos Warmer:
> Deleting shapes or connection do not remove any business objects.
>
> Jos
Re: delete with deletion of connections to nested shapes [message #664425 is a reply to message #664322] Fri, 08 April 2011 18:28 Go to previous messageGo to next message
Jos Warmer is currently offline Jos WarmerFriend
Messages: 114
Registered: October 2010
Senior Member
Henrik, you are right. It does for EObjects. We use custom features for deletion and manage removing shapes and connections ourselves.

Jos
Re: delete with deletion of connections to nested shapes [message #667096 is a reply to message #664425] Tue, 26 April 2011 17:19 Go to previous messageGo to next message
Daniele is currently offline DanieleFriend
Messages: 45
Registered: August 2010
Member
Hi Jos (and Henrik),

can you provide an example?

I had a similar problem in :

http://www.eclipse.org/forums/index.php?t=msg&goto=66709 0&S=e545c26285f418ae58b1f7eded5a1b09#msg_667090

Should I extend the class DefaultDeleteFeature with my OWNDefaultDeleteFeature, and override the method preDelete as Henrik did?
Thanks for the help. Much appreciated!
D.


Re: delete with deletion of connections to nested shapes [message #667110 is a reply to message #664307] Tue, 26 April 2011 19:05 Go to previous message
Daniele is currently offline DanieleFriend
Messages: 45
Registered: August 2010
Member
Hi guys, I did it by following (and adapting) Henrik 's solution:

I mainly extended the DefaultDeleteFeature and Override the method preDelete:

public class MyOWNDefaultDeleteFeature extends DefaultDeleteFeature {
...
@Override
public void preDelete(IDeleteContext context) {

super.preDelete(context);

if (!(context.getPictogramElement() instanceof ContainerShape))
return;

ContainerShape container = (ContainerShape) context.getPictogramElement();


for (Iterator<Anchor> iter = container.getAnchors().iterator(); iter.hasNext();) {
Anchor anchor = iter.next();
for (Iterator<Connection> iterator = Graphiti.getPeService().getAllConnections(anchor).iterator() ; iterator.hasNext();) {
Connection connection = iterator.next();
DeleteContext ctx = new DeleteContext(connection);
ctx.setMultiDeleteInfo(new MultiDeleteInfo(false, false, 1));
IDeleteFeature deleteFeature = getFeatureProvider().getDeleteFeature(ctx);
if (deleteFeature!=null)
deleteFeature.delete(ctx);
}
}

For people that are not expert (e.g. myself), remember that you need also to call your MyOwnDefaultDeleteFeature in your FeatureProvider

public IDeleteFeature getDeleteFeature(IDeleteContext context) {

...
else {
Util.log("BIMFeatureProvider: calling MyOwnDefaultDeleteFeature for "+context,true);
return new MyOwnDefaultDeleteFeature(this);
}
...
}

Maybe, there is a better solution, but at least this seems work for me.
Thanks for your help and support!
D.

[Updated on: Tue, 26 April 2011 19:07]

Report message to a moderator

Previous Topic:Iinstallation and Tutorial
Next Topic:Problems in deleting pictogram elements and model elements
Goto Forum:
  


Current Time: Tue Apr 16 14:23:42 GMT 2024

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

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

Back to the top