Search in sources :

Example 36 with RepositoryDirectoryInterface

use of org.pentaho.di.repository.RepositoryDirectoryInterface in project pentaho-kettle by pentaho.

the class UIRepositoryDirectory method createFolder.

public UIRepositoryDirectory createFolder(String name) throws Exception {
    RepositoryDirectoryInterface thisDir = getDirectory();
    RepositoryDirectoryInterface dir;
    // PDI-5202: the directory might exist already. If so, don't create a new one.
    String dirName = checkDirNameExistsInRepo(name);
    if (dirName == null) {
        dir = rep.createRepositoryDirectory(thisDir, name);
    } else {
        dir = rep.findDirectory(thisDir.getPath() + "/" + dirName);
    }
    UIRepositoryDirectory newDir = null;
    try {
        newDir = UIObjectRegistry.getInstance().constructUIRepositoryDirectory(dir, this, rep);
    } catch (UIObjectCreationException uoe) {
        newDir = new UIRepositoryDirectory(dir, this, rep);
    }
    UIRepositoryDirectories directories = getChildren();
    if (!contains(directories, newDir)) {
        directories.add(newDir);
    } else {
        throw new KettleException("Unable to create folder with the same name [" + name + "]");
    }
    // rebuild the element cache for correct positioning.
    kidElementCache = null;
    return newDir;
}
Also used : RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) KettleException(org.pentaho.di.core.exception.KettleException)

Example 37 with RepositoryDirectoryInterface

use of org.pentaho.di.repository.RepositoryDirectoryInterface in project pentaho-kettle by pentaho.

the class RepositoryDirectoryUI method chooseDirectory.

public static RepositoryDirectoryInterface chooseDirectory(Shell shell, Repository rep, RepositoryDirectoryInterface directoryFrom) {
    if (rep == null) {
        return null;
    }
    if (directoryFrom == null) {
        try {
            directoryFrom = rep.getUserHomeDirectory();
        } catch (KettleException ex) {
            directoryFrom = new RepositoryDirectory();
        }
    }
    ObjectId idDirectoryFrom = directoryFrom.getObjectId();
    SelectDirectoryDialog sdd = new SelectDirectoryDialog(shell, SWT.NONE, rep);
    // PDI-13867: root dir and its direct subdirectories are restricted.
    HashSet<String> restrictedPaths = new HashSet<String>();
    restrictedPaths.add(directoryFrom.findRoot().getPath());
    restrictedPaths.add("/home");
    sdd.setRestrictedPaths(restrictedPaths);
    // TODO: expand and select directoryFrom in the dialog.
    RepositoryDirectoryInterface rd = sdd.open();
    if (rd == null || idDirectoryFrom == rd.getObjectId()) {
        return null;
    }
    return rd;
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) RepositoryDirectory(org.pentaho.di.repository.RepositoryDirectory) ObjectId(org.pentaho.di.repository.ObjectId) SelectDirectoryDialog(org.pentaho.di.ui.repository.dialog.SelectDirectoryDialog) HashSet(java.util.HashSet)

Example 38 with RepositoryDirectoryInterface

use of org.pentaho.di.repository.RepositoryDirectoryInterface in project pentaho-kettle by pentaho.

the class RepositoryDirectoryUI method getTreeWithNames.

/**
 * Set the name of this directory on a TreeItem. Also, create children on this TreeItem to reflect the subdirectories.
 * In these sub-directories, fill in the available transformations from the repository.
 *
 * @param ti
 *          The TreeItem to set the name on and to create the subdirectories
 * @param rep
 *          The repository
 * @param objectMap
 *          The tree path to repository object mapping to populate.
 * @param dircolor
 *          The color in which the directories will be drawn.
 * @param sortPosition
 *          The sort position
 * @param ascending
 *          The ascending flag
 * @param getTransformations
 *          Include transformations in the tree or not
 * @param getJobs
 *          Include jobs in the tree or not
 * @throws KettleDatabaseException
 */
