|
|
|
|
|
Re: the right way to deal with requests [message #248857 is a reply to message #248842] |
Fri, 08 May 2009 00:11 |
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 |
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 |
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?
>>
>>
|
|
|
Powered by
FUDForum. Page generated in 0.03306 seconds