// needs to be called.
parent.setVisible(true);
}
// First remove existing menu item
IContributionItem item = parent.find(ad.getId());
if (item != null) {
parent.remove(ad.getId());
}
// Find reference group.
if (mgroup == null)
mgroup = IWorkbenchActionConstants.MB_ADDITIONS;
IContributionItem sep = parent.find(mgroup);
if (sep == null) {
if (appendIfMissing)
parent.add(sep = new Separator(mgroup));
else {
Logger.log(Logger.ERROR, "Invalid Menu Extension (Group is invalid): " + ad.getId()); //$NON-NLS-1$
return null;
}
}
// Add action.
try {
if (popupmenu) {
// Context menu need a newly created contribution item
if (sep != null && sep.isGroupMarker())
parent.appendToGroup(sep.getId(), ad.getAction());
else
parent.insertAfter(mgroup, ad.getAction());
}
else {
// Normal menu need to add existing contribution item to
// remove it from menu listener
if (sep != null && sep.isGroupMarker())
parent.appendToGroup(sep.getId(), ad.getContributionItem());
else
parent.insertAfter(mgroup, ad.getContributionItem());
}
}
catch (IllegalArgumentException e) {