|
|
Re: Delete from model/diagram [message #885549 is a reply to message #848680] |
Wed, 13 June 2012 08:31 |
supermmao supermmao Messages: 1 Registered: June 2012 |
Junior Member |
|
|
hi,do you solve this problem now?
maybe this method can help you:
1. modify DiagramEditorContextMenuProvider's method:
public void buildContextMenu(...) {
...
public void run() {
...
// add this line
menu.remove(ActionIds.ACTION_DELETE_FROM_DIAGRAM); // remove "delete from
// diagram" action
}
}
2. in the XXXEditPart's createDefaultEditPolicies(),add this line:
installEditPolicy(EditPolicy.CONNECTION_ROLE, new XXXEditPolicy());
3. then create a class,names XXXEditPolicy:
public class XXXEditPolicy extends ConnectionEditPolicy{
@Override
protected boolean shouldDeleteSemantic() { // override this method,
// make shouldDeleteSemantic()
// return true;
return true;
}
}
Through the 3 steps,you can forbid the "delete from diagram",if you press the "delete", the element can be deleted from model.
But when you press the "delete" or "backspace", it will pop-up a message dialog.If you don't want it pops up dialog, you can override the createDeleteSemanticCommand method of ConnectionEditPolicy in XXXEditPolicy:
@Override
protected Command createDeleteSemanticCommand(...) {
...
semReq =
new EditCommandRequestWrapper(new DestroyElementRequest(editingDomain,
false), ....); // use false replaces
// grDeleteRequest.isShowInformationDialog()
...
}
|
|
|
|
Powered by
FUDForum. Page generated in 0.03465 seconds