////////////////////////////////////////////////////////////////////////////
private void contributeContextMenu(IMenuManager manager, final ComponentInfo component) {
Map<String, MenuManagerEx> eventManagers = Maps.newTreeMap();
for (final EventDescription description : getEventDescriptions(component)) {
// prepare MenuManager for event
MenuManagerEx eventManager;
{
String event = description.getEvent();
eventManager = eventManagers.get(event);
if (eventManager == null) {
eventManager = new MenuManagerEx(event);
eventManager.setImage(EventsPropertyUtils.LISTENER_INTERFACE_IMAGE);
eventManagers.put(event, eventManager);
manager.appendToGroup(IContextMenuConstants.GROUP_EVENTS2, eventManager);
}
}
// add specific name
Action action = new Action() {
@Override
public void runWithEvent(Event event) {
if ((event.stateMask & SWT.CTRL) != 0) {
removeListener(component, description);
} else {
openListener(component, description);
}
}
};
{
String text = description.getName();
MethodInvocation invocation = getInvocation(component, description);
if (invocation != null) {
int line = 1 + component.getEditor().getLineNumber(invocation.getStartPosition());
text += "\tline " + line;
}
action.setText(text);
}
action.setImageDescriptor(EventsPropertyUtils.LISTENER_METHOD_IMAGE_DESCRIPTOR);
eventManager.add(action);
}
}