Package org.python.pydev.ui.dialogs

Examples of org.python.pydev.ui.dialogs.TreeSelectionDialog


        final DialogMemento memento = new DialogMemento(getShell(),
                "org.python.pydev.debug.ui.actions.RunEditorAsCustomUnitTestAction");
        SimpleNode ast = pyEdit.getAST();

        TreeSelectionDialog dialog = new TreeSelectionDialog(getShell(), new SelectTestLabelProvider(),
                new SelectTestTreeContentProvider()) {

            Link configTestRunner;

            public boolean close() {
                memento.writeSettings(getShell());
                return super.close();
            }

            public Control createDialogArea(Composite parent) {
                memento.readSettings();
                Control ret = super.createDialogArea(parent);
                this.text.addKeyListener(new KeyListener() {

                    public void keyReleased(KeyEvent e) {
                    }

                    public void keyPressed(KeyEvent e) {
                        if (e.keyCode == SWT.CR || e.keyCode == SWT.LF || e.keyCode == SWT.KEYPAD_CR) {
                            okPressed();
                        }
                    }
                });
                return ret;
            }

            /* (non-Javadoc)
             * @see org.python.pydev.ui.dialogs.TreeSelectionDialog#createButtonBar(org.eclipse.swt.widgets.Composite)
             */
            @Override
            protected Control createButtonBar(Composite parent) {
                configTestRunner = new Link(parent, SWT.PUSH);
                configTestRunner.setText(" <a>Configure test runner</a>");
                configTestRunner.addSelectionListener(new SelectionAdapter() {
                    public void widgetSelected(SelectionEvent e) {
                        PyUnitPrefsPage2.showPage();
                    }

                });
                return configTestRunner;
            }

            protected Point getInitialSize() {
                return memento.getInitialSize(super.getInitialSize(), getShell());
            }

            protected Point getInitialLocation(Point initialSize) {
                return memento.getInitialLocation(initialSize, super.getInitialLocation(initialSize), getShell());
            }

            /*
             * @see SelectionStatusDialog#computeResult()
             */
            @SuppressWarnings("unchecked")
            protected void computeResult() {
                doFinalUpdateBeforeComputeResult();

                IStructuredSelection selection = (IStructuredSelection) getTreeViewer().getSelection();
                List<Object> list = selection.toList();
                if (list.size() > 0) {
                    setResult(list);
                } else {
                    Tree tree = getTreeViewer().getTree();
                    TreeItem[] items = tree.getItems();
                    list = new ArrayList<Object>();
                    //Now, if he didn't select anything, let's create tests with all that is currently filtered
                    //in the interface
                    createListWithLeafs(items, list);
                    setResult(list);
                }
            }

            private void createListWithLeafs(TreeItem[] items, List<Object> leafObjectsList) {
                for (TreeItem item : items) {
                    TreeItem[] children = item.getItems();
                    if (children.length == 0) {
                        leafObjectsList.add(item.getData());
                    } else {
                        createListWithLeafs(children, leafObjectsList);
                    }
                }
            }

        };

        dialog.setTitle("PyDev: Select tests to run");
        dialog.setMessage("Select the tests to run (press enter to run tests shown/selected)");
        dialog.setInitialFilter("test");
        dialog.setAllowMultiple(true);
        dialog.setInput(ast);
        int open = dialog.open();
        if (open != Window.OK) {
            return;
        }
        Object[] result = dialog.getResult();

        final FastStringBuffer buf = new FastStringBuffer();
        if (result != null && result.length > 0) {

            for (Object o : result) {
View Full Code Here


     * @return the command to be executed or null if no command was selected for execution.
     */
    private String chooseCommand() {
        final IPreferenceStore preferenceStore = PydevPlugin.getDefault().getPreferenceStore();

        TreeSelectionDialog dialog = new SelectExistingOrCreateNewDialog(PyAction.getShell(), preferenceStore,
                DJANGO_CUSTOM_COMMANDS_PREFERENCE_KEY, SHELL_MEMENTO_ID);

        dialog.setTitle("Select the command to run or enter a new command");
        dialog.setMessage("Select the command to run or enter a new command");
        dialog.setInitialFilter("");

        int open = dialog.open();
        if (open != Window.OK) {
            return null;
        }
        Object[] result = dialog.getResult();
        if (result != null && result.length == 1) {
            return result[0].toString();
        }
        return null;
    }
View Full Code Here

    public void run(IAction action) {

        PyEdit pyEdit = getPyEdit();

        TreeSelectionDialog dialog = new PyOutlineSelectionDialog(PyAction.getShell(), pyEdit);

        dialog.open(); //The dialog will take care of everything.
    }
View Full Code Here

TOP

Related Classes of org.python.pydev.ui.dialogs.TreeSelectionDialog

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.