Skip to main content



      Home
Home » Eclipse Projects » GEF » Help for a newbie
Help for a newbie [message #165644] Wed, 26 January 2005 05:15 Go to next message
Eclipse UserFriend
Originally posted by: no.mail.please

Hi !

I'm trying to make a simple gef editor witch can be defined as :
- a white area(where I don't want users to drop figures) containing a
blue area where I can put figures
- a gray background where I don't want the user to drop figures

So I started from the shape editor and made the following changes :
- in shapeEditor, to have a gray background :
FigureCanvas canvas = (FigureCanvas)viewer.getControl();
canvas.setBackground(ColorConstants.gray);
- in DiagramEditPart :
ImageFigure f = new ImageFigure();
f.setLayoutManager(new XYLayout());
f.setBackgroundColor(ColorConstants.white);
f.setBounds(new Rectangle(10, 10, 300, 300));
contentArea = new Label("This is my content pane");
contentArea.setBounds(new Rectangle(10, 10, 100, 100));
contentArea.setBackgroundColor(ColorConstants.lightBlue);
contentArea.setOpaque(true);
f.add(contentArea);
f.setOpaque(true);
return f;

But what I get is a 4 dimensions extending ImageFigure occupying all the
viewer's area (I wanted it to be 300 x 300 instead) and a blue rectangle.

Then I tried making a separate class SchemaFigure with these contents
and adding getContentPane() to the DiagramEditPart to set the Label as
the content pane, but it returned an error.

I know I'm doing wrong, so could you help me ?
What kind of layout should I use for each of my components ?
How to prevent the white area to extend in all 4 dimensions ?
How to set the blue area as the content pane ?

TIA

--
Arnaud
Re: Help for a newbie [message #165794 is a reply to message #165644] Wed, 26 January 2005 19:11 Go to previous messageGo to next message
Eclipse UserFriend
Do something like the following in the editor's configureGraphicalViewer()
method:

viewer.setRootEditPart(new ScalableRootEditPart() {
protected IFigure createFigure() {
Viewport viewport = createViewport();

innerLayers = new LayeredPane();
createLayers(innerLayers);

IFigure grayArea = new Figure();
grayArea.setBackgroundColor(ColorConstants.gray);
grayArea.setOpaque(true);
grayArea.setLayoutManager(new XYLayout());
IFigure whiteArea = new Figure();
whiteArea.setBackgroundColor(ColorConstants.white);
whiteArea.setOpaque(true);
grayArea.add(whiteArea, new Rectangle(0, 0, 300, 300));
whiteArea.setLayoutManager(new XYLayout());
IFigure blueArea = new Figure();
blueArea.setBackgroundColor(ColorConstants.lightBlue);
blueArea.setOpaque(true);
whiteArea.add(blueArea, new Rectangle(50, 50, 200, 200));
blueArea.setLayoutManager(new StackLayout());
blueArea.add(innerLayers);

viewport.setContents(grayArea);
return viewport;
}
});

If you need to make any of those areas draggable or something, you should
create model elements for them and create their figures in their respective
editparts. The EditPolicies can then control whether or not something can
be added to those areas. You might also want to add a scrollpane to the
blue area (you'll have to update the zoom manager created in the
ScalableRootEditPart accordingly).

"Arnaud" <no@mail.please> wrote in message
news:ct7qkb$b6k$1@www.eclipse.org...
> Hi !
>
> I'm trying to make a simple gef editor witch can be defined as :
> - a white area(where I don't want users to drop figures) containing a
> blue area where I can put figures
> - a gray background where I don't want the user to drop figures
>
> So I started from the shape editor and made the following changes :
> - in shapeEditor, to have a gray background :
> FigureCanvas canvas = (FigureCanvas)viewer.getControl();
> canvas.setBackground(ColorConstants.gray);
> - in DiagramEditPart :
> ImageFigure f = new ImageFigure();
> f.setLayoutManager(new XYLayout());
> f.setBackgroundColor(ColorConstants.white);
> f.setBounds(new Rectangle(10, 10, 300, 300));
> contentArea = new Label("This is my content pane");
> contentArea.setBounds(new Rectangle(10, 10, 100, 100));
> contentArea.setBackgroundColor(ColorConstants.lightBlue);
> contentArea.setOpaque(true);
> f.add(contentArea);
> f.setOpaque(true);
> return f;
>
> But what I get is a 4 dimensions extending ImageFigure occupying all the
> viewer's area (I wanted it to be 300 x 300 instead) and a blue rectangle.
>
> Then I tried making a separate class SchemaFigure with these contents
> and adding getContentPane() to the DiagramEditPart to set the Label as
> the content pane, but it returned an error.
>
> I know I'm doing wrong, so could you help me ?
> What kind of layout should I use for each of my components ?
> How to prevent the white area to extend in all 4 dimensions ?
> How to set the blue area as the content pane ?
>
> TIA
>
> --
> Arnaud
Re: Help for a newbie [message #165994 is a reply to message #165794] Thu, 27 January 2005 12:57 Go to previous message
Eclipse UserFriend
Originally posted by: no.mail.please

thanks for the example, this helps me going on the right way. I should
manage to do it now, reading a bit deeper the API doc.

--
Arnaud
Previous Topic:Dragging from the Palette does not have the source feedback
Next Topic:Printing Across Multiple Pages
Goto Forum:
  


Current Time: Sun May 11 22:02:13 EDT 2025

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

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

Back to the top