Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Customizing conext menu
Customizing conext menu [message #1071096] Fri, 19 July 2013 10:44 Go to next message
Phil H is currently offline Phil HFriend
Messages: 267
Registered: November 2012
Senior Member
Hi,

I'm not sure if it's called context menu, but I mean the menu which opens by right clicking elements in the EMF editor (see image).

index.php/fa/15643/0/


1. Is it possible to remove/add new context menu entries? If yes, which class is responsible for this?

2. I would like to modify the "new child" menu items in order to add new menu items which create then the accordingly objects. Will it be effort to realize this?

Hope you understand what I'm meaning. Otherwise I'll try to explain more detailed.

Cheers,
Phil
Re: Customizing conext menu [message #1071104 is a reply to message #1071096] Fri, 19 July 2013 10:51 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33218
Registered: July 2009
Senior Member
Phil,

Comments below.

On 19/07/2013 12:44 PM, Phil H wrote:
> Hi,
>
> I'm not sure if it's called context menu, but I mean the menu which opens by right clicking elements in the EMF editor (see image).
Yes, that's right.
>
>
>
>
> 1. Is it possible to remove/add new context menu entries? If yes, which class is responsible for this?
Of course. You can look in your generated XyzActionBarContributor to
see how it populates these menus.
>
> 2. I would like to modify the "new child" menu items in order to add new menu items which create then the accordingly objects. Will it be effort to realize this?
Probably you should do this by specializing the protected void
collectNewChildDescriptors(Collection<Object> newChildDescriptors,
Object object) methods and let the existing infrastructure populate the
menu from that information.
>
> Hope you understand what I'm meaning. Otherwise I'll try to explain more detailed.
>
> Cheers,
> Phil


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Customizing conext menu [message #1071136 is a reply to message #1071104] Fri, 19 July 2013 12:17 Go to previous messageGo to next message
Christophe Bouhier is currently offline Christophe BouhierFriend
Messages: 937
Registered: July 2009
Senior Member
On 19-07-13 12:51, Ed Merks wrote:
> Phil,
>
> Comments below.
>
> On 19/07/2013 12:44 PM, Phil H wrote:
>> Hi,
>>
>> I'm not sure if it's called context menu, but I mean the menu which
>> opens by right clicking elements in the EMF editor (see image).
> Yes, that's right.
>>
>>
>>
>>
>> 1. Is it possible to remove/add new context menu entries? If yes,
>> which class is responsible for this?
> Of course. You can look in your generated XyzActionBarContributor to
> see how it populates these menus.
>>
>> 2. I would like to modify the "new child" menu items in order to add
>> new menu items which create then the accordingly objects. Will it be
>> effort to realize this?
> Probably you should do this by specializing the protected void
> collectNewChildDescriptors(Collection<Object> newChildDescriptors,
> Object object) methods and let the existing infrastructure populate the
> menu from that information.

Something I use is the IChildCreationExtender interface.
You can define a concrete implementation in a plugin.xml

<extension
point="org.eclipse.emf.edit.childCreationExtenders">
<extender
class="MyCoolChildCreationExtender"
uri="http://package uri for your package holding the objects">
</extender>

The extender is consulted when selecting an object in your view,
so instead of having static definitions in your
collecNewChildDescriptors you can make it dynamic by considering your
model status or UI options. I prefer this way, as the ItemProviders are
difficult IMHO to be fed with the model or UI stuff.

>>
>> Hope you understand what I'm meaning. Otherwise I'll try to explain
>> more detailed.
>>
>> Cheers,
>> Phil
>
Re: Customizing conext menu [message #1075643 is a reply to message #1071136] Mon, 29 July 2013 20:07 Go to previous messageGo to next message
Phil H is currently offline Phil HFriend
Messages: 267
Registered: November 2012
Senior Member
Ed Merks wrote on Fri, 19 July 2013 12:51
Phil,

Comments below.

On 19/07/2013 12:44 PM, Phil H wrote:
1. Is it possible to remove/add new context menu entries? If yes, which class is responsible for this?
Of course. You can look in your generated XyzActionBarContributor to
see how it populates these menus.


Thx Ed,

I had a look inside this class, but could only see how the Child and Sibling menus are realized. I'm wondering how I could remove the Wizard, Run as or Debug as entries?


Christophe Bouhier wrote on Fri, 19 July 2013 14:17
On 19-07-13 12:51, Ed Merks wrote:

Something I use is the IChildCreationExtender interface.
You can define a concrete implementation in a plugin.xml

<extension
point="org.eclipse.emf.edit.childCreationExtenders">
<extender
class="MyCoolChildCreationExtender"
uri="http://package uri for your package holding the objects">
</extender>

The extender is consulted when selecting an object in your view,
so instead of having static definitions in your
collecNewChildDescriptors you can make it dynamic by considering your
model status or UI options. I prefer this way, as the ItemProviders are
difficult IMHO to be fed with the model or UI stuff.


Thx Christophe,

are there any examples or tutorials how to use this interface. Or maybe any running example so that I can see how these interfaces looks like?

Cheers,
Phil
Re: Customizing conext menu [message #1075867 is a reply to message #1075643] Tue, 30 July 2013 08:19 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33218
Registered: July 2009
Senior Member
Phil,

I'm not sure how to remove things contributed from the base frameworks.
You'll notice that even in the explorer views, such menu items always
appear.


On 29/07/2013 10:07 PM, Phil H wrote:
> Ed Merks wrote on Fri, 19 July 2013 12:51
>> Phil,
>>
>> Comments below.
>>
>> On 19/07/2013 12:44 PM, Phil H wrote:
>> 1. Is it possible to remove/add new context menu entries? If yes,
>> which class is responsible for this?
>> Of course. You can look in your generated XyzActionBarContributor to
>> see how it populates these menus.
>
>
> Thx Ed,
> I had a look inside this class, but could only see how the Child and
> Sibling menus are realized. I'm wondering how I could remove the
> Wizard, Run as or Debug as entries?
>
>
> Christophe Bouhier wrote on Fri, 19 July 2013 14:17
>> On 19-07-13 12:51, Ed Merks wrote:
>>
>> Something I use is the IChildCreationExtender interface.
>> You can define a concrete implementation in a plugin.xml
>>
>> <extension
>> point="org.eclipse.emf.edit.childCreationExtenders">
>> <extender
>> class="MyCoolChildCreationExtender"
>> uri="http://package uri for your package holding the
>> objects">
>> </extender>
>>
>> The extender is consulted when selecting an object in your view,
>> so instead of having static definitions in your
>> collecNewChildDescriptors you can make it dynamic by considering your
>> model status or UI options. I prefer this way, as the ItemProviders
>> are difficult IMHO to be fed with the model or UI stuff.
>
>
> Thx Christophe,
>
> are there any examples or tutorials how to use this interface. Or
> maybe any running example so that I can see how these interfaces looks
> like?
>
> Cheers,
> Phil


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:where could I get map file of EMF?
Next Topic:Unset on isMany containment-ref doesn't trigger detachment
Goto Forum:
  


Current Time: Wed Sep 25 00:07:57 GMT 2024

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

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

Back to the top