Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » WindowBuilder » Add Context Menu Item(How to add a menu item in the right-click context menu)
Add Context Menu Item [message #1016963] Fri, 08 March 2013 11:21 Go to next message
Simon-Lennert Raesch is currently offline Simon-Lennert RaeschFriend
Messages: 1
Registered: March 2013
Junior Member
Hi all,

as the title suggest, what I am trying to achieve is to add a context menu item to the WB context menu. The one I am trying to contribute to is the menu you get by right-clicking in the tree view of the current elements.

I have created a plugin project that has an extension to

org.eclipse.wb.swt.controlEditPartDelegateProviders

I have found

org.eclipse.wb.internal.swt.model.widgets.ControlInfo

which contains the code that provides the context menu via a broadcast listener as follows:

addBroadcastListener(new ObjectEventListener() {
      @Override
      public void addContextMenu(List<? extends ObjectInfo> objects,
          ObjectInfo object,
          IMenuManager manager) throws Exception {
        if (object == ControlInfo.this) {
          ExposeComponentSupport.contribute(
              ControlInfo.this,
              manager,
              ModelMessages.ControlInfo_exposeText);
          MorphingSupport.contribute("org.eclipse.swt.widgets.Control", ControlInfo.this, manager);
          FactoryActionsSupport.contribute(ControlInfo.this, manager);
          RenameConvertSupport.contribute(objects, manager);
        }
      }
    });


How can I contribute an item to that context menu in a plugin project? Have I chosen the right extension point to do so? The extension point is the only one in that project (org.eclipse.wb.swt) but maybe it is anothers project extension point I need to extend?

Thanks a lot for your help!
Re: Add Context Menu Item [message #1017093 is a reply to message #1016963] Sat, 09 March 2013 00:32 Go to previous message
Konstantin Scheglov is currently offline Konstantin ScheglovFriend
Messages: 555
Registered: July 2009
Senior Member
Yes, you are on the right way in general.
You need to use addBroadcastListener(), but you should add it to some ObjectInfo model.
To do this externally you need to create org.eclipse.wb.core.model.IRootProcessor, contribute it to org.eclipse.wb.core.rootProcessors.
There are several implementations of IRootProcessor in WB source.


Konstantin Scheglov,
Google, Inc.
Previous Topic:Parse problems in design mode after reparse
Next Topic:WindowBuilder Palette Issue
Goto Forum:
  


Current Time: Sat Nov 29 02:54:07 GMT 2014

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

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