*
* @see org.geomajas.gwt.client.widget.attribute.FeatureForm#toForm(java.lang.String,
* org.geomajas.layer.feature.Attribute)
*/
public void toForm(String name, Attribute<?> attribute) {
AttributeInfo info = attributeInfoMap.get(name);
if (info == null || !isIncluded(info)) {
return;
}
FormItem item = formWidget.getField(info.getName());
if (item != null) {
if (info instanceof PrimitiveAttributeInfo) {
PrimitiveAttribute<?> primitive = (PrimitiveAttribute<?>) attribute;
if (attribute == null) {
item.setDisabled(true);
} else {
switch (primitive.getType()) {
case BOOLEAN:
setValue(info.getName(), (BooleanAttribute) primitive); // NOSONAR valid cast
break;
case SHORT:
setValue(info.getName(), (ShortAttribute) primitive); // NOSONAR valid cast
break;
case INTEGER:
setValue(info.getName(), (IntegerAttribute) primitive); // NOSONAR valid cast
break;
case LONG:
setValue(info.getName(), (LongAttribute) primitive); // NOSONAR valid cast
break;
case FLOAT:
setValue(info.getName(), (FloatAttribute) primitive); // NOSONAR valid cast
break;
case DOUBLE:
setValue(info.getName(), (DoubleAttribute) primitive); // NOSONAR valid cast
break;
case CURRENCY:
setValue(info.getName(), (CurrencyAttribute) primitive); // NOSONAR valid cast
break;
case STRING:
setValue(info.getName(), (StringAttribute) primitive); // NOSONAR valid cast
break;
case URL:
setValue(info.getName(), (UrlAttribute) primitive); // NOSONAR valid cast
break;
case IMGURL:
setValue(info.getName(), (ImageUrlAttribute) primitive); // NOSONAR valid cast
break;
case DATE:
setValue(info.getName(), (DateAttribute) primitive); // NOSONAR valid cast
break;
default:
throw new IllegalStateException("Unhandled primitive attribute type " +
primitive.getType());
}