// the element always overrides all properties; properties not defined in the meta-data layer
// will be removed from the stylesheet or attribute collection.
final DataAttributes attributes = dataSchema.getAttributes(fieldName);
if (attributes == null)
{
return false;
}
final MetaDataStyleEvaluator.VolatileDataAttributeContext context = getAttributeContext();
final String typeName = e.getElementType().getMetaData().getName();
if (Boolean.TRUE.equals(allowStylingFlag))
{
final Boolean bold = (Boolean) attributes.getMetaAttribute
(MetaAttributeNames.Style.NAMESPACE, MetaAttributeNames.Style.BOLD, Boolean.class, context);
final Boolean italic = (Boolean) attributes.getMetaAttribute
(MetaAttributeNames.Style.NAMESPACE, MetaAttributeNames.Style.ITALIC, Boolean.class, context);
final Boolean strikethrough = (Boolean) attributes.getMetaAttribute
(MetaAttributeNames.Style.NAMESPACE, MetaAttributeNames.Style.STRIKETHROUGH, Boolean.class, context);
final Boolean underline = (Boolean) attributes.getMetaAttribute
(MetaAttributeNames.Style.NAMESPACE, MetaAttributeNames.Style.UNDERLINE, Boolean.class, context);
final Integer fontSize = (Integer) attributes.getMetaAttribute
(MetaAttributeNames.Style.NAMESPACE, MetaAttributeNames.Style.FONTSIZE, Integer.class, context);
final String font = (String) attributes.getMetaAttribute
(MetaAttributeNames.Style.NAMESPACE, MetaAttributeNames.Style.FONTFAMILY, String.class, context);
final Color textColor = (Color) attributes.getMetaAttribute
(MetaAttributeNames.Style.NAMESPACE, MetaAttributeNames.Style.COLOR, Color.class, context);
final Color bgColor = (Color) attributes.getMetaAttribute
(MetaAttributeNames.Style.NAMESPACE, MetaAttributeNames.Style.BACKGROUND_COLOR, Color.class, context);
final ElementAlignment hAlign = (ElementAlignment) attributes.getMetaAttribute
(MetaAttributeNames.Style.NAMESPACE, MetaAttributeNames.Style.HORIZONTAL_ALIGNMENT,
ElementAlignment.class, context);
final ElementAlignment vAlign = (ElementAlignment) attributes.getMetaAttribute
(MetaAttributeNames.Style.NAMESPACE, MetaAttributeNames.Style.VERTICAL_ALIGNMENT, ElementAlignment.class,
context);
final ElementStyleSheet styleSheet = e.getStyle();
if (isMetaStylingEnabled(e.getAttributes().getAttribute
(AttributeNames.Wizard.NAMESPACE, AttributeNames.Wizard.ENABLE_STYLE_VALIGNMENT)))
{
styleSheet.setStyleProperty(ElementStyleKeys.VALIGNMENT, vAlign);
}
if (isMetaStylingEnabled(e.getAttributes().getAttribute
(AttributeNames.Wizard.NAMESPACE, AttributeNames.Wizard.ENABLE_STYLE_ALIGNMENT)))
{
if (hAlign != null)
{
styleSheet.setStyleProperty(ElementStyleKeys.ALIGNMENT, hAlign);
}
else
{
if (LabelType.INSTANCE.getMetaData().getName().equals(typeName) == false &&
ResourceLabelType.INSTANCE.getMetaData().getName().equals(typeName) == false)
{
styleSheet.setStyleProperty(ElementStyleKeys.ALIGNMENT, computeAlignment(attributes, context));
}
}
}
if (isMetaStylingEnabled(e.getAttributes().getAttribute
(AttributeNames.Wizard.NAMESPACE, AttributeNames.Wizard.ENABLE_STYLE_BACKGROUND_COLOR)))
{
styleSheet.setStyleProperty(ElementStyleKeys.BACKGROUND_COLOR, bgColor);
}
if (isMetaStylingEnabled(e.getAttributes().getAttribute
(AttributeNames.Wizard.NAMESPACE, AttributeNames.Wizard.ENABLE_STYLE_COLOR)))
{
styleSheet.setStyleProperty(ElementStyleKeys.PAINT, textColor);
}
if (isMetaStylingEnabled(e.getAttributes().getAttribute
(AttributeNames.Wizard.NAMESPACE, AttributeNames.Wizard.ENABLE_STYLE_FONTFAMILY)))
{
styleSheet.setStyleProperty(TextStyleKeys.FONT, font);
}
if (isMetaStylingEnabled(e.getAttributes().getAttribute
(AttributeNames.Wizard.NAMESPACE, AttributeNames.Wizard.ENABLE_STYLE_FONTSIZE)))
{
styleSheet.setStyleProperty(TextStyleKeys.FONTSIZE, fontSize);
}
if (isMetaStylingEnabled(e.getAttributes().getAttribute
(AttributeNames.Wizard.NAMESPACE, AttributeNames.Wizard.ENABLE_STYLE_UNDERLINE)))
{
styleSheet.setStyleProperty(TextStyleKeys.UNDERLINED, underline);
}
if (isMetaStylingEnabled(e.getAttributes().getAttribute
(AttributeNames.Wizard.NAMESPACE, AttributeNames.Wizard.ENABLE_STYLE_BOLD)))
{
styleSheet.setStyleProperty(TextStyleKeys.BOLD, bold);
}
if (isMetaStylingEnabled(e.getAttributes().getAttribute
(AttributeNames.Wizard.NAMESPACE, AttributeNames.Wizard.ENABLE_STYLE_STRIKETHROUGH)))
{
styleSheet.setStyleProperty(TextStyleKeys.STRIKETHROUGH, strikethrough);
}
if (isMetaStylingEnabled(e.getAttributes().getAttribute
(AttributeNames.Wizard.NAMESPACE, AttributeNames.Wizard.ENABLE_STYLE_ITALICS)))
{
styleSheet.setStyleProperty(TextStyleKeys.ITALIC, italic);
}
}
final boolean legacyMode = isLegacyMode();
if (Boolean.TRUE.equals(allowAttributesFlag) &&
((legacyMode == false) || (Boolean.TRUE.equals(allowStylingFlag))))
{
if (LabelType.INSTANCE.getMetaData().getName().equals(typeName) == false &&
ResourceLabelType.INSTANCE.getMetaData().getName().equals(typeName) == false)
{
final String format = (String) attributes.getMetaAttribute
(MetaAttributeNames.Formatting.NAMESPACE, MetaAttributeNames.Formatting.FORMAT,
String.class, context);
if (format != null)
{
e.setAttribute(AttributeNames.Core.NAMESPACE, AttributeNames.Core.FORMAT_STRING, format);
}
else
{
final String autoFormat = AutoGeneratorUtility.computeFormatString(attributes, context);
e.setAttribute(AttributeNames.Core.NAMESPACE, AttributeNames.Core.FORMAT_STRING, autoFormat);
}
}
else
{
// only change the static text of labels. We do not touch anything else.
if ("label".equals(typeName)) // NON-NLS
{
final String format = (String) attributes.getMetaAttribute
(MetaAttributeNames.Formatting.NAMESPACE, MetaAttributeNames.Formatting.LABEL,
String.class, context);
e.setAttribute(AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE, format);
}
}