Search in sources :

Example 1 with SpoonMenuABSController

use of org.pentaho.di.ui.repository.pur.repositoryexplorer.abs.controller.SpoonMenuABSController in project pentaho-kettle by pentaho.

the class EESpoonPlugin method applyToContainer.

public void applyToContainer(String category, XulDomContainer container) throws XulException {
    container.registerClassLoader(getClass().getClassLoader());
    if (category.equals("spoon")) {
        // $NON-NLS-1$
        // register the two controllers, note that the lock controller must come
        // after the abs controller so the biz logic between the two hold.
        // Register the ABS Menu controller
        getSpoonInstance().addSpoonMenuController(new SpoonMenuABSController());
        // Register the SpoonMenuLockController to modify the main Spoon Menu structure
        getSpoonInstance().addSpoonMenuController(new SpoonMenuLockController());
    } else if (category.equals("trans-graph") || category.equals("job-graph")) {
        // $NON-NLS-1$ //$NON-NLS-2$
        if ((getSpoonInstance() != null) && (getSpoonInstance().getRepository() != null) && (getSpoonInstance().getRepository() instanceof PurRepository)) {
            // $NON-NLS-1$
            container.getDocumentRoot().addOverlay("org/pentaho/di/ui/repository/pur/xul/spoon-lock-overlay.xul");
            container.addEventHandler(new SpoonLockController());
        }
        try {
            Repository repository = getSpoonInstance().getRepository();
            if (repository != null) {
                IAbsSecurityProvider securityProvider = (IAbsSecurityProvider) repository.getService(IAbsSecurityProvider.class);
                if (securityProvider != null) {
                    enablePermission(securityProvider);
                }
            }
        } catch (KettleException e) {
            e.printStackTrace();
        }
    } else if (category.equals("repository-explorer")) {
        // $NON-NLS-1$
        try {
            Repository repository = getSpoonInstance().getRepository();
            IAbsSecurityProvider securityProvider = null;
            if (repository != null) {
                securityProvider = (IAbsSecurityProvider) repository.getService(IAbsSecurityProvider.class);
            }
            if (securityProvider != null) {
                boolean createPermitted = securityProvider.isAllowed(IAbsSecurityProvider.CREATE_CONTENT_ACTION);
                boolean executePermitted = securityProvider.isAllowed(IAbsSecurityProvider.EXECUTE_CONTENT_ACTION);
                // Disable export if user can not create or execute content (prevents execution outside of this repo)
                container.getDocumentRoot().getElementById("folder-context-export").setDisabled(!createPermitted || !executePermitted);
            }
        } catch (KettleException e) {
            e.printStackTrace();
        }
    }
}
Also used : IAbsSecurityProvider(org.pentaho.di.ui.repository.pur.services.IAbsSecurityProvider) SpoonMenuLockController(org.pentaho.di.ui.repository.pur.controller.SpoonMenuLockController) KettleException(org.pentaho.di.core.exception.KettleException) PurRepository(org.pentaho.di.repository.pur.PurRepository) Repository(org.pentaho.di.repository.Repository) PurRepository(org.pentaho.di.repository.pur.PurRepository) SpoonLockController(org.pentaho.di.ui.repository.pur.controller.SpoonLockController) SpoonMenuABSController(org.pentaho.di.ui.repository.pur.repositoryexplorer.abs.controller.SpoonMenuABSController)

Aggregations

KettleException (org.pentaho.di.core.exception.KettleException)1 Repository (org.pentaho.di.repository.Repository)1 PurRepository (org.pentaho.di.repository.pur.PurRepository)1 SpoonLockController (org.pentaho.di.ui.repository.pur.controller.SpoonLockController)1 SpoonMenuLockController (org.pentaho.di.ui.repository.pur.controller.SpoonMenuLockController)1 SpoonMenuABSController (org.pentaho.di.ui.repository.pur.repositoryexplorer.abs.controller.SpoonMenuABSController)1 IAbsSecurityProvider (org.pentaho.di.ui.repository.pur.services.IAbsSecurityProvider)1