Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » problems in sending a command when deleting an editpart
problems in sending a command when deleting an editpart [message #900687] Wed, 08 August 2012 07:45 Go to next message
Chris B. is currently offline Chris B.Friend
Messages: 37
Registered: November 2011
Member
Hi,

I have created a new edit policy that reacts to the deletion of a certain edit part. The problem is that installing a ComponentEditPolicy results in ignoring the deletion request of GMF.This is what I've done.

public class DeleteExpressionLinksOnNodeDeleteEditPolicy extends ComponentEditPolicy
{

    @Override
    public Command getCommand(Request request)
    {
       return super.getCommand(request);
    }
}


Even if i just delegate the request to the super class it doesn't work, which means that it has nothing to do with the implementation in the 'getCommand' method itself.
Any idea what's going wrong?

Regards,
Chris



Re: problems in sending a command when deleting an editpart [message #900690 is a reply to message #900687] Wed, 08 August 2012 07:56 Go to previous messageGo to next message
Ralph Gerbig is currently offline Ralph GerbigFriend
Messages: 702
Registered: November 2009
Senior Member
Hi,

did you try to use the handleNotificationEvent method of your editpart? Alternatively you can insatll a resourceset listener on the the diagram resource and listen to changes in the whole diagram. If handleNotificationEvent does not react on changes to children I can post you some code to get it doing so.

Ralph
Re: problems in sending a command when deleting an editpart [message #900700 is a reply to message #900690] Wed, 08 August 2012 08:32 Go to previous messageGo to next message
Chris B. is currently offline Chris B.Friend
Messages: 37
Registered: November 2011
Member
Hi Ralph,

thanks for your reply. The handleNotificationEvent method responds to any attribute changes. How can I find out that the edit part is about to be deleted? I only want to respond to that action. in other words, it should only change attributes either when the delete button was pressed or the "delete from model" item was selected in the context menu.

Chris
Re: problems in sending a command when deleting an editpart [message #900744 is a reply to message #900700] Wed, 08 August 2012 11:31 Go to previous messageGo to next message
Ralph Gerbig is currently offline Ralph GerbigFriend
Messages: 702
Registered: November 2009
Senior Member
Hi,

us an if-statement to filter for what you are interested in.

With notification.getNotifier() instanceof MySemanticModelElement you can prevent getting notified about changes to the NotationModel etc. ((EStructuralFeature) notification.getFeature()).getName().equals("featureIamInterestedIn") can help you to filter for a distinct feature. Here you will have a list that changes after deleting the model element. With .getOldValue and .getNewValue you can see if you have an add or remove operation. All you need to do is to construct an if-statement around the code you want to execute. To find the right values the debugger can help you a lot there.

Ralph
Re: problems in sending a command when deleting an editpart [message #900955 is a reply to message #900744] Thu, 09 August 2012 08:26 Go to previous messageGo to next message
Chris B. is currently offline Chris B.Friend
Messages: 37
Registered: November 2011
Member
Hi Ralph,

what i want to achieve actually is to delete the connector of the edit part that preceds the deleted edit part. The reason is i'm getting the following exception:
"The feature [connector] contains a dangling reference [connection source]"
I had a look at the XMI content of the diagram and the connector, with which the deleted edit part was connected, still exists in the semantic model, while the edge in the notation part was correctly deleted and therefore not visible in the diagram.
I've managed it to delete the connectors now in the handleNotificationEvent method but i'm still facing this error. Do you know what the problem could be?

Regards,
Chris
Re: problems in sending a command when deleting an editpart [message #900993 is a reply to message #900955] Thu, 09 August 2012 11:09 Go to previous message
Chris B. is currently offline Chris B.Friend
Messages: 37
Registered: November 2011
Member
OK, finally I solved the problem. I had to call
EcoreUtil.delete(connector);
on each element in the operation children list of the node before clearing the list.

Regards,
Chris

[Updated on: Thu, 09 August 2012 11:10]

Report message to a moderator

Previous Topic:Dummy Node
Next Topic:Cannot build update site with GMF 3.0.0.v201206221900
Goto Forum:
  


Current Time: Fri Mar 29 11:51:07 GMT 2024

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

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

Back to the top