Search in sources :

Example 1 with UIRepositoryDirectory

use of org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryDirectory in project pentaho-kettle by pentaho.

the class PermissionsController method applyOnObjectOnly.

/**
 * applyOnObjectOnly is called to save acl for a file object only
 *
 * @param roList
 * @param hideDialog
 */
private void applyOnObjectOnly(List<UIRepositoryObject> roList, boolean hideDialog) {
    try {
        if (roList.get(0) instanceof UIRepositoryDirectory) {
            UIRepositoryDirectory rd = (UIRepositoryDirectory) roList.get(0);
            if (rd instanceof IAclObject) {
                ((IAclObject) rd).setAcls(viewAclsModel);
            } else {
                // $NON-NLS-1$
                throw new IllegalStateException(BaseMessages.getString(PKG, "PermissionsController.NoAclSupport"));
            }
        } else {
            UIRepositoryContent rc = (UIRepositoryContent) roList.get(0);
            if (rc instanceof ILockObject && ((ILockObject) rc).isLocked()) {
                // $NON-NLS-1$
                messageBox.setTitle(BaseMessages.getString(PKG, "Dialog.Error"));
                // $NON-NLS-1$
                messageBox.setAcceptLabel(BaseMessages.getString(PKG, "Dialog.Ok"));
                // $NON-NLS-1$
                messageBox.setMessage(BaseMessages.getString(PKG, "PermissionsController.LockedObjectWarning"));
                messageBox.open();
                viewAclsModel.setModelDirty(false);
                return;
            } else if (rc instanceof IAclObject) {
                ((IAclObject) rc).setAcls(viewAclsModel);
            } else {
                // $NON-NLS-1$
                throw new IllegalStateException(BaseMessages.getString(PKG, "PermissionsController.NoAclSupport"));
            }
        }
        /*
       * if (hideDialog) { applyAclConfirmationDialog.hide(); }
       */
        viewAclsModel.setModelDirty(false);
        // $NON-NLS-1$
        messageBox.setTitle(BaseMessages.getString(PKG, "Dialog.Success"));
        // $NON-NLS-1$
        messageBox.setAcceptLabel(BaseMessages.getString(PKG, "Dialog.Ok"));
        // $NON-NLS-1$
        messageBox.setMessage(BaseMessages.getString(PKG, "PermissionsController.PermissionAppliedSuccessfully"));
        messageBox.open();
    } catch (AccessDeniedException ade) {
        /*
       * if (hideDialog) { applyAclConfirmationDialog.hide(); }
       */
        if (mainController == null || !mainController.handleLostRepository(ade)) {
            // $NON-NLS-1$
            messageBox.setTitle(BaseMessages.getString(PKG, "Dialog.Error"));
            // $NON-NLS-1$
            messageBox.setAcceptLabel(BaseMessages.getString(PKG, "Dialog.Ok"));
            messageBox.setMessage(ade.getLocalizedMessage());
            messageBox.open();
        }
    } catch (KettleException kex) {
        if (mainController == null || !mainController.handleLostRepository(kex)) {
            // $NON-NLS-1$
            messageBox.setTitle(BaseMessages.getString(PKG, "Dialog.Error"));
            // $NON-NLS-1$
            messageBox.setAcceptLabel(BaseMessages.getString(PKG, "Dialog.Ok"));
            messageBox.setMessage(kex.getLocalizedMessage());
            messageBox.open();
        }
    }
}
Also used : UIRepositoryDirectory(org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryDirectory) KettleException(org.pentaho.di.core.exception.KettleException) AccessDeniedException(org.pentaho.di.ui.repository.repositoryexplorer.AccessDeniedException) ILockObject(org.pentaho.di.ui.repository.pur.repositoryexplorer.ILockObject) UIRepositoryContent(org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryContent) IAclObject(org.pentaho.di.ui.repository.pur.repositoryexplorer.IAclObject)

Example 2 with UIRepositoryDirectory

use of org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryDirectory in project pentaho-kettle by pentaho.

the class RepositoryLockController method onDragFromLocalTable.

