Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 404741

Summary: PluginImageHelper does not allow to use images from Referenced Plugins
Product: [Modeling] TMF Reporter: Christian Dietrich <christian.dietrich.opensource>
Component: XtextAssignee: Project Inbox <tmf.xtext-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: christian.dietrich.opensource, miklossy, sebastian.zarnekow
Version: 2.4.0Keywords: helpwanted
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard: v2.14

Description Christian Dietrich CLA 2013-04-02 12:33:36 EDT
PluginImageHelper allows Images from the Plugin itself only.
thus you may have to copy and paste images if you have multiple DSLs
using the same metamodel or working with inheritance.
Comment 1 Sebastian Zarnekow CLA 2013-04-02 12:38:20 EDT
Reminds me of bug 313072 which I still would like to have. A patch is most welcome.
Comment 2 Christian Dietrich CLA 2013-04-03 02:54:18 EDT
I cannot provide a patch but we have following code as Workaround

public class ClasspathAwareImageHelper extends PluginImageHelper {

	@Override
	public Image getImage(String imageName) {
		String imgname = imageName == null ? getDefaultImage() : imageName;
		if (imgname != null) {
			Image result = null;
			String name = getPathSuffix() + imgname;
			URL imgUrl = getPlugin().getBundle().getResource(name); // use class loader (in Helios SR1 the class loader
																	// is not used)
			if (imgUrl != null) {
				ImageDescriptor id = null;
				result = getPlugin().getImageRegistry().get(imgUrl.toExternalForm());
				if (result == null) {
					id = ImageDescriptor.createFromURL(imgUrl);
					if (id != null) {
						result = id.createImage();
						getPlugin().getImageRegistry().put(imgUrl.toExternalForm(), result);
					}
				}
				return result;
			}
			String notFound = getNotFound();
			if (!imgname.equals(notFound)) {
				return getImage(notFound);
			}
		}
		return null;
	}

}
Comment 3 Tamas Miklossy CLA 2019-11-27 02:23:37 EST
I have just analyzed the PluginImageHelper class and noticed that it has been extended to be able to load images from other plugins. See also PR https://github.com/eclipse/xtext-eclipse/commit/d8b6369587cc05f2b15fae3fce258a1d34073f48

@Christian Dietrich: Have this change solved the problem described here?
Comment 4 Christian Dietrich CLA 2019-11-27 02:29:00 EST
i dont know since i have no longer access to the codebase the problem was reported to
Comment 5 Sebastian Zarnekow CLA 2019-11-27 02:55:44 EST
Yes, the changed addressed the issue