if (entityType.isChoice()) {
I_EntityAttribute attribute = entity.getAttribute(Type.CHOICE_ATTRIBUTE_NAME);
assert (attribute != null) && attribute.isComplexValue() : "a choice type must have a choice attribute";
AttributeHandler handler = new AttributeHandler(m_vie, entity, Type.CHOICE_ATTRIBUTE_NAME, m_widgetService);
parentHandler.setHandler(attributeIndex, Type.CHOICE_ATTRIBUTE_NAME, handler);
ValuePanel attributeElement = new ValuePanel();
for (I_Entity choiceEntity : attribute.getComplexValues()) {
I_Type choiceType = m_vie.getType(choiceEntity.getTypeName());
List<I_EntityAttribute> choiceAttributes = choiceEntity.getAttributes();
assert (choiceAttributes.size() == 1) && choiceAttributes.get(0).isSingleValue() : "each choice entity may only have a single attribute with a single value";
I_EntityAttribute choiceAttribute = choiceAttributes.get(0);
I_Type attributeType = choiceType.getAttributeType(choiceAttribute.getAttributeName());
I_EntityRenderer renderer = m_widgetService.getRendererForAttribute(
choiceAttribute.getAttributeName(),
attributeType);
String label = m_widgetService.getAttributeLabel(choiceAttribute.getAttributeName());
String help = m_widgetService.getAttributeHelp(choiceAttribute.getAttributeName());
context.add(attributeElement);
AttributeValueView valueWidget = new AttributeValueView(handler, label, help);
attributeElement.add(valueWidget);
if (choiceAttribute.isSimpleValue()) {
valueWidget.setValueWidget(
m_widgetService.getAttributeFormWidget(choiceAttribute.getAttributeName()),
choiceAttribute.getSimpleValue(),
true);
} else {
valueWidget.setValueEntity(renderer, choiceAttribute.getComplexValue());
}
setAttributeChoice(valueWidget, entityType);
}
handler.updateButtonVisisbility();
} else {
List<String> attributeNames = entityType.getAttributeNames();
for (String attributeName : attributeNames) {
int minOccurrence = entityType.getAttributeMinOccurrence(attributeName);
I_EntityAttribute attribute = entity.getAttribute(attributeName);
if ((attribute == null) && (minOccurrence > 0)) {
attribute = createEmptyAttribute(entity, attributeName, minOccurrence);
}
I_Type attributeType = entityType.getAttributeType(attributeName);
I_EntityRenderer renderer = m_widgetService.getRendererForAttribute(attributeName, attributeType);
String label = m_widgetService.getAttributeLabel(attributeName);
String help = m_widgetService.getAttributeHelp(attributeName);
ValuePanel attributeElement = new ValuePanel();
context.add(attributeElement);
AttributeHandler handler = new AttributeHandler(m_vie, entity, attributeName, m_widgetService);
parentHandler.setHandler(attributeIndex, attributeName, handler);
if (attribute != null) {
for (int i = 0; i < attribute.getValueCount(); i++) {
AttributeValueView valueWidget = new AttributeValueView(handler, label, help);
attributeElement.add(valueWidget);
if (attribute.isSimpleValue()) {
valueWidget.setValueWidget(
m_widgetService.getAttributeFormWidget(attributeName),
attribute.getSimpleValues().get(i),
true);
} else {
valueWidget.setValueEntity(renderer, attribute.getComplexValues().get(i));
}
setAttributeChoice(valueWidget, attributeType);
}
} else {
AttributeValueView valueWidget = new AttributeValueView(handler, label, help);
attributeElement.add(valueWidget);
if (attributeType.isSimpleType()) {
// create a deactivated widget, to add the attribute on click
valueWidget.setValueWidget(
m_widgetService.getAttributeFormWidget(attributeName),
m_widgetService.getDefaultAttributeValue(attributeName),