public static void getTreeWithNames(TreeItem ti, Repository rep, Color dircolor, int sortPosition, boolean includeDeleted, boolean ascending, boolean getTransformations, boolean getJobs, RepositoryDirectoryInterface dir, String filterString, Pattern pattern) throws KettleDatabaseException {
    ti.setText(dir.getName());
    ti.setData(dir);
    ti.setData("isFolder", true);
    // First, we draw the directories
    List<RepositoryDirectoryInterface> children = dir.getChildren();
    Collections.sort(children, new Comparator<RepositoryDirectoryInterface>() {

        @Override
        public int compare(RepositoryDirectoryInterface o1, RepositoryDirectoryInterface o2) {
            return o1.getName().compareToIgnoreCase(o2.getName());
        }
    });
    for (int i = 0; i < children.size(); i++) {
        RepositoryDirectory subdir = (RepositoryDirectory) children.get(i);
        TreeItem subti = new TreeItem(ti, SWT.NONE);
        subti.setImage(GUIResource.getInstance().getImageFolder());
        subti.setData("isFolder", true);
        getTreeWithNames(subti, rep, dircolor, sortPosition, includeDeleted, ascending, getTransformations, getJobs, subdir, filterString, pattern);
    }
    List<RepositoryElementMetaInterface> repositoryObjects = loadRepositoryObjects(dir, getTransformations, getJobs, rep);
    // Sort the directory list appropriately...
    RepositoryObject.sortRepositoryObjects(repositoryObjects, sortPosition, ascending);
    addToTree(ti, filterString, pattern, repositoryObjects);
    ti.setExpanded(dir.isRoot());
}
Also used : RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) RepositoryDirectory(org.pentaho.di.repository.RepositoryDirectory) TreeItem(org.eclipse.swt.widgets.TreeItem) RepositoryElementMetaInterface(org.pentaho.di.repository.RepositoryElementMetaInterface)

Example 39 with RepositoryDirectoryInterface

use of org.pentaho.di.repository.RepositoryDirectoryInterface in project pentaho-kettle by pentaho.

the class RepositoryExplorerDialog method getDirectory.

public RepositoryDirectoryInterface getDirectory(TreeItem ti) {
    RepositoryDirectoryInterface repdir = null;
    int level = ConstUI.getTreeLevel(ti);
    String[] path = ConstUI.getTreeStrings(ti);
    if (level > 1) {
        int cat = getItemCategory(ti);
        String[] realpath;
        switch(cat) {
            case ITEM_CATEGORY_JOB:
            case ITEM_CATEGORY_TRANSFORMATION:
                // The first 3 levels of text[] don't belong to the path to this transformation!
                realpath = new String[level - 2];
                for (int i = 0; i < realpath.length; i++) {
                    realpath[i] = path[i + 2];
                }
                repdir = directoryTree.findDirectory(realpath);
                break;
            case ITEM_CATEGORY_JOB_DIRECTORY:
            case ITEM_CATEGORY_TRANSFORMATION_DIRECTORY:
                // The first 3 levels of text[] don't belong to the path to this transformation!
                realpath = new String[level - 1];
                for (int i = 0; i < realpath.length; i++) {
                    realpath[i] = path[i + 2];
                }
                repdir = directoryTree.findDirectory(realpath);
                break;
            default:
                break;
        }
    }
    return repdir;
}
Also used : RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface)

Example 40 with RepositoryDirectoryInterface

use of org.pentaho.di.repository.RepositoryDirectoryInterface in project pentaho-kettle by pentaho.

the class RepositoryExplorerDialog method setTreeMenu.

