Search in sources :

Example 1 with Presentations

use of com.haulmont.cuba.gui.presentations.Presentations in project cuba by cuba-platform.

the class WindowDelegate method saveSettings.

public void saveSettings() {
    if (settings != null) {
        ComponentsHelper.walkComponents(window, (component, name) -> {
            if (component.getId() != null && component instanceof Component.HasSettings) {
                log.trace("Saving settings for : {} : {}", name, component);
                Element e = WindowDelegate.this.settings.get(name);
                boolean modified = ((Component.HasSettings) component).saveSettings(e);
                if (component instanceof Component.HasPresentations && ((Component.HasPresentations) component).isUsePresentations()) {
                    Object def = ((Component.HasPresentations) component).getDefaultPresentationId();
                    e.addAttribute("presentation", def != null ? def.toString() : "");
                    Presentations presentations = ((Component.HasPresentations) component).getPresentations();
                    if (presentations != null) {
                        presentations.commit();
                    }
                }
                WindowDelegate.this.settings.setModified(modified);
            }
        });
        settings.commit();
    }
}
Also used : Element(org.dom4j.Element) Presentations(com.haulmont.cuba.gui.presentations.Presentations)

Example 2 with Presentations

use of com.haulmont.cuba.gui.presentations.Presentations in project cuba by cuba-platform.

the class FilterDelegateImpl method saveAsFolder.

protected void saveAsFolder(boolean isAppFolder) {
    final AbstractSearchFolder folder;
    if (isAppFolder)
        folder = (metadata.create(AppFolder.class));
    else
        folder = (metadata.create(SearchFolder.class));
    if (filterEntity.getCode() == null) {
        String folderName = filterEntity != adHocFilter ? filterEntity.getName() : "";
        folder.setName(folderName);
        folder.setTabName(folderName);
    } else {
        String name = messages.getMainMessage(filterEntity.getCode());
        folder.setName(name);
        folder.setTabName(name);
    }
    String newXml = filterParser.getXml(conditions, Param.ValueProperty.VALUE);
    folder.setFilterComponentId(filterEntity.getComponentId());
    folder.setFilterXml(newXml);
    if (!isAppFolder) {
        if (uerCanEditGlobalFilter())
            ((SearchFolder) folder).setUser(filterEntity.getUser());
        else
            ((SearchFolder) folder).setUser(userSessionSource.getUserSession().getCurrentOrSubstitutedUser());
    }
    Presentations presentations;
    if (applyTo != null && applyTo instanceof HasPresentations) {
        final HasPresentations presentationsOwner = (HasPresentations) applyTo;
        presentations = presentationsOwner.isUsePresentations() ? presentationsOwner.getPresentations() : null;
    } else {
        presentations = null;
    }
    Runnable commitHandler;
    if (isAppFolder) {
        commitHandler = () -> {
            AbstractSearchFolder savedFolder = saveFolder(folder);
            filterEntity.setFolder(savedFolder);
        };
    } else {
        commitHandler = () -> {
            AbstractSearchFolder savedFolder = saveFolder(folder);
            filterEntity.setFolder(savedFolder);
        };
    }
    filterHelper.openFolderEditWindow(isAppFolder, folder, presentations, commitHandler);
}
Also used : AppFolder(com.haulmont.cuba.core.entity.AppFolder) AbstractSearchFolder(com.haulmont.cuba.core.entity.AbstractSearchFolder) AbstractSearchFolder(com.haulmont.cuba.core.entity.AbstractSearchFolder) SearchFolder(com.haulmont.cuba.security.entity.SearchFolder) Presentations(com.haulmont.cuba.gui.presentations.Presentations)

Example 3 with Presentations

use of com.haulmont.cuba.gui.presentations.Presentations in project cuba by cuba-platform.

the class ScreenSettings method saveSettings.

/**
 * Save settings of screen.
 *
 * @param screen   screen
 * @param settings settings
 */
public void saveSettings(Screen screen, Settings settings) {
    checkNotNullArgument(screen);
    checkNotNullArgument(settings);
    walkComponents(screen.getWindow(), (component, name) -> {
        if (component.getId() != null && component instanceof HasSettings) {
            log.trace("Saving settings for {} : {}", name, component);
            Element e = settings.get(name);
            boolean modified = ((HasSettings) component).saveSettings(e);
            if (component instanceof HasPresentations && ((HasPresentations) component).isUsePresentations()) {
                Object def = ((HasPresentations) component).getDefaultPresentationId();
                e.addAttribute("presentation", def != null ? def.toString() : "");
                Presentations presentations = ((HasPresentations) component).getPresentations();
                if (presentations != null) {
                    presentations.commit();
                }
            }
            if (modified) {
                settings.setModified(true);
            }
        }
    });
    settings.commit();
}
Also used : HasPresentations(com.haulmont.cuba.gui.components.HasPresentations) Element(org.dom4j.Element) HasSettings(com.haulmont.cuba.gui.components.HasSettings) Presentations(com.haulmont.cuba.gui.presentations.Presentations) HasPresentations(com.haulmont.cuba.gui.components.HasPresentations)

Example 4 with Presentations

use of com.haulmont.cuba.gui.presentations.Presentations in project cuba by cuba-platform.

the class WebAbstractTable method handleSpecificVariables.

protected boolean handleSpecificVariables(Map<String, Object> variables) {
    if (isUsePresentations() && presentations != null) {
        Presentations p = getPresentations();
        if (p.getCurrent() != null && p.isAutoSave(p.getCurrent()) && needUpdatePresentation(variables)) {
            Element e = p.getSettings(p.getCurrent());
            saveSettings(e);
            p.setSettings(p.getCurrent(), e);
        }
    }
    return false;
}
Also used : Element(org.dom4j.Element) Presentations(com.haulmont.cuba.gui.presentations.Presentations) TablePresentations(com.haulmont.cuba.web.gui.components.presentations.TablePresentations)

Example 5 with Presentations

use of com.haulmont.cuba.gui.presentations.Presentations in project cuba by cuba-platform.

the class TablePresentations method buildPresentationsList.

protected void buildPresentationsList() {
    menuBar.removeItems();
    presentationsMenuMap = new HashMap<>();
    Presentations p = table.getPresentations();
    for (Object presId : p.getPresentationIds()) {
        MenuBar.MenuItem item = menuBar.addItem(defaultString(p.getCaption(presId)), selectedItem -> table.applyPresentation(presId));
        Presentation current = p.getCurrent();
        if (current != null && presId.equals(current.getId())) {
            setCurrentItemStyle(item);
        }
        Presentation defaultPresentation = p.getDefault();
        if (defaultPresentation != null && presId.equals(defaultPresentation.getId())) {
            setDefaultItemStyle(item);
        }
        presentationsMenuMap.put(presId, item);
    }
}
Also used : CubaMenuBar(com.haulmont.cuba.web.widgets.CubaMenuBar) Presentation(com.haulmont.cuba.security.entity.Presentation) Presentations(com.haulmont.cuba.gui.presentations.Presentations)

Aggregations

Presentations (com.haulmont.cuba.gui.presentations.Presentations)11 Presentation (com.haulmont.cuba.security.entity.Presentation)6 Element (org.dom4j.Element)4 HasPresentations (com.haulmont.cuba.gui.components.HasPresentations)3 AbstractSearchFolder (com.haulmont.cuba.core.entity.AbstractSearchFolder)1 AppFolder (com.haulmont.cuba.core.entity.AppFolder)1 HasSettings (com.haulmont.cuba.gui.components.HasSettings)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.widgets.CubaMenuBar)1 Document (org.dom4j.Document)1