final String message = (String) oldAttributes.getAttribute(CORE_NAMESPACE, VALUE_ATTRIBUTE);
visualElement.setAttribute(CORE_NAMESPACE, VALUE_ATTRIBUTE, null);
try
{
final MessageFormatSupport fmt = new MessageFormatSupport();
fmt.setFormatString(message);
final String rawFormat = fmt.getCompiledFormat();
final MessageFormat msg = new MessageFormat(rawFormat);
final Format[] subFormats = msg.getFormats();
if (targetElementType instanceof DateFieldType)
{
final int sdf = findFirstDateFormat(subFormats);
if (sdf != -1)
{
final SimpleDateFormat df = (SimpleDateFormat) subFormats[sdf];
final String[] fields = fmt.getFields();
visualElement.setAttribute(CORE_NAMESPACE, FIELD_ATTRIBUTE, fields[sdf]);
visualElement.setAttribute(CORE_NAMESPACE, FORMAT_ATTRIBUTE, df.toPattern());
}
}
else if (targetElementType instanceof NumberFieldType)
{
final int sdf = findFirstNumberFormat(subFormats);
if (sdf != -1)
{
final DecimalFormat df = (DecimalFormat) subFormats[sdf];
final String[] fields = fmt.getFields();
visualElement.setAttribute(CORE_NAMESPACE, FIELD_ATTRIBUTE, fields[sdf]);
visualElement.setAttribute(CORE_NAMESPACE, FORMAT_ATTRIBUTE, df.toPattern());
}
}
else
{
final String[] fields = fmt.getFields();
if (fields.length > 0)
{
visualElement.setAttribute(CORE_NAMESPACE, FIELD_ATTRIBUTE, fields[0]);
}
else