Link to node connection deletion [message #215905] |
Tue, 20 January 2009 12:03  |
Eclipse User |
|
|
|
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 #216603 is a reply to message #216595] |
Wed, 28 January 2009 12:12   |
Eclipse User |
|
|
|
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 #217026 is a reply to message #216809] |
Sat, 31 January 2009 12:55  |
Eclipse User |
|
|
|
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
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.25894 seconds