use of com.haulmont.cuba.gui.WindowContext in project cuba by cuba-platform.
the class ScreenHistorySupport method saveScreenHistory.
public void saveScreenHistory(Screen frameOwner) {
WindowContext windowContext = frameOwner.getWindow().getContext();
if (security.isEntityOpPermitted(ScreenHistoryEntity.class, EntityOp.CREATE) && (frameOwner instanceof EditorScreen) && windowContext.getLaunchMode() != OpenMode.DIALOG && (screenIds.contains(frameOwner.getId()))) {
String caption = frameOwner.getWindow().getCaption();
Object entityId = null;
Entity entity = ((EditorScreen) frameOwner).getEditedEntity();
if (entity != null) {
if (PersistenceHelper.isNew(entity)) {
return;
}
if (StringUtils.isBlank(caption)) {
caption = messages.getTools().getEntityCaption(entity.getMetaClass()) + " " + metadata.getTools().getInstanceName(entity);
}
entityId = referenceToEntitySupport.getReferenceIdForLink(entity);
}
ScreenHistoryEntity screenHistoryEntity = metadata.create(ScreenHistoryEntity.class);
screenHistoryEntity.setCaption(StringUtils.abbreviate(caption, 255));
screenHistoryEntity.setUrl(makeLink(frameOwner));
screenHistoryEntity.setObjectEntityId(entityId);
addAdditionalFields(screenHistoryEntity, entity);
CommitContext cc = new CommitContext(Collections.singleton(screenHistoryEntity));
dataManager.commit(cc);
}
}
Aggregations