Java – eclipse menumanager: get imagedescriptor of image?
I can't let this work, so I think posting here may be a wise idea
My problem is, I want to attach a small icon to the menu, but I struggle!
Code:
manager.add(new Separator());
// icon for the "change color" menu
ImageDescriptor icon = ImageDescriptor.createFromFile(null,"icons/palette_brush.png");
// submenu
MenuManager colorMenu = new MenuManager("Menu",icon,null);
// Actions
colorMenu.add(someAction);
// add the action to the submenu
manager.add(colorMenu);
....
My problem is that you can call the new menumanager with 2 parameters (no additional image) or 3 (with additional image) The image should be passed as an imagedescriptor The main question is: "how do I get an imagedescriptor from an image?"
Maybe it's a stupid mistake – but I can't get the imagedescriptor from the image file I have a * Png icons are available, but it's hard for me to merge them If someone can help solve a fragment, it would be great to get an imagedescriptor from the image file!
Best wishes!
Menumanager document: menumanager docu
Solution
Bundle bundle = Platform.getBundle(pluginId);
Bundle bundle = Platform.getBundle(pluginId); URL fullPathString = BundleUtility.find(bundle,"icons/palette_brush.png"); ImageDescriptor.createFromURL(fullPathString);
Pluginid is the ID of the plug-in where you placed the icon
