sectionLayout.numColumns = 1;
sectionClient.setLayout(sectionLayout);
final HyperlinkGroup group = new HyperlinkGroup(sectionClient.getDisplay());
final IEditorPart fEditor = editor;
IMenuService ms = (IMenuService)editor.getSite().getService(IMenuService.class);
ContributionManager manager = new ContributionManager() {
public void update(boolean force) {
IContributionItem[] items = getItems();
for (IContributionItem item : items) {
if (item instanceof MenuManager) {
final MenuManager menu = (MenuManager) item;
ImageHyperlink link = new ImageHyperlink(sectionClient, SWT.None);
link.setText(menu.getMenuText());
if (menu.getImageDescriptor() != null) {
link.setImage(menu.getImageDescriptor().createImage());
}
link.addHyperlinkListener(new HyperlinkAdapter() {
public void linkActivated(HyperlinkEvent e) {
IHandlerService handlerService = (IHandlerService) fEditor.getSite().getService(IHandlerService.class);
if (handlerService != null) {
try {
handlerService.executeCommand(menu.getId(), null);
} catch (Exception ex) {
WorkbenchUtils.showErrorDialog(Plugin.getDefault(), fEditor.getSite().getShell(), "Execution of hyperlink failed", "Unable to execute hyperlink command '" + menu.getId() + "'.", ex);
}
}
}
});
group.add(link);