*/
public EntityUpdateTablePanel(final ModelContext modelContext,
final ViewContext viewContext) {
super(modelContext, viewContext);
try {
final App app = viewContext.getApp();
final IEntities entities = modelContext.getEntities();
final ConceptConfig conceptConfig = entities.getConceptConfig();
// Table title
String conceptsKey = conceptConfig.getEntitiesCode();
String conceptsName = getLocalizer().getString(conceptsKey, this);
add(new Label("conceptsName", conceptsName));
// Absorbed parent essential property names
List<String> parentEssentialPropertyNames = new ArrayList<String>();
List<String> parentEssentialPropertyCodes = entities
.getConceptConfig().getParentCodeEssentialPropertyCodes();
for (String parentPropertyKey : parentEssentialPropertyCodes) {
String parentPropertyName = getLocalizer().getString(
parentPropertyKey, this);
parentEssentialPropertyNames.add(parentPropertyName);
}
// Concept essential property names
List<String> conceptEssentialPropertyNames = new ArrayList<String>();
List<String> conceptEssentiaPropertyCodes = entities
.getConceptConfig().getConceptCodeEssentialPropertyCodes();
for (String conceptPropertyKey : conceptEssentiaPropertyCodes) {
String conceptPropertyName = getLocalizer().getString(
conceptPropertyKey, this);
conceptEssentialPropertyNames.add(conceptPropertyName);
}
List<String> essentialPropertyNames = parentEssentialPropertyNames;
essentialPropertyNames.addAll(conceptEssentialPropertyNames);
add(new PropertyNameLabelListView("propertyNameLabelListView",
essentialPropertyNames));
// Neighbor empty labels
List<String> childInternalNeighborNames = conceptConfig
.getInternalChildNeighborNames();
add(new NeighborEmptyNameLabelListView(
"neighborEmptyNameLabelListViewHead",
childInternalNeighborNames));
ModelContext entityUpdateTableListModelContext = new ModelContext(
modelContext);
ViewContext entityUpdateTableListViewContext = new ViewContext(
viewContext);
entityUpdateTableListViewContext
.setWicketId("entityUpdateTableListView");
PageableListView entityUpdateTableListView = app.getViewMeta()
.getPageableListView("EntityUpdateTableListView",
entityUpdateTableListModelContext,
entityUpdateTableListViewContext);
add(entityUpdateTableListView);
if (!app.isConceptDisplayAllowed(getAppSession(), conceptConfig)) {
entityUpdateTableListView.setVisible(false);
}
add(new PropertyEmptyNameLabelListView(
"propertyEmptyNameLabelListView", essentialPropertyNames));
add(new PagingNavigator("blockNavigator", entityUpdateTableListView));
add(new NeighborEmptyNameLabelListView(
"neighborEmptyNameLabelListViewTail",
childInternalNeighborNames));
final Integer currentBlock = new Integer(entityUpdateTableListView
.getCurrentPage());
Link addLink = new Link("add") {
static final long serialVersionUID = 200761L;
public void onClick() {
if (app.isConceptUpdateAllowed(getAppSession(),
conceptConfig, null, "add")) {
ModelContext entityAddFormPageModelContext = new ModelContext(
modelContext);
entityAddFormPageModelContext.setEntity(null);
ViewContext entityAddPageContext = new ViewContext(
viewContext);
entityAddPageContext.setPageBlock(currentBlock);
setResponsePage(app.getViewMeta().getPage(
"EntityAddFormPage",
entityAddFormPageModelContext,
entityAddPageContext));
} else {
String error = getLocalizer().getString(
"entities.config.add", this);
error(error);
}
}
};
add(addLink);
final IEntity clipboardEntity = getAppSession().getClipboard()
.getEntity();
Link pasteLink = new Link("paste") {
static final long serialVersionUID = 200762L;
public void onClick() {
try {
if (clipboardEntity != null) {
if (app.isConceptUpdateAllowed(getAppSession(),
conceptConfig, clipboardEntity, "add")
&& clipboardEntity.getConceptConfig() == entities
.getConceptConfig()) {
if (entities.add(clipboardEntity)) {
ViewContext entityUpdateTablePageContext = new ViewContext(
viewContext);
entityUpdateTablePageContext
.setPageBlock(currentBlock);
setResponsePage(app.getViewMeta().getPage(
"EntityUpdateTablePage",
modelContext,
entityUpdateTablePageContext));
} else {
addDmLiteErrorKeys(entities);