Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Displaying EditParts on a GraphicalEditor
Displaying EditParts on a GraphicalEditor [message #20128] Wed, 18 September 2002 20:57 Go to next message
Eclipse UserFriend
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 #20131 is a reply to message #20128] Wed, 18 September 2002 21:27 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: hudsonr.us.eye-bee-em.com

"Jason Yuen" <jayuen@alumni.uwaterloo.ca> wrote in message
news:amaob0$qvc$1@rogue.oti.com...
> 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.

you probably don't need any policies at all.

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

In the JavaDOC, look at the methods on AbstractEditPart that are marked with
Green Circles. Those are the ones that are most commonly overridden. You
should have a ScrollingGraphicalViewer. You then give it an EditPartFactory
that know how to create your EditPArt subclasses for each model in the
viewer. Then you setContents() on the Editor.

The editpart that your factory returns for the content model object should
override getModelChildren() to return the child "glyph" model objects. The
factory will then be asked to create EditParts for each of those glyphs.
Re: Displaying EditParts on a GraphicalEditor [message #20134 is a reply to message #20131] Wed, 18 September 2002 22:56 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jayuen.alumni.uwaterloo.ca

Hmmm... I had actually put in all the steps you had mentioned..

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

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?

Thanks a lot

Jason

"Randy Hudson" <hudsonr@us.eye-bee-em.com> wrote in message
news:amaq4l$s29$1@rogue.oti.com...
>
> "Jason Yuen" <jayuen@alumni.uwaterloo.ca> wrote in message
> news:amaob0$qvc$1@rogue.oti.com...
> > 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.
>
> you probably don't need any policies at all.
>
> > 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.
>
> In the JavaDOC, look at the methods on AbstractEditPart that are marked
with
> Green Circles. Those are the ones that are most commonly overridden. You
> should have a ScrollingGraphicalViewer. You then give it an
EditPartFactory
> that know how to create your EditPArt subclasses for each model in the
> viewer. Then you setContents() on the Editor.
>
> The editpart that your factory returns for the content model object should
> override getModelChildren() to return the child "glyph" model objects.
The
> factory will then be asked to create EditParts for each of those glyphs.
>
>
>
Re: Displaying EditParts on a GraphicalEditor [message #20137 is a reply to message #20134] Thu, 19 September 2002 13:01 Go to previous messageGo to next message
Eclipse UserFriend
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 14:42 Go to previous message
Eclipse UserFriend
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.
>
>
>
>
Previous Topic:GEF logic editor startup
Next Topic:JavaDoc
Goto Forum:
  


Current Time: Sun Dec 22 02:21:38 GMT 2024

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

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

Back to the top