Search in sources :

Example 1 with AccessDeniedException

use of com.haulmont.cuba.core.global.AccessDeniedException in project cuba by cuba-platform.

the class FileBrowser method init.

@Override
public void init(Map<String, Object> params) {
    super.init(params);
    filesTable.addAction(new ItemTrackingAction("download").withCaption(getMessage("download")).withHandler(event -> {
        FileDescriptor fileDescriptor = filesTable.getSingleSelected();
        if (fileDescriptor != null) {
            exportDisplay.show(fileDescriptor, null);
        }
    }));
    BaseAction multiUploadAction = new BaseAction("multiupload").withCaption(getMessage("multiupload")).withHandler(event -> {
        if (!security.isEntityOpPermitted(FileDescriptor.class, EntityOp.READ)) {
            throw new AccessDeniedException(PermissionType.ENTITY_OP, FileDescriptor.class.getSimpleName());
        }
        Window window = openWindow("multiuploadDialog", OpenType.DIALOG);
        window.addCloseListener(actionId -> {
            if (COMMIT_ACTION_ID.equals(actionId)) {
                Collection<FileDescriptor> items = ((MultiUploader) window).getFiles();
                for (FileDescriptor fdesc : items) {
                    boolean modified = filesDs.isModified();
                    filesDs.addItem(fdesc);
                    ((DatasourceImplementation) filesDs).setModified(modified);
                }
                filesTable.requestFocus();
            }
        });
    });
    multiUploadAction.setEnabled(security.isEntityOpPermitted(FileDescriptor.class, EntityOp.CREATE));
    multiUploadBtn.setAction(multiUploadAction);
}
Also used : Security(com.haulmont.cuba.core.global.Security) Table(com.haulmont.cuba.gui.components.Table) Collection(java.util.Collection) Button(com.haulmont.cuba.gui.components.Button) ExportDisplay(com.haulmont.cuba.gui.export.ExportDisplay) PermissionType(com.haulmont.cuba.security.entity.PermissionType) UUID(java.util.UUID) FileDescriptor(com.haulmont.cuba.core.entity.FileDescriptor) DatasourceImplementation(com.haulmont.cuba.gui.data.impl.DatasourceImplementation) Inject(javax.inject.Inject) AbstractLookup(com.haulmont.cuba.gui.components.AbstractLookup) EntityOp(com.haulmont.cuba.security.entity.EntityOp) Window(com.haulmont.cuba.gui.components.Window) Map(java.util.Map) BaseAction(com.haulmont.cuba.gui.components.actions.BaseAction) AccessDeniedException(com.haulmont.cuba.core.global.AccessDeniedException) ItemTrackingAction(com.haulmont.cuba.gui.components.actions.ItemTrackingAction) CollectionDatasource(com.haulmont.cuba.gui.data.CollectionDatasource) OpenType(com.haulmont.cuba.gui.WindowManager.OpenType) Window(com.haulmont.cuba.gui.components.Window) AccessDeniedException(com.haulmont.cuba.core.global.AccessDeniedException) ItemTrackingAction(com.haulmont.cuba.gui.components.actions.ItemTrackingAction) BaseAction(com.haulmont.cuba.gui.components.actions.BaseAction) DatasourceImplementation(com.haulmont.cuba.gui.data.impl.DatasourceImplementation) FileDescriptor(com.haulmont.cuba.core.entity.FileDescriptor)

Aggregations

FileDescriptor (com.haulmont.cuba.core.entity.FileDescriptor)1 AccessDeniedException (com.haulmont.cuba.core.global.AccessDeniedException)1 Security (com.haulmont.cuba.core.global.Security)1 OpenType (com.haulmont.cuba.gui.WindowManager.OpenType)1 AbstractLookup (com.haulmont.cuba.gui.components.AbstractLookup)1 Button (com.haulmont.cuba.gui.components.Button)1 Table (com.haulmont.cuba.gui.components.Table)1 Window (com.haulmont.cuba.gui.components.Window)1 BaseAction (com.haulmont.cuba.gui.components.actions.BaseAction)1 ItemTrackingAction (com.haulmont.cuba.gui.components.actions.ItemTrackingAction)1 CollectionDatasource (com.haulmont.cuba.gui.data.CollectionDatasource)1 DatasourceImplementation (com.haulmont.cuba.gui.data.impl.DatasourceImplementation)1 ExportDisplay (com.haulmont.cuba.gui.export.ExportDisplay)1 EntityOp (com.haulmont.cuba.security.entity.EntityOp)1 PermissionType (com.haulmont.cuba.security.entity.PermissionType)1 Collection (java.util.Collection)1 Map (java.util.Map)1 UUID (java.util.UUID)1 Inject (javax.inject.Inject)1