Moving a block container and its children NOT WORKING [message #225620] |
Wed, 01 November 2006 01:05 |
Eclipse User |
|
|
|
Originally posted by: vinhtran2004-eclipsezone.yahoo.com
Hi,
I have an GEF editor that draws a block container which has children in the box (boxes). I move the block container around and see the block container children move with it, but when I select a child box in block container, the selected and the other children are back to the original location. I believe the children locations don't update and I check it. My questions are:
How to get the x and y position when the parent box move?
Do I have to make the children x and y position relative to parent box?
Any suggestion? Thanks.
Vinh
|
|
|
Re: Moving a block container and its children NOT WORKING [message #225630 is a reply to message #225620] |
Wed, 01 November 2006 05:50 |
Xiang Qinxian Messages: 119 Registered: July 2009 |
Senior Member |
|
|
VINH TRAN 写道:
> Hi,
> I have an GEF editor that draws a block container which has children in the box (boxes). I move the block container around and see the block container children move with it, but when I select a child box in block container, the selected and the other children are back to the original location. I believe the children locations don't update and I check it. My questions are:
>
> How to get the x and y position when the parent box move?
> Do I have to make the children x and y position relative to parent box?
> Any suggestion? Thanks.
>
> Vinh
Hi,
Maybe there not a layout in block container box, if so, set it with a
layout manager.
If have layoutEditPolicy in editPart, can do
createChangeConstraintCommand in LayoutEditPolicy subclass, for example,
XYLayoutEditPolicy.
@Override
protected Command createChangeConstraintCommand(EditPart child,
Object constraint) {
Rectangle bounds = null;
if (constraint instanceof Rectangle) {
bounds = (Rectangle) constraint;
} else if (constraint instanceof Point) {
bounds = new Rectangle();
bounds.setLocation((Point) constraint);
}
....
}
this code answer question 1, if x, y location referred to child in the
question, if referred to parent self, so the code is in parent of parent
editpolicy.
when use layout, x, y of child are default ralative to parent figure.
Qinxian
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03838 seconds