Drag drop - creating multiple elements at once [message #211704] |
Wed, 15 March 2006 07:01  |
Eclipse User |
|
|
|
Originally posted by: lesliesoftware.yahoo.com
I recently hooked up drag and drop to my GEF editor following the example
http://www.eclipse.org/articles/Article-GEF-dnd/GEF-dnd.html . I wanted
extend my application to be able to create multiple model elements at once
after the drop. So, I created a CreateMultipleRequest patterned after
CreateRequest and substituted it in to my drag and drop code. My new
request was ignored and after digging around I realized that my request
was being ignored because it was unknown to any edit policies.
In this situation:
Should I create a new edit policy to handle multiple creation?
Should I have my class derived from XYLayoutEditPolicy overide and add
handling for my new request?
Or should I type check the request in the getCreateCommand to handle
creating multiple elements (which implies deriving my new request from the
existing CreateRequest)?
Are there any tutorials on creating / working with edit policies?
Any help or advice would be appreciated.
Thanks,
Ian
|
|
|
Re: Drag drop - creating multiple elements at once [message #211721 is a reply to message #211704] |
Wed, 15 March 2006 08:00   |
Eclipse User |
|
|
|
Hi Ian,
not really being a GEF insider myself, I encapsulated it all in its own
set of classes, like you were already thinking. I created a new edit
policy DNDEditPolicy that extends GraphicalEditPolicy and implements
getCommand(Request request). There, it type checks for my new request
type:
if (request.getType().equals(AddElementsRequest.REQ_ADD_MANY))
The request extends Request and implements DropRequest. (Extending
CreateRequest was what I tried first, but that was a little
uncomfortable because the design seems to go for a single object.)
Works fine, here. But maybe the GEF gurus tell us the recommended way.
HTH, Thomas.
Ian Leslie schrieb:
> I recently hooked up drag and drop to my GEF editor following the
> example http://www.eclipse.org/articles/Article-GEF-dnd/GEF-dnd.html . I
> wanted extend my application to be able to create multiple model
> elements at once after the drop. So, I created a CreateMultipleRequest
> patterned after CreateRequest and substituted it in to my drag and drop
> code. My new request was ignored and after digging around I realized
> that my request was being ignored because it was unknown to any edit
> policies.
>
> In this situation:
> Should I create a new edit policy to handle multiple creation?
> Should I have my class derived from XYLayoutEditPolicy overide and add
> handling for my new request?
> Or should I type check the request in the getCreateCommand to handle
> creating multiple elements (which implies deriving my new request from
> the existing CreateRequest)?
>
> Are there any tutorials on creating / working with edit policies?
>
> Any help or advice would be appreciated.
>
> Thanks,
>
> Ian
>
|
|
|
Re: Drag drop - creating multiple elements at once [message #211729 is a reply to message #211704] |
Wed, 15 March 2006 10:37  |
Eclipse User |
|
|
|
Originally posted by: none.us.ibm.com
"Ian Leslie" <lesliesoftware@yahoo.com> wrote in message
news:7e24305464c3933d42e45111a37f938b$1@www.eclipse.org...
>I recently hooked up drag and drop to my GEF editor following the example
> http://www.eclipse.org/articles/Article-GEF-dnd/GEF-dnd.html . I wanted
>extend my application to be able to create multiple model elements at once
>after the drop. So, I created a CreateMultipleRequest patterned after
>CreateRequest and substituted it in to my drag and drop code. My new
>request was ignored and after digging around I realized that my request was
>being ignored because it was unknown to any edit policies.
>
> In this situation:
> Should I create a new edit policy to handle multiple creation?
Always an option, or you could mix it in to an existing one. One question to
ask is whether its related to another policy, and whether you need to use
this behavior or the one you would add it to, separately. If you never need
the behaviors separate, you can combine them.
> Should I have my class derived from XYLayoutEditPolicy overide and add
> handling for my new request?
Probably
> Or should I type check the request in the getCreateCommand to handle
> creating multiple elements (which implies deriving my new request from the
> existing CreateRequest)?
It doesn't have to imply that. You could also do this as the current create
request, and just have a new factory which indicates a special type
(CreateRequest.getNewObjectType() could return "multiple" ID), and
getNewObject would return an Array instead of one new object.
>
> Are there any tutorials on creating / working with edit policies?
>
> Any help or advice would be appreciated.
>
> Thanks,
>
> Ian
>
|
|
|
Powered by
FUDForum. Page generated in 0.05225 seconds