Search in sources :

Example 6 with EntityDataUnit

use of io.jmix.ui.component.data.meta.EntityDataUnit in project jmix by jmix-framework.

the class ViewAction method isPermitted.

@Override
protected boolean isPermitted() {
    if (target == null || !(target.getItems() instanceof EntityDataUnit)) {
        return false;
    }
    MetaClass metaClass = ((EntityDataUnit) target.getItems()).getEntityMetaClass();
    if (metaClass == null) {
        return true;
    }
    UiEntityContext entityContext = new UiEntityContext(metaClass);
    accessManager.applyRegisteredConstraints(entityContext);
    if (!entityContext.isViewPermitted()) {
        return false;
    }
    return super.isPermitted();
}
Also used : UiEntityContext(io.jmix.ui.accesscontext.UiEntityContext) MetaClass(io.jmix.core.metamodel.model.MetaClass) EntityDataUnit(io.jmix.ui.component.data.meta.EntityDataUnit)

Example 7 with EntityDataUnit

use of io.jmix.ui.component.data.meta.EntityDataUnit in project jmix by jmix-framework.

the class AddToSetAction method actionPerform.

@Override
public void actionPerform(Component component) {
    MetaClass entityMetaClass;
    if (target.getItems() instanceof EntityDataUnit) {
        entityMetaClass = ((EntityDataUnit) target.getItems()).getEntityMetaClass();
    } else {
        throw new UnsupportedOperationException("Unsupported data unit " + target.getItems());
    }
    String query;
    if (filter.getDatasource() != null) {
        query = filter.getDatasource().getQuery();
    } else {
        query = filter.getDataLoader().getQuery();
    }
    String[] strings = ValuePathHelper.parse(CubaComponentsHelper.getFilterComponentPath(filter));
    String componentId = ValuePathHelper.pathSuffix(strings);
    Set ownerSelection = target.getSelected();
    Map<String, Object> params = new HashMap<>();
    params.put("entityType", entityMetaClass.getName());
    params.put("items", ownerSelection);
    params.put("componentPath", CubaComponentsHelper.getFilterComponentPath(filter));
    params.put("componentId", componentId);
    params.put("foldersPane", filterHelper.getFoldersPane());
    params.put("entityClass", entityMetaClass.getJavaClass().getName());
    params.put("query", query);
    params.put("username", userSessionSource.getUserSession().getUser().getUsername());
    Screens screens = ComponentsHelper.getScreenContext(filter).getScreens();
    screens.create("saveSetInFolder", OpenMode.DIALOG, new MapScreenOptions(params)).show();
}
Also used : Set(java.util.Set) MetaClass(io.jmix.core.metamodel.model.MetaClass) HashMap(java.util.HashMap) EntityDataUnit(io.jmix.ui.component.data.meta.EntityDataUnit) MapScreenOptions(io.jmix.ui.screen.MapScreenOptions) Screens(io.jmix.ui.Screens)

Example 8 with EntityDataUnit

use of io.jmix.ui.component.data.meta.EntityDataUnit in project jmix by jmix-framework.

the class AbstractDataGrid method setupPaginationDataSourceProvider.

public void setupPaginationDataSourceProvider() {
    if (pagination == null) {
        return;
    }
    DataUnit items = getItems();
    PaginationDataBinder provider;
    if (items instanceof ContainerDataUnit) {
        provider = applicationContext.getBean(PaginationDataUnitBinder.class, items);
    } else if (items instanceof EmptyDataUnit && items instanceof EntityDataUnit) {
        provider = new PaginationEmptyBinder(((EntityDataUnit) items).getEntityMetaClass());
    } else {
        throw new IllegalStateException("Unsupported data unit type: " + items);
    }
    pagination.setDataBinder(provider);
}
Also used : PaginationDataUnitBinder(io.jmix.ui.component.pagination.data.PaginationDataUnitBinder) PaginationEmptyBinder(io.jmix.ui.component.pagination.data.PaginationEmptyBinder) EmptyDataUnit(io.jmix.ui.component.data.meta.EmptyDataUnit) DataUnit(io.jmix.ui.component.data.DataUnit) EntityDataUnit(io.jmix.ui.component.data.meta.EntityDataUnit) ContainerDataUnit(io.jmix.ui.component.data.meta.ContainerDataUnit) EmptyDataUnit(io.jmix.ui.component.data.meta.EmptyDataUnit) PaginationDataBinder(io.jmix.ui.component.pagination.data.PaginationDataBinder) ContainerDataUnit(io.jmix.ui.component.data.meta.ContainerDataUnit) EntityDataUnit(io.jmix.ui.component.data.meta.EntityDataUnit)

