Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » the right way to deal with requests
the right way to deal with requests [message #248822] Wed, 06 May 2009 16:21 Go to next message
René is currently offline René
Messages: 45
Registered: July 2009
Member
hi folks,

i want to create components in my diagram via the context menu of my
editor. therefore i added a action that create a CreateRequest and a
CreationFactory. The next step was that i called the
performRequest-method of my responsible editpart. but the default
implementation of this method is empty and i have to implement the
method myself. but i m in doubt how i do this. can you please give me
some hints what are the next steps? is it possible to determine the
position where the context menu was opened?
Re: the right way to deal with requests [message #248828 is a reply to message #248822] Wed, 06 May 2009 16:22 Go to previous messageGo to next message
René is currently offline René
Messages: 45
Registered: July 2009
Member
i forgot something :)

thanks in advance!
best regards,
rené
Re: the right way to deal with requests [message #248832 is a reply to message #248822] Wed, 06 May 2009 17:09 Go to previous messageGo to next message
Ben Vitale is currently offline Ben Vitale
Messages: 247
Registered: July 2009
Senior Member
Regarding the location of the context menu,

http://wiki.eclipse.org/index.php/GEF_Developer_FAQ#How_do_I _find_the_location_of_the_context_menu.3F

-Ben

René wrote:
> hi folks,
>
> i want to create components in my diagram via the context menu of my
> editor. therefore i added a action that create a CreateRequest and a
> CreationFactory. The next step was that i called the
> performRequest-method of my responsible editpart. but the default
> implementation of this method is empty and i have to implement the
> method myself. but i m in doubt how i do this. can you please give me
> some hints what are the next steps? is it possible to determine the
> position where the context menu was opened?
Re: the right way to deal with requests [message #248837 is a reply to message #248832] Wed, 06 May 2009 18:19 Go to previous messageGo to next message
Eclipse User
Originally posted by: alamothe.ptt.yu

That doesn't help at all, the author of the FAQ was just being a smartass.
They should have explained how to find the location of the context menu if
it was brought via mouse. I'm sure that GMF creates parts via the context
menu, so what is the problem?

Ben Vitale wrote:
> Regarding the location of the context menu,
>
> http://wiki.eclipse.org/index.php/GEF_Developer_FAQ#How_do_I _find_the_location_of_the_context_menu.3F
>
> -Ben
>
> Ren
Re: the right way to deal with requests [message #248842 is a reply to message #248837] Thu, 07 May 2009 01:57 Go to previous messageGo to next message
Ben Vitale is currently offline Ben Vitale
Messages: 247
Registered: July 2009
Senior Member
The entry is not suggesting that you can't create new parts using the
context menu.

It seems like good advice to me that you shouldn't rely on a location
that may not work in all scenarios.

If you have a snippet to get the context menu location, please post it.

Thanks
Ben

Nikola Mihajlovic wrote:
> That doesn't help at all, the author of the FAQ was just being a smartass.
> They should have explained how to find the location of the context menu if
> it was brought via mouse. I'm sure that GMF creates parts via the context
> menu, so what is the problem?
>
> Ben Vitale wrote:
>> Regarding the location of the context menu,
>>
>> http://wiki.eclipse.org/index.php/GEF_Developer_FAQ#How_do_I _find_the_location_of_the_context_menu.3F
>>
>> -Ben
>>
>> René wrote:
>>> hi folks,
>>>
>>> i want to create components in my diagram via the context menu of my
>>> editor. therefore i added a action that create a CreateRequest and a
>>> CreationFactory. The next step was that i called the
>>> performRequest-method of my responsible editpart. but the default
>>> implementation of this method is empty and i have to implement the
>>> method myself. but i m in doubt how i do this. can you please give me
>>> some hints what are the next steps? is it possible to determine the
>>> position where the context menu was opened?
>
>
Re: the right way to deal with requests [message #248857 is a reply to message #248842] Fri, 08 May 2009 00:11 Go to previous messageGo to next message
Eclipse User
Originally posted by: alamothe.ptt.yu

AbstractTool tool = (AbstractTool) editDomain.getActiveTool();
Method m = AbstractTool.class.getDeclaredMethod("getLocation");
m.setAccessible(true);
location = (Point) m.invoke(tool);

:-)

You also need to traslate the point, take a look at
org.eclipse.gef.editpolicies.ConstrainedLayoutEditPolicy on how to do this

Ben Vitale wrote:
> The entry is not suggesting that you can't create new parts using the
> context menu.
>
> It seems like good advice to me that you shouldn't rely on a location
> that may not work in all scenarios.
>
> If you have a snippet to get the context menu location, please post
> it.
> Thanks
> Ben
>
> Nikola Mihajlovic wrote:
>> That doesn't help at all, the author of the FAQ was just being a
>> smartass. They should have explained how to find the location of the
>> context menu if it was brought via mouse. I'm sure that GMF creates
>> parts via the context menu, so what is the problem?
>>
>> Ben Vitale wrote:
>>> Regarding the location of the context menu,
>>>
>>> http://wiki.eclipse.org/index.php/GEF_Developer_FAQ#How_do_I _find_the_location_of_the_context_menu.3F
>>>
>>> -Ben
>>>
>>> Ren
Re: the right way to deal with requests [message #248988 is a reply to message #248857] Fri, 15 May 2009 10:03 Go to previous messageGo to next message
René is currently offline René
Messages: 45
Registered: July 2009
Member
hey folks,

thanks for your many many replies. unfortunately i was very busy the
last 2 weeks, so that i have today the first chance to look at your posts.
you have post a lot to determine the location where the actions is
performed. thanks for that. maybe you can give me a short overview how
to deal with request? that would very useful.

thanks again and regards,
rené


Nikola Mihajlovic wrote:
> AbstractTool tool = (AbstractTool) editDomain.getActiveTool();
> Method m = AbstractTool.class.getDeclaredMethod("getLocation");
> m.setAccessible(true);
> location = (Point) m.invoke(tool);
>
> :-)
>
> You also need to traslate the point, take a look at
> org.eclipse.gef.editpolicies.ConstrainedLayoutEditPolicy on how to do this
>
> Ben Vitale wrote:
>> The entry is not suggesting that you can't create new parts using the
>> context menu.
>>
>> It seems like good advice to me that you shouldn't rely on a location
>> that may not work in all scenarios.
>>
>> If you have a snippet to get the context menu location, please post
>> it.
>> Thanks
>> Ben
>>
>> Nikola Mihajlovic wrote:
>>> That doesn't help at all, the author of the FAQ was just being a
>>> smartass. They should have explained how to find the location of the
>>> context menu if it was brought via mouse. I'm sure that GMF creates
>>> parts via the context menu, so what is the problem?
>>>
>>> Ben Vitale wrote:
>>>> Regarding the location of the context menu,
>>>>
>>>> http://wiki.eclipse.org/index.php/GEF_Developer_FAQ#How_do_I _find_the_location_of_the_context_menu.3F
>>>>
>>>> -Ben
>>>>
>>>> René wrote:
>>>>> hi folks,
>>>>>
>>>>> i want to create components in my diagram via the context menu of
>>>>> my editor. therefore i added a action that create a CreateRequest
>>>>> and a CreationFactory. The next step was that i called the
>>>>> performRequest-method of my responsible editpart. but the default
>>>>> implementation of this method is empty and i have to implement the
>>>>> method myself. but i m in doubt how i do this. can you please give
>>>>> me some hints what are the next steps? is it possible to determine
>>>>> the position where the context menu was opened?
>
>
Re: the right way to deal with requests [message #248993 is a reply to message #248988] Fri, 15 May 2009 15:49 Go to previous message
René is currently offline René
Messages: 45
Registered: July 2009
Member
hey,

its me again. i solved the problem with the request. it was much easier
than i thought. you have to call just getCommand(Request) of the
responsible edit part. this uses the registered edit policies to create
and return the correct command...

i just want to thank you again. specially nikolas post was very helpful
and works immediately. the use of reflection to get the drop location is
a nice hack and i properly have to pondering for years to come to this
idea. btw: i didn't have to translate the location. it was out of the
box relative to my diagram domain.

best regards,
rené

René wrote:
> hey folks,
>
> thanks for your many many replies. unfortunately i was very busy the
> last 2 weeks, so that i have today the first chance to look at your posts.
> you have post a lot to determine the location where the actions is
> performed. thanks for that. maybe you can give me a short overview how
> to deal with request? that would very useful.
>
> thanks again and regards,
> rené
>
>
> Nikola Mihajlovic wrote:
>> AbstractTool tool = (AbstractTool) editDomain.getActiveTool();
>> Method m = AbstractTool.class.getDeclaredMethod("getLocation");
>> m.setAccessible(true);
>> location = (Point) m.invoke(tool);
>>
>> :-)
>>
>> You also need to traslate the point, take a look at
>> org.eclipse.gef.editpolicies.ConstrainedLayoutEditPolicy on how to do
>> this
>>
>> Ben Vitale wrote:
>>> The entry is not suggesting that you can't create new parts using the
>>> context menu.
>>>
>>> It seems like good advice to me that you shouldn't rely on a location
>>> that may not work in all scenarios.
>>>
>>> If you have a snippet to get the context menu location, please post
>>> it.
>>> Thanks
>>> Ben
>>>
>>> Nikola Mihajlovic wrote:
>>>> That doesn't help at all, the author of the FAQ was just being a
>>>> smartass. They should have explained how to find the location of the
>>>> context menu if it was brought via mouse. I'm sure that GMF creates
>>>> parts via the context menu, so what is the problem?
>>>>
>>>> Ben Vitale wrote:
>>>>> Regarding the location of the context menu,
>>>>>
>>>>> http://wiki.eclipse.org/index.php/GEF_Developer_FAQ#How_do_I _find_the_location_of_the_context_menu.3F
>>>>>
>>>>>
>>>>> -Ben
>>>>>
>>>>> René wrote:
>>>>>> hi folks,
>>>>>>
>>>>>> i want to create components in my diagram via the context menu of
>>>>>> my editor. therefore i added a action that create a CreateRequest
>>>>>> and a CreationFactory. The next step was that i called the
>>>>>> performRequest-method of my responsible editpart. but the default
>>>>>> implementation of this method is empty and i have to implement the
>>>>>> method myself. but i m in doubt how i do this. can you please give
>>>>>> me some hints what are the next steps? is it possible to determine
>>>>>> the position where the context menu was opened?
>>
>>
Previous Topic:AbstractBackground
Next Topic:copy paste issue
Goto Forum:
  


Current Time: Sun Sep 21 20:16:31 GMT 2014

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

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