[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.modeling.gmf] Re: Link to node connection deletion

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