*/
protected void populateItem(ListItem item) {
try {
IEntity entity = (IEntity) item.getModelObject();
App app = viewContext.getApp();
ConceptConfig conceptConfig = entity.getConceptConfig();
String conceptCode = conceptConfig.getCode();
ModelContext entityModelContext = new ModelContext(modelContext);
entityModelContext.setEntity(entity);
List<PropertyNameLabelValuePanelPair> propertyNameLabelValuePanelPairs = new ArrayList<PropertyNameLabelValuePanelPair>();
// Properties absorbed from parents.
NeighborsConfig neighborsConfig = conceptConfig
.getNeighborsConfig();
for (IEntity neighborConfigEntity : neighborsConfig) {
NeighborConfig neighborConfig = (NeighborConfig) neighborConfigEntity;
if (neighborConfig.getType().equals("parent")
&& neighborConfig.getMax().equals("1")
&& neighborConfig.isAbsorb()) {
ConceptConfig parentConceptConfig = neighborConfig
.getNeighborDestinationConceptConfig();
if (parentConceptConfig != null) {
if (conceptCode.equals(neighborConfig
.getContextConceptConfig().getCode())
&& parentConceptConfig.getDisplayType().equals(
"slide")) {
// Do not absorb the context parent properties when
// the parent is displayed as a slide.
continue;
}
PropertiesConfig parentConceptPropertiesConfig = parentConceptConfig
.getPropertiesConfig();
for (IEntity parentPropertyConfigEntity : parentConceptPropertiesConfig) {
PropertyConfig parentConceptPropertyConfig = (PropertyConfig) parentPropertyConfigEntity;
if (parentConceptPropertyConfig.isEssential()) {
IEntity parentEntity = entity
.getNeighborEntity(neighborConfig
.getCode());
if (parentEntity != null) {
String parentCode = parentEntity
.getConceptConfig().getCode();
String parentPropertyKey = parentCode
+ "."
+ parentConceptPropertyConfig
.getCode();
String parentPropertyName = getLocalizer()
.getString(parentPropertyKey, this);
Label parentPropertyNameLabel = new Label(
"propertyName", parentPropertyName);
PropertyNameLabelValuePanelPair propertyNameLabelValuePanelPair = new PropertyNameLabelValuePanelPair();
propertyNameLabelValuePanelPair
.setPropertyNameLabel(parentPropertyNameLabel);
ModelContext parentModelContext = new ModelContext(
modelContext);
parentModelContext.setEntity(parentEntity);
parentModelContext
.setPropertyConfig(parentConceptPropertyConfig);
ViewContext parentViewContext = new ViewContext(
viewContext);
parentViewContext.setWicketId("valuePanel");
Panel parentPropertyPanel;
if (parentConceptPropertyConfig
.getPropertyClass().equals(
"java.net.URL")
|| parentConceptPropertyConfig
.getPropertyClass()
.equals(
"org.dmlite.type.email.Email")) {
parentPropertyPanel = new ExternalLinkPanel(
parentModelContext,
parentViewContext);
} else {
parentPropertyPanel = new LabelPanel(
parentModelContext,
parentViewContext);
} // if
if (!app.isNeighborDisplayAllowed(
getAppSession(), neighborConfig)) {
parentPropertyPanel.setVisible(false);
} else if (!app.isPropertyDisplayAllowed(
getAppSession(),
parentConceptPropertyConfig)) {
parentPropertyPanel.setVisible(false);
}
propertyNameLabelValuePanelPair
.setPropertyValuePanel(parentPropertyPanel);
propertyNameLabelValuePanelPairs
.add(propertyNameLabelValuePanelPair);
} // if
} // if
} // for
} // if
} // if
} // for
PropertiesConfig propertiesConfig = conceptConfig
.getPropertiesConfig();
for (IEntity propertyConfigEntity : propertiesConfig) {
PropertyConfig propertyConfig = (PropertyConfig) propertyConfigEntity;
if (!propertyConfig.isReference()) {
String propertyKey = conceptCode + "."
+ propertyConfig.getCode();
String propertyName = getLocalizer().getString(propertyKey,
this);
Label propertyNameLabel = new Label("propertyName",
propertyName);
PropertyNameLabelValuePanelPair propertyNameLabelValuePanelPair = new PropertyNameLabelValuePanelPair();
propertyNameLabelValuePanelPair
.setPropertyNameLabel(propertyNameLabel);
entityModelContext.setPropertyConfig(propertyConfig);
ViewContext propertiesViewContext = new ViewContext(
viewContext);
propertiesViewContext.setWicketId("valuePanel");
Panel propertyValuePanel;
if (propertyConfig.getPropertyClass()
.equals("java.net.URL")
|| propertyConfig.getPropertyClass().equals(
"org.dmlite.type.email.Email")) {
propertyValuePanel = new ExternalLinkPanel(
entityModelContext, propertiesViewContext);
} else if (propertyConfig.getPropertyClass().equals(
"java.lang.String")
&& propertyConfig.isValidateType()
&& (propertyConfig.getValidationType().equals(
"java.net.URL") || propertyConfig
.getValidationType().equals(
"org.dmlite.type.email.Email"))) {
propertyValuePanel = new ExternalLinkPanel(
entityModelContext, propertiesViewContext);
} else {
propertyValuePanel = new LabelPanel(entityModelContext,
propertiesViewContext);
}
if (!app.isPropertyDisplayAllowed(getAppSession(),
propertyConfig)) {
propertyNameLabel.setVisible(false);
propertyValuePanel.setVisible(false);
}
propertyNameLabelValuePanelPair
.setPropertyValuePanel(propertyValuePanel);
propertyNameLabelValuePanelPairs
.add(propertyNameLabelValuePanelPair);
}
}
ListView propertyNameLabelValuePanelListView = new PropertyNameLabelValuePanelListView(
"propertyNameLabelValuePanelListView",
propertyNameLabelValuePanelPairs);
item.add(propertyNameLabelValuePanelListView);
if (!app.isConceptDisplayAllowed(getAppSession(), conceptConfig)) {
propertyNameLabelValuePanelListView.setVisible(false);
}
List<Panel> childList = new ArrayList<Panel>();
for (IEntity neighborConfigEntity : neighborsConfig) {
NeighborConfig neighborConfig = (NeighborConfig) neighborConfigEntity;
if (neighborConfig.getType().equals("child")) {
String childCode = neighborConfig.getCode();
IDomainModel domainModel = app.getDomainModel();
IOrderedEntities childEntities = (IOrderedEntities) domainModel
.getModelMeta().getNeighborEntities(entity,
childCode);
ModelContext childEntitiesContext = new ModelContext(
modelContext);
childEntitiesContext.setEntities(childEntities);
ViewContext entityDisplayListPanelContext = new ViewContext(
viewContext);
entityDisplayListPanelContext
.setWicketId("entityDisplayListPanel");
Panel entityDisplayListPanel = app.getViewMeta().getPanel(
"EntityDisplayListPanel", childEntitiesContext,
entityDisplayListPanelContext);
childList.add(entityDisplayListPanel);
if (!app.isNeighborDisplayAllowed(getAppSession(),
neighborConfig)) {
entityDisplayListPanel.setVisible(false);
}
} // if (neighborConfig.getType().equals("child")) {
} // for