Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 313072 - Support absolute (workspace-relative) icon paths
Summary: Support absolute (workspace-relative) icon paths
Status: CLOSED WONTFIX
Alias: None
Product: TMF
Classification: Modeling
Component: Xtext (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows Vista
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-05-17 02:12 EDT by Ed Willink CLA
Modified: 2019-11-27 02:58 EST (History)
1 user (show)

See Also:
sebastian.zarnekow: indigo+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ed Willink CLA 2010-05-17 02:12:40 EDT
DefaultLabelProvider currently supports icon paths relative to icons in the current plugin.

It would be helpful to facilitate use of icons in other plugins by recognising a first character in the icon name as an absolute indicator. Thus the following override could be incorporated in the String case.

	
	@Override
	protected Image convertToImage(Object imageDescription) {
		if (imageDescription instanceof String) {
			String imagePath = (String)imageDescription;
			if (imagePath.startsWith("/")) {	
				int index = imagePath.indexOf('/', 1);
				if (index > 1) {
					String bundlePath = imagePath.substring(1, index);
					Bundle bundle = Platform.getBundle(bundlePath);
					if (bundle != null) {
						String imageFile = imagePath.substring(index+1);
						Path path = new Path(imageFile);
						URL imgUrl = FileLocator.find(bundle, path, null);
						if (imgUrl != null) {
							return super.convertToImage(ImageDescriptor.createFromURL(imgUrl));
						}
					}
				}
			}				
		}
		return super.convertToImage(imageDescription);
	}
Comment 1 Sebastian Zarnekow CLA 2010-12-06 03:46:28 EST
Removed target milestone M3.
Comment 2 Sven Efftinge CLA 2012-11-14 04:04:13 EST
Please bind a custom IImageHelper that does that for you.
Comment 3 Sebastian Zarnekow CLA 2019-11-27 02:58:07 EST
see also bug 404741 which was fixed in 2.14

It allows image paths of the shape 'platform:/plugin/...'