[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[news.eclipse.tools.gef] Custom XYLayout re-sizing problem.

I have the DiagramEditPart which has an xylayout.

I have Container A that has an xylayout. I've manipulated the layout to allow the user to resize the figure manually, which has broken the auto-resizing functionality of the layout. I want the auto-resizing to work only when child figures are added/moved that exceed the bounds of Container A.

The children that are added to A have ToolbarLayouts and hence have a width and height of -1.

I spent a while trying to override the xylayout.layout () and change the bounds of the parent figure but this didn't work, as the parent figures bounds always revert back to the original value the next time layout is called. I not sure why this happens. The size of Container A is obtained from the model in Containter A's editPart, so maybe this is changing the bounds again? The bounds are never updated in the model using this method.

I can get the autosizing to work if I move Container A. This calls a changeConstraintCommand which sets the Container Model to the correct size.


So I've been trying to get around this problem by creating a ChangeConstraint command in refreshVisuals of the Container A. See code below. This also allows the autosizing to work, but I now can't move Container A? Do I need to set the constraint values here? If so how? I've tried putting values in request.setLocation but that does not seem to help.


Any advice would be appreciated and I'm aware I could be barking up the wrong tree altogether?

//**************************************************************
Request request = new ChangeBoundsRequest ();
request.setType (RequestConstants.REQ_RESIZE_CHILDREN);
((GroupRequest) request).setEditParts (getParent ()); Command cmd = getParent ().getParent ().getCommand (request);
if (cmd != null)
{
getViewer ().getEditDomain ().getCommandStack ().execute (cmd);
}
//***************************************************************


Thanks in advance,
Mark Robinson.