boolean changed = false;
final Element[] elements = getDataBackend().getData();
for (int i = 0; i < elements.length; i++)
{
final Element element = elements[i];
final Expression attribute = element.getStyleExpression(metaData.getStyleKey());
if ((ObjectUtilities.equal(attribute, value)) == false)
{
changed = true;
}
}
if (changed)
{
final ReportDocumentContext reportRenderContext = getReportRenderContext();
if (reportRenderContext == null)
{
throw new IllegalStateException("No report render context? Thats bad.");
}
final UndoManager undo = reportRenderContext.getUndo();
final ArrayList<UndoEntry> undos = new ArrayList<UndoEntry>();
for (int i = 0; i < elements.length; i++)
{
final Element element = elements[i];
final Expression attribute = element.getStyleExpression(metaData.getStyleKey());
if (value == null)
{
undos.add(new StyleExpressionEditUndoEntry
(element.getObjectID(), metaData.getStyleKey(), attribute, null));
element.setStyleExpression(metaData.getStyleKey(), null);
element.notifyNodePropertiesChanged();
}
else
{
final Expression expression = value.getInstance();
undos.add(new StyleExpressionEditUndoEntry
(element.getObjectID(), metaData.getStyleKey(), attribute, expression));
element.setStyleExpression(metaData.getStyleKey(), expression);
element.notifyNodePropertiesChanged();
}