1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-01 06:05:24 +02:00

Bug 525539: show template label and description even if icon is missing

When a template doesn't specify an icon, gracefully skip drawing icon
and assume image height of 48 pixel for drawing template label and
description.

Change-Id: I3cd19b33be11af94ae68c3d119899939ec9a32d3
Signed-off-by: Chin Huat Ang <chin.huat.ang@intel.com>
This commit is contained in:
Chin Huat Ang 2017-10-04 16:33:22 +08:00
parent 0435f27589
commit db4acb2bb5
2 changed files with 8 additions and 1 deletions

View file

@ -43,6 +43,11 @@ public class Template {
public ImageDescriptor getIcon() {
String iconPath = element.getAttribute("icon"); //$NON-NLS-1$
if (iconPath == null) {
return null;
}
return AbstractUIPlugin.imageDescriptorFromPlugin(element.getNamespaceIdentifier(), iconPath);
}

View file

@ -142,7 +142,7 @@ public class TemplateTable implements Listener {
Template template = (Template) item.getData();
ImageDescriptor imageDesc = template.getIcon();
Image image = images.get(imageDesc);
if (image == null) {
if (image == null && imageDesc != null) {
image = imageDesc.createImage();
images.put(imageDesc, image);
}
@ -152,6 +152,8 @@ public class TemplateTable implements Listener {
rect = image.getBounds();
y = event.y + Math.max(0, (event.height - rect.height) / 2);
gc.drawImage(image, event.x + 4, y);
} else {
y = event.y + Math.max(0, (event.height - 48) / 2);
}
gc.setFont(fontBold);
String name = template.getLabel();