public void setTreeMenu() {
    Menu mTree = new Menu(shell, SWT.POP_UP);
    final TreeItem[] tisel = wTree.getSelection();
    if (tisel.length == 1 || sameCategory(tisel)) {
        final TreeItem ti = tisel[0];
        final int level = ConstUI.getTreeLevel(ti);
        final String[] path = ConstUI.getTreeStrings(ti);
        final String fullPath = ConstUI.getTreePath(ti, 0);
        final String item = ti.getText();
        final RepositoryElementMetaInterface repositoryObject = objectMap.get(fullPath);
        int cat = getItemCategory(ti);
        switch(cat) {
            case ITEM_CATEGORY_ROOT:
                // Export all
                MenuItem miExp = new MenuItem(mTree, SWT.PUSH);
                miExp.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.PopupMenu.Objects.ExportAll"));
                SelectionAdapter lsExp = new SelectionAdapter() {

                    @Override
                    public void widgetSelected(SelectionEvent e) {
                        exportAll(directoryTree);
                    }
                };
                miExp.addSelectionListener(lsExp);
                // Import all
                MenuItem miImp = new MenuItem(mTree, SWT.PUSH);
                miImp.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.PopupMenu.Objects.ImportAll"));
                SelectionAdapter lsImp = new SelectionAdapter() {

                    @Override
                    public void widgetSelected(SelectionEvent e) {
                        importAll();
                    }
                };
                miImp.addSelectionListener(lsImp);
                miImp.setEnabled(!readonly);
                // Export transMeta
                MenuItem miTrans = new MenuItem(mTree, SWT.PUSH);
                miTrans.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.PopupMenu.Objects.ExportTrans"));
                SelectionAdapter lsTrans = new SelectionAdapter() {

                    @Override
                    public void widgetSelected(SelectionEvent e) {
                        exportTransformations(directoryTree);
                    }
                };
                miTrans.addSelectionListener(lsTrans);
                // Export jobs
                MenuItem miJobs = new MenuItem(mTree, SWT.PUSH);
                miJobs.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.PopupMenu.Objects.ExportJob"));
                SelectionAdapter lsJobs = new SelectionAdapter() {

                    @Override
                    public void widgetSelected(SelectionEvent e) {
                        exportJobs(directoryTree);
                    }
                };
                miJobs.addSelectionListener(lsJobs);
                break;
            case ITEM_CATEGORY_DATABASES_ROOT:
                // New database
                MenuItem miNew = new MenuItem(mTree, SWT.PUSH);
                miNew.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.PopupMenu.ConnectionsRoot.New"));
                SelectionAdapter lsNew = new SelectionAdapter() {

                    @Override
                    public void widgetSelected(SelectionEvent e) {
                        newDatabase();
                    }
                };
                miNew.addSelectionListener(lsNew);
                miNew.setEnabled(!readonly);
                break;
            case ITEM_CATEGORY_DATABASE:
                // New database
                miNew = new MenuItem(mTree, SWT.PUSH);
                miNew.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.PopupMenu.Connections.New"));
                lsNew = new SelectionAdapter() {

                    @Override
                    public void widgetSelected(SelectionEvent e) {
                        newDatabase();
                    }
                };
                miNew.addSelectionListener(lsNew);
                miNew.setEnabled(!readonly);
                // Edit database info
                MenuItem miEdit = new MenuItem(mTree, SWT.PUSH);
                miEdit.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.PopupMenu.Connections.Edit"));
                SelectionAdapter lsEdit = new SelectionAdapter() {

                    @Override
                    public void widgetSelected(SelectionEvent e) {
                        editDatabase(item);
                    }
                };
                miEdit.addSelectionListener(lsEdit);
                miEdit.setEnabled(!readonly);
                // Delete database info
                MenuItem miDel = new MenuItem(mTree, SWT.PUSH);
                miDel.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.PopupMenu.Connections.Delete"));
                SelectionAdapter lsDel = new SelectionAdapter() {

                    @Override
                    public void widgetSelected(SelectionEvent e) {
                        delDatabase(item);
                    }
                };
                miDel.addSelectionListener(lsDel);
                miDel.setEnabled(!readonly);
                break;
            case ITEM_CATEGORY_SLAVES_ROOT:
                // New slave
                miNew = new MenuItem(mTree, SWT.PUSH);
                miNew.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.PopupMenu.Slave.New"));
                lsNew = new SelectionAdapter() {

                    @Override
                    public void widgetSelected(SelectionEvent e) {
                        newSlaveServer();
                    }
                };
                miNew.addSelectionListener(lsNew);
                miNew.setEnabled(!readonly);
                break;
            case ITEM_CATEGORY_SLAVE:
                // New slave
                miNew = new MenuItem(mTree, SWT.PUSH);
                miNew.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.PopupMenu.Slave.New"));
                lsNew = new SelectionAdapter() {

                    @Override
                    public void widgetSelected(SelectionEvent e) {
                        newSlaveServer();
                    }
                };
                miNew.addSelectionListener(lsNew);
                miNew.setEnabled(!readonly);
                // Edit slave
                miEdit = new MenuItem(mTree, SWT.PUSH);
                miEdit.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.PopupMenu.Slave.Edit"));
                lsEdit = new SelectionAdapter() {

                    @Override
                    public void widgetSelected(SelectionEvent e) {
                        editSlaveServer(item);
                    }
                };
                miEdit.addSelectionListener(lsEdit);
                miEdit.setEnabled(!readonly);
                // Delete slave
                miDel = new MenuItem(mTree, SWT.PUSH);
                miDel.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.PopupMenu.Slave.Delete"));
                lsDel = new SelectionAdapter() {

                    @Override
                    public void widgetSelected(SelectionEvent e) {
                        delSlaveServer(item);
                    }
                };
                miDel.addSelectionListener(lsDel);
                miDel.setEnabled(!readonly);
                break;
            case ITEM_CATEGORY_PARTITIONS_ROOT:
                // New partition schema
                miNew = new MenuItem(mTree, SWT.PUSH);
                miNew.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.PopupMenu.PartitionSchema.New"));
                lsNew = new SelectionAdapter() {

                    @Override
                    public void widgetSelected(SelectionEvent e) {
                        newPartitionSchema();
                    }
                };
                miNew.addSelectionListener(lsNew);
                miNew.setEnabled(!readonly);
                break;
            case ITEM_CATEGORY_PARTITION:
                // New partition schema
                miNew = new MenuItem(mTree, SWT.PUSH);
                miNew.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.PopupMenu.PartitionSchema.New"));
                lsNew = new SelectionAdapter() {

                    @Override
                    public void widgetSelected(SelectionEvent e) {
                        newPartitionSchema();
                    }
                };
                miNew.addSelectionListener(lsNew);
                miNew.setEnabled(!readonly);
                // Edit partition schema
                miEdit = new MenuItem(mTree, SWT.PUSH);
                miEdit.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.PopupMenu.PartitionSchema.Edit"));
                lsEdit = new SelectionAdapter() {

                    @Override
                    public void widgetSelected(SelectionEvent e) {
                        editPartitionSchema(item);
                    }
                };
                miEdit.addSelectionListener(lsEdit);
                miEdit.setEnabled(!readonly);
                // Delete partition schema
                miDel = new MenuItem(mTree, SWT.PUSH);
                miDel.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.PopupMenu.PartitionSchema.Delete"));
                lsDel = new SelectionAdapter() {

                    @Override
                    public void widgetSelected(SelectionEvent e) {
                        delPartitionSchema(item);
                    }
                };
                miDel.addSelectionListener(lsDel);
                miDel.setEnabled(!readonly);
                break;
            case ITEM_CATEGORY_CLUSTERS_ROOT:
                // New cluster
                miNew = new MenuItem(mTree, SWT.PUSH);
                miNew.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.PopupMenu.Cluster.New"));
                lsNew = new SelectionAdapter() {

                    @Override
                    public void widgetSelected(SelectionEvent e) {
                        newCluster();
                    }
                };
                miNew.addSelectionListener(lsNew);
                miNew.setEnabled(!readonly);
                break;
            case ITEM_CATEGORY_CLUSTER:
                // New cluster
                miNew = new MenuItem(mTree, SWT.PUSH);
                miNew.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.PopupMenu.Cluster.New"));
                lsNew = new SelectionAdapter() {

                    @Override
                    public void widgetSelected(SelectionEvent e) {
                        newCluster();
                    }
                };
                miNew.addSelectionListener(lsNew);
                miNew.setEnabled(!readonly);
                // Edit cluster
                miEdit = new MenuItem(mTree, SWT.PUSH);
                miEdit.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.PopupMenu.Cluster.Edit"));
                lsEdit = new SelectionAdapter() {

                    @Override
                    public void widgetSelected(SelectionEvent e) {
                        editCluster(item);
                    }
                };
                miEdit.addSelectionListener(lsEdit);
                miEdit.setEnabled(!readonly);
                // Delete cluster
                miDel = new MenuItem(mTree, SWT.PUSH);
                miDel.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.PopupMenu.Cluster.Delete"));
                lsDel = new SelectionAdapter() {

                    @Override
                    public void widgetSelected(SelectionEvent e) {
                        delCluster(item);
                    }
                };
                miDel.addSelectionListener(lsDel);
                miDel.setEnabled(!readonly);
                break;
            case ITEM_CATEGORY_TRANSFORMATIONS_ROOT:
                break;
            case ITEM_CATEGORY_TRANSFORMATION:
                if (level >= 2 && repositoryObject != null) {
                    final RepositoryDirectoryInterface repdir = repositoryObject.getRepositoryDirectory();
                    if (tisel.length == 1) {
                        if (!repositoryObject.isDeleted()) {
                            // Open transformation...
                            MenuItem miOpen = new MenuItem(mTree, SWT.PUSH);
                            miOpen.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.PopupMenu.Transformations.Open"));
                            miOpen.addSelectionListener(new SelectionAdapter() {

                                @Override
                                public void widgetSelected(SelectionEvent e) {
                                    openTransformation(item, repdir);
                                }
                            });
                            // Rename transformation
                            MenuItem miRen = new MenuItem(mTree, SWT.PUSH);
                            miRen.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.PopupMenu.Transformations.Rename"));
                            miRen.addSelectionListener(new SelectionAdapter() {

                                @Override
                                public void widgetSelected(SelectionEvent e) {
                                    renameTransformation(item, repdir);
                                }
                            });
                            miRen.setEnabled(!readonly);
                        }
                    }
                    if (repositoryObject.isDeleted()) {
                        if (capabilities.supportsRevisions()) {
                            // Restore transformation
                            MenuItem miRestore = new MenuItem(mTree, SWT.PUSH);
                            miRestore.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.PopupMenu.Transformations.Restore"));
                            miRestore.addSelectionListener(new SelectionAdapter() {

                                @Override
                                public void widgetSelected(SelectionEvent e) {
                                    restoreSelectedObjects();
                                }
                            });
                        }
                    } else {
                        // Delete transformation
                        miDel = new MenuItem(mTree, SWT.PUSH);
                        miDel.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.PopupMenu.Transformations.Delete"));
                        miDel.addSelectionListener(new SelectionAdapter() {

                            @Override
                            public void widgetSelected(SelectionEvent e) {
                                delSelectedObjects();
                            }
                        });
                        miDel.setEnabled(!readonly);
                    }
                }
                break;
            case ITEM_CATEGORY_JOB_DIRECTORY:
            case ITEM_CATEGORY_TRANSFORMATION_DIRECTORY:
                if (level >= 2) {
                    // The first levels of path[] don't belong to the path to this directory!
                    String[] realpath = new String[level - 1];
                    for (int i = 0; i < realpath.length; i++) {
                        realpath[i] = path[i + 2];
                    }
                    // Find the directory in the directory tree...
                    final RepositoryDirectoryInterface repdir = directoryTree.findDirectory(realpath);
                    // Export xforms and jobs from directory
                    miExp = new MenuItem(mTree, SWT.PUSH);
                    miExp.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.PopupMenu.Objects.ExportAll"));
                    lsExp = new SelectionAdapter() {

                        @Override
                        public void widgetSelected(SelectionEvent e) {
                            exportAll(repdir);
                        }
                    };
                    miExp.addSelectionListener(lsExp);
                    miExp.setEnabled(!readonly);
                    if (cat == ITEM_CATEGORY_TRANSFORMATION_DIRECTORY) {
                        // Export transMeta
                        miTrans = new MenuItem(mTree, SWT.PUSH);
                        miTrans.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.PopupMenu.Objects.ExportTrans"));
                        lsTrans = new SelectionAdapter() {

                            @Override
                            public void widgetSelected(SelectionEvent e) {
                                exportTransformations(repdir);
                            }
                        };
                        miTrans.addSelectionListener(lsTrans);
                    }
                    if (cat == ITEM_CATEGORY_JOB_DIRECTORY) {
                        // Export jobs
                        miJobs = new MenuItem(mTree, SWT.PUSH);
                        miJobs.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.PopupMenu.Objects.ExportJob"));
                        lsJobs = new SelectionAdapter() {

                            @Override
                            public void widgetSelected(SelectionEvent e) {
                                exportJobs(repdir);
                            }
                        };
                        miJobs.addSelectionListener(lsJobs);
                    }
                    // create directory...
                    MenuItem miCreate = new MenuItem(mTree, SWT.PUSH);
                    miCreate.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.PopupMenu.TransDirectory.Create"));
                    miCreate.addSelectionListener(new SelectionAdapter() {

                        @Override
                        public void widgetSelected(SelectionEvent e) {
                            createDirectory(ti, repdir);
                        }
                    });
                    if (level > 2) {
                        // Can't rename or delete root directory...
                        // Rename directory
                        MenuItem miRename = new MenuItem(mTree, SWT.PUSH);
                        miRename.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.PopupMenu.TransDirectory.Rename"));
                        miRename.addSelectionListener(new SelectionAdapter() {

                            @Override
                            public void widgetSelected(SelectionEvent e) {
                                renameDirectory(ti, repdir);
                            }
                        });
                        // Delete directory
                        MenuItem miDelete = new MenuItem(mTree, SWT.PUSH);
                        miDelete.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.PopupMenu.TransDirectory.Delete"));
                        miDelete.addSelectionListener(new SelectionAdapter() {

                            @Override
                            public void widgetSelected(SelectionEvent e) {
                                delDirectory(ti, repdir);
                            }
                        });
                    }
                }
                break;
            case ITEM_CATEGORY_JOBS_ROOT:
                break;
            case ITEM_CATEGORY_JOB:
                if (level >= 2 && repositoryObject != null) {
                    final RepositoryDirectoryInterface repdir = repositoryObject.getRepositoryDirectory();
                    if (tisel.length == 1) {
                        if (!repositoryObject.isDeleted()) {
                            // Open job...
                            MenuItem miOpen = new MenuItem(mTree, SWT.PUSH);
                            miOpen.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.PopupMenu.Jobs.Open"));
                            miOpen.addSelectionListener(new SelectionAdapter() {

                                @Override
                                public void widgetSelected(SelectionEvent e) {
                                    openJob(item, repdir);
                                }
                            });
                            // Rename job
                            MenuItem miRen = new MenuItem(mTree, SWT.PUSH);
                            miRen.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.PopupMenu.Jobs.Rename"));
                            miRen.addSelectionListener(new SelectionAdapter() {

                                @Override
                                public void widgetSelected(SelectionEvent e) {
                                    renameJob(ti, item, repdir);
                                }
                            });
                            miRen.setEnabled(!readonly);
                        }
                    }
                    if (repositoryObject.isDeleted()) {
                        if (capabilities.supportsRevisions()) {
                            // Restore job
                            MenuItem miRestore = new MenuItem(mTree, SWT.PUSH);
                            miRestore.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.PopupMenu.Jobs.Restore"));
                            miRestore.addSelectionListener(new SelectionAdapter() {

                                @Override
                                public void widgetSelected(SelectionEvent e) {
                                    restoreSelectedObjects();
                                }
                            });
                        }
                    } else {
                        // Delete job
                        miDel = new MenuItem(mTree, SWT.PUSH);
                        miDel.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.PopupMenu.Jobs.Delete"));
                        miDel.addSelectionListener(new SelectionAdapter() {

                            @Override
                            public void widgetSelected(SelectionEvent e) {
                                delSelectedObjects();
                            }
                        });
                        miDel.setEnabled(!readonly);
                    }
                }
                break;
            case ITEM_CATEGORY_USERS_ROOT:
                mTree = new Menu(shell, SWT.POP_UP);
                // New user
                miNew = new MenuItem(mTree, SWT.PUSH);
                miNew.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.PopupMenu.UsersRoot.New"));
                lsNew = new SelectionAdapter() {

                    @Override
                    public void widgetSelected(SelectionEvent e) {
                        newUser();
                    }
                };
                miNew.addSelectionListener(lsNew);
                miNew.setEnabled(!readonly);
                break;
            case ITEM_CATEGORY_USER:
                // New user
                miNew = new MenuItem(mTree, SWT.PUSH);
                miNew.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.PopupMenu.Users.New"));
                lsNew = new SelectionAdapter() {

                    @Override
                    public void widgetSelected(SelectionEvent e) {
                        newUser();
                    }
                };
                miNew.addSelectionListener(lsNew);
                miNew.setEnabled(!readonly);
                // Edit user info
                miEdit = new MenuItem(mTree, SWT.PUSH);
                miEdit.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.PopupMenu.Users.Edit"));
                lsEdit = new SelectionAdapter() {

                    @Override
                    public void widgetSelected(SelectionEvent e) {
                        editUser(item);
                    }
                };
                miEdit.addSelectionListener(lsEdit);
                miEdit.setEnabled(!readonly);
                // Rename user
                MenuItem miRen = new MenuItem(mTree, SWT.PUSH);
                miRen.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.PopupMenu.Users.Rename"));
                SelectionAdapter lsRen = new SelectionAdapter() {

                    @Override
                    public void widgetSelected(SelectionEvent e) {
                        renameUser();
                    }
                };
                miRen.addSelectionListener(lsRen);
                miRen.setEnabled(!readonly);
                // Delete user info
                miDel = new MenuItem(mTree, SWT.PUSH);
                miDel.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.PopupMenu.Users.Delete"));
                lsDel = new SelectionAdapter() {

                    @Override
                    public void widgetSelected(SelectionEvent e) {
                        delUser(item);
                    }
                };
                miDel.addSelectionListener(lsDel);
                miDel.setEnabled(!readonly);
                break;
            default:
                mTree = null;
        }
    }
    ConstUI.displayMenu(mTree, wTree);
}
Also used : RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) TreeItem(org.eclipse.swt.widgets.TreeItem) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) MenuItem(org.eclipse.swt.widgets.MenuItem) Menu(org.eclipse.swt.widgets.Menu) RepositoryElementMetaInterface(org.pentaho.di.repository.RepositoryElementMetaInterface)

Aggregations

RepositoryDirectoryInterface (org.pentaho.di.repository.RepositoryDirectoryInterface)163 KettleException (org.pentaho.di.core.exception.KettleException)68 Test (org.junit.Test)32 TransMeta (org.pentaho.di.trans.TransMeta)30 ObjectId (org.pentaho.di.repository.ObjectId)27 JobMeta (org.pentaho.di.job.JobMeta)23 Repository (org.pentaho.di.repository.Repository)22 ArrayList (java.util.ArrayList)17 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)17 RepositoryDirectory (org.pentaho.di.repository.RepositoryDirectory)15 IOException (java.io.IOException)14 RepositoryElementMetaInterface (org.pentaho.di.repository.RepositoryElementMetaInterface)13 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)11 RepositoryObject (org.pentaho.di.repository.RepositoryObject)11 FileObject (org.apache.commons.vfs2.FileObject)10 List (java.util.List)8 TreeItem (org.eclipse.swt.widgets.TreeItem)8 KettleFileException (org.pentaho.di.core.exception.KettleFileException)8 Date (java.util.Date)7 FileSystemException (org.apache.commons.vfs2.FileSystemException)7