|Insert node on the point where I clicked [message #216537]
||Fri, 19 May 2006 13:38
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,
|Re: Insert node on the point where I clicked [message #216830 is a reply to message #216789]
||Thu, 25 May 2006 11:31
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
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
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:
// -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.
Powered by FUDForum
. Page generated in 0.03583 seconds