Package org.eclipse.jface.dialogs

Examples of org.eclipse.jface.dialogs.IInputValidator


        final IPath prefix = resource.getFullPath().removeLastSegments(1);
        final String returnValue[] = { "" }; //$NON-NLS-1$

        messageShell.getDisplay().syncExec(new Runnable() {
            public void run() {
                IInputValidator validator = new IInputValidator() {
                    public String isValid(String string) {
                        if (resource.getName().equals(string)) {
                            return IDEWorkbenchMessages.CopyFilesAndFoldersOperation_nameMustBeDifferent;
                        }
                        IStatus status = workspace.validateName(string, resource.getType());
View Full Code Here


    public void widgetSelected(SelectionEvent e) {
        Object source = e.getSource();
        if (source == btAdd) {
            InputDialog dialog = new InputDialog(getShell(), "Add custom command to list",
                    "Add custom command to list", "", new IInputValidator() {

                        public String isValid(String newText) {
                            if (newText.trim().length() == 0) {
                                return "Command not entered.";
                            }
View Full Code Here

        if (index >= 0) {
            TreeItem curr = treeWithInterpreters.getItem(index);

            final String initialName = getNameFromTreeItem(curr);
            InputDialog d = new InputDialog(this.getShell(), "New name",
                    "Please specify the new name of the interpreter.", initialName, new IInputValidator() {
                        public String isValid(String newText) {
                            if (newText == null || newText.trim().equals("")) {
                                return "Please specify a non-empty name.";
                            }
                            newText = newText.trim();
View Full Code Here

                }
                exeOrJarOfInterpretersWithBuiltinsChanged.add(info.getExecutableOrJar());
            }

            protected String getInput() {
                IInputValidator validator = new IInputValidator() {

                    public String isValid(String newText) {
                        for (char c : newText.toCharArray()) {
                            if (!Character.isJavaIdentifierPart(c) && c != ' ' && c != ',' && c != '.') {
                                return "Can only accept valid python module names (char: '" + c + "' not accepted)";
                            }
                        }
                        return null;
                    }
                };
                InputDialog d = new InputDialog(getShell(), "Builtin to add", "Builtin to add (comma separated)", "",
                        validator);

                int retCode = d.open();
                String builtins = null;
                if (retCode == InputDialog.OK) {
                    builtins = d.getValue();
                }
                return builtins;
            }

            protected void addInputToInfo(InterpreterInfo info, String builtins) {
                java.util.List<String> split = StringUtils.splitAndRemoveEmptyTrimmed(builtins, ',');
                for (String string : split) {
                    String trimmed = string.trim();
                    if (trimmed.length() > 0) {
                        info.addForcedLib(trimmed);
                    }
                }
                exeOrJarOfInterpretersWithBuiltinsChanged.add(info.getExecutableOrJar());
            }

        };
        forcedBuiltins.createTab("Forced Builtins", "Forced Builtins (check <a>Manual</a> for more info).");

        //----------------------- PREDEFINED COMPLETIONS
        predefinedCompletions = new AbstractListWithNewRemoveControl(this) {

            private Button addAPIBt;

            protected List<String> getStringsFromInfo(InterpreterInfo info) {
                return info.getPredefinedCompletionsPath();
            }

            protected void removeSelectedFrominfo(InterpreterInfo info, String[] items) {
                for (String item : items) {
                    info.removePredefinedCompletionPath(item);
                }
                exeOrJarOfInterpretersWithPredefinedChanged.add(info.getExecutableOrJar());
            }

            protected String getInput() {
                DirectoryDialog dialog = new DirectoryDialog(getShell());
                dialog.setFilterPath(lastDirectoryDialogPath);
                String filePath = dialog.open();
                if (filePath != null) {
                    lastDirectoryDialogPath = filePath;
                }
                return filePath;
            }

            protected void addInputToInfo(InterpreterInfo info, String item) {
                info.addPredefinedCompletionsPath(item);
                exeOrJarOfInterpretersWithPredefinedChanged.add(info.getExecutableOrJar());
            }

            protected void createButtons(AbstractInterpreterEditor interpreterEditor) {
                super.createButtons(interpreterEditor);
                addAPIBt = interpreterEditor.createBt(box, "Add from QScintilla api file", this);//$NON-NLS-1$
            }

            public void widgetDisposed(DisposeEvent event) {
                super.widgetDisposed(event);
                if (addAPIBt != null) {
                    addAPIBt.dispose();
                    addAPIBt = null;
                }
            }

            public void widgetSelected(SelectionEvent event) {
                super.widgetSelected(event);
                Widget widget = event.widget;
                if (widget == addAPIBt) {
                    addAPIBt();
                }
            }

            private void addAPIBt() {
                final AbstractInterpreterEditor interpreterEditor = this.container.get();
                Assert.isNotNull(interpreterEditor);

                final InterpreterInfo info = interpreterEditor.getSelectedInfo();
                if (info != null) {
                    FileDialog dialog = new FileDialog(getShell(), SWT.PRIMARY_MODAL | SWT.MULTI);

                    dialog.setFilterExtensions(new String[] { "*.api" });
                    dialog.setText("Select .api file to be converted to .pypredef.");

                    dialog.setFilterPath(lastFileDialogPath);
                    final String filePath = dialog.open();
                    if (filePath != null) {
                        lastFileDialogPath = filePath;
                        File filePath1 = new File(filePath);
                        final String dir = filePath1.getParent();

                        IInputValidator validator = new IInputValidator() {

                            public String isValid(String newText) {
                                if (newText.length() == 0) {
                                    return "Number not provided.";
                                }
View Full Code Here

    private String getNameForContentsPasted(final IContainer container) {
        final IWorkspace workspace = container.getWorkspace();
        final String returnValue[] = { null };

        final IInputValidator validator = new IInputValidator() {
            public String isValid(String string) {
                IStatus status = workspace.validateName(string, IResource.FILE);
                if (!status.isOK()) {
                    return status.getMessage();
                }
                if (container.getFile(new Path(string)).exists()) {
                    return "File already exists";
                }
                return null;
            }
        };

        String base = "snippet%s.py";
        for (int i = 0; i < 1000; i++) {
            String newCheck;
            if (i == 0) {
                newCheck = com.aptana.shared_core.string.StringUtils.format(base, "");
            } else {
                newCheck = com.aptana.shared_core.string.StringUtils.format(base, i);

            }
            if (validator.isValid(newCheck) == null) {
                base = newCheck;
                break;
            }
        }
View Full Code Here

            }

            @Override
            protected String getNewInputObject() {
                InputDialog d = new InputDialog(getShell(), "New word", "Add the word you wish.", "",
                        new IInputValidator() {

                            public String isValid(String newText) {
                                if (newText.indexOf(' ') != -1) {
                                    return "The input cannot have spaces";
                                }
View Full Code Here

            Tuple<String, Integer> currToken = pySelection.getCurrToken();
            String actTok = currToken.o1;
            List<String> parametersAfterCall = null;
            if (actTok.length() == 0) {
                InputDialog dialog = new InputDialog(PyAction.getShell(), asTitle + " name",
                        "Please enter the name of the " + asTitle + " to be created.", "", new IInputValidator() {

                            public String isValid(String newText) {
                                if (newText.length() == 0) {
                                    return "The " + asTitle + " name may not be empty";
                                }
View Full Code Here

            if (settingsModule == null) {
                InputDialog d = new InputDialog(PyAction.getShell(), "Settings module",
                        "Please enter the settings module to be used.\n" + "\n"
                                + "Note that it can be edited later in:\np"
                                + "roject properties > pydev pythonpath > string substitution variables.",
                        selectedProject.getName() + ".settings", new IInputValidator() {

                            public String isValid(String newText) {
                                if (newText.length() == 0) {
                                    return "Text must be entered.";
                                }
View Full Code Here

import org.python.pydev.editor.actions.PyAction;

public class DjangoCreateApp extends DjangoAction {

    public void run(IAction action) {
        IInputValidator validator = new IInputValidator() {

            public String isValid(String newText) {
                if (newText.trim().length() == 0) {
                    return "Name cannot be empty";
                }
View Full Code Here

    if (shortName != null) {
      name.setText(shortName);
      name.setSelection(0, shortName.length());
    }

    final IInputValidator inputValidator = ValidationUtils
        .getRefNameInputValidator(repository, prefix, true);
    name.addModifyListener(new ModifyListener() {
      public void modifyText(ModifyEvent e) {
        String error = inputValidator.isValid(name.getText());
        setErrorMessage(error);
        getButton(OK).setEnabled(error == null);
      }
    });
View Full Code Here

TOP

Related Classes of org.eclipse.jface.dialogs.IInputValidator

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.