Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Editparts, Figures and children
Editparts, Figures and children [message #158146] Tue, 16 November 2004 16:55 Go to next message
Eclipse UserFriend
Originally posted by: spam.nospam.com

Hi all,

I've designed a GEF editor to edit bean properties. I have a
BeanEditPart and a PropertyEditPart. The BeanEditPart will have a child
PropertyEditPart for every property (as defined via commons Attributes
xdoclet markup).

I have all this working, but would like a sanity check on my use of
Figures and EditParts.

My BeanEditPart has a EditPolicy.COMPONENT_ROLE as it is not strictly a
container in the GEF sense of the word. I.e. It has children but this is
a fixed number of PropertyEditParts. You cannot add/delete or move these
children so it is not a GEF container.

The PropertyEditPart is a container which allows a single child - the
value that will set the property of the bean. When a value is set, this
in turn will cause a BeanEditPart to be created etc, etc.

Now, when I created my figures, the PropertyEditPart simply returns a
Figure with a FlowLayout; no problem there. I want the BeanEditPart to
construct a Figure containing both labels and PropertyEditPart figures.
Ultimately I want to achieve something like this:

------------ ------------
| property | is greater than | property |
------------ ------------

I.e. Parts of the figure are just non-editable layout and information to
describe the interrelation of the properties.

And finally the question:
Is it safe to override addChildVisual and removeChildVisual to do
nothing. I can then take the responsibility for adding child
PropertyEditPart figures in the createFigure() method. I have so far
added placeholders for the child figures and replaced them by overridden
add/removeChildVisual() methods.

Thanks for your help. Looking forward to a response.

Pat

p.s. Appreciated all of the mails in the newsgroup. This is certainly a
valuable resource to understanding GEF.
Re: Editparts, Figures and children [message #158236 is a reply to message #158146] Wed, 17 November 2004 03:19 Go to previous messageGo to next message
Pratik Shah is currently offline Pratik ShahFriend
Messages: 1077
Registered: July 2009
Senior Member
"Pat" <spam@nospam.com> wrote in message
news:cndbj7$scg$1@www.eclipse.org...
> Hi all,
>
> I've designed a GEF editor to edit bean properties. I have a
> BeanEditPart and a PropertyEditPart. The BeanEditPart will have a child
> PropertyEditPart for every property (as defined via commons Attributes
> xdoclet markup).
>
> I have all this working, but would like a sanity check on my use of
> Figures and EditParts.
>
> My BeanEditPart has a EditPolicy.COMPONENT_ROLE as it is not strictly a
> container in the GEF sense of the word. I.e. It has children but this is
> a fixed number of PropertyEditParts. You cannot add/delete or move these
> children so it is not a GEF container.

####
Doesn't matter. It's still a container. Containment is defined by ability
to have children. The constraints on the children are irrelevant.

>
> The PropertyEditPart is a container which allows a single child - the
> value that will set the property of the bean. When a value is set, this
> in turn will cause a BeanEditPart to be created etc, etc.
>
> Now, when I created my figures, the PropertyEditPart simply returns a
> Figure with a FlowLayout; no problem there. I want the BeanEditPart to
> construct a Figure containing both labels and PropertyEditPart figures.
> Ultimately I want to achieve something like this:
>
> ------------ ------------
> | property | is greater than | property |
> ------------ ------------
>
> I.e. Parts of the figure are just non-editable layout and information to
> describe the interrelation of the properties.
>
> And finally the question:
> Is it safe to override addChildVisual and removeChildVisual to do
> nothing. I can then take the responsibility for adding child
> PropertyEditPart figures in the createFigure() method. I have so far
> added placeholders for the child figures and replaced them by overridden
> add/removeChildVisual() methods.

####
Okay, I'm not familiar with the xdoclet markup and hence it's not entirely
clear to me what you're trying to do. But it seems that you have a case
where two distinct model entities are to be shown as having a parent/child
relationship on the screen. While their relationship may not be as such in
the model, it's perfectly fine to have the BeanEditPart be the parent of the
PropertyEditParts (if that's how you want to represent them).

To answer your actual question, there's nothing stopping you from overriding
those methods. If you're not ever going to have children editparts, it
shouldn't create any problems. However, I wouldn't recommend it; moreso
because it seems you don't need to. It's easy to end up with some ugly code
if you don't know what you're doing or don't understand the framework
entirely.

>
> Thanks for your help. Looking forward to a response.
>
> Pat
>
> p.s. Appreciated all of the mails in the newsgroup. This is certainly a
> valuable resource to understanding GEF.
Re: Editparts, Figures and children [message #158291 is a reply to message #158236] Wed, 17 November 2004 08:28 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: spam.nospam.com

Pratik Shah wrote:

> ####
> Doesn't matter. It's still a container. Containment is defined by ability
> to have children. The constraints on the children are irrelevant.

Agreed. Only to all intents it isn't a container to GEF as it isn't
possible to add or remove the children. They are a fixed number, and so
to GEF it only has a component role.

> ####
> Okay, I'm not familiar with the xdoclet markup and hence it's not entirely
> clear to me what you're trying to do. But it seems that you have a case
> where two distinct model entities are to be shown as having a parent/child
> relationship on the screen. While their relationship may not be as such in
> the model, it's perfectly fine to have the BeanEditPart be the parent of the
> PropertyEditParts (if that's how you want to represent them).

Yep, I know this. This bit is working fine :-)

> To answer your actual question, there's nothing stopping you from overriding
> those methods. If you're not ever going to have children editparts, it
> shouldn't create any problems. However, I wouldn't recommend it; moreso
> because it seems you don't need to. It's easy to end up with some ugly code
> if you don't know what you're doing or don't understand the framework
> entirely.

That's all I need to know. I was concerned that I shouldn't be adding
child figures in the createFigure method, and effectively disabling the
GEF from getting them added and removed in add/removeChildVisual(). Just
being cautious.

Thanks
Pat
Re: Editparts, Figures and children [message #158341 is a reply to message #158146] Wed, 17 November 2004 18:18 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

It sounds like you want 2 children figures to be at figure indexes 0 and 2.
Why not just extend the method and correct the indexed? In other words, if
index==1, set index := 2.

"Pat" <spam@nospam.com> wrote in message
news:cndbj7$scg$1@www.eclipse.org...
> Hi all,
>
> I've designed a GEF editor to edit bean properties. I have a
> BeanEditPart and a PropertyEditPart. The BeanEditPart will have a child
> PropertyEditPart for every property (as defined via commons Attributes
> xdoclet markup).
>
> I have all this working, but would like a sanity check on my use of
> Figures and EditParts.
>
> My BeanEditPart has a EditPolicy.COMPONENT_ROLE as it is not strictly a
> container in the GEF sense of the word. I.e. It has children but this is
> a fixed number of PropertyEditParts. You cannot add/delete or move these
> children so it is not a GEF container.
>
> The PropertyEditPart is a container which allows a single child - the
> value that will set the property of the bean. When a value is set, this
> in turn will cause a BeanEditPart to be created etc, etc.
>
> Now, when I created my figures, the PropertyEditPart simply returns a
> Figure with a FlowLayout; no problem there. I want the BeanEditPart to
> construct a Figure containing both labels and PropertyEditPart figures.
> Ultimately I want to achieve something like this:
>
> ------------ ------------
> | property | is greater than | property |
> ------------ ------------
>
> I.e. Parts of the figure are just non-editable layout and information to
> describe the interrelation of the properties.
>
> And finally the question:
> Is it safe to override addChildVisual and removeChildVisual to do
> nothing. I can then take the responsibility for adding child
> PropertyEditPart figures in the createFigure() method. I have so far
> added placeholders for the child figures and replaced them by overridden
> add/removeChildVisual() methods.
>
> Thanks for your help. Looking forward to a response.
>
> Pat
>
> p.s. Appreciated all of the mails in the newsgroup. This is certainly a
> valuable resource to understanding GEF.
Re: Editparts, Figures and children [message #158441 is a reply to message #158341] Thu, 18 November 2004 09:28 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: spam.nospam.com

Hi Randy,

this would be fine for the simple example I cited. However, sometimes I
need to build up more complex figures for layout reasons. I.e. one
editpart has a figure with any number of nested figures to lay out the
EditPart. In this case I might not actually be adding to the EditPart's
top level figure, but to one of its children. It also isn't necessarily
a case of having a 'content pane' to which child visuals are added. They
can be placed anywhere in the figure hierarchy.

I've worked round the problem by having a superclass EditPart which
allows 'placeholders' to be added to a figure by subclasses. The
placeholders are stored in a List for retrieval later. The signature for
the method is

protected void addPlaceholder(Figure container)

This allows the subclass to determine where the child EditPart's figure
will ultimately be placed. The superclass overrides
addChildVisual/removeChildVisual to look up the placeholder by index and
replaces it with the child editpart's figure. Seems to work well.

BTW as I'm sure you know, overriding add/removeChildVisual to do nothing
was not a solution. When createFigure() is called, the parent EditPart
doesn't have any child EditParts so it can't add them at that point.

Thanks for the help.

Pat


Randy Hudson wrote:
> It sounds like you want 2 children figures to be at figure indexes 0 and 2.
> Why not just extend the method and correct the indexed? In other words, if
> index==1, set index := 2.
Re: Editparts, Figures and children [message #220590 is a reply to message #158341] Wed, 02 August 2006 15:24 Go to previous message
Andreas Herz is currently offline Andreas HerzFriend
Messages: 196
Registered: July 2009
Senior Member
Randy Hudson wrote:
> It sounds like you want 2 children figures to be at figure indexes 0 and 2.
> Why not just extend the method and correct the indexed? In other words, if
> index==1, set index := 2.
>

.....thanks. I have had the same problem and your solution is
quit easy and works fine for me.

greetings

Andreas
Previous Topic:Printing with RCP
Next Topic:DirectEdit and FieldAssist
Goto Forum:
  


Current Time: Wed Jan 22 19:21:05 GMT 2025

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

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

Back to the top