Search in sources :

Example 6 with Presentations

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;
}
Also used : Presentation(com.haulmont.cuba.security.entity.Presentation) Presentations(com.haulmont.cuba.gui.presentations.Presentations)

Example 7 with Presentations

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());
        }
    });
}
Also used : User(com.haulmont.cuba.security.entity.User) Document(org.dom4j.Document) Presentations(com.haulmont.cuba.gui.presentations.Presentations)

Example 8 with Presentations

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();
}
Also used : Presentation(com.haulmont.cuba.security.entity.Presentation) Presentations(com.haulmont.cuba.gui.presentations.Presentations)

Example 9 with Presentations

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"));
}
Also used : Presentation(com.haulmont.cuba.security.entity.Presentation) Presentations(com.haulmont.cuba.gui.presentations.Presentations)

Example 10 with Presentations

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();
}
Also used : Element(org.dom4j.Element) Presentation(com.haulmont.cuba.security.entity.Presentation) Presentations(com.haulmont.cuba.gui.presentations.Presentations)

Aggregations

Presentations (com.haulmont.cuba.gui.presentations.Presentations)10 Presentation (com.haulmont.cuba.security.entity.Presentation)6 Element (org.dom4j.Element)3 AbstractSearchFolder (com.haulmont.cuba.core.entity.AbstractSearchFolder)1 AppFolder (com.haulmont.cuba.core.entity.AppFolder)1 SearchFolder (com.haulmont.cuba.security.entity.SearchFolder)1 User (com.haulmont.cuba.security.entity.User)1 TablePresentations (com.haulmont.cuba.web.gui.components.presentations.TablePresentations)1 CubaMenuBar (com.haulmont.cuba.web.toolkit.ui.CubaMenuBar)1 Document (org.dom4j.Document)1