| Summary: | Support absolute (workspace-relative) icon paths | ||
|---|---|---|---|
| Product: | [Modeling] TMF | Reporter: | Ed Willink <ed> |
| Component: | Xtext | Assignee: | Project Inbox <tmf.xtext-inbox> |
| Status: | CLOSED WONTFIX | QA Contact: | |
| Severity: | enhancement | ||
| Priority: | P3 | CC: | sebastian.zarnekow |
| Version: | unspecified | Flags: | sebastian.zarnekow:
indigo+
|
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Windows Vista | ||
| Whiteboard: | |||
Removed target milestone M3. Please bind a custom IImageHelper that does that for you. see also bug 404741 which was fixed in 2.14 It allows image paths of the shape 'platform:/plugin/...' |
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); }