Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » confused about ConstrainedLayoutPolicy.createAddCommand()
confused about ConstrainedLayoutPolicy.createAddCommand() [message #65367] Tue, 18 February 2003 15:48 Go to next message
Eclipse UserFriend
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 20:59 Go to previous messageGo to next message
Eclipse UserFriend
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 #65523 is a reply to message #65502] Tue, 18 February 2003 23:07 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: john-mason.shackelford.pearson.com

Randy,

Thanks for your comments.


> Commands are only used to make changes to the model,
> and the model is not being changed at startup.

This is the rub for me I think. Since Annotations (location, etc.) are
not part of my primary model they are actually changed/created at
startup. I understood your previous email (quoted below) to suggest that
the layout policy should have something to do with establishing the
initial constraint.

> 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).

Earlier I had thought that you meant that my layout policy is/should be
keeping track of the children in the view.

I am now proceeding on the assumption that by "child's index in the
parent" you mean that the ContentsEditPart should be keeping track of
the children added to it and supply that info in a getter to the child
EditPart. Please alert me if I have missed something here.

I suppose you may also have meant that the top level model object should
provide "the child's index in the parent."


> Have you used the integrated online help? Help->Contents.

I've been camped out there lately :) Thanks for your willingness to
answer questions. There is a lot of information here to digest and I am
picking it up slowly.

--

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 #65544 is a reply to message #65523] Wed, 19 February 2003 02:03 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: user.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).


> IFigure parent = figure.getParent();
> int index = parent.indexOf(figure);

Ah, now I understand.

John-Mason P. Shackelford
Re: confused about ConstrainedLayoutPolicy.createAddCommand() [message #65565 is a reply to message #65544] Wed, 19 February 2003 04:41 Go to previous message
Eclipse UserFriend
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
>
Previous Topic:copy and paste in GEF
Next Topic:Change the Figure after it is first created
Goto Forum:
  


Current Time: Sun Dec 22 01:56:19 GMT 2024

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

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

Back to the top