Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Intercept deleting connection command
Intercept deleting connection command [message #480804] Tue, 18 August 2009 14:32 Go to next message
Nikola Milikic is currently offline Nikola MilikicFriend
Messages: 10
Registered: July 2009
Junior Member
Hi,

When user deletes specific connection from my diagram, I would like to
perform some cleaning before that reference is deleted from the model.

I tried to implement that behavior into class called
XXXItemSemanticEditPolicy in method getDestroyReferenceCommand(), but the
problem is that the method is called also when user just select that
connection on diagram.

Has anyone maybe had the similar problem or know how to do this?

Appreciate for your help and time.

Nikola Milikic
Re: Intercept deleting connection command [message #481009 is a reply to message #480804] Wed, 19 August 2009 10:50 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Nikola,

> XXXItemSemanticEditPolicy in method getDestroyReferenceCommand(), but
This is a proper place - you have to create new command there and return
it. This command will delete all the necessary model elements (clean it up)
on its execution.

-----------------
Alex Shatalin
Re: Intercept deleting connection command [message #481278 is a reply to message #481009] Thu, 20 August 2009 10:34 Go to previous message
Nikola Milikic is currently offline Nikola MilikicFriend
Messages: 10
Registered: July 2009
Junior Member
Thank you Alex for the answer.

Actually, what I wanted is to delete this connection (and reference) in
opposite direction which is automatically created when connection is
created in one direction.

I've managed to do this by in before-mentioned method

getDestroyReferenceCommand(DestroyReferenceRequest req)

manually creating another request where I just switched places for
container and referenced object:

DestroyReferenceRequest oppReq = new
DestroyReferenceRequest(req.getReferencedObject(),
req.getContainingFeature(), req.getContainer(),
req.isConfirmationRequired());


and I just returned CompoundCommand with this two request wrapped

CompoundCommand cc = new CompoundCommand();

cc.add(getGEFWrapper(new DestroyReferenceCommand(req)));
cc.add(getGEFWrapper(new DestroyReferenceCommand(oppReq)));


It works fine. Maybe it's not the best solution, but works for my case. I
just wanted to share it with others.

Chears,
Nikola Milikic
Previous Topic:how to gmf editor image if the gmf editor is closed!
Next Topic:To send notification to editor from view on button click
Goto Forum:
  


Current Time: Thu Mar 28 13:10:47 GMT 2024

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

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

Back to the top