Java 类org.eclipse.jface.dialogs.IInputValidator 实例源码

项目:dockerfoundry    文件:DockerContainersView.java   
private void hookRenameAction() {
    DockerContainerElement elem = getSelectedElement();
    if(elem != null && getClient() != null){
        IInputValidator validator = new IInputValidator() {
            public String isValid(String newText) {
                if (newText.contains("\\") || newText.contains(":") || newText.contains("/")
                        )
                    return newText + " is not a valid Docker container's name.";
                else
                    return null;
            }
        };
        InputDialog dialog = new InputDialog(viewer.getControl().getShell(), "Rename an existing container",
                "New name:", elem.getNames().get(0)+"2",
                validator);
        if (dialog.open() == Window.OK) {
            String newName = dialog.getValue();
            //@ TODO docker client does not provide renaming API now.
        } 
    }
}
项目:PDFReporter-Studio    文件:AddKeyAction.java   
/**
 * @see org.eclipse.jface.action.Action#run()
 */
@Override
public void run() {
    KeyTreeNode node = getNodeSelection();
    String key = node != null ? node.getMessageKey() : "new_key";
    String msgHead = Messages.dialog_add_head;
    String msgBody = Messages.dialog_add_body;
    InputDialog dialog = new InputDialog(getShell(), msgHead, msgBody, key,
            new IInputValidator() {
                public String isValid(String newText) {
                    if (getBundleGroup().isMessageKey(newText)) {
                        return Messages.dialog_error_exists;
                    }
                    return null;
                }
            });
    dialog.open();
    if (dialog.getReturnCode() == Window.OK) {
        String inputKey = dialog.getValue();
        MessagesBundleGroup messagesBundleGroup = getBundleGroup();
        messagesBundleGroup.addMessages(inputKey);
    }
}
项目:gama    文件:EditboxPreferencePage.java   
@Override
public void widgetSelected(final SelectionEvent e) {
    final InputDialog dialog = new InputDialog(getShell(), "New Category", "Name:", null,
            new IInputValidator() {

                @Override
                public String isValid(final String newText) {
                    if (newText != null && newText.trim().length() > 0
                            && !contains(categoryList.getItems(), newText)) {
                        return null;
                    }
                    return "Unique name required";
                }
            });

    if (dialog.open() == Window.OK) {
        newTab(dialog.getValue());
        providersChanged = true;
    }

}
项目:gama    文件:EditboxPreferencePage.java   
@Override
public void widgetSelected(final SelectionEvent e) {
    final InputDialog dialog = new InputDialog(getShell(), "New Name", "File name pattern like *.java, my.xml:",
            null, new IInputValidator() {

                @Override
                public String isValid(final String newText) {
                    if (newText != null && newText.trim().length() > 0) {
                        return null;
                    }
                    return "";
                }
            });

    if (dialog.open() == Window.OK) {
        addFileName(dialog.getValue());
    }

}
项目:gama    文件:RenameResourceAction.java   
/**
 * Return the new name to be given to the target resource.
 *
 * @return java.lang.String
 * @param resource
 *            the resource to query status on
 */
protected String queryNewResourceName(final IResource resource) {
    final IWorkspace workspace = IDEWorkbenchPlugin.getPluginWorkspace();
    final IPath prefix = resource.getFullPath().removeLastSegments(1);
    final IInputValidator validator = string -> {
        if (resource.getName()
                .equals(string)) { return IDEWorkbenchMessages.RenameResourceAction_nameMustBeDifferent; }
        final IStatus status = workspace.validateName(string, resource.getType());
        if (!status.isOK()) { return status.getMessage(); }
        if (workspace.getRoot()
                .exists(prefix.append(string))) { return IDEWorkbenchMessages.RenameResourceAction_nameExists; }
        return null;
    };

    final InputDialog dialog =
            new InputDialog(WorkbenchHelper.getShell(), IDEWorkbenchMessages.RenameResourceAction_inputDialogTitle,
                    IDEWorkbenchMessages.RenameResourceAction_inputDialogMessage, resource.getName(), validator);
    dialog.setBlockOnOpen(true);
    final int result = dialog.open();
    if (result == Window.OK)
        return dialog.getValue();
    return null;
}
项目:vTM-eclipse    文件:ZDialog.java   
/**
 * Show a custom input dialog with a message and configurable buttons.
 * @param title The dialog window's title.
 * @param message The message to display in the dialog
 * @param icon The icon to display next to the message, or null to not show
 * an icon.
 * @param validator Class to check a the entered text is valid. Must be set.
 * @param initial The initial text of the input text box.
 * @param defaultOption The default option (button)
 * @param options The different options (buttons) the dialog should have.
 * @return The dialog option that was selected.
 */
