mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-12 11:35:21 +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:
parent
0435f27589
commit
db4acb2bb5
2 changed files with 8 additions and 1 deletions
|
@ -43,6 +43,11 @@ public class Template {
|
||||||
|
|
||||||
public ImageDescriptor getIcon() {
|
public ImageDescriptor getIcon() {
|
||||||
String iconPath = element.getAttribute("icon"); //$NON-NLS-1$
|
String iconPath = element.getAttribute("icon"); //$NON-NLS-1$
|
||||||
|
|
||||||
|
if (iconPath == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return AbstractUIPlugin.imageDescriptorFromPlugin(element.getNamespaceIdentifier(), iconPath);
|
return AbstractUIPlugin.imageDescriptorFromPlugin(element.getNamespaceIdentifier(), iconPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -142,7 +142,7 @@ public class TemplateTable implements Listener {
|
||||||
Template template = (Template) item.getData();
|
Template template = (Template) item.getData();
|
||||||
ImageDescriptor imageDesc = template.getIcon();
|
ImageDescriptor imageDesc = template.getIcon();
|
||||||
Image image = images.get(imageDesc);
|
Image image = images.get(imageDesc);
|
||||||
if (image == null) {
|
if (image == null && imageDesc != null) {
|
||||||
image = imageDesc.createImage();
|
image = imageDesc.createImage();
|
||||||
images.put(imageDesc, image);
|
images.put(imageDesc, image);
|
||||||
}
|
}
|
||||||
|
@ -152,6 +152,8 @@ public class TemplateTable implements Listener {
|
||||||
rect = image.getBounds();
|
rect = image.getBounds();
|
||||||
y = event.y + Math.max(0, (event.height - rect.height) / 2);
|
y = event.y + Math.max(0, (event.height - rect.height) / 2);
|
||||||
gc.drawImage(image, event.x + 4, y);
|
gc.drawImage(image, event.x + 4, y);
|
||||||
|
} else {
|
||||||
|
y = event.y + Math.max(0, (event.height - 48) / 2);
|
||||||
}
|
}
|
||||||
gc.setFont(fontBold);
|
gc.setFont(fontBold);
|
||||||
String name = template.getLabel();
|
String name = template.getLabel();
|
||||||
|
|
Loading…
Add table
Reference in a new issue