Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Insert node on the point where I clicked
Insert node on the point where I clicked [message #216537] Fri, 19 May 2006 13:38 Go to next message
Eclipse User
Originally posted by: alissonbn.frb.br

hi, guys! I'm making my first project in GEF, so I'm a newbie here. I took as point of start the schema editor example, that you can find in the GEF homepage.
The project is almost ready, but I got a problem. When I add a new node, it appears in the top-left corner. I would like it to appear in the point where the mouse clicked. can someone help me?
thanks in advance,
Alisson
Re: Insert node on the point where I clicked [message #216789 is a reply to message #216537] Wed, 24 May 2006 13:20 Go to previous messageGo to next message
Eclipse User
Originally posted by: cmahoney.ca.ibm.com

Alisson,

Are you adding the new node from a palette? Are you using GEF's
CreationTool?

- Cherie

"Alisson" <alissonbn@frb.br> wrote in message
news:28869837.1148045962861.JavaMail.root@cp1.javalobby.org...
> hi, guys! I'm making my first project in GEF, so I'm a newbie here. I took
as point of start the schema editor example, that you can find in the GEF
homepage.
> The project is almost ready, but I got a problem. When I add a new node,
it appears in the top-left corner. I would like it to appear in the point
where the mouse clicked. can someone help me?
> thanks in advance,
> Alisson
Re: Insert node on the point where I clicked [message #216830 is a reply to message #216789] Thu, 25 May 2006 11:31 Go to previous message
Eclipse User
Originally posted by: eclipse.chris-lott.org

The out-of-the-box behavior of the database table schema editor example is
to place newly added tables at 0,0. I considered this a bug. If we were
in school I think this would be marked "left as an exercise for the
reader" :-)

Anyhow I'm not in school anymore, so here's how I fixed it:

1. TableAddCommand needs a private field of type Point, and a setter
method:

private Point location;

/**
* Sets the desired location of the new item
*
* @param location
* the location to use
*/
public void setLocation(Point location)
{
this.location = location;
}

2. The execute() method of TableAddCommand needs to use the Point data to
set the bounds of the newly added table object:

Line 43:
// -1 for width, height means "resize to accomodate contents"
this.table.modifyBounds(new Rectangle(location.x, location.y, -1, -1));

3. SchemaContainerEditPolicy.getCreateCommand has to pass the point
(location) on to the table add command object:

Line 55: tableAddCommand.setLocation(location);

Hope this helps.

chris...
Previous Topic:DND in a EditPartViewer
Next Topic:import packages in gef cannot be resolved
Goto Forum:
  


Current Time: Sun Sep 21 06:11:51 GMT 2014

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

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