[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.modeling.gmf] Re: Change location on creation

Javier wrote:

So that child node isn't actually contained in the parent node, but just a reference.... so then you have to handle the behavior in the handleNotificationEvent() method of the container (the real one, maybe it's the diagram), and there you should search for the parent of the reference and act accordingly.

Hi Javier, thanks for your help! I found a way using policies but I have a problem.

I write the code to move B near A. If I install the policy in B as an OPEN_POLICY (double click on B) it works, if I install as a DRAG_DROP_POLICY on A (When I create A this policy is called) it doesen't work. I can access to B but the code doesn't work, B stay in the original position.

This is the code to move b, i get b editPart looping on diagram's sons looking for the right b (the one that as a reference to the same a of the policy)


b = (BEditPart) a.getViewer().getEditPartRegistry().get(child); Point aPoint = a.getLocation(); Point bPoint = b.getLocation(); //Calculate b new position bPoint.x = aPoint.x - bPoint.x + (a.getSize().width / 2); bPoint.y = aPoint.y - bPoint.y + (a.getSize().height / 2); //Create the command move_req = new ChangeBoundsRequest(RequestConstants.REQ_MOVE); move_req.setMoveDelta(bPoint); move_req.setEditParts(b); cmd = balloon.getCommand(move_req); return cmd;

This code works in OpenEditPolicy installed in B, but not in DRAG_DROP policy