Package pivot.wtk.text.validation

Examples of pivot.wtk.text.validation.Validator


     *
     * @param validator
     * The validator to use, or <tt>null</tt> to use no validator.
     */
    public void setValidator(Validator validator) {
        Validator previousValidator = this.validator;

        if (validator != previousValidator) {
            this.validator = validator;
            textInputListeners.textValidatorChanged(this, previousValidator);
            updateTextValid();
View Full Code Here


        textinputDateRegex.setValidator(new RegexTextValidator(
            "(19|20)\\d\\d[- /.](0[1-9]|1[012])[-/.](0[1-9]|[12][0-9]|3[01])"));

        // creating a custom model that only accepts "true" or "false"
        textinputCustomBoolean.setText("true");
        textinputCustomBoolean.setValidator(new Validator() {
            public boolean isValid(String s) {
                return "true".equals(s) || "false".equals(s);
            }
        });
View Full Code Here

        textinputDateRegex.setValidator(new RegexTextValidator(
            "(19|20)\\d\\d[- /.](0[1-9]|1[012])[-/.](0[1-9]|[12][0-9]|3[01])"));

        // creating a custom model that only accepts "true" or "false"
        textinputCustomBoolean.setText("true");
        textinputCustomBoolean.setValidator(new Validator() {
            public boolean isValid(String s) {
                return "true".equals(s) || "false".equals(s);
            }
        });
View Full Code Here

     *
     * @param validator
     * The validator to use, or <tt>null</tt> to use no validator.
     */
    public void setValidator(Validator validator) {
        Validator previousValidator = this.validator;

        if (validator != previousValidator) {
            this.validator = validator;
            textInputListeners.textValidatorChanged(this, previousValidator);
            updateTextValid();
View Full Code Here

            TextInput textInput = (TextInput)getComponent();
            TextNode textNode = textInput.getTextNode();

            if (textNode.getCharacterCount() < textInput.getMaximumLength()) {
                int index = textInput.getSelectionStart();
                Validator validator = textInput.getValidator();

                if (validator != null
                    && strictValidation) {
                    StringBuilder buf = new StringBuilder(textNode.getText());
                    buf.insert(index, character);

                    if (validator.isValid(buf.toString())) {
                        textInput.insertText(character, index);
                    } else {
                        ApplicationContext.beep();
                    }
                } else {
View Full Code Here

        if (keyCode == Keyboard.KeyCode.DELETE
            || keyCode == Keyboard.KeyCode.BACKSPACE) {
            Direction direction = (keyCode == Keyboard.KeyCode.DELETE ?
                Direction.FORWARD : Direction.BACKWARD);

            Validator validator = textInput.getValidator();

            if (validator != null
                && strictValidation) {
                StringBuilder buf = new StringBuilder(textNode.getText());
                int index = textInput.getSelectionStart();
                int count = textInput.getSelectionLength();

                if (count > 0) {
                    buf.delete(index, index + count);
                } else {
                    if (direction == Direction.BACKWARD) {
                        index--;
                    }

                    if (index >= 0
                        && index < textNode.getCharacterCount()) {
                        buf.deleteCharAt(index);
                    }
                }

                if (validator.isValid(buf.toString())) {
                    textInput.delete(direction);
                } else {
                    ApplicationContext.beep();
                }
            } else {
View Full Code Here

TOP

Related Classes of pivot.wtk.text.validation.Validator

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.