Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » getCreateCommand called repeatedly
getCreateCommand called repeatedly [message #227706] Sun, 10 December 2006 23:28 Go to next message
Eclipse User
Originally posted by: taylorpj.btopenworld.com

Hi there,

I am still getting to grips with GEF, and am currently trying to create
new elements in a simple diagram editor.

I am a bit confused by some of the GEF examples I have seen. It seems that
EditPolicy.getCreateCommand() is called every time a mouse move event
occurs, while adding a new element. The examples create a new command in
this method, so it seems to me that a lot of new objects are being created
unnecessarily. Have I misunderstood something?

For an example, see LogicXYLayoutEditPolicy in the Logic Editor example.

Thanks.
Re: getCreateCommand called repeatedly [message #227734 is a reply to message #227706] Mon, 11 December 2006 03:19 Go to previous messageGo to next message
Eclipse User
Originally posted by: none.unknown.com

The new model object is only created once. See CreateRequest#getNewObject()
which is what the LXYLEP is using. You could defer the creation of that one
object as well until the command is executed by using
CreateRequest#getNewObjectType() instead of getNewObject().

"Paul Taylor" <taylorpj@btopenworld.com> wrote in message
news:066f674bf0f77ca4f8e7e8d76adcc756$1@www.eclipse.org...
> Hi there,
>
> I am still getting to grips with GEF, and am currently trying to create
> new elements in a simple diagram editor.
> I am a bit confused by some of the GEF examples I have seen. It seems that
> EditPolicy.getCreateCommand() is called every time a mouse move event
> occurs, while adding a new element. The examples create a new command in
> this method, so it seems to me that a lot of new objects are being created
> unnecessarily. Have I misunderstood something?
>
> For an example, see LogicXYLayoutEditPolicy in the Logic Editor example.
>
> Thanks.
>
Re: getCreateCommand called repeatedly [message #227784 is a reply to message #227734] Mon, 11 December 2006 10:13 Go to previous messageGo to next message
Eclipse User
Originally posted by: taylorpj.btopenworld.com

Thanks for your reply. I understand that the model object is created only once, but I am concerned with the Command object that creates the model object. It seems to me that a Command object will be created for every mouse event that is processed, and that the final Command object will create the model object.

Aren't all those other Command objects redundant?


&gt; The new model object is only created once. See
&gt; CreateRequest#getNewObject()
&gt; which is what the LXYLEP is using. You could defer
&gt; the creation of that one
&gt; object as well until the command is executed by using
&gt;
&gt; CreateRequest#getNewObjectType() instead of
&gt; getNewObject().
&gt;
&gt; "Paul Taylor" <taylorpj@btopenworld.com> wrote in
&gt; message
&gt; news:066f674bf0f77ca4f8e7e8d76adcc756$1@www.eclipse.or
&gt; g...
&gt; > Hi there,
&gt; >
&gt; > I am still getting to grips with GEF, and am
&gt; currently trying to create
&gt; > new elements in a simple diagram editor.
&gt; > I am a bit confused by some of the GEF examples I
&gt; have seen. It seems that
&gt; > EditPolicy.getCreateCommand() is called every time
&gt; a mouse move event
&gt; > occurs, while adding a new element. The examples
&gt; create a new command in
&gt; > this method, so it seems to me that a lot of new
&gt; objects are being created
&gt; > unnecessarily. Have I misunderstood something?
&gt; >
&gt; > For an example, see LogicXYLayoutEditPolicy in the
&gt; Logic Editor example.
&gt; >
&gt; > Thanks.
&gt; >
&gt;
Re: getCreateCommand called repeatedly [message #227895 is a reply to message #227784] Tue, 12 December 2006 18:43 Go to previous messageGo to next message
Eclipse User
Originally posted by: none.unknown.com

No. They are used to find out if the object can be created at the current
mouse location. That's the price you pay for instant feedback. The memory
footprint is not affected though, since when a new command is gotten, the
previous one is thrown away.

"Paul Taylor" <taylorpj@btopenworld.com> wrote in message
news:915852.1165832012538.JavaMail.root@cp1.javalobby.org...
> Thanks for your reply. I understand that the model object is created only
> once, but I am concerned with the Command object that creates the model
> object. It seems to me that a Command object will be created for every
> mouse event that is processed, and that the final Command object will
> create the model object.
>
> Aren't all those other Command objects redundant?
>
>
> &gt; The new model object is only created once. See
> &gt; CreateRequest#getNewObject()
> &gt; which is what the LXYLEP is using. You could defer
> &gt; the creation of that one
> &gt; object as well until the command is executed by using
> &gt;
> &gt; CreateRequest#getNewObjectType() instead of
> &gt; getNewObject().
> &gt;
> &gt; "Paul Taylor" <taylorpj@btopenworld.com> wrote in
> &gt; message
> &gt; news:066f674bf0f77ca4f8e7e8d76adcc756$1@www.eclipse.or
> &gt; g...
> &gt; > Hi there,
> &gt; >
> &gt; > I am still getting to grips with GEF, and am
> &gt; currently trying to create
> &gt; > new elements in a simple diagram editor.
> &gt; > I am a bit confused by some of the GEF examples I
> &gt; have seen. It seems that
> &gt; > EditPolicy.getCreateCommand() is called every time
> &gt; a mouse move event
> &gt; > occurs, while adding a new element. The examples
> &gt; create a new command in
> &gt; > this method, so it seems to me that a lot of new
> &gt; objects are being created
> &gt; > unnecessarily. Have I misunderstood something?
> &gt; >
> &gt; > For an example, see LogicXYLayoutEditPolicy in the
> &gt; Logic Editor example.
> &gt; >
> &gt; > Thanks.
> &gt; >
> &gt;
Re: getCreateCommand called repeatedly [message #228239 is a reply to message #227784] Mon, 18 December 2006 16:15 Go to previous message
Eclipse User
Originally posted by: none.ibm.com

"Paul Taylor" <taylorpj@btopenworld.com> wrote in message
news:915852.1165832012538.JavaMail.root@cp1.javalobby.org...
> Thanks for your reply. I understand that the model object is created only
> once, but I am concerned with the Command object that creates the model
> object. It seems to me that a Command object will be created for every
> mouse event that is processed, and that the final Command object will
> create the model object.

So what? The MouseEvent itself is an object. The location of the mouse is an
object. Searching for the proper target creates objects. There are objects
getting created everywhere.
Previous Topic:Problem sizing the LayeredPane
Next Topic:error GraphicalEditor.doSave
Goto Forum:
  


Current Time: Tue Sep 30 11:49:41 GMT 2014

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

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