confused about ConstrainedLayoutPolicy.createAddCommand() [message #65367] |
Tue, 18 February 2003 10:48  |
Eclipse User |
|
|
|
Originally posted by: john-mason.shackelford.pearson.com
Please forgive my ignorance, but I am having trouble understanding why
the layout policy is not used when initially saturating the model.
As I understand it the flow (abbreviated) is as follows:
1. ContentsEditPart.setModel(model)
2. ContentsEditPart.getModelChildren()
3. GraphicalEditPartFactory().createEditPart(parent, model)
4. ChildEditPart().createEditPolicies()
5. ChildEditPart().createFigure()
6. ChildEditPart().refresh()
But I would have expected the parent's
LayoutEditPolicy.createAddCommand() to have been called, otherwise the
initial creation of figures and constraints has to be handled by the
GraphicalEditPartFactory or the ChildEditPart directly whereas
ordinarily you'd let the Policy manipulate the model with commands.
What am I failing to understand? (Thanks for entertaining what is
probably a dumb question.)
--
John-Mason Shackelford
Software Developer
Pearson Educational Measurement - eMeasurement Group
2510 North Dodge St.
Iowa City, IA 52245
ph. 319-354-9200x6214
john-mason.shackelford@pearson.com
http://etest.ncspearson.com
|
|
|
Re: confused about ConstrainedLayoutPolicy.createAddCommand() [message #65502 is a reply to message #65367] |
Tue, 18 February 2003 15:59   |
Eclipse User |
|
|
|
Originally posted by: none.us.ibm.com
"John-Mason P. Shackelford" <john-mason.shackelford@pearson.com> wrote in
message news:3E5255D4.2040807@pearson.com...
> Please forgive my ignorance, but I am having trouble understanding why
> the layout policy is not used when initially saturating the model.
>
> As I understand it the flow (abbreviated) is as follows:
>
> 1. ContentsEditPart.setModel(model)
By the time you create the first EditPart, here, the model has already been
completely saturated from its file. So what is happening is that the
EditParts are getting built to parellel (approximately) the model. Commands
are only used to make changes to the model, and the model is not being
changed at startup.
You should not be calling EditPart.addXxx at any time. This is called
internally as a result of changing your model, and then calling
refreshXxx(). It is necessary to call refresh (after startup, such as when
the user makes a change), and also override getModelChildren().
Have you used the integrated online help? Help->Contents.
> 2. ContentsEditPart.getModelChildren()
> 3. GraphicalEditPartFactory().createEditPart(parent, model)
> 4. ChildEditPart().createEditPolicies()
> 5. ChildEditPart().createFigure()
> 6. ChildEditPart().refresh()
>
> But I would have expected the parent's
> LayoutEditPolicy.createAddCommand() to have been called, otherwise the
> initial creation of figures and constraints has to be handled by the
> GraphicalEditPartFactory or the ChildEditPart directly whereas
> ordinarily you'd let the Policy manipulate the model with commands.
>
> What am I failing to understand? (Thanks for entertaining what is
> probably a dumb question.)
>
> --
>
> John-Mason Shackelford
>
> Software Developer
> Pearson Educational Measurement - eMeasurement Group
>
> 2510 North Dodge St.
> Iowa City, IA 52245
> ph. 319-354-9200x6214
> john-mason.shackelford@pearson.com
> http://etest.ncspearson.com
>
|
|
|
|
|
Re: confused about ConstrainedLayoutPolicy.createAddCommand() [message #65565 is a reply to message #65544] |
Tue, 18 February 2003 23:41  |
Eclipse User |
|
|
|
Originally posted by: none.us.ibm.com
<user@domain.invalid> wrote in message
news:3E52E5F9.7030102@domain.invalid...
> Randy,
>
> > You should be using an XYLayout. One way to handle this would be in
> > the code in the child EditPart that sets the constraint in the
> > XYLayout associated with the child. If the child *model* has no
> > stored constraint, then generate one based on the child's index in the
> > parent. Such as
> > new Rectangle (index*avgWidth, 20, avgWidth, vgHeight).
Wow, did I really post this? This is a cheap way to layout figures. You
could probably do much better depending on the domain. For example, if the
figures are connected to each other, there are hundreds of (difficult) ways
to generate a layout.
>
> > IFigure parent = figure.getParent();
> > int index = parent.indexOf(figure);
>
> Ah, now I understand.
>
> John-Mason P. Shackelford
>
|
|
|
Powered by
FUDForum. Page generated in 0.03589 seconds