String label = m_widgetService.getAttributeLabel(attributeName);
String help = m_widgetService.getAttributeHelp(attributeName);
if (attribute != null) {
I_EntityRenderer renderer = m_widgetService.getRendererForAttribute(attributeName, attributeType);
for (int i = 0; i < attribute.getValueCount(); i++) {
AttributeValueView valueWidget = new AttributeValueView(handler, 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(i),
m_widgetService.getDefaultAttributeValue(attributeName),
true);
// check for compact view setting
if (m_widgetService.isDisplayCompact(attributeName)) {
// widget should be displayed in compact view, using only 50% of the available width
if (lastCompactView == null) {
// set mode to first column
valueWidget.setCompactMode(AttributeValueView.COMPACT_MODE_FIRST_COLUMN);
lastCompactView = valueWidget;
} else {
// previous widget is displayed as first column, set second column mode
valueWidget.setCompactMode(AttributeValueView.COMPACT_MODE_SECOND_COLUMN);
lastCompactView = null;
}
} else {
if (lastCompactView != null) {
// previous widget was set to first column mode,
// revert that as the current widget will be displayed in a new line
lastCompactView.setCompactMode(AttributeValueView.COMPACT_MODE_WIDE);
lastCompactView = null;
}
if (m_widgetService.isDisplaySingleLine(attributeName)) {
valueWidget.setCompactMode(AttributeValueView.COMPACT_MODE_SINGLE_LINE);
}
}
} else {
valueWidget.setValueEntity(renderer, attribute.getComplexValues().get(i));
if (lastCompactView != null) {
// previous widget was set to first column mode,
// revert that as the current widget will be displayed in a new line
lastCompactView.setCompactMode(AttributeValueView.COMPACT_MODE_WIDE);
lastCompactView = null;
}
if (m_widgetService.isDisplayCompact(attributeName)) {
valueWidget.setCompactMode(AttributeValueView.COMPACT_MODE_NESTED);
}
}
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),
false);
// check for compact view setting
if (m_widgetService.isDisplayCompact(attributeName)) {
// widget should be displayed in compact view, using only 50% of the available width
if (lastCompactView == null) {
// set mode to first column
valueWidget.setCompactMode(AttributeValueView.COMPACT_MODE_FIRST_COLUMN);
lastCompactView = valueWidget;
} else {
// previous widget is displayed as first column, set second column mode
valueWidget.setCompactMode(AttributeValueView.COMPACT_MODE_SECOND_COLUMN);
lastCompactView = null;
}
} else {
if (lastCompactView != null) {
// previous widget was set to first column mode,
// revert that as the current widget will be displayed in a new line
lastCompactView.setCompactMode(AttributeValueView.COMPACT_MODE_WIDE);
lastCompactView = null;
}
if (m_widgetService.isDisplaySingleLine(attributeName)) {
valueWidget.setCompactMode(AttributeValueView.COMPACT_MODE_SINGLE_LINE);
}
}
} else {
if (lastCompactView != null) {
// previous widget was set to first column mode,
// revert that as the current widget will be displayed in a new line
lastCompactView.setCompactMode(AttributeValueView.COMPACT_MODE_WIDE);
lastCompactView = null;
}
if (m_widgetService.isDisplayCompact(attributeName)) {
valueWidget.setCompactMode(AttributeValueView.COMPACT_MODE_NESTED);
}
}
setAttributeChoice(valueWidget, attributeType);
}
handler.updateButtonVisisbility();