Example 9 with EntityDataUnit

use of io.jmix.ui.component.data.meta.EntityDataUnit in project jmix by jmix-framework.

the class ChangePasswordAction method isPermitted.

@Override
protected boolean isPermitted() {
    if (target == null || !(target.getItems() instanceof EntityDataUnit)) {
        return false;
    }
    MetaClass metaClass = ((EntityDataUnit) target.getItems()).getEntityMetaClass();
    if (metaClass == null) {
        return true;
    }
    UiEntityContext entityContext = new UiEntityContext(metaClass);
    accessManager.applyRegisteredConstraints(entityContext);
    if (!entityContext.isEditPermitted()) {
        return false;
    }
    return super.isPermitted();
}
Also used : UiEntityContext(io.jmix.ui.accesscontext.UiEntityContext) MetaClass(io.jmix.core.metamodel.model.MetaClass) EntityDataUnit(io.jmix.ui.component.data.meta.EntityDataUnit)

Example 10 with EntityDataUnit

use of io.jmix.ui.component.data.meta.EntityDataUnit in project jmix by jmix-framework.

the class ChangePasswordAction method execute.

/**
 * Executes the action.
 */
@Override
public void execute() {
    if (target == null) {
        throw new IllegalStateException("Target is not set");
    }
    if (!(target.getItems() instanceof EntityDataUnit)) {
        throw new IllegalStateException("Target dataSource is null or does not implement EntityDataUnit");
    }
    MetaClass metaClass = ((EntityDataUnit) target.getItems()).getEntityMetaClass();
    if (metaClass == null) {
        throw new IllegalStateException("Target is not bound to entity");
    }
    Object editedEntity = target.getSingleSelected();
    if (editedEntity == null) {
        throw new IllegalStateException("There is not selected item in ChangePassword target");
    }
    if (!(editedEntity instanceof UserDetails)) {
        throw new IllegalStateException("Target does not implement a UserDetails");
    }
    UserDetails user = (UserDetails) editedEntity;
    buildAndShowChangePasswordDialog(user);
}
Also used : UserDetails(org.springframework.security.core.userdetails.UserDetails) MetaClass(io.jmix.core.metamodel.model.MetaClass) EntityDataUnit(io.jmix.ui.component.data.meta.EntityDataUnit)

Aggregations

EntityDataUnit (io.jmix.ui.component.data.meta.EntityDataUnit)23 MetaClass (io.jmix.core.metamodel.model.MetaClass)19 UiEntityContext (io.jmix.ui.accesscontext.UiEntityContext)9 DataUnit (io.jmix.ui.component.data.DataUnit)5 EditorBuilder (io.jmix.ui.builder.EditorBuilder)3 InMemoryCrudEntityContext (io.jmix.core.accesscontext.InMemoryCrudEntityContext)2 ContainerDataUnit (io.jmix.ui.component.data.meta.ContainerDataUnit)2 EmptyDataUnit (io.jmix.ui.component.data.meta.EmptyDataUnit)2 PaginationDataBinder (io.jmix.ui.component.pagination.data.PaginationDataBinder)2 PaginationDataUnitBinder (io.jmix.ui.component.pagination.data.PaginationDataUnitBinder)2 PaginationEmptyBinder (io.jmix.ui.component.pagination.data.PaginationEmptyBinder)2 FrameOwner (io.jmix.ui.screen.FrameOwner)2 UserDetails (org.springframework.security.core.userdetails.UserDetails)2 UserSubstitutionEntity (io.jmix.securitydata.entity.UserSubstitutionEntity)1 Notifications (io.jmix.ui.Notifications)1 Screens (io.jmix.ui.Screens)1 UiBulkEditContext (io.jmix.ui.accesscontext.UiBulkEditContext)1 Component (io.jmix.ui.component.Component)1 Frame (io.jmix.ui.component.Frame)1 Window (io.jmix.ui.component.Window)1