Bug 404741 - PluginImageHelper does not allow to use images from Referenced Plugins
Summary: PluginImageHelper does not allow to use images from Referenced Plugins
Status: RESOLVED FIXED
Alias: None
Product: TMF
Classification: Modeling
Component: Xtext (show other bugs)
Version: 2.4.0   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard: v2.14
Keywords: helpwanted
Depends on:
Blocks:
 
Reported: 2013-04-02 12:33 EDT by Christian Dietrich CLA
Modified: 2019-11-27 02:55 EST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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