Search in sources :

Example 76 with MenuItem

use of org.eclipse.swt.widgets.MenuItem in project hale by halestudio.

the class RecentProjectsMenu method fill.

/**
 * @see ContributionItem#fill(Menu, int)
 */
@Override
public void fill(final Menu menu, int index) {
    RecentProjectsService rfs = PlatformUI.getWorkbench().getService(RecentProjectsService.class);
    RecentProjectsService.Entry[] entries = rfs.getRecentFiles();
    if (entries == null || entries.length == 0) {
        return;
    }
    // add separator
    new MenuItem(menu, SWT.SEPARATOR, index);
    int i = entries.length;
    for (RecentProjectsService.Entry entry : entries) {
        String file = entry.getFile();
        MenuItem mi = new MenuItem(menu, SWT.PUSH, index);
        String filename = FilenameUtils.getName(file);
        String shortened = shorten(file, MAX_LENGTH, filename.length());
        String nr = String.valueOf(i);
        if (i <= 9) {
            // add mnemonic for the first 9 items
            // $NON-NLS-1$
            nr = "&" + nr;
        }
        // $NON-NLS-1$
        mi.setText(nr + "  " + shortened);
        mi.setData(file);
        mi.addSelectionListener(new MenuItemSelectionListener(new File(file)));
        --i;
    }
}
Also used : MenuItem(org.eclipse.swt.widgets.MenuItem) File(java.io.File)

Example 77 with MenuItem

use of org.eclipse.swt.widgets.MenuItem in project hale by halestudio.

the class FileSourceFileFieldEditor method setContentTypes.

@Override
public void setContentTypes(Set<IContentType> types) {
    super.setContentTypes(types);
    RecentResources rr = PlatformUI.getWorkbench().getService(RecentResources.class);
    if (rr != null) {
        final List<Pair<URI, IContentType>> files = rr.getRecent(types, true);
        if (!files.isEmpty()) {
            historyButton.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    Menu filesMenu = new Menu(historyButton);
                    for (Pair<URI, IContentType> pair : files) {
                        final File file;
                        try {
                            file = new File(pair.getFirst());
                            if (file.exists()) {
                                // only offer existing files
                                MenuItem item = new MenuItem(filesMenu, SWT.PUSH);
                                item.setText(RecentProjectsMenu.shorten(file.toString(), 80, file.getName().length()));
                                item.addSelectionListener(new SelectionAdapter() {

                                    @Override
                                    public void widgetSelected(SelectionEvent e) {
                                        String text = processFile(file);
                                        if (text != null) {
                                            getTextControl().setText(text);
                                            getTextControl().setFocus();
                                            valueChanged();
                                        }
                                    }
                                });
                            }
                        } catch (Exception e1) {
                        // ignore
                        }
                    }
                    Point histLoc = historyButton.getParent().toDisplay(historyButton.getLocation());
                    filesMenu.setLocation(histLoc.x, histLoc.y + historyButton.getSize().y);
                    filesMenu.setVisible(true);
                }
            });
            historyButton.setEnabled(true);
        }
    }
}
Also used : SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) MenuItem(org.eclipse.swt.widgets.MenuItem) RecentProjectsMenu(eu.esdihumboldt.hale.ui.service.project.RecentProjectsMenu) Menu(org.eclipse.swt.widgets.Menu) Point(org.eclipse.swt.graphics.Point) File(java.io.File) RecentResources(eu.esdihumboldt.hale.ui.service.project.RecentResources) Pair(eu.esdihumboldt.util.Pair)

Example 78 with MenuItem

use of org.eclipse.swt.widgets.MenuItem in project hale by halestudio.

the class MapMenu method fill.

/**
 * @see ContributionItem#fill(Menu, int)
 */
@Override
public void fill(Menu menu, int index) {
    serverMenu.fill(menu, index);
    index = menu.getItemCount();
    separator.fill(menu, index++);
    MenuItem item = new MenuItem(menu, SWT.CASCADE, index++);
    item.setText(Messages.MapMenu_0);
    Menu submenu = new Menu(item);
    item.setMenu(submenu);
    for (IContributionItem con : overlayMenu) {
        con.fill(submenu, 0);
    }
    item = new MenuItem(menu, SWT.CASCADE, index++);
    item.setText(Messages.MapMenu_1);
    submenu = new Menu(item);
    item.setMenu(submenu);
    cacheMenu.fill(submenu, 0);
}
Also used : IContributionItem(org.eclipse.jface.action.IContributionItem) MenuItem(org.eclipse.swt.widgets.MenuItem) Menu(org.eclipse.swt.widgets.Menu)

Example 79 with MenuItem

use of org.eclipse.swt.widgets.MenuItem in project pentaho-kettle by pentaho.

the class RepositoryConnectMenu method renderConnectDropdown.

