use of org.eclipse.elk.graph.properties.IPropertyValueProxy in project elk by eclipse.
the class EMapPropertyHolderImpl method copyProperties.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated NOT
*/
public IPropertyHolder copyProperties(IPropertyHolder source) {
if (source == null) {
return this;
}
if (source instanceof EMapPropertyHolder) {
EMapPropertyHolder other = (EMapPropertyHolder) source;
EMap<IProperty<?>, Object> ourProps = this.getProperties();
for (Map.Entry<IProperty<?>, Object> entry : other.getProperties()) {
Object value = entry.getValue();
if (value instanceof IPropertyValueProxy) {
IPropertyValueProxy proxy = (IPropertyValueProxy) value;
Object newValue = proxy.resolveValue(entry.getKey());
if (newValue != null) {
entry.setValue(newValue);
value = newValue;
}
}
ourProps.put(entry.getKey(), value);
}
} else {
this.getProperties().putAll(source.getAllProperties());
}
return this;
}
use of org.eclipse.elk.graph.properties.IPropertyValueProxy in project elk by eclipse.
the class EMapPropertyHolderImpl method getProperty.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated NOT
*/
@SuppressWarnings("unchecked")
public <T> T getProperty(IProperty<T> property) {
Object value = getProperties().get(property);
if (value instanceof IPropertyValueProxy) {
value = ((IPropertyValueProxy) value).resolveValue(property);
if (value != null) {
getProperties().put(property, value);
return (T) value;
}
} else if (value != null) {
return (T) value;
}
// the reason for the side effect below is that if a default value has been returned
// and the object is altered by the user, the user expects the altered object to be
// the value of the property in case he asks for the property again
T defaultValue = property.getDefault();
if (defaultValue instanceof Cloneable) {
// We are now dealing with a clone of the default value which me may safely store away
// for further modification
setProperty(property, defaultValue);
}
return defaultValue;
}
use of org.eclipse.elk.graph.properties.IPropertyValueProxy in project elk by eclipse.
the class EMapPropertyHolderImpl method getAllProperties.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated NOT
*/
public Map<IProperty<?>, Object> getAllProperties() {
EMap<IProperty<?>, Object> props = getProperties();
// check for unresolved properties
for (Map.Entry<IProperty<?>, Object> entry : props) {
if (entry.getValue() instanceof IPropertyValueProxy && entry.getKey() != null) {
IPropertyValueProxy proxy = (IPropertyValueProxy) entry.getValue();
// Try to resolve the proxy's value, maybe the layout option was
// registered by now. If not, we preserve the proxy.
Object value = proxy.resolveValue(entry.getKey());
if (value != null) {
entry.setValue(value);
}
}
}
return props.map();
}
Aggregations