Search in sources :

Example 6 with UIRepositoryObject

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

the class RepositoryLockController method lockContent.

public void lockContent() throws Exception {
    List<UIRepositoryObject> selectedRepoObjects = browseController.getSelectedFileItems();
    if (selectedRepoObjects.size() > 0 && selectedRepoObjects.get(0) instanceof UIRepositoryContent) {
        final UIRepositoryContent contentToLock = (UIRepositoryContent) selectedRepoObjects.get(0);
        if (((ILockObject) contentToLock).isLocked()) {
            // Unlock the item
            ((ILockObject) contentToLock).unlock();
            browseController.getSelectedItemsBinding().fireSourceChanged();
        } else {
            // Lock the item
            XulPromptBox lockNotePrompt = promptLockMessage(document, messages, null);
            lockNotePrompt.addDialogCallback(new XulDialogCallback<String>() {

                public void onClose(XulComponent component, Status status, String value) {
                    if (!status.equals(Status.CANCEL)) {
                        try {
                            ((ILockObject) contentToLock).lock(value);
                            browseController.getSelectedItemsBinding().fireSourceChanged();
                        } catch (Exception e) {
                            // convert to runtime exception so it bubbles up through the UI
                            throw new RuntimeException(e);
                        }
                    } else {
                        // $NON-NLS-1$
                        XulMenuitem lockMenuItem = (XulMenuitem) document.getElementById("lock-context-lock");
                        lockMenuItem.setSelected(false);
                        // $NON-NLS-1$
                        lockMenuItem = (XulMenuitem) document.getElementById("file-context-lock");
                        lockMenuItem.setSelected(false);
                    }
                }

                public void onError(XulComponent component, Throwable err) {
                    throw new RuntimeException(err);
                }
            });
            lockNotePrompt.open();
        }
    }
}
Also used : UIRepositoryContent(org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryContent) XulException(org.pentaho.ui.xul.XulException) KettleException(org.pentaho.di.core.exception.KettleException) ControllerInitializationException(org.pentaho.di.ui.repository.repositoryexplorer.ControllerInitializationException) UIRepositoryObject(org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryObject) XulMenuitem(org.pentaho.ui.xul.components.XulMenuitem) ILockObject(org.pentaho.di.ui.repository.pur.repositoryexplorer.ILockObject) XulPromptBox(org.pentaho.ui.xul.components.XulPromptBox) XulComponent(org.pentaho.ui.xul.XulComponent)

Example 7 with UIRepositoryObject

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

the class BrowseController method deleteContent.

public void deleteContent() throws Exception {
    for (Object object : fileTable.getSelectedItems()) {
        if (object instanceof UIRepositoryObject) {
            final UIRepositoryObject repoObject = (UIRepositoryObject) object;
            Callable<Void> deleteCallable = new Callable<Void>() {

                @Override
                public Void call() throws Exception {
                    deleteContent(repoObject);
                    return null;
                }
            };
            // otherwise we will end this method call
            if (repoObject instanceof UIRepositoryDirectory) {
                confirm("BrowseController.DeleteNonEmptyFolderWarningTitle", "BrowseController.DeleteFolderWarningMessage", deleteCallable);
            } else {
                confirm("BrowseController.DeleteFileWarningTitle", "BrowseController.DeleteFileWarningMessage", deleteCallable);
            }
        }
    }
}
Also used : UIRepositoryObject(org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryObject) UIRepositoryDirectory(org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryDirectory) UIRepositoryObject(org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryObject) Callable(java.util.concurrent.Callable)

Example 8 with UIRepositoryObject

use of org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryObject in project pdi-dataservice-server-plugin by pentaho.

the class DeleteRepositoryObjectExtensionPointPlugin method callExtensionPoint.

