Displaying EditParts on a GraphicalEditor [message #20128] |
Wed, 18 September 2002 16:57  |
Eclipse User |
|
|
|
Originally posted by: jayuen.alumni.uwaterloo.ca
Hi:
I'm fairly new to Eclipse.
I am trying to display some GraphicalEditParts on a GraphicalEditor. I want
the output to look similar to the LogicDiagram example but less interactive
(i.e. the EditParts are hardcoded to appear in the editor as opposed to
being dragged on by the user).
So far, I am able to display my editor (as a plugin) and I can change the
color of the RootEditPart..
I've also installed a :Layout EditPolicy on the RootEditPart that implements
the getCreateCommand method. I'm not even sure if I NEED to create Commands
since (at this stage) I do not require any user interaction with my editor.
However, I can't seem to add any glyphs to the RootEditPart or get them to
appear.
I was wondering if anyone could provide some sample code or a checklist of
things that I must do in order to display these EditParts.
Thanks a lot!
Jason
|
|
|
|
|
Re: Displaying EditParts on a GraphicalEditor [message #20137 is a reply to message #20134] |
Thu, 19 September 2002 09:01   |
Eclipse User |
|
|
|
Originally posted by: hudsonr.us.eye-bee-em.com
> 1. I have a ScrollingGraphicalViewer.
> 2. I have added my own EditPartFactory to the viewer
> 3. The EditPartFactory that I have created creates different EditParts
based
> on the type of model passed in
> BTW - I noticed that in the Shapes example, the ShapeEditPartFactory
> does not use the EditPart parameter that is passed in. Why?
In some cases it is interesting to know the context in which the child is
being viewed. That's why we pass the parent, but it is normally ignored.
> 4. I have called setContents on the viewer to add an EditPart
> 5. this EditPart overrides getModelChildren() and returns a list of
"glyph"
> model children
> 6. I have also created some models and their corresponding EditParts.
Each
> of these EditParts implements the refreshVisuals method (not sure if
> necessary?)
What do you mean you created them? Did you create the models before
everything else? You should not directly create EditParts. The factory
will do this. Step into setContents on the viewer. When the contents is
added to the "root" edit part, it will initialize itself (doInitialize()).
That is when *IT* will create the child EditParts provided that
getModelChildren() returns a list of children at that time.
If you add model children later on, your container editpart needs to get
notified, and call refreshChildren().
> In order to get some EditParts onto the viewer, should I be invoking
> createEditPart via the EditPartFactory? If so, where should I be creating
> my EditParts (right now, I have the code in the configureGraphicalViewer
> method?)
> Or is there something I am still missing?
See above, you don't create the parts directly.
|
|
|
Re: Displaying EditParts on a GraphicalEditor [message #20139 is a reply to message #20137] |
Thu, 19 September 2002 10:42  |
Eclipse User |
|
|
|
Originally posted by: jayuen.alumni.uwaterloo.ca
Thanks for all the help Randy.
Turns out that I was not firing propertyChangeEvents from my "root" model so
I guess each time I was adding glyphs to my "root" glyph, the root edit part
was not receiving any events.
"Randy Hudson" <hudsonr@us.eye-bee-em.com> wrote in message
news:amcgr1$l92$1@rogue.oti.com...
> > 1. I have a ScrollingGraphicalViewer.
> > 2. I have added my own EditPartFactory to the viewer
> > 3. The EditPartFactory that I have created creates different EditParts
> based
> > on the type of model passed in
> > BTW - I noticed that in the Shapes example, the ShapeEditPartFactory
> > does not use the EditPart parameter that is passed in. Why?
>
> In some cases it is interesting to know the context in which the child is
> being viewed. That's why we pass the parent, but it is normally ignored.
>
> > 4. I have called setContents on the viewer to add an EditPart
> > 5. this EditPart overrides getModelChildren() and returns a list of
> "glyph"
> > model children
> > 6. I have also created some models and their corresponding EditParts.
> Each
> > of these EditParts implements the refreshVisuals method (not sure if
> > necessary?)
>
> What do you mean you created them? Did you create the models before
> everything else? You should not directly create EditParts. The factory
> will do this. Step into setContents on the viewer. When the contents is
> added to the "root" edit part, it will initialize itself (doInitialize()).
> That is when *IT* will create the child EditParts provided that
> getModelChildren() returns a list of children at that time.
>
> If you add model children later on, your container editpart needs to get
> notified, and call refreshChildren().
>
> > In order to get some EditParts onto the viewer, should I be invoking
> > createEditPart via the EditPartFactory? If so, where should I be
creating
> > my EditParts (right now, I have the code in the configureGraphicalViewer
> > method?)
> > Or is there something I am still missing?
>
> See above, you don't create the parts directly.
>
>
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.03279 seconds