*/
public EntityDisplayPanel(final ModelContext modelContext,
final ViewContext viewContext) {
super(viewContext.getWicketId());
try {
App app = viewContext.getApp();
IEntity entity = modelContext.getEntity();
ConceptConfig conceptConfig = entity.getConceptConfig();
String conceptKey = conceptConfig.getCode();
String conceptName = getLocalizer().getString(conceptKey, this);
add(new Label("conceptName", conceptName));
ModelContext entityContext = new ModelContext(modelContext);
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) {
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 parentPropertyValuePanel;
if (parentConceptPropertyConfig
.getPropertyClass().equals(
"java.net.URL")
|| parentConceptPropertyConfig
.getPropertyClass()
.equals(
"org.dmlite.type.email.Email")) {
parentPropertyValuePanel = new ExternalLinkPanel(
parentModelContext,
parentViewContext);
} else {
parentPropertyValuePanel = new LabelPanel(
parentModelContext,
parentViewContext);
}
if (!app.isNeighborDisplayAllowed(
getAppSession(), neighborConfig)) {
parentPropertyNameLabel.setVisible(false);
parentPropertyValuePanel.setVisible(false);
} else if (!app.isPropertyDisplayAllowed(
getAppSession(),
parentConceptPropertyConfig)) {
parentPropertyNameLabel.setVisible(false);
parentPropertyValuePanel.setVisible(false);
}
propertyNameLabelValuePanelPair
.setPropertyValuePanel(parentPropertyValuePanel);
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 = conceptConfig.getCode() + "."
+ propertyConfig.getCode();
String propertyName = getLocalizer().getString(propertyKey,
this);
Label propertyNameLabel = new Label("propertyName",
propertyName);
PropertyNameLabelValuePanelPair propertyNameLabelValuePanelPair = new PropertyNameLabelValuePanelPair();
propertyNameLabelValuePanelPair
.setPropertyNameLabel(propertyNameLabel);
entityContext.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(entityContext,
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(entityContext,
propertiesViewContext);
} else if (propertyConfig.getPropertyClass().equals(
"java.lang.Boolean")) {
propertyValuePanel = new CheckBoxPanel(entityContext,
propertiesViewContext);
} else if (propertyConfig.getPropertyClass().equals(
"java.lang.String")
&& propertyConfig.getDisplayLengthInt() > App.MIN_LONG_TEXT_LENGTH) {
propertyValuePanel = new MultiLineLabelPanel(entityContext,
propertiesViewContext);
} else {
propertyValuePanel = new LabelPanel(entityContext,
propertiesViewContext);
} // end if
if (!app.isPropertyDisplayAllowed(getAppSession(),
propertyConfig)) {
propertyNameLabel.setVisible(false);
propertyValuePanel.setVisible(false);
}
propertyNameLabelValuePanelPair
.setPropertyValuePanel(propertyValuePanel);
propertyNameLabelValuePanelPairs
.add(propertyNameLabelValuePanelPair);
} // end if (!propertyConfig.isReference()) {
} // end for
ListView propertyNameLabelValuePanelListView = new PropertyNameLabelValuePanelListView(
"propertyNameLabelValuePanelListView",
propertyNameLabelValuePanelPairs);
add(propertyNameLabelValuePanelListView);
if (!app.isConceptDisplayAllowed(getAppSession(), conceptConfig)) {
propertyNameLabelValuePanelListView.setVisible(false);
}
} catch (Exception e) {
log.error("Error in EntityDisplayPanel: "
+ modelContext.getEntityCode() + " - " + e.getMessage());