|
| Re: Delete from model/diagram [message #855455 is a reply to message #848680] |
Tue, 24 April 2012 17:00   |
Arto Jarvinen Messages: 32 Registered: May 2010 Location: Sweden |
Member |
|
|
Hi, don't you see any of these two menus? When I set the Diagram -> Synchronized property to true I only get "Delete from Model" activated which makes sense since the diagram and the (domain) model shall be in total sync. When I set it to false which is what I really want to do, both "Delete from Model" and "Delete from Diagram" appear. Again this makes sense since I want to be able to have stuff in the domain model that doesn't show in every diagram. (If this latter case one has to think a bit about what "Delete from Model" means. I for instance need to delete all view elements representing the domain model element I wish to delete which is not the default behavior.) The global Delete menu remains greyed out in my case though which I don't understand - yet. -A
Blog: http://www.ostrogothia.com/process/
|
|
|
| Re: Delete from model/diagram [message #885549 is a reply to message #848680] |
Wed, 13 June 2012 04: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.01753 seconds