Bug 350459 [Compatibility] NPE with GEF editor
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/menus/MenuHelper.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/menus/MenuHelper.java
index 88fa51f..41c310b 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/menus/MenuHelper.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/menus/MenuHelper.java
@@ -717,16 +717,22 @@
} else {
MDirectToolItem toolItem = MenuFactoryImpl.eINSTANCE.createDirectToolItem();
String itemId = item.getId();
- toolItem.setElementId(itemId == null ? id : itemId);
+ toolItem.setElementId(itemId);
String iconURI = getIconURI(action.getImageDescriptor());
if (iconURI == null) {
- iconURI = getIconURI(id, application.getContext());
- if (iconURI == null) {
+ if (itemId == null) {
if (action.getText() != null) {
toolItem.setLabel(action.getText());
}
} else {
- toolItem.setIconURI(iconURI);
+ iconURI = getIconURI(itemId, application.getContext());
+ if (iconURI == null) {
+ if (action.getText() != null) {
+ toolItem.setLabel(action.getText());
+ }
+ } else {
+ toolItem.setIconURI(iconURI);
+ }
}
} else {
toolItem.setIconURI(iconURI);
@@ -894,6 +900,10 @@
}
private static String getIconURI(String commandId, IEclipseContext workbench) {
+ if (commandId == null) {
+ return null;
+ }
+
ICommandImageService imageService = workbench.get(ICommandImageService.class);
ImageDescriptor descriptor = imageService.getImageDescriptor(commandId);
return getIconURI(descriptor);