use of com.haulmont.cuba.gui.presentations.Presentations in project cuba by cuba-platform.
the class PresentationEditor method validate.
protected boolean validate() {
Presentations presentations = component.getPresentations();
// check that name is empty
if (StringUtils.isEmpty(nameField.getValue())) {
App.getInstance().getWindowManager().showNotification(messages.getMainMessage("PresentationsEditor.error"), messages.getMainMessage("PresentationsEditor.error.nameRequired"), Frame.NotificationType.HUMANIZED);
return false;
}
// check that name is unique
final Presentation pres = presentations.getPresentationByName(nameField.getValue());
if (pres != null && !pres.equals(presentation)) {
App.getInstance().getWindowManager().showNotification(messages.getMainMessage("PresentationsEditor.error"), messages.getMainMessage("PresentationsEditor.error.nameAlreadyExists"), Frame.NotificationType.HUMANIZED);
return false;
}
return true;
}
use of com.haulmont.cuba.gui.presentations.Presentations in project cuba by cuba-platform.
the class PresentationEditor method commit.
protected void commit() {
Presentations presentations = component.getPresentations();
Document doc = DocumentHelper.createDocument();
doc.setRootElement(doc.addElement("presentation"));
component.saveSettings(doc.getRootElement());
String xml = Dom4j.writeDocument(doc, false);
presentation.setXml(xml);
presentation.setName(nameField.getValue());
presentation.setAutoSave(autoSaveField.getValue());
presentation.setDefault(defaultField.getValue());
User user = sessionSource.getUserSession().getCurrentOrSubstitutedUser();
boolean userOnly = !allowGlobalPresentations || !BooleanUtils.isTrue(globalField.getValue());
presentation.setUser(userOnly ? user : null);
if (log.isTraceEnabled()) {
log.trace(String.format("XML: %s", Dom4j.writeDocument(doc, true)));
}
if (isNew) {
presentations.add(presentation);
} else {
presentations.modify(presentation);
}
presentations.commit();
addCloseListener(e -> {
if (isNew) {
component.applyPresentation(presentation.getId());
}
});
}
use of com.haulmont.cuba.gui.presentations.Presentations in project cuba by cuba-platform.
the class DeletePresentationAction method actionPerform.
@Override
public void actionPerform(Component component) {
tableImpl.hidePresentationsPopup();
Presentations presentations = table.getPresentations();
Presentation current = presentations.getCurrent();
presentations.remove(current);
presentations.commit();
}
use of com.haulmont.cuba.gui.presentations.Presentations in project cuba by cuba-platform.
the class PresentationActionsBuilder method isGlobalPresentation.
protected boolean isGlobalPresentation() {
Presentations presentations = table.getPresentations();
Presentation presentation = presentations.getCurrent();
return presentation != null && (!presentations.isGlobal(presentation) || userSessionSource.getUserSession().isSpecificPermitted("cuba.gui.presentations.global"));
}
use of com.haulmont.cuba.gui.presentations.Presentations in project cuba by cuba-platform.
the class SavePresentationAction method actionPerform.
@Override
public void actionPerform(Component component) {
tableImpl.hidePresentationsPopup();
Presentations presentations = table.getPresentations();
Presentation current = presentations.getCurrent();
Element e = presentations.getSettings(current);
table.saveSettings(e);
presentations.setSettings(current, e);
presentations.commit();
}
Aggregations