public static CustomResult showCustomInputDialog( String title, String message, 
   Icon icon,
   IInputValidator validator, String initial,
   DialogOption defaultOption, DialogOption ... options )
{
   DialogRunner runner = new DialogRunner( 
      DialogType.CUSTOM, title, message
   );
   runner.setIcon( icon );
   runner.setValidator( validator );
   runner.setInitialString( initial );
   runner.setDefaultOption( defaultOption );
   runner.setOptions( options );

   SWTUtil.exec( runner );

   return new CustomResult( runner.getResultString(), runner.getResultOption() );
}
项目:APICloud-Studio    文件:InputURLDialog.java   
/**
   * Creates an input URL dialog with OK and Cancel buttons. Note that the dialog
   * will have no visual representation (no widgets) until it is told to open.
   * <p>
   * Note that the <code>open</code> method blocks for input dialogs.
   * </p>
   * 
   * @param parentShell
   *            the parent shell, or <code>null</code> to create a top-level
   *            shell
   * @param dialogTitle
   *            the dialog title, or <code>null</code> if none
   * @param dialogMessage
   *            the dialog message, or <code>null</code> if none
   * @param initialValue
   *            the initial input value, or <code>null</code> if none
   *            (equivalent to the empty string)
   */
  public InputURLDialog(Shell parentShell, String dialogTitle,
          String dialogMessage, String initialValue) {
      super(parentShell);
      this.title = dialogTitle;
      message = dialogMessage;
      if (initialValue == null) {
    value = StringUtil.EMPTY;
} else {
    value = initialValue;
}
      this.validator = new IInputValidator() {
    public String isValid(String newText) {
        try {
            new URI(newText).toURL();
        } catch (Exception e) {
            return EplMessages.InputURLDialog_InvalidURL;
        }
        return null;
    }
      };
  }
项目:mytourbook    文件:AddKeyAction.java   
/**
 * @see org.eclipse.jface.action.Action#run()
 */
public void run() {
    KeyTreeNode node = getNodeSelection();
    String key = node.getMessageKey();
    String msgHead = MessagesEditorPlugin.getString("dialog.add.head");
    String msgBody = MessagesEditorPlugin.getString("dialog.add.body");
    InputDialog dialog = new InputDialog(
            getShell(), msgHead, msgBody, key, new IInputValidator() {
                public String isValid(String newText) {
                    if (getBundleGroup().isMessageKey(newText)) {
                        return  MessagesEditorPlugin.getString(
                                "dialog.error.exists");
                    }
                    return null;
                }
            });
    dialog.open();
    if (dialog.getReturnCode() == Window.OK ) {
        String inputKey = dialog.getValue();
        MessagesBundleGroup messagesBundleGroup = getBundleGroup();
        messagesBundleGroup.addMessages(inputKey);
    }
}
项目:mytourbook    文件:AddKeyAction.java   
/**
 * @see org.eclipse.jface.action.Action#run()
 */
public void run() {
    KeyTreeNode node = getNodeSelection();
    String key = node.getMessageKey();
    String msgHead = MessagesEditorPlugin.getString("dialog.add.head");
    String msgBody = MessagesEditorPlugin.getString("dialog.add.body");
    InputDialog dialog = new InputDialog(
            getShell(), msgHead, msgBody, key, new IInputValidator() {
                public String isValid(String newText) {
                    if (getBundleGroup().isMessageKey(newText)) {
                        return  MessagesEditorPlugin.getString(
                                "dialog.error.exists");
                    }
                    return null;
                }
            });
    dialog.open();
    if (dialog.getReturnCode() == Window.OK ) {
        String inputKey = dialog.getValue();
        MessagesBundleGroup messagesBundleGroup = getBundleGroup();
        messagesBundleGroup.addMessages(inputKey);
    }
}
项目:mytourbook    文件:AddKeyAction.java   
/**
 * @see org.eclipse.jface.action.Action#run()
 */
