I_Type entityType = m_vie.getType(parentEntity.getTypeName());
I_Type attributeType = attributeHandler.getAttributeType();
String attributeName = attributeHandler.getAttributeName();
int minOccurrence = entityType.getAttributeMinOccurrence(attributeName);
I_EntityAttribute attribute = parentEntity.getAttribute(attributeName);
if ((attribute == null) && (minOccurrence > 0)) {
attribute = createEmptyAttribute(parentEntity, attributeName, minOccurrence);
}
ValuePanel attributeElement = new ValuePanel();
context.add(attributeElement);
context.addStyleName(ENTITY_CLASS);
RootHandler parentHandler = new RootHandler();
parentHandler.ensureHandlers(attributeIndex);
parentHandler.setHandler(attributeIndex, attributeName, attributeHandler);
attributeHandler.setSingleValueIndex(attributeIndex);
String label = m_widgetService.getAttributeLabel(attributeName);
String help = m_widgetService.getAttributeHelp(attributeName);
if (attribute != null) {
I_EntityRenderer renderer = m_widgetService.getRendererForAttribute(attributeName, attributeType);
AttributeValueView valueWidget = new AttributeValueView(attributeHandler, label, help);
if (attributeType.isChoice() && (entityType.getAttributeMaxOccurrence(attributeName) == 1)) {
valueWidget.setCollapsed(true);
}
attributeElement.add(valueWidget);
if (attribute.isSimpleValue()) {
valueWidget.setValueWidget(
m_widgetService.getAttributeFormWidget(attributeName),
attribute.getSimpleValues().get(attributeIndex),
m_widgetService.getDefaultAttributeValue(attributeName),
true);
if (m_widgetService.isDisplayCompact(attributeName)) {
// widget should be displayed in compact view, using only 50% of the available width
valueWidget.setCompactMode(AttributeValueView.COMPACT_MODE_FIRST_COLUMN);
} else {
if (m_widgetService.isDisplaySingleLine(attributeName)) {
valueWidget.setCompactMode(AttributeValueView.COMPACT_MODE_SINGLE_LINE);
}
}
} else {
valueWidget.setValueEntity(renderer, attribute.getComplexValues().get(attributeIndex));
if (m_widgetService.isDisplayCompact(attributeName)) {
valueWidget.setCompactMode(AttributeValueView.COMPACT_MODE_NESTED);
}
}
setAttributeChoice(valueWidget, attributeType);