Problem with the deletion of a child view - Delete-EditPolicy is not called [message #1711752] |
Mon, 19 October 2015 14:00 |
Eclipse User |
|
|
|
Hi all,
I've got a problem with the deletion of 'child-editParts' (view). If I delete in the editor a parent-editPart (view) the child-editPart (which is not selectable) won't be deleted correctly. Here is the detailed description: In my editor you can add a 'parent node'. Furthermore you can add a child node ('image') to the parent node. So the parent node represents a container for the child node and it can also exists without a child node. The child node represents an image which should not be selectable. It has the same size as the parent node and contains an image file. The child node has got a EditPolicy ('DeletePolicy') to handle a delete-request to delete the image file. Now I create a parent node and add a child node ('image') to it. Now if I click to the image the parent node will be selected because the image isn't selectable. Everything is ok until now. If I select the parent node and press 'delete' the parent node will be deleted but the image-file of the child node is still there because the DeletePolicy of the child node won't be used. Only if the child node is selectable the DeletePolicy will be used and the image-file will be deleted.
EditPart of parent node:
nodeEditPart extends AbstractBorderedShapeEditPart
EditPart of child node:
ImageShapeOfNodeEditPart extends org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeEditPart {
...
@Override
protected void createDefaultEditPolicies() {
super.createDefaultEditPolicies();
installEditPolicy("shapeImageOfNodeDeletePolicy", new ShapeImageOfNodeDeletePolicy());
}
...
@Override
public boolean isSelectable() {
// if this is 'true',
return false;
}
}
Here is the code for adding the child node to the parent node:
...
File imageFile = new File(imagePath);
final Node imageNode = NotationFactory.eINSTANCE.createNode();
imageNode.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
imageNode.setType(ImageShapeOfNodeEditPartProvider.TOOL_IMAGE);
ImageBufferStyle ibs = NotationFactory.eINSTANCE.createImageBufferStyle();
final DescriptionStyle descStyle = NotationFactory.eINSTANCE.createDescriptionStyle();
EList<Style> styles = imageNode.getStyles();
styles.add(ibs);
styles.add(descStyle);
// store image file
String uuid = UUID.randomUUID().toString();
String imagePath = uuid + "_" + imageFile.getName();
FileUtil.storeImageFile(diagramFile, imagePath, imageFile);
descStyle.setDescription(imagePath);
ViewUtil.insertChildView(((View) ((EditPart) nodeEditPart).getModel()), imageNode, 1, true);
DescriptionStyle ds = (DescriptionStyle) imageNode.getStyle(NotationPackage.eINSTANCE.getDescriptionStyle());
node.setElement(null);
...
Can anyone help me with this issue?
|
|
|
Powered by
FUDForum. Page generated in 0.03700 seconds