// Object being dragged from the file listing table
public void onDragFromLocalTable(DropEvent event) {
    try {
        Collection<Object> selectedRepoObjects = fileTable.getSelectedItems();
        if (selectedRepoObjects.size() > 0) {
            for (Object ro : selectedRepoObjects) {
                if (ro instanceof UIRepositoryObject && ro instanceof ILockObject) {
                    final UIRepositoryContent contentToLock = (UIRepositoryContent) ro;
                    if (((ILockObject) contentToLock).isLocked()) {
                        // Content is locked, not allowed to move
                        event.setAccepted(false);
                        // $NON-NLS-1$
                        messageBox.setTitle(BaseMessages.getString(PKG, "Dialog.Error"));
                        // $NON-NLS-1$
                        messageBox.setAcceptLabel(BaseMessages.getString(PKG, "Dialog.Ok"));
                        // $NON-NLS-1$
                        messageBox.setMessage(BaseMessages.getString(PKG, "BrowseController.MoveNotAllowed"));
                        messageBox.open();
                        break;
                    } else {
                        // Content is not locked, check default permissions
                        browseController.onDragFromLocalTable(event);
                    }
                } else if (ro instanceof UIRepositoryDirectory && repositoryDirectoryHasLockedObject(event, (UIRepositoryDirectory) ro)) {
                    // locked content nested in this directory. move not allowed.
                    event.setAccepted(false);
                    break;
                }
            }
        }
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : UIRepositoryObject(org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryObject) UIRepositoryDirectory(org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryDirectory) ILockObject(org.pentaho.di.ui.repository.pur.repositoryexplorer.ILockObject) UIRepositoryContent(org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryContent) ILockObject(org.pentaho.di.ui.repository.pur.repositoryexplorer.ILockObject) UIRepositoryObject(org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryObject) XulException(org.pentaho.ui.xul.XulException) KettleException(org.pentaho.di.core.exception.KettleException) ControllerInitializationException(org.pentaho.di.ui.repository.repositoryexplorer.ControllerInitializationException)

Example 3 with UIRepositoryDirectory

use of org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryDirectory in project pentaho-kettle by pentaho.

the class BrowseController method renameFolder.

public void renameFolder() throws Exception {
    try {
        Collection<UIRepositoryDirectory> directory = folderTree.getSelectedItems();
        final UIRepositoryDirectory toRename = directory.iterator().next();
        renameRepositoryObject(toRename);
        directoryBinding.fireSourceChanged();
        selectedItemsBinding.fireSourceChanged();
    } catch (Throwable th) {
        if (mainController == null || !mainController.handleLostRepository(th)) {
            messageBox.setTitle(BaseMessages.getString(PKG, "Dialog.Error"));
            messageBox.setAcceptLabel(BaseMessages.getString(PKG, "Dialog.Ok"));
            messageBox.setMessage(BaseMessages.getString(PKG, th.getLocalizedMessage()));
            messageBox.open();
        }
    }
}
Also used : UIRepositoryDirectory(org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryDirectory)

Example 4 with UIRepositoryDirectory

use of org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryDirectory in project pentaho-kettle by pentaho.

the class BrowseController method createFolder.

public void createFolder() throws Exception {
    try {
        Collection<UIRepositoryDirectory> directories = folderTree.getSelectedItems();
        if (directories == null || directories.size() == 0) {
            return;
        }
        UIRepositoryDirectory selectedFolder = directories.iterator().next();
        // First, ask for a name for the folder
        XulPromptBox prompt = promptForName(null);
        prompt.addDialogCallback(new XulDialogCallback<String>() {

            public void onClose(XulComponent component, Status status, String value) {
                if (status == Status.ACCEPT) {
                    newName = value;
                } else {
                    newName = null;
                }
            }

            public void onError(XulComponent component, Throwable err) {
                throw new RuntimeException(err);
            }
        });
        prompt.open();
        if (newName != null) {
            if (selectedFolder == null) {
                selectedFolder = repositoryDirectory;
            }
            // Do an explicit check here to see if the folder already exists in the ui
            // This is to prevent a double message being sent in case the folder does
            // not exist in the ui but does exist in the repo (PDI-5202)
            boolean folderExistsInUI = selectedFolder.contains(newName);
            if (folderExistsInUI) {
                throw new Exception(BaseMessages.getString(PKG, "BrowserController.DirAlreadyExistsInUI", newName));
            }
            // PDI-5202
            String newNameInRepo = selectedFolder.checkDirNameExistsInRepo(newName);
            if (newNameInRepo != null) {
                messageBox.setTitle(BaseMessages.getString(PKG, "Dialog.Warning"));
                messageBox.setAcceptLabel(BaseMessages.getString(PKG, "Dialog.Ok"));
                messageBox.setMessage(BaseMessages.getString(PKG, "BrowserController.DirAlreadyExistsInRepository", newNameInRepo));
                messageBox.open();
                newName = newNameInRepo;
            }
            UIRepositoryDirectory newDir = selectedFolder.createFolder(newName);
            dirMap.put(newDir.getObjectId(), newDir);
            directoryBinding.fireSourceChanged();
            selectedItemsBinding.fireSourceChanged();
            this.folderTree.setSelectedItems(Collections.singletonList(selectedFolder));
        }
        newName = null;
    } catch (Exception e) {
        if (mainController == null || !mainController.handleLostRepository(e)) {
            confirm(BaseMessages.getString(PKG, "Dialog.Error"), e.getLocalizedMessage());
        }
    }
}
Also used : UIRepositoryDirectory(org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryDirectory) XulPromptBox(org.pentaho.ui.xul.components.XulPromptBox) XulComponent(org.pentaho.ui.xul.XulComponent) XulException(org.pentaho.ui.xul.XulException) ControllerInitializationException(org.pentaho.di.ui.repository.repositoryexplorer.ControllerInitializationException) UIObjectCreationException(org.pentaho.di.ui.repository.repositoryexplorer.model.UIObjectCreationException) KettleException(org.pentaho.di.core.exception.KettleException)

Example 5 with UIRepositoryDirectory

use of org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryDirectory in project pentaho-kettle by pentaho.

the class BrowseController method deleteFolder.

public void deleteFolder() throws Exception {
    UIRepositoryDirectory newSelectedItem = null;
    for (Object object : folderTree.getSelectedItems()) {
        if (object instanceof UIRepositoryDirectory) {
            repoDir = (UIRepositoryDirectory) object;
            newSelectedItem = repoDir.getParent();
            confirm("BrowseController.DeleteNonEmptyFolderWarningTitle", "BrowseController.DeleteFolderWarningMessage", () -> {
                deleteFolder(repoDir);
                return null;
            });
            break;
        } else {
            deleteFolder(repoDir);
        }
    }
    // since old selected item is the now deleted one, set the parent as the selected item
    if (newSelectedItem != null) {
        folderTree.setSelectedItems(Arrays.asList(newSelectedItem));
    }
}
Also used : UIRepositoryDirectory(org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryDirectory) UIRepositoryObject(org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryObject)

Aggregations

UIRepositoryDirectory (org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryDirectory)16 UIRepositoryObject (org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryObject)10 KettleException (org.pentaho.di.core.exception.KettleException)9 ControllerInitializationException (org.pentaho.di.ui.repository.repositoryexplorer.ControllerInitializationException)7 XulException (org.pentaho.ui.xul.XulException)7 ArrayList (java.util.ArrayList)5 UIObjectCreationException (org.pentaho.di.ui.repository.repositoryexplorer.model.UIObjectCreationException)5 UIRepositoryContent (org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryContent)5 List (java.util.List)2 RepositoryDirectoryInterface (org.pentaho.di.repository.RepositoryDirectoryInterface)2 ILockObject (org.pentaho.di.ui.repository.pur.repositoryexplorer.ILockObject)2 Binding (org.pentaho.ui.xul.binding.Binding)2 BindingConvertor (org.pentaho.ui.xul.binding.BindingConvertor)2 PropertyChangeEvent (java.beans.PropertyChangeEvent)1 PropertyChangeListener (java.beans.PropertyChangeListener)1 Callable (java.util.concurrent.Callable)1 Point (org.eclipse.swt.graphics.Point)1 Shell (org.eclipse.swt.widgets.Shell)1 Before (org.junit.Before)1 ObjectId (org.pentaho.di.repository.ObjectId)1