Search in sources :

Example 1 with TablePresentations

use of io.jmix.ui.presentation.TablePresentations in project jmix by jmix-framework.

the class PresentationEditor method commit.

protected void commit() {
    TablePresentations presentations = component.getPresentations();
    String stringSettings = getStringSettings();
    presentation.setSettings(stringSettings);
    presentation.setName(nameField.getValue());
    presentation.setAutoSave(autoSaveField.getValue());
    presentation.setIsDefault(defaultField.getValue());
    UserDetails user = currentUserSubstitution.getEffectiveUser();
    boolean userOnly = !allowGlobalPresentations || !BooleanUtils.isTrue(globalField.getValue());
    presentation.setUsername(userOnly ? user.getUsername() : null);
    if (log.isTraceEnabled()) {
        log.trace(String.format("Presentation: %s", stringSettings));
    }
    if (isNew) {
        presentations.add(presentation);
    } else {
        presentations.modify(presentation);
    }
    presentations.commit();
    addCloseListener(e -> {
        if (isNew) {
            component.applyPresentation(EntityValues.<UUID>getId(presentation));
        }
    });
}
Also used : UserDetails(org.springframework.security.core.userdetails.UserDetails) TablePresentations(io.jmix.ui.presentation.TablePresentations) HasTablePresentations(io.jmix.ui.component.HasTablePresentations)

Example 2 with TablePresentations

use of io.jmix.ui.presentation.TablePresentations in project jmix by jmix-framework.

the class PresentationEditor method validate.

protected boolean validate() {
    TablePresentations presentations = component.getPresentations();
    // check that name is empty
    if (StringUtils.isEmpty(nameField.getValue()) && AppUI.getCurrent() != null) {
        AppUI.getCurrent().getNotifications().create(Notifications.NotificationType.HUMANIZED).withCaption(messages.getMessage("PresentationsEditor.error")).withDescription(messages.getMessage("PresentationsEditor.error.nameRequired")).show();
        return false;
    }
    // check that name is unique
    final TablePresentation pres = presentations.getPresentationByName(nameField.getValue());
    if (pres != null && !pres.equals(presentation) && AppUI.getCurrent() != null) {
        AppUI.getCurrent().getNotifications().create(Notifications.NotificationType.HUMANIZED).withCaption(messages.getMessage("PresentationsEditor.error")).withDescription(messages.getMessage("PresentationsEditor.error.nameAlreadyExists")).show();
        return false;
    }
    return true;
}
Also used : TablePresentation(io.jmix.ui.presentation.model.TablePresentation) TablePresentations(io.jmix.ui.presentation.TablePresentations) HasTablePresentations(io.jmix.ui.component.HasTablePresentations)

Example 3 with TablePresentations

use of io.jmix.ui.presentation.TablePresentations in project jmix by jmix-framework.

the class DeletePresentationAction method actionPerform.

@Override
public void actionPerform(Component component) {
    tableImpl.hidePresentationsPopup();
    TablePresentations presentations = table.getPresentations();
    TablePresentation current = presentations.getCurrent();
    presentations.remove(current);
    presentations.commit();
}
Also used : TablePresentation(io.jmix.ui.presentation.model.TablePresentation) TablePresentations(io.jmix.ui.presentation.TablePresentations)

Example 4 with TablePresentations

use of io.jmix.ui.presentation.TablePresentations in project jmix by jmix-framework.

the class EditPresentationAction method actionPerform.

@Override
public void actionPerform(Component component) {
    tableImpl.hidePresentationsPopup();
    TablePresentations presentations = table.getPresentations();
    TablePresentation current = presentations.getCurrent();
    openEditor(current);
}
Also used : TablePresentation(io.jmix.ui.presentation.model.TablePresentation) TablePresentations(io.jmix.ui.presentation.TablePresentations)

Example 5 with TablePresentations

use of io.jmix.ui.presentation.TablePresentations in project jmix by jmix-framework.

the class WebTable method createTablePresentations.

@Override
protected TablePresentations createTablePresentations() {
    Presentations presentations = applicationContext.getBean(Presentations.class, this);
    presentationsDelegate = applicationContext.getBean(LegacyPresentationsDelegate.class, this, presentations, getSettingsBinder());
    return presentations;
}
Also used : LegacyPresentationsDelegate(com.haulmont.cuba.gui.presentation.LegacyPresentationsDelegate) Presentations(com.haulmont.cuba.gui.presentation.Presentations) TablePresentations(io.jmix.ui.presentation.TablePresentations)

Aggregations

TablePresentations (io.jmix.ui.presentation.TablePresentations)12 TablePresentation (io.jmix.ui.presentation.model.TablePresentation)5 Presentations (com.haulmont.cuba.gui.presentation.Presentations)4 LegacyPresentationsDelegate (com.haulmont.cuba.gui.presentation.LegacyPresentationsDelegate)3 HasTablePresentations (io.jmix.ui.component.HasTablePresentations)3 HasPresentations (com.haulmont.cuba.gui.components.HasPresentations)2 HasSettings (com.haulmont.cuba.gui.components.HasSettings)2 Element (org.dom4j.Element)2 AbstractSearchFolder (com.haulmont.cuba.core.entity.AbstractSearchFolder)1 SearchFolder (com.haulmont.cuba.security.entity.SearchFolder)1 CubaLegacySettings (com.haulmont.cuba.settings.CubaLegacySettings)1 UiGlobalPresentationContext (io.jmix.ui.accesscontext.UiGlobalPresentationContext)1 UserDetails (org.springframework.security.core.userdetails.UserDetails)1