Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Custom XYLayout re-sizing problem.
Custom XYLayout re-sizing problem. [message #229366] Thu, 18 January 2007 17:51 Go to next message
Mark Robinson is currently offline Mark RobinsonFriend
Messages: 37
Registered: July 2009
Member
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.
Re: Custom XYLayout re-sizing problem. [message #229390 is a reply to message #229366] Thu, 18 January 2007 18:40 Go to previous messageGo to next message
Nhu Le is currently offline Nhu LeFriend
Messages: 47
Registered: July 2009
Member
I think you have to override getMinimumSize()/getPreferredSize() in the
layout manager.

Nhu

Mark Robinson wrote:
> 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.
>
Re: Custom XYLayout re-sizing problem. [message #229461 is a reply to message #229390] Fri, 19 January 2007 17:22 Go to previous message
Mark Robinson is currently offline Mark RobinsonFriend
Messages: 37
Registered: July 2009
Member
Thanks Nhu.

I got this working. I still generate a ChangeConstraintCommand, but I was
originally doing it in the wrong place. I now generate the command in the
refreshVisuals of the container A's children. I check the preferredSize of
the parent Container, if it is larger than the values held in Container
A's model then I create the command. Bingo! It works.

Regards,
Mark Robinson.





Nhu Le wrote:

> I think you have to override getMinimumSize()/getPreferredSize() in the
> layout manager.

> Nhu

> Mark Robinson wrote:
>> 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.
>>
Previous Topic:Loop Connections
Next Topic:Execution problem with GEF text example
Goto Forum:
  


Current Time: Sat Apr 20 03:53:50 GMT 2024

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

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

Back to the top