Add Context Menu Item [message #1016963] |
Fri, 08 March 2013 06:21  |
Eclipse User |
|
|
|
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] |
Fri, 08 March 2013 19:32  |
Eclipse User |
|
|
|
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.
|
|
|
Powered by
FUDForum. Page generated in 0.03983 seconds