Search in sources :

Example 1 with TablePresentation

use of io.jmix.ui.presentation.model.TablePresentation 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 2 with TablePresentation

use of io.jmix.ui.presentation.model.TablePresentation 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 3 with TablePresentation

use of io.jmix.ui.presentation.model.TablePresentation 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 4 with TablePresentation

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

the class SaveAsPresentationAction method actionPerform.

@Override
public void actionPerform(Component component) {
    tableImpl.hidePresentationsPopup();
    TablePresentation presentation = table.getPresentations().create();
    presentation.setComponentId(ComponentsHelper.getComponentPath(table));
    openEditor(presentation);
}
Also used : TablePresentation(io.jmix.ui.presentation.model.TablePresentation)

Example 5 with TablePresentation

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

the class TablePresentationsImpl method checkLoad.

protected void checkLoad() {
    if (presentations == null) {
        LoadContext<UiTablePresentation> ctx = new LoadContext<>(metadata.getClass(UiTablePresentation.class));
        ctx.setFetchPlan(fetchPlanRepository.getFetchPlan(UiTablePresentation.class, "app"));
        UserDetails user = currentUserSubstitution.getEffectiveUser();
        ctx.setQueryString("select p from ui_TablePresentation p " + "where p.componentId = :component and (p.username is null or p.username = :username)").setParameter("component", name).setParameter("username", user.getUsername());
        final List<UiTablePresentation> list = dataManager.loadList(ctx);
        presentations = new LinkedHashMap<>(list.size());
        for (final TablePresentation p : list) {
            presentations.put(EntityValues.<UUID>getId(p), p);
        }
    }
}
Also used : TablePresentation(io.jmix.ui.presentation.model.TablePresentation) UiTablePresentation(io.jmix.uidata.entity.UiTablePresentation) UserDetails(org.springframework.security.core.userdetails.UserDetails) UiTablePresentation(io.jmix.uidata.entity.UiTablePresentation)

Aggregations

TablePresentation (io.jmix.ui.presentation.model.TablePresentation)12 TablePresentations (io.jmix.ui.presentation.TablePresentations)5 UiTablePresentation (io.jmix.uidata.entity.UiTablePresentation)4 UiGlobalPresentationContext (io.jmix.ui.accesscontext.UiGlobalPresentationContext)1 HasTablePresentations (io.jmix.ui.component.HasTablePresentations)1 UserDetails (org.springframework.security.core.userdetails.UserDetails)1