Search in sources :

Example 1 with UIRepositoryContent

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

the class Spoon method exploreRepository.

public void exploreRepository() {
    if (rep != null) {
        final RepositoryExplorerCallback cb = new RepositoryExplorerCallback() {

            @Override
            public boolean open(UIRepositoryContent element, String revision) throws Exception {
                String objName = element.getName();
                if (objName != null) {
                    RepositoryObjectType objectType = element.getRepositoryElementType();
                    RepositoryDirectory repDir = element.getRepositoryDirectory();
                    if (element.getObjectId() != null) {
                        // new way
                        loadObjectFromRepository(element.getObjectId(), objectType, revision);
                    } else {
                        // old way
                        loadObjectFromRepository(objName, objectType, repDir, revision);
                    }
                }
                // do not close explorer
                return false;
            }

            @Override
            public boolean error(String message) throws Exception {
                closeRepository();
                return true;
            }
        };
        try {
            final KettleWaitBox box = (KettleWaitBox) this.mainSpoonContainer.getDocumentRoot().createElement("iconwaitbox");
            box.setIndeterminate(true);
            box.setCanCancel(false);
            box.setIcon("ui/images/kettle_logo_small.svg");
            box.setTitle(BaseMessages.getString(RepositoryDialogInterface.class, "RepositoryExplorerDialog.Connection.Wait.Title"));
            box.setMessage(BaseMessages.getString(RepositoryDialogInterface.class, "RepositoryExplorerDialog.Explorer.Wait.Message"));
            box.setDialogParent(shell);
            box.setRunnable(new WaitBoxRunnable(box) {

                @Override
                public void run() {
                    shell.getDisplay().syncExec(new Runnable() {

                        @Override
                        public void run() {
                            RepositoryExplorer explorer;
                            try {
                                try {
                                    explorer = new RepositoryExplorer(shell, rep, cb, Variables.getADefaultVariableSpace(), sharedObjectSyncUtil);
                                } catch (final KettleRepositoryLostException krle) {
                                    handleRepositoryLost(krle);
                                    closeRepository();
                                    return;
                                } finally {
                                    box.stop();
                                }
                                if (explorer.isInitialized()) {
                                    explorer.show();
                                } else {
                                    return;
                                }
                                explorer.dispose();
                            } catch (final Throwable e) {
                                shell.getDisplay().asyncExec(new Runnable() {

                                    @Override
                                    public void run() {
                                        new ErrorDialog(shell, BaseMessages.getString(PKG, "Spoon.Error"), e.getMessage(), e);
                                    }
                                });
                            }
                        }
                    });
                }

                @Override
                public void cancel() {
                }
            });
            box.start();
        } catch (Throwable e) {
            new ErrorDialog(shell, BaseMessages.getString(PKG, "Spoon.Error"), e.getMessage(), e);
        }
    }
}
Also used : RepositoryExplorer(org.pentaho.di.ui.repository.repositoryexplorer.RepositoryExplorer) RepositoryDirectory(org.pentaho.di.repository.RepositoryDirectory) UIRepositoryContent(org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryContent) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) RepositoryExplorerCallback(org.pentaho.di.ui.repository.repositoryexplorer.RepositoryExplorerCallback) KettleRepositoryLostException(org.pentaho.di.repository.KettleRepositoryLostException) WaitBoxRunnable(org.pentaho.ui.xul.components.WaitBoxRunnable) WaitBoxRunnable(org.pentaho.ui.xul.components.WaitBoxRunnable) RepositoryObjectType(org.pentaho.di.repository.RepositoryObjectType) RepositoryDialogInterface(org.pentaho.di.ui.repository.dialog.RepositoryDialogInterface) KettleWaitBox(org.pentaho.di.ui.xul.KettleWaitBox)

Example 2 with UIRepositoryContent

use of org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryContent 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 3 with UIRepositoryContent

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

the class RepositoryLockController method viewLockNote.

public void viewLockNote() throws Exception {
    List<UIRepositoryObject> selectedRepoObjects = browseController.getSelectedFileItems();
    if (selectedRepoObjects.size() > 0 && selectedRepoObjects.get(0) instanceof UIRepositoryContent) {
        final UIRepositoryContent contentToLock = (UIRepositoryContent) selectedRepoObjects.get(0);
        // $NON-NLS-1$
        XulMessageBox msgBox = (XulMessageBox) document.createElement("messagebox");
        // $NON-NLS-1$
        msgBox.setTitle(BaseMessages.getString(PKG, "PurRepository.LockNote.Title"));
        msgBox.setMessage(((ILockObject) contentToLock).getLockMessage());
        msgBox.open();
    }
}
Also used : UIRepositoryObject(org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryObject) XulMessageBox(org.pentaho.ui.xul.components.XulMessageBox) UIRepositoryContent(org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryContent)

Example 4 with UIRepositoryContent

use of org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryContent 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 5 with UIRepositoryContent

use of org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryContent 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)

Aggregations

UIRepositoryContent (org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryContent)12 UIRepositoryObject (org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryObject)8 KettleException (org.pentaho.di.core.exception.KettleException)7 ControllerInitializationException (org.pentaho.di.ui.repository.repositoryexplorer.ControllerInitializationException)6 XulException (org.pentaho.ui.xul.XulException)6 ILockObject (org.pentaho.di.ui.repository.pur.repositoryexplorer.ILockObject)5 UIRepositoryDirectory (org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryDirectory)5 ArrayList (java.util.ArrayList)3 List (java.util.List)2 IRevisionObject (org.pentaho.di.ui.repository.pur.repositoryexplorer.IRevisionObject)2 UIRepositoryObjectRevision (org.pentaho.di.ui.repository.pur.repositoryexplorer.model.UIRepositoryObjectRevision)2 RepositoryExplorerCallback (org.pentaho.di.ui.repository.repositoryexplorer.RepositoryExplorerCallback)2 XulComponent (org.pentaho.ui.xul.XulComponent)2 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)1 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)1 KettleRepositoryLostException (org.pentaho.di.repository.KettleRepositoryLostException)1 RepositoryDirectory (org.pentaho.di.repository.RepositoryDirectory)1 RepositoryObjectType (org.pentaho.di.repository.RepositoryObjectType)1 UserInfo (org.pentaho.di.repository.UserInfo)1 KettleDatabaseRepository (org.pentaho.di.repository.kdr.KettleDatabaseRepository)1