Thursday, December 27, 2012

Image decorator






Here is the simple snippet to add a decorator to the image.



@Override
public Image getImage(Object element) {


if (resource instanceof Column)
{
 return decorateImage(SImageRegistry.getImage(SImageConstants.column), element);
}

}


public Image decorateImage(Image image, Object element) {
if (element instanceof Column) {
if (((Column) element).isPrimaryKeyPart()) {
DecorationOverlayIcon decorationOverlayIcon = new DecorationOverlayIcon(image,
SImageRegistry.getImageDescriptor(SImageConstants.primary_key), IDecoration.TOP_LEFT);
return decorationOverlayIcon.createImage();
}
return image;
}
return null;
}

No comments:

Post a Comment