|
|
|
|
|
Re: delete with deletion of connections to nested shapes [message #667110 is a reply to message #664307] |
Tue, 26 April 2011 19:05 |
Daniele 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
|
|
|
Powered by
FUDForum. Page generated in 0.02586 seconds