Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Link to node connection deletion
Link to node connection deletion [message #215905] Tue, 20 January 2009 17:03 Go to next message
Guillaume Gauffre is currently offline Guillaume GauffreFriend
Messages: 65
Registered: July 2009
Member
Hi,

My generated editor contains a link to node connection which refer to a
containment in my metamodel. It works fine but there is a problem for
the deletion !
link1
NodeA ---------------------> NodeB
|
|link2
|
NodeC

Deleting the NodeC deletes also the link2
Deleting the link1 doesn't make anything, even after reloading the diagram.
So I had some code to the Link1ItemSementicPolicy by modifying
getDestroyElementCommand: the NodeC and link2 are deleted but the link1
is still visible. I need to relaod the diagram to see changes.

Here is the code added:
protected Command getDestroyElementCommand(DestroyElementRequest req) {
CompoundCommand cmd = new CompoundCommand();
View view = (View) getHost().getModel();
for (Iterator it = view.getSourceEdges().iterator(); it.hasNext();) {
Edge ed = (Edge) it.next();
Node node = (Node) ed.getTarget();
if (node != null && node.getElement() instanceof NodeC)
cmd.add(getDestroyElementCommand(node));
}
cmd.add(getGEFWrapper(new DestroyElementCommand(req)));
return cmd.unwrap();
}

Does it miss something ?
Is it possible to add a command to refresh the elements of the diagram ?

Thanks,
Guillaume
Re: Link to node connection deletion [message #216461 is a reply to message #215905] Tue, 27 January 2009 11:03 Go to previous messageGo to next message
Guillaume Gauffre is currently offline Guillaume GauffreFriend
Messages: 65
Registered: July 2009
Member
Hi,
Any idea ?

Guillaume a écrit :
> Hi,
>
> My generated editor contains a link to node connection which refer to a
> containment in my metamodel. It works fine but there is a problem for
> the deletion !
> link1
> NodeA ---------------------> NodeB
> |
> |link2
> |
> NodeC
>
> Deleting the NodeC deletes also the link2
> Deleting the link1 doesn't make anything, even after reloading the diagram.
> So I had some code to the Link1ItemSementicPolicy by modifying
> getDestroyElementCommand: the NodeC and link2 are deleted but the link1
> is still visible. I need to relaod the diagram to see changes.
>
> Here is the code added:
> protected Command getDestroyElementCommand(DestroyElementRequest req) {
> CompoundCommand cmd = new CompoundCommand();
> View view = (View) getHost().getModel();
> for (Iterator it = view.getSourceEdges().iterator(); it.hasNext();) {
> Edge ed = (Edge) it.next();
> Node node = (Node) ed.getTarget();
> if (node != null && node.getElement() instanceof NodeC)
> cmd.add(getDestroyElementCommand(node));
> }
> cmd.add(getGEFWrapper(new DestroyElementCommand(req)));
> return cmd.unwrap();
> }
>
> Does it miss something ?
> Is it possible to add a command to refresh the elements of the diagram ?
>
> Thanks,
> Guillaume
Re: Link to node connection deletion [message #216510 is a reply to message #216461] Tue, 27 January 2009 16:11 Go to previous messageGo to next message
Alex Boyko is currently offline Alex BoykoFriend
Messages: 200
Registered: July 2009
Senior Member
Hi,

As far as I understood the problem is that when you select and delete link
1, you want link2 and NodeC to be deleted too, but only link1 and link2
are deleted is that correct?
One place to look at would be NotationViewDependentsAdvice.

Cheers,
Alex
Re: Link to node connection deletion [message #216595 is a reply to message #216510] Wed, 28 January 2009 17:06 Go to previous messageGo to next message
Guillaume Gauffre is currently offline Guillaume GauffreFriend
Messages: 65
Registered: July 2009
Member
Hi,
link1
NodeA ----------------------> NodeB
|
|link2
|
NodeC

The fact is that all elements are deleted from the emf model but link1
remain visible in the diagram using the code I had to the
semanticEditPolicy of the link1.
I don't know how to use the NotationViewDependentsAdvice,
I tried :

CompoundCommand cmd = new CompoundCommand();
cmd.add(getGEFWrapper(new
NotationViewDependentsAdvice().getBeforeEditCommand(req)));
cmd.add(getGEFWrapper(new DestroyElementCommand(req)));
return cmd;

but the link1 is not deleted, and is not deleted in the emf model too.
Do you have an example for using this Class ?

Thanks

Guilaume

Alex Boyko a écrit :
> Hi,
>
> As far as I understood the problem is that when you select and delete
> link 1, you want link2 and NodeC to be deleted too, but only link1 and
> link2 are deleted is that correct?
> One place to look at would be NotationViewDependentsAdvice.
>
> Cheers,
> Alex
>
>
Re: Link to node connection deletion [message #216603 is a reply to message #216595] Wed, 28 January 2009 17:12 Go to previous messageGo to next message
Guillaume Gauffre is currently offline Guillaume GauffreFriend
Messages: 65
Registered: July 2009
Member
I tried with another trick :

return getGEFWrapper(CompositeCommand.compose(new
NotationViewDependentsAdvice().getBeforeEditCommand(req),
new DestroyElementCommand(req)));

In that case, everything is deleted from the emf model, but the notation
elements remain visible until I reload the diagram.

Guillaume

Guillaume a écrit :
> Hi,
> link1
> NodeA ----------------------> NodeB
> |
> |link2
> |
> NodeC
>
> The fact is that all elements are deleted from the emf model but link1
> remain visible in the diagram using the code I had to the
> semanticEditPolicy of the link1.
> I don't know how to use the NotationViewDependentsAdvice,
> I tried :
>
> CompoundCommand cmd = new CompoundCommand();
> cmd.add(getGEFWrapper(new
> NotationViewDependentsAdvice().getBeforeEditCommand(req)));
> cmd.add(getGEFWrapper(new DestroyElementCommand(req)));
> return cmd;
>
> but the link1 is not deleted, and is not deleted in the emf model too.
> Do you have an example for using this Class ?
>
> Thanks
>
> Guilaume
>
> Alex Boyko a écrit :
>> Hi,
>>
>> As far as I understood the problem is that when you select and delete
>> link 1, you want link2 and NodeC to be deleted too, but only link1 and
>> link2 are deleted is that correct?
>> One place to look at would be NotationViewDependentsAdvice.
>>
>> Cheers,
>> Alex
>>
>>
Re: Link to node connection deletion [message #216682 is a reply to message #216603] Thu, 29 January 2009 12:11 Go to previous messageGo to next message
Guillaume Gauffre is currently offline Guillaume GauffreFriend
Messages: 65
Registered: July 2009
Member
Hi,

It seems that NotationViewDependentsAdvice is made to delete all
elements constituing a NotationView (fontstyle, bendpoints, etc.)
I traced the execution of my command and this helper is not necessary
because with my code, all notation elements are deleted. The notation
file is correctly modified, but the diagram is not updated for my link1.

Is there a command for updating the diagram that could be added to my
destroy command ?
Or maybe must I customize a specific helper or policy ?

Guillaume
Re: Link to node connection deletion [message #216809 is a reply to message #215905] Fri, 30 January 2009 10:45 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Guillaume,

You can use generated EcoreBaseItemSemanticEditPolicy.getDestroyEdgesCommand()
if you want to delete link pointing to the link being deleted.

In addition you can submit a request to support this situation in GMF code
generator (shutdown all incoming/outgoing links to/from “the link” during
“the link” deletion).

> Does it miss something ?
Looks like posted snipped is correct. Can you see any exceptions in the log/debugger
thrown during link deletion?

-----------------
Alex Shatalin
Re: Link to node connection deletion [message #217026 is a reply to message #216809] Sat, 31 January 2009 17:55 Go to previous message
Guillaume Gauffre is currently offline Guillaume GauffreFriend
Messages: 65
Registered: July 2009
Member
Hi Alex,

Thanks for your help.
I saw the log and found an error which lead me to a problem in a
selectionEditPlociy I made. The problem came from that.
In fact the GMF code is perfect in that case !
Thanks for the framework and the help !

Guillaume

Alex Shatalin a écrit :
> Hello Guillaume,
>
> You can use generated
> EcoreBaseItemSemanticEditPolicy.getDestroyEdgesCommand() if you want to
> delete link pointing to the link being deleted.
>
> In addition you can submit a request to support this situation in GMF
> code generator (shutdown all incoming/outgoing links to/from “the link”
> during “the link” deletion).
>
>> Does it miss something ?
> Looks like posted snipped is correct. Can you see any exceptions in the
> log/debugger thrown during link deletion?
>
> -----------------
> Alex Shatalin
>
>
Previous Topic:[Announce] GMF 2.2.0 I200901301450 is available
Next Topic:Creating elements in GMF outside of the current editor
Goto Forum:
  


Current Time: Tue Apr 23 12:42:25 GMT 2024

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

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

Back to the top