context.getElement().setAttribute("typeof", entity.getTypeName());
context.getElement().setAttribute("about", entity.getId());
I_Type entityType = m_vie.getType(entity.getTypeName());
AttributeValueView lastCompactView = null;
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(),
m_widgetService.getDefaultAttributeValue(choiceAttribute.getAttributeName()),
true);
if (m_widgetService.isDisplaySingleLine(choiceAttribute.getAttributeName())) {
valueWidget.setCompactMode(AttributeValueView.COMPACT_MODE_SINGLE_LINE);
}
} else {
valueWidget.setValueEntity(renderer, choiceAttribute.getComplexValue());
if (m_widgetService.isDisplayCompact(choiceAttribute.getAttributeName())) {
valueWidget.setCompactMode(AttributeValueView.COMPACT_MODE_NESTED);
}
}
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);
ValuePanel attributeElement = new ValuePanel();