@Override
public void callExtensionPoint(LogChannelInterface log, Object object) throws KettleException {
    RepositoryExtension repositoryExtension = (RepositoryExtension) object;
    UIRepositoryObject repositoryObject = repositoryExtension.getRepositoryObject();
    // if a directory get all transformations recursively
    if (repositoryObject instanceof UIRepositoryDirectory) {
        List<UIRepositoryObject> transformationList = new ArrayList<UIRepositoryObject>();
        getAllTransformations((UIRepositoryDirectory) repositoryObject, transformationList);
        for (UIRepositoryObject uiRepositoryObject : transformationList) {
            Repository repository = uiRepositoryObject.getRepository();
            metaStoreUtil.clearReferences(repository.loadTransformation(uiRepositoryObject.getObjectId(), null));
        }
    } else if (repositoryObject.getRepositoryElementType().equals(RepositoryObjectType.TRANSFORMATION)) {
        Repository repository = repositoryObject.getRepository();
        metaStoreUtil.clearReferences(repository.loadTransformation(repositoryObject.getObjectId(), null));
    }
}
Also used : UIRepositoryObject(org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryObject) UIRepositoryDirectory(org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryDirectory) Repository(org.pentaho.di.repository.Repository) RepositoryExtension(org.pentaho.di.ui.repository.RepositoryExtension) ArrayList(java.util.ArrayList)

Example 9 with UIRepositoryObject

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

the class RepositoryLockController method repositoryDirectoryHasLockedObject.

private boolean repositoryDirectoryHasLockedObject(DropEvent event, UIRepositoryDirectory dir) throws KettleException {
    if (areAnyRepositoryObjectsLocked(event, dir.getRepositoryObjects())) {
        return true;
    }
    for (UIRepositoryObject ro : dir.getChildren()) {
        if (ro instanceof UIRepositoryDirectory) {
            UIRepositoryDirectory directory = (UIRepositoryDirectory) ro;
            repositoryDirectoryHasLockedObject(event, directory);
        }
    }
    return false;
}
Also used : UIRepositoryObject(org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryObject) UIRepositoryDirectory(org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryDirectory)

Example 10 with UIRepositoryObject

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

the class RepositoryLockController method areAnyRepositoryObjectsLocked.

private boolean areAnyRepositoryObjectsLocked(DropEvent event, UIRepositoryObjects repositoryObjects) throws KettleException {
    for (UIRepositoryObject ro : repositoryObjects) {
        if (ro instanceof ILockObject) {
            final UIRepositoryContent contentToLock = (UIRepositoryContent) ro;
            if (((ILockObject) contentToLock).isLocked()) {
                // Content is locked, move is not allowed.
                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.FolderMoveNotAllowed"));
                messageBox.open();
                return true;
            }
        }
    }
    return false;
}
Also used : UIRepositoryObject(org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryObject) ILockObject(org.pentaho.di.ui.repository.pur.repositoryexplorer.ILockObject) UIRepositoryContent(org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryContent)

Aggregations

UIRepositoryObject (org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryObject)16 KettleException (org.pentaho.di.core.exception.KettleException)8 ControllerInitializationException (org.pentaho.di.ui.repository.repositoryexplorer.ControllerInitializationException)8 UIRepositoryDirectory (org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryDirectory)8 ArrayList (java.util.ArrayList)7 UIRepositoryContent (org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryContent)7 XulException (org.pentaho.ui.xul.XulException)7 List (java.util.List)4 ILockObject (org.pentaho.di.ui.repository.pur.repositoryexplorer.ILockObject)4 XulComponent (org.pentaho.ui.xul.XulComponent)3 BindingConvertor (org.pentaho.ui.xul.binding.BindingConvertor)3 Repository (org.pentaho.di.repository.Repository)2 IAclObject (org.pentaho.di.ui.repository.pur.repositoryexplorer.IAclObject)2 IRevisionObject (org.pentaho.di.ui.repository.pur.repositoryexplorer.IRevisionObject)2 UIObjectCreationException (org.pentaho.di.ui.repository.repositoryexplorer.model.UIObjectCreationException)2 RepositoryFilePermission (org.pentaho.platform.api.repository2.unified.RepositoryFilePermission)2 XulMenuitem (org.pentaho.ui.xul.components.XulMenuitem)2 XulPromptBox (org.pentaho.ui.xul.components.XulPromptBox)2 PropertyChangeEvent (java.beans.PropertyChangeEvent)1 PropertyChangeListener (java.beans.PropertyChangeListener)1