Package org.apache.pivot.wtk.validation

Examples of org.apache.pivot.wtk.validation.Validator


            if (textNode != null) {
                if (textInput.getSelectionLength() == 0
                    && textNode.getCharacterCount() == textInput.getMaximumLength()) {
                    Toolkit.getDefaultToolkit().beep();
                } else {
                    Validator validator = textInput.getValidator();
                    boolean strictValidation = textInput.isStrictValidation();

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

                        if (validator.isValid(buf.toString())) {
                            textInput.insert(character);
                        } else {
                            Toolkit.getDefaultToolkit().beep();
                        }
                    } else {
View Full Code Here


            Keyboard.Modifier commandModifier = Platform.getCommandModifier();
            if (keyCode == Keyboard.KeyCode.DELETE
                || keyCode == Keyboard.KeyCode.BACKSPACE) {
                boolean backspace = (keyCode == Keyboard.KeyCode.DELETE ? false : true);

                Validator validator = textInput.getValidator();
                boolean strictValidation = textInput.isStrictValidation();

                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 (backspace) {
                            index--;
                        }

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

                    if (validator.isValid(buf.toString())) {
                        textInput.delete(backspace);
                    } else {
                        Toolkit.getDefaultToolkit().beep();
                    }
                } else {
View Full Code Here

TOP

Related Classes of org.apache.pivot.wtk.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.