public void run() {
    KeyTreeNode node = getNodeSelection();
    String key = node.getMessageKey();
    String msgHead = MessagesEditorPlugin.getString("dialog.add.head");
    String msgBody = MessagesEditorPlugin.getString("dialog.add.body");
    InputDialog dialog = new InputDialog(
            getShell(), msgHead, msgBody, key, new IInputValidator() {
                public String isValid(String newText) {
                    if (getBundleGroup().isMessageKey(newText)) {
                        return  MessagesEditorPlugin.getString(
                                "dialog.error.exists");
                    }
                    return null;
                }
            });
    dialog.open();
    if (dialog.getReturnCode() == Window.OK ) {
        String inputKey = dialog.getValue();
        MessagesBundleGroup messagesBundleGroup = getBundleGroup();
        messagesBundleGroup.addMessages(inputKey);
    }
}
项目:OpenSPIFe    文件:CreateWaiverOperation.java   
public static WaiverRationaleDialog getWaiverRationaleDialog(Shell shell, String dialogMessage) {
    return new WaiverRationaleDialog(shell,
            "Waiver Rationale",
            dialogMessage,
            "Not specified", new IInputValidator() {
                @Override
                public String isValid(String newText) {
                    // Don't allow '<' '>' characters
                    String invalidChars = newText.replaceAll("[^><]", "");
                    if (!StringUtils.isEmpty(invalidChars)) {
                        return "Please remove the following invalid character(s): '" + invalidChars + "'";
                    }
                    return null;
                }
            });
}
项目:Eclipse-Postfix-Code-Completion    文件:NewNameQueries.java   
private static INewNameQuery createStaticQuery(final IInputValidator validator, final String message, final String initial, final Shell shell){
    return new INewNameQuery(){
        public String getNewName() throws OperationCanceledException {
            InputDialog dialog= new InputDialog(shell, ReorgMessages.ReorgQueries_nameConflictMessage, message, initial, validator) {
                /* (non-Javadoc)
                 * @see org.eclipse.jface.dialogs.InputDialog#createDialogArea(org.eclipse.swt.widgets.Composite)
                 */
                @Override
                protected Control createDialogArea(Composite parent) {
                    Control area= super.createDialogArea(parent);
                    TextFieldNavigationHandler.install(getText());
                    return area;
                }
            };
            if (dialog.open() == Window.CANCEL)
                throw new OperationCanceledException();
            return dialog.getValue();
        }
    };
}
项目:Eclipse-Postfix-Code-Completion    文件:NewNameQueries.java   
private static IInputValidator createResourceNameValidator(final IResource res){
    IInputValidator validator= new IInputValidator(){
        public String isValid(String newText) {
            if (newText == null || "".equals(newText) || res.getParent() == null) //$NON-NLS-1$
                return INVALID_NAME_NO_MESSAGE;
            if (res.getParent().findMember(newText) != null)
                return ReorgMessages.ReorgQueries_resourceWithThisNameAlreadyExists;
            if (! res.getParent().getFullPath().isValidSegment(newText))
                return ReorgMessages.ReorgQueries_invalidNameMessage;
            IStatus status= res.getParent().getWorkspace().validateName(newText, res.getType());
            if (status.getSeverity() == IStatus.ERROR)
                return status.getMessage();

            if (res.getName().equalsIgnoreCase(newText))
                return ReorgMessages.ReorgQueries_resourceExistsWithDifferentCaseMassage;

            return null;
        }
    };
    return validator;
}
项目:Eclipse-Postfix-Code-Completion    文件:NewNameQueries.java   
private static IInputValidator createCompilationUnitNameValidator(final ICompilationUnit cu) {
    IInputValidator validator= new IInputValidator(){
        public String isValid(String newText) {
            if (newText == null || "".equals(newText)) //$NON-NLS-1$
                return INVALID_NAME_NO_MESSAGE;
            String newCuName= JavaModelUtil.getRenamedCUName(cu, newText);
            IStatus status= JavaConventionsUtil.validateCompilationUnitName(newCuName, cu);
            if (status.getSeverity() == IStatus.ERROR)
                return status.getMessage();
            RefactoringStatus refStatus;
            refStatus= Checks.checkCompilationUnitNewName(cu, newText);
            if (refStatus.hasFatalError())
                return refStatus.getMessageMatchingSeverity(RefactoringStatus.FATAL);

            if (cu.getElementName().equalsIgnoreCase(newCuName))
                return ReorgMessages.ReorgQueries_resourceExistsWithDifferentCaseMassage;

            return null;
        }
    };
    return validator;
}
项目:Eclipse-Postfix-Code-Completion    文件:NewNameQueries.java   
private static IInputValidator createPackageNameValidator(final IPackageFragment pack) {
    IInputValidator validator= new IInputValidator(){
        public String isValid(String newText) {
            if (newText == null || "".equals(newText)) //$NON-NLS-1$
                return INVALID_NAME_NO_MESSAGE;
            IStatus status= JavaConventionsUtil.validatePackageName(newText, pack);
            if (status.getSeverity() == IStatus.ERROR)
                return status.getMessage();

            IJavaElement parent= pack.getParent();
            try {
                if (parent instanceof IPackageFragmentRoot){
                    if (! RenamePackageProcessor.isPackageNameOkInRoot(newText, (IPackageFragmentRoot)parent))
                        return ReorgMessages.ReorgQueries_packagewithThatNameexistsMassage;
                }
            } catch (CoreException e) {
                return INVALID_NAME_NO_MESSAGE;
            }
            if (pack.getElementName().equalsIgnoreCase(newText))
                return ReorgMessages.ReorgQueries_resourceExistsWithDifferentCaseMassage;

            return null;
        }
    };
    return validator;
}
项目:cmake4cdt    文件:AvailArchsEditor.java   
@Override
protected String getNewInputObject() {

    IInputValidator validator = new IInputValidator() {
        public String isValid(String newText) {
            if(newText.contains("\t \n\r"))
                return "No whitespace characters allowed in architecture name";
            else
                return null;
        }
    };
    InputDialog dialog = new InputDialog(getShell(), 
            "Name of new architecture", 
            "Please specify the name of the new architectire. \n" +
            "I must a name known to buildif, e.g. arm, ppc, x86", 
            null, 
            validator);
    if(dialog.open() == Window.OK) {
        return dialog.getValue();
    }else{
        return null;
    }
}
项目:cmake4cdt    文件:TargetDevicesEditor.java   
@Override
protected String getNewInputObject() {

    IInputValidator validator = new IInputValidator() {
        public String isValid(String newText) {
            if(newText.contains("\t \n\r"))
                return "No whitespace characters allowed in architecture name";
            else
                return null;
        }
    };
    InputDialog dialog = new InputDialog(getShell(), 
            "Name of new instrument", 
            "Please specify the name of the new instrument. \n" +
            "This instrument name will be used in directory \n" +
            "names for projects that have been marked as \n" +
            "instrument specific in projects properties and when \n" +
            "assembling the installation path.", 
            null, 
            validator);
    if(dialog.open() == Window.OK) {
        return dialog.getValue();
    }else{
        return null;
    }
}
项目:emfstore-rest    文件:ImportProjectHandler.java   
/**
 * Shows a dialog so that the user can provide a name for the imported project.
 * 
 * @param initialProjectName the name of the project that should be shown when opening the dialog
 * @return the entered project name
 */
