protected void setShapesProperties(){
// Get properties that have changed
List changedProperties = new ArrayList();
AbstractShape shapeReference = (AbstractShape)shapes.get(0);
String[] contentsProperties = content.getPropertyNames();
for(int i=0; i < contentsProperties.length; i++){
Object newValue = content.getPropertyValue(contentsProperties[i]);
Object refValue = shapeReference.getPropertyValue(contentsProperties[i]);
if ( ( (newValue == null) && (refValue != null))
|| ( (newValue != null) && (refValue == null))
|| ( newValue!=null && refValue != null && !newValue.equals(refValue))
){
changedProperties.add(contentsProperties[i]);
}
}
// If some properties have changed, apply them to all shapes
if (!changedProperties.isEmpty()){
CompoundEdit shapesEdit = new CompoundEdit();
for(int i=0;i<shapes.size(); i++){
AbstractShape shape = (AbstractShape)shapes.get(i);
// Merge the changes with all shape properties before
ChangedProperties shapeProperties = new ChangedProperties();
String[] shapePropertiesName = shape.getPropertyNames();
for(int j=0; j < shapePropertiesName.length; j++){
String property = shapePropertiesName[j];
if (changedProperties.contains(property)){
shapeProperties.setPropertyValue(property, content.getPropertyValue(property));
} else {
shapeProperties.setPropertyValue(property, shape.getPropertyValue(property));
}
}
CompoundEdit ce = new CompoundEdit();
if (shape.setProperties(shapeProperties, ce)) {
shapesEdit.addEdit(ce);
}
ce.end();
}