/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ILightweightLabelDecorator#decorate(java.lang.Object, org.eclipse.jface.viewers.IDecoration)
*/
public void decorate( Object element, IDecoration decoration )
{
SchemaChecker schemaChecker = Activator.getDefault().getSchemaChecker();
if ( element instanceof AttributeTypeWrapper )
{
AttributeTypeImpl at = ( ( AttributeTypeWrapper ) element ).getAttributeType();
if ( schemaChecker.hasErrors( at ) )
{
decoration.addOverlay( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
PluginConstants.IMG_OVERLAY_ERROR ), IDecoration.BOTTOM_LEFT );
return;
}
if ( schemaChecker.hasWarnings( at ) )
{
decoration.addOverlay( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
PluginConstants.IMG_OVERLAY_WARNING ), IDecoration.BOTTOM_LEFT );
}
}
else if ( element instanceof ObjectClassWrapper )
{
ObjectClassImpl oc = ( ( ObjectClassWrapper ) element ).getObjectClass();
if ( schemaChecker.hasErrors( oc ) )
{
decoration.addOverlay( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
PluginConstants.IMG_OVERLAY_ERROR ), IDecoration.BOTTOM_LEFT );
return;
}
if ( schemaChecker.hasWarnings( oc ) )
{
decoration.addOverlay( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
PluginConstants.IMG_OVERLAY_WARNING ), IDecoration.BOTTOM_LEFT );
}
}
else if ( element instanceof SchemaWrapper )
{
Schema schema = ( ( SchemaWrapper ) element ).getSchema();
for ( AttributeTypeImpl at : schema.getAttributeTypes() )
{
if ( schemaChecker.hasErrors( at ) )
{
decoration.addOverlay( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
PluginConstants.IMG_OVERLAY_ERROR ), IDecoration.BOTTOM_LEFT );
return;
}
if ( schemaChecker.hasWarnings( at ) )
{
decoration.addOverlay( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
PluginConstants.IMG_OVERLAY_WARNING ), IDecoration.BOTTOM_LEFT );
}
}
for ( ObjectClassImpl oc : schema.getObjectClasses() )
{
if ( schemaChecker.hasErrors( oc ) )
{
decoration.addOverlay( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
PluginConstants.IMG_OVERLAY_ERROR ), IDecoration.BOTTOM_LEFT );
return;
}
if ( schemaChecker.hasWarnings( oc ) )
{
decoration.addOverlay( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
PluginConstants.IMG_OVERLAY_WARNING ), IDecoration.BOTTOM_LEFT );
}
}
}
else if ( element instanceof Folder )
{
Folder folder = ( Folder ) element;
Schema schema = ( ( SchemaWrapper ) folder.getParent() ).getSchema();
if ( folder.getType().equals( FolderType.ATTRIBUTE_TYPE ) )
{
for ( AttributeTypeImpl at : schema.getAttributeTypes() )
{
if ( schemaChecker.hasErrors( at ) )
{
decoration.addOverlay( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
PluginConstants.IMG_OVERLAY_ERROR ), IDecoration.BOTTOM_LEFT );
return;
}
if ( schemaChecker.hasWarnings( at ) )
{
decoration.addOverlay( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
PluginConstants.IMG_OVERLAY_WARNING ), IDecoration.BOTTOM_LEFT );
}
}
}
else if ( folder.getType().equals( FolderType.OBJECT_CLASS ) )
{
for ( ObjectClassImpl oc : schema.getObjectClasses() )
{
if ( schemaChecker.hasErrors( oc ) )
{
decoration.addOverlay( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
PluginConstants.IMG_OVERLAY_ERROR ), IDecoration.BOTTOM_LEFT );
return;
}
if ( schemaChecker.hasWarnings( oc ) )
{
decoration.addOverlay( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
PluginConstants.IMG_OVERLAY_WARNING ), IDecoration.BOTTOM_LEFT );
}
}