private void renderConnectDropdown() {
    connectDropdown = new ToolItem(toolBar, SWT.DROP_DOWN, toolBar.getItems().length);
    connectDropdown.setText(BaseMessages.getString(PKG, "RepositoryConnectMenu.Connect"));
    connectDropdown.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent event) {
            final Menu connectionMenu = new Menu(toolBar.getShell());
            if (repositoriesMeta != null) {
                for (int i = 0; i < repositoriesMeta.nrRepositories(); i++) {
                    MenuItem item = new MenuItem(connectionMenu, SWT.CHECK);
                    String truncatedName = truncateName(repositoriesMeta.getRepository(i).getName());
                    item.setText(truncatedName);
                    item.setData(repositoriesMeta.getRepository(i).getName());
                    if (spoon.rep != null && spoon.getRepositoryName().equals(repositoriesMeta.getRepository(i).getName())) {
                        item.setSelection(true);
                        continue;
                    }
                    item.addSelectionListener(new SelectionAdapter() {

                        @Override
                        public void widgetSelected(SelectionEvent selectionEvent) {
                            String repoName = (String) (selectionEvent.widget).getData();
                            RepositoryMeta repositoryMeta = repositoriesMeta.findRepository(repoName);
                            if (repositoryMeta != null) {
                                try {
                                    if (!spoon.promptForSave()) {
                                        return;
                                    }
                                } catch (KettleException ke) {
                                    log.logError("Error prompting for save", ke);
                                }
                                if (repositoryMeta.getId().equals("KettleFileRepository")) {
                                    try {
                                        repoConnectController.connectToRepository(repositoryMeta);
                                    } catch (KettleException ke) {
                                        log.logError("Error connecting to repository", ke);
                                    }
                                } else {
                                    new RepositoryDialog(spoon.getShell(), repoConnectController).openLogin(repositoryMeta);
                                }
                                renderAndUpdate();
                            }
                        }
                    });
                }
            }
            new MenuItem(connectionMenu, SWT.SEPARATOR);
            MenuItem managerItem = new MenuItem(connectionMenu, SWT.NONE);
            managerItem.setText(BaseMessages.getString(PKG, "RepositoryConnectMenu.RepositoryManager"));
            managerItem.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent selectionEvent) {
                    new RepositoryDialog(spoon.getShell(), repoConnectController).openManager();
                    RepositoryMeta current = repoConnectController.getCurrentRepository();
                    if (current != null) {
                        spoon.setRepositoryName(current.getName());
                    }
                    renderAndUpdate();
                }
            });
            new MenuItem(connectionMenu, SWT.SEPARATOR);
            MenuItem disconnectItem = new MenuItem(connectionMenu, SWT.NONE);
            disconnectItem.setEnabled(spoon.rep != null);
            disconnectItem.setText(BaseMessages.getString(PKG, "RepositoryConnectMenu.Disconnect"));
            disconnectItem.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent selectionEvent) {
                    boolean cancelled = false;
                    try {
                        cancelled = !spoon.promptForSave();
                    } catch (KettleException e) {
                        log.logError("Error saving Job or Transformation", e);
                    }
                    if (!cancelled) {
                        spoon.closeRepository();
                        repoConnectController.setConnectedRepository(null);
                        renderAndUpdate();
                    }
                }
            });
            ToolItem item = (ToolItem) event.widget;
            Rectangle rect = item.getBounds();
            org.eclipse.swt.graphics.Point pt = item.getParent().toDisplay(new org.eclipse.swt.graphics.Point(rect.x, rect.y + rect.height));
            connectionMenu.setLocation(pt.x, pt.y);
            connectionMenu.setVisible(true);
        }
    });
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Rectangle(org.eclipse.swt.graphics.Rectangle) MenuItem(org.eclipse.swt.widgets.MenuItem) Point(org.eclipse.swt.graphics.Point) RepositoryMeta(org.pentaho.di.repository.RepositoryMeta) RepositoryDialog(org.pentaho.di.ui.repo.dialog.RepositoryDialog) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Menu(org.eclipse.swt.widgets.Menu) ToolItem(org.eclipse.swt.widgets.ToolItem)

Example 80 with MenuItem

use of org.eclipse.swt.widgets.MenuItem 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

MenuItem (org.eclipse.swt.widgets.MenuItem)386 Menu (org.eclipse.swt.widgets.Menu)259 SelectionEvent (org.eclipse.swt.events.SelectionEvent)247 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)208 Event (org.eclipse.swt.widgets.Event)58 ArrayList (java.util.ArrayList)55 Point (org.eclipse.swt.graphics.Point)52 GridData (org.eclipse.swt.layout.GridData)49 Listener (org.eclipse.swt.widgets.Listener)48 SelectionListener (org.eclipse.swt.events.SelectionListener)46 Composite (org.eclipse.swt.widgets.Composite)43 GridLayout (org.eclipse.swt.layout.GridLayout)42 Rectangle (org.eclipse.swt.graphics.Rectangle)35 Label (org.eclipse.swt.widgets.Label)34 Shell (org.eclipse.swt.widgets.Shell)34 Table (org.eclipse.swt.widgets.Table)33 MenuEvent (org.eclipse.swt.events.MenuEvent)32 Button (org.eclipse.swt.widgets.Button)32 List (java.util.List)31 NatTable (org.eclipse.nebula.widgets.nattable.NatTable)29