private String showProjectNameDialog(String initialProjectName) {

    IInputValidator inputValidator = new IInputValidator() {
        public String isValid(String newText) {
            if (newText == null || newText.equals("") || newText.matches("\\s*")) {
                return "No project name provided!";
            }
            return null;
        }

    };

    InputDialog inputDialog = new InputDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
        "Project Name", "Please enter a name for the imported project:", initialProjectName, inputValidator);

    if (inputDialog.open() == Dialog.OK) {
        return inputDialog.getValue();
    } else {
        return null;
    }

}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:NewNameQueries.java   
private static INewNameQuery createStaticQuery(final IInputValidator validator, final String message, final String initial, final Shell shell){
    return new INewNameQuery(){
        public String getNewName() throws OperationCanceledException {
            InputDialog dialog= new InputDialog(shell, ReorgMessages.ReorgQueries_nameConflictMessage, message, initial, validator) {
                /* (non-Javadoc)
                 * @see org.eclipse.jface.dialogs.InputDialog#createDialogArea(org.eclipse.swt.widgets.Composite)
                 */
                @Override
                protected Control createDialogArea(Composite parent) {
                    Control area= super.createDialogArea(parent);
                    TextFieldNavigationHandler.install(getText());
                    return area;
                }
            };
            if (dialog.open() == Window.CANCEL)
                throw new OperationCanceledException();
            return dialog.getValue();
        }
    };
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:NewNameQueries.java   
private static IInputValidator createResourceNameValidator(final IResource res){
    IInputValidator validator= new IInputValidator(){
        public String isValid(String newText) {
            if (newText == null || "".equals(newText) || res.getParent() == null) //$NON-NLS-1$
                return INVALID_NAME_NO_MESSAGE;
            if (res.getParent().findMember(newText) != null)
                return ReorgMessages.ReorgQueries_resourceWithThisNameAlreadyExists;
            if (! res.getParent().getFullPath().isValidSegment(newText))
                return ReorgMessages.ReorgQueries_invalidNameMessage;
            IStatus status= res.getParent().getWorkspace().validateName(newText, res.getType());
            if (status.getSeverity() == IStatus.ERROR)
                return status.getMessage();

            if (res.getName().equalsIgnoreCase(newText))
                return ReorgMessages.ReorgQueries_resourceExistsWithDifferentCaseMassage;

            return null;
        }
    };
    return validator;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:NewNameQueries.java   
private static IInputValidator createCompilationUnitNameValidator(final ICompilationUnit cu) {
    IInputValidator validator= new IInputValidator(){
        public String isValid(String newText) {
            if (newText == null || "".equals(newText)) //$NON-NLS-1$
                return INVALID_NAME_NO_MESSAGE;
            String newCuName= JavaModelUtil.getRenamedCUName(cu, newText);
            IStatus status= JavaConventionsUtil.validateCompilationUnitName(newCuName, cu);
            if (status.getSeverity() == IStatus.ERROR)
                return status.getMessage();
            RefactoringStatus refStatus;
            refStatus= Checks.checkCompilationUnitNewName(cu, newText);
            if (refStatus.hasFatalError())
                return refStatus.getMessageMatchingSeverity(RefactoringStatus.FATAL);

            if (cu.getElementName().equalsIgnoreCase(newCuName))
                return ReorgMessages.ReorgQueries_resourceExistsWithDifferentCaseMassage;

            return null;
        }
    };
    return validator;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:NewNameQueries.java   
private static IInputValidator createPackageNameValidator(final IPackageFragment pack) {
    IInputValidator validator= new IInputValidator(){
        public String isValid(String newText) {
            if (newText == null || "".equals(newText)) //$NON-NLS-1$
                return INVALID_NAME_NO_MESSAGE;
            IStatus status= JavaConventionsUtil.validatePackageName(newText, pack);
            if (status.getSeverity() == IStatus.ERROR)
                return status.getMessage();

            IJavaElement parent= pack.getParent();
            try {
                if (parent instanceof IPackageFragmentRoot){
                    if (! RenamePackageProcessor.isPackageNameOkInRoot(newText, (IPackageFragmentRoot)parent))
                        return ReorgMessages.ReorgQueries_packagewithThatNameexistsMassage;
                }
            } catch (CoreException e) {
                return INVALID_NAME_NO_MESSAGE;
            }
            if (pack.getElementName().equalsIgnoreCase(newText))
                return ReorgMessages.ReorgQueries_resourceExistsWithDifferentCaseMassage;

            return null;
        }
    };
    return validator;
}
项目:Bookmark-plugin-for-eclipse    文件:ValidationUtils.java   
public static IInputValidator getIInputValidatorInstance() {
    IInputValidator validator = new IInputValidator() {

        @Override
        public String isValid(String input) {
            try {
                if (input.matches("(?s)[^\\\\/:*?\"<>|\\x00-\\x1F]+$")) {
                    return null;
                } else {
                    return "Invalid file name";
                }
            } catch (PatternSyntaxException ex) {
                // Syntax error in the regular expression
            }
            return "There occure an error in the bookmark plugin,report it to the author.";
        }

    };
    return validator;
}
项目:Pydev    文件:DialogHelpers.java   
public static Integer openAskInt(String title, String message, int initial) {
    Shell shell = EditorUtils.getShell();
    String initialValue = "" + initial;
    IInputValidator validator = new IInputValidator() {

        @Override
        public String isValid(String newText) {
            if (newText.length() == 0) {
                return "At least 1 char must be provided.";
            }
            try {
                Integer.parseInt(newText);
            } catch (Exception e) {
                return "A number is required.";
            }
            return null;
        }
    };
    InputDialog dialog = new InputDialog(shell, title, message, initialValue, validator);
    dialog.setBlockOnOpen(true);
    if (dialog.open() == Window.OK) {
        return Integer.parseInt(dialog.getValue());
    }
    return null;
}
项目:Pydev    文件:DjangoMakeMigrations.java   
@Override
public void run(IAction action) {
    IInputValidator validator = new IInputValidator() {

        @Override
        public String isValid(String newText) {
            if (newText.trim().length() == 0) {
                return "Name cannot be empty";
            }
            return null;
        }
    };
    InputDialog d = new InputDialog(EditorUtils.getShell(), "App name",
            "Name of the django app to makemigrations on", "",
            validator);

    int retCode = d.open();
    if (retCode == InputDialog.OK) {
        createApp(d.getValue().trim());
    }
}
项目:Pydev    文件:DjangoCreateApp.java   
@Override
public void run(IAction action) {
    IInputValidator validator = new IInputValidator() {

        @Override
        public String isValid(String newText) {
            if (newText.trim().length() == 0) {
                return "Name cannot be empty";
            }
            return null;
        }
    };
    InputDialog d = new InputDialog(EditorUtils.getShell(), "App name", "Name of the django app to be created", "",
            validator);

    int retCode = d.open();
    if (retCode == InputDialog.OK) {
        createApp(d.getValue().trim());
    }
}
项目:arx    文件:DialogComboSelection.java   
/**
 * Creates a new instance
 * @param parentShell
 * @param dialogTitle
 * @param dialogMessage
 * @param choices
 * @param initialValue
 * @param validator
 */
public DialogComboSelection(Shell parentShell,
                            String dialogTitle,
                            String dialogMessage,
                            String[] choices,
                            String initialValue,
                            IInputValidator validator) {
    super(parentShell);
    this.title = dialogTitle;
    message = dialogMessage;
    this.choices = choices;
    if (initialValue == null) {
        value = "";//$NON-NLS-1$
    } else {
        value = initialValue;
    }
    this.validator = validator;
}
项目:launchpi    文件:RPITab.java   
private void createNewHost() {
    final IHost[] hosts = getHosts();
    IInputValidator validator = new HostNameInputValidator(hosts);
    InputDialog inputDialog = new InputDialog(getShell(), Messages.New_RPI_Host, Messages.Enter_Host_Name, "", validator); //$NON-NLS-3$ //$NON-NLS-1$
    int result = inputDialog.open();
    if (result == Dialog.OK) {
        String hostName = inputDialog.getValue();
        inputDialog.close();
        try {
            IHost host = RSECorePlugin.getTheSystemRegistry().createHost(
                    RSECorePlugin.getTheCoreRegistry().getSystemTypeById(IRSESystemType.SYSTEMTYPE_SSH_ONLY_ID), hostName, hostName, hostName);
            updateRPICombo(getHosts(), host);
        } catch (Exception ex) {
            LaunchPlugin.reportError(Messages.Create_Config_Failed, ex);
        }
    }

}
项目:elexis-3-core    文件:FallPlaneRechnung.java   
public Object execute(ExecutionEvent arg0) throws ExecutionException{
    InputDialog dlg =
        new InputDialog(UiDesk.getTopShell(), Messages.FallPlaneRechnung_PlanBillingHeading,
            Messages.FallPlaneRechnung_PlanBillingAfterDays, "30", new IInputValidator() { //$NON-NLS-1$

                public String isValid(String newText){
                    if (newText.matches("[0-9]*")) { //$NON-NLS-1$
                        return null;
                    }
                    return Messages.FallPlaneRechnung_PlanBillingPleaseEnterPositiveInteger;
                }
            });
    if (dlg.open() == Dialog.OK) {
        return dlg.getValue();
    }
    return null;
}
项目:n4js    文件:InputComposedValidator.java   
@Override
public String isValid(String newText) {
    String result = null;
    for (IInputValidator validator : validators) {
        result = validator.isValid(newText);
        if (result != null)
            break;
    }

    return result;
}
项目:n4js    文件:ExternalLibraryPreferencePage.java   
/**
 * Validator that checks if given name is valid package name and can be used to install new package (i.e. there is
 * no installed package with the same name).
 *
 * @return validator checking if provided name can be used to install new package
 */
private IInputValidator getPackageNameToInstallValidator() {
    return InputComposedValidator.compose(
            getBasicPackageValidator(), InputFunctionalValidator.from(
                    (final String name) -> !isNpmWithNameInstalled(name) ? null
                            /* error message */
                            : "The npm package '" + name + "' is already available."));
}
项目:n4js    文件:ExternalLibraryPreferencePage.java   
/**
 * Validator that checks if given name is valid package name and can be used to uninstall new package (i.e. there is
 * installed package with the same name).
 *
 * @return validator checking if provided name can be used to install new package
 */
private IInputValidator getPackageNameToUninstallValidator() {
    return InputComposedValidator.compose(
            getBasicPackageValidator(), InputFunctionalValidator.from(
                    (final String name) -> isNpmWithNameInstalled(name) ? null
                            /* error case */
                            : "The npm package '" + name + "' is not installed."));
}
项目:n4js    文件:ExternalLibraryPreferencePage.java   
private IInputValidator getBasicPackageValidator() {
    return InputFunctionalValidator.from(
            (final String name) -> {
                if (npmManager.invalidPackageName(name))
                    return "The npm package name should be specified.";
                for (int i = 0; i < name.length(); i++) {
                    if (Character.isWhitespace(name.charAt(i)))
                        return "The npm package name must not contain any whitespaces.";

                    if (Character.isUpperCase(name.charAt(i)))
                        return "The npm package name must not contain any upper case letter.";
                }
                return null;
            });
}
项目:n4js    文件:InstallNpmDependencyDialog.java   
/** Creates dialog with custom validators. */
public InstallNpmDependencyDialog(Shell parentShell, IInputValidator packageNameValidator,
        IInputValidator packageVersionValidator) {
    super(parentShell);
    this.packageNameValidator = packageNameValidator;
    this.packageVersionValidator = packageVersionValidator;
}
项目:n4js    文件:InstallNpmDependencyButtonListener.java   
InstallNpmDependencyButtonListener(BiFunction<Map<String, String>, IProgressMonitor, IStatus> installAction,
        Supplier<IInputValidator> packageNameValidator, Supplier<IInputValidator> packageVersionValidator,
        StatusHelper statusHelper) {
    this.installAction = installAction;
    this.packageNameValidator = packageNameValidator;
    this.packageVersionValidator = packageVersionValidator;
    this.statusHelper = statusHelper;
}
项目:n4js    文件:UninstallNpmDependencyButtonListener.java   
UninstallNpmDependencyButtonListener(BiFunction<Collection<String>, IProgressMonitor, IStatus> uninstallAction,
        Supplier<IInputValidator> validator, StatusHelper statusHelper, Supplier<String> initalValue) {
    this.statusHelper = statusHelper;
    this.validator = validator;
    this.uninstallAction = uninstallAction;
    this.initalValue = initalValue;
}
项目:pgcodekeeper    文件:IgnoredObjectPrefListEditor.java   
public NewIgnoredObjectDialog(Shell shell, IgnoredObject objInitial) {
    super(shell, Messages.IgnoredObjectPrefListEditor_new_ignored, Messages.IgnoredObjectPrefListEditor_object_name,
            objInitial == null ? null : objInitial.getName(),
                    new IInputValidator() {

        @Override
        public String isValid(String newText) {
            return newText.isEmpty() ? Messages.IgnoredObjectPrefListEditor_enter_name : null;
        }
    });
    this.objInitial = objInitial;
}
项目:avro-schema-editor    文件:TextValidator.java   
public TextValidator(Text control, int position, IInputValidator validator, IValueChangeListener valueChangeListener) {
    this.validator = validator;
    this.valueChangeListener = valueChangeListener;
    this.deco = new ControlDecoration(control, position, control.getParent());
    this.deco.setMarginWidth(2);
    this.errorImg = AvroSchemaEditorActivator.getImage(AvroSchemaEditorImages.ERROR_OVERLAY);
    control.addModifyListener(this);
    control.addFocusListener(this);
    control.addKeyListener(this);
}
项目:avro-schema-editor    文件:AvroNameValidatorProvider.java   
@Override
public IInputValidator getInputValidator(AvroNode node, AvroContext context) {

    NodeType type = node.getType();
    switch (type) {
    case RECORD:
    case ENUM:
    case FIXED:
        return new AvroNameValidator(context, node);
    default:
        return null;
    }

}
项目:avro-schema-editor    文件:AvroNameSpaceValidatorProvider.java   
@Override
public IInputValidator getInputValidator(AvroNode node, AvroContext context) {

    NodeType type = node.getType();
    switch (type) {
    case RECORD:
    case ENUM:
    case FIXED:
        return new AvroNameSpaceValidator(context, node);
    default:
        return null;
    }

}