StylePropertyBrowseAction browseAction = StylePropertyMetadata.getBrowseAction(styleProperty);
StyleType supportedStructure = styleProperty.getStandardDetails().
getSupportedStructure();
final StyleValueEditor styleEditor = new StyleValueEditor(this,
SWT.NONE, styleProperty, supportedStructure, true,
browseAction, context);
data = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
styleEditor.setLayoutData(data);
if (isSpecialSynchronization) {
// Special synchronization
if (synchronizationGroup != null) {
// Setting up a modify listener to update the properties
// if the synchronization control is set
styleEditor.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
PropertyAccessor synchAccessor = (PropertyAccessor) accessors
.get(synchronizationGroup);
Object value = synchAccessor.getPropertyValue();
PropertyDescriptor[] controlledProperties = synchronizationGroup
.getControlledDescriptors();
for (int i = 0; i < controlledProperties.length; i++) {
PropertyIdentifier identifier = controlledProperties[i]
.getIdentifier();
PropertyAccessor accessor = (PropertyAccessor) accessors
.get(identifier);
accessor.setPropertyValue(value);
propertyChanged(controlledProperties[i], value);
}
}
});
} else {
// Synchronization group must not be null
// when isSpecialSynchronization is set to true
throw new IllegalArgumentException(
"Synchronization group for special synchronization must not be null");
}
} else {
// Normal synchronization
if (synchronizationGroup != null) {
// Setting up a modify listener to update the synchronization
// control if one of the synchronized properties changes
styleEditor.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
propertyChanged(descriptor, styleEditor.getValue());
updateSynchControl(synchronizationGroup);
}
});
} else {
// Setting up a normal modify listener
styleEditor.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
propertyChanged(descriptor, styleEditor.getValue());
}
});
}
}
final Object key = isSpecialSynchronization ?
(Object) synchronizationGroup : descriptor.getIdentifier();
addControls(key, styleEditor, label);
accessors.put(key, new PropertyAccessor() {
public Object getPropertyValue() {
String textValue = styleEditor.getValue();
final EditorPropertyParser parser = new EditorPropertyParser();
return parser.parsePropertyValue(styleProperty, textValue,
styleEditor.isImportant());
}
public void setPropertyValue(Object newValue) {
if (newValue instanceof PropertyValue) {
styleEditor.setPropertyValue((PropertyValue) newValue);
} else {
styleEditor.setPropertyValue(null);
}
}
});
}