final Integer currentPageBlock = new Integer(getCurrentPage());
final ModelContext entityModelContext = new ModelContext(
modelContext);
entityModelContext.setEntity(entity);
Link copyLink = new Link("copy") {
static final long serialVersionUID = 200741L;
public void onClick() {
getAppSession().getClipboard().setEntity(entity);
ViewContext entityCopyPageContext = new ViewContext(
viewContext);
entityCopyPageContext.setPageBlock(currentPageBlock);
setResponsePage(app.getViewMeta().getPage(
"EntityUpdateTablePage", entityModelContext,
entityCopyPageContext));
}
};
item.add(copyLink);
final ViewContext entityUpdatePageContext = new ViewContext(
viewContext);
entityUpdatePageContext.setPageBlock(currentPageBlock);
Link editLink = new PageLink("edit", new IPageLink() {
static final long serialVersionUID = 200742L;
public Page getPage() {
return app.getViewMeta().getPage("EntityEditFormPage",
entityModelContext, entityUpdatePageContext);
}
public Class getPageIdentity() {
return app.getViewMeta().getPageClass("EntityEditFormPage",
entityModelContext, entityUpdatePageContext);
}
});
item.add(editLink);
final ViewContext entityRemovePageContext = new ViewContext(
viewContext);
entityRemovePageContext.setPageBlock(currentPageBlock);
item.add(new Link("remove") {
static final long serialVersionUID = 200743L;
public void onClick() {
try {
if (app.isConceptUpdateAllowed(
getAppSession(), conceptConfig, entity, "remove")) {
entities.getErrors().empty();
if (app.getModelConfig().isConfirmRemove()) {
setResponsePage(app.getViewMeta().getPage(
"EntityConfirmRemovePage",
entityModelContext,
entityRemovePageContext));
} else if (entities.remove(entity)) {
setResponsePage(app.getViewMeta().getPage(
"EntityUpdateTablePage",
entityModelContext,
entityRemovePageContext));
} else {
addDmLiteErrorKeys(entities);
}
} else {
String error = getLocalizer().getString(
"entities.config.remove", this);
error(error);
}
} catch (DmException e) {
log.error("Error in EntityUpdateTableListView: "
+ modelContext.getEntitiesCode() + " - "
+ e.getMessage());
}
}
});
// Neighbor update links
List<NeighborNameLabelLinkPair> neighborNameLabelLinkPairs = new ArrayList<NeighborNameLabelLinkPair>();
NeighborsConfig neighborsConfig = conceptConfig
.getNeighborsConfig();
for (IEntity neighborConfigEntity : neighborsConfig) {
NeighborConfig neighborConfig = (NeighborConfig) neighborConfigEntity;
if (neighborConfig.getType().equals("child")
&& neighborConfig.isInternal()) {
NeighborNameLabelLinkPair neighborNameLabelLinkPair = new NeighborNameLabelLinkPair();
String conceptCode = conceptConfig.getCode();
String neighborKey = conceptCode + "."
+ neighborConfig.getCode();
String neighborName = getLocalizer().getString(neighborKey,
this);
Label neighborNameLabel = new Label("neighborName",
neighborName);
neighborNameLabelLinkPair
.setNeighborNameLabel(neighborNameLabel);
Link neighborLink = null;
IDomainModel domainModel = app.getDomainModel();
final IOrderedEntities neighborEntities = (IOrderedEntities) domainModel
.getModelMeta().getNeighborEntities(entity,
neighborConfig.getCode());
final ModelContext neighborModelContext = new ModelContext(
modelContext);
neighborModelContext.setContextEntities(entities);
neighborModelContext.setContextEntity(entity);
neighborModelContext.setEntities(neighborEntities);
final ViewContext neighborViewContext = new ViewContext(
viewContext);
neighborViewContext.setPageBlock(new Integer(0));
neighborLink = new PageLink("neighbor", new IPageLink() {
static final long serialVersionUID = 200744L;
public Page getPage() {
return app.getViewMeta().getPage(
"EntityUpdateTablePage",
neighborModelContext, neighborViewContext);
}
public Class getPageIdentity() {
return app.getViewMeta().getPageClass(
"EntityUpdateTablePage",
neighborModelContext, neighborViewContext);
}
});
if (!app.isNeighborDisplayAllowed(getAppSession(),
neighborConfig)) {
neighborLink.setVisible(false);
} else if (!app.isNeighborUpdateAllowed(getAppSession(),
neighborConfig)) {
neighborLink.setVisible(false);
}
neighborNameLabelLinkPair.setNeighborLink(neighborLink);
neighborNameLabelLinkPairs.add(neighborNameLabelLinkPair);
}