Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » How to add an EditPart below the Primary Layer
How to add an EditPart below the Primary Layer [message #156010] Thu, 28 October 2004 18:32 Go to next message
Steve Harper is currently offline Steve HarperFriend
Messages: 29
Registered: July 2009
Junior Member
The GEF editor that I'm working on is a Visual Builder for a 4GL language.
One of the components on my Palette is a GroupBox that is really just a
box drawn around some other components.

The run-time is implemented using Swing, so during Design time with GEF
I'm using ImageFigures that capture an off-screen Swing image (sort of the
same trick that VE uses for WYSIWYG).

Everything works well except when a GroupBox is drawn around some existing
components. Even though the IFigure is transparent, it overlays the
components that it surrounds because the whole offscreen image is used.

I tried to fix this by overriding paintFigure() for the IFigure of the
GroupBox. In the override I only drew the outside of the GroupBox and thus
it would not hide the components it surrounded. But clicking on a
Component inside the GroupBox would select the GroupBox itself and not the
Component that was clicked on.

So I'm thinking the way to fix this would be to place the GroupBox on the
ConnectionLayer of something "below" the PrimaryLayer. I see how to call
ScalableRootEditPart.getLayer(), but have no idea how to use the returned
IFigure to control the layer that my GroupBox is added to. Also feels like
I'd do this in my EditPartFactory, but again see no way to control Layer
there. Also tried overriding AbstractGraphicalEditPart.getLayer() thinking
it would use the value returned, but found that this is never called.

I'm open to suggestions...
Re: How to add an EditPart below the Primary Layer [message #156072 is a reply to message #156010] Fri, 29 October 2004 06:09 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: eostroukhov.hotmail.com

1. The Draw2d draws the figures in the order they are in the children list
(i.e. if you want one figure to be drawn above the other you should add it
second). In most cases you should return the children in the correct order
from the getModelChildren method of your container edit part. That's the
principle I used to implement the move above/below actions and it actually
works :)
2. If, for some reason, case #1 is not helpful for you, you could switch to
layered figure.
3. In your case it looks like the children edit parts must be put into the
groupbox edit parts.

"Steve Harper" <steve_harper@adp.com> wrote in message
news:clre0d$5nj$1@eclipse.org...
> The GEF editor that I'm working on is a Visual Builder for a 4GL language.
> One of the components on my Palette is a GroupBox that is really just a
> box drawn around some other components.
>
> The run-time is implemented using Swing, so during Design time with GEF
> I'm using ImageFigures that capture an off-screen Swing image (sort of the
> same trick that VE uses for WYSIWYG).
>
> Everything works well except when a GroupBox is drawn around some existing
> components. Even though the IFigure is transparent, it overlays the
> components that it surrounds because the whole offscreen image is used.
>
> I tried to fix this by overriding paintFigure() for the IFigure of the
> GroupBox. In the override I only drew the outside of the GroupBox and thus
> it would not hide the components it surrounded. But clicking on a
> Component inside the GroupBox would select the GroupBox itself and not the
> Component that was clicked on.
>
> So I'm thinking the way to fix this would be to place the GroupBox on the
> ConnectionLayer of something "below" the PrimaryLayer. I see how to call
> ScalableRootEditPart.getLayer(), but have no idea how to use the returned
> IFigure to control the layer that my GroupBox is added to. Also feels like
> I'd do this in my EditPartFactory, but again see no way to control Layer
> there. Also tried overriding AbstractGraphicalEditPart.getLayer() thinking
> it would use the value returned, but found that this is never called.
>
> I'm open to suggestions...
>
Re: How to add an EditPart below the Primary Layer [message #156087 is a reply to message #156072] Fri, 29 October 2004 11:57 Go to previous messageGo to next message
Steve Harper is currently offline Steve HarperFriend
Messages: 29
Registered: July 2009
Junior Member
Eugene Ostroukhov wrote:

> 1. The Draw2d draws the figures in the order they are in the children list
> (i.e. if you want one figure to be drawn above the other you should add it
> second). In most cases you should return the children in the correct order
> from the getModelChildren method of your container edit part. That's the
> principle I used to implement the move above/below actions and it actually
> works :)
> 2. If, for some reason, case #1 is not helpful for you, you could switch to
> layered figure.
> 3. In your case it looks like the children edit parts must be put into the
> groupbox edit parts.

1. I don't want to make users add the GroupBox first, as a hack guess I
could programmatically ensure that all GroupBox components appear as the
last children. That makes the add logic a little ugly.
3. The GroupBox is not a parent to the children that it encloses. You can
move or delete the GroupBox independantly of the components it encloses.

2. Yes a layered figure seems to be what I need. But I've been unable to
determine how to add the GroupBox components at any layer other than the
Primary.
Re: How to add an EditPart below the Primary Layer [message #156254 is a reply to message #156087] Mon, 01 November 2004 07:24 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: eostroukhov.hotmail.com

I guess, in your case you could write your getModelChildren this way:
public List getModelChildren() {
final List children = new LinkedList();
final Model model = (Model) getModel(); // Your model
children.addAll(model.getGroupboxes());
children.addAll(model.getChildren()); // Excluding groupboxes
return children;
}

I guess, using layered approach could overcomplicate your code.

"Steve Harper" <steve_harper@adp.com> wrote in message
news:cltb6h$6pc$1@eclipse.org...
> Eugene Ostroukhov wrote:
>
> > 1. The Draw2d draws the figures in the order they are in the children
list
> > (i.e. if you want one figure to be drawn above the other you should add
it
> > second). In most cases you should return the children in the correct
order
> > from the getModelChildren method of your container edit part. That's the
> > principle I used to implement the move above/below actions and it
actually
> > works :)
> > 2. If, for some reason, case #1 is not helpful for you, you could switch
to
> > layered figure.
> > 3. In your case it looks like the children edit parts must be put into
the
> > groupbox edit parts.
>
> 1. I don't want to make users add the GroupBox first, as a hack guess I
> could programmatically ensure that all GroupBox components appear as the
> last children. That makes the add logic a little ugly.
> 3. The GroupBox is not a parent to the children that it encloses. You can
> move or delete the GroupBox independantly of the components it encloses.
>
> 2. Yes a layered figure seems to be what I need. But I've been unable to
> determine how to add the GroupBox components at any layer other than the
> Primary.
>
>
Re: How to add an EditPart below the Primary Layer [message #158730 is a reply to message #156254] Fri, 19 November 2004 14:41 Go to previous message
Steve Harper is currently offline Steve HarperFriend
Messages: 29
Registered: July 2009
Junior Member
Yes, that's exactly what I ended up doing. Turned out to be very easy to
change getModelChildren() to put the GroupBoxes at the end.
Seems to work fine, thanks for your great advice.

Still wonder if there's a way to Layer parts that I create. API didn't
seem to be open to this.

Eugene Ostroukhov wrote:

> I guess, in your case you could write your getModelChildren this way:
> public List getModelChildren() {
> final List children = new LinkedList();
> final Model model = (Model) getModel(); // Your model
> children.addAll(model.getGroupboxes());
> children.addAll(model.getChildren()); // Excluding groupboxes
> return children;
> }

> I guess, using layered approach could overcomplicate your code.
Previous Topic:Convert Rectangle to Ellipse in SchemaEditor sample
Next Topic:Preventing newlines in TextCellEditor with SWT.WRAP
Goto Forum:
  


Current Time: Sat Nov 09 00:01:53 GMT 2024

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

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

Back to the top