TextArea area = (TextArea) loader.getNamespace().get("stackTraceArea"); ValidationSupport validation = new ValidationSupport();
ValidationSupport support = new ValidationSupport(); Validator<String> validator = new Validator<String>() { @Override public ValidationResult apply( Control control, String value ) { boolean condition = value != null ? !value .matches( "[\\x00-\\x20]*[+-]?(((((\\p{Digit}+)(\\.)?((\\p{Digit}+)?)([eE][+-]?(\\p{Digit}+))?)|(\\.((\\p{Digit}+))([eE][+-]?(\\p{Digit}+))?)|(((0[xX](\\p{XDigit}+)(\\.)?)|(0[xX](\\p{XDigit}+)?(\\.)(\\p{XDigit}+)))[pP][+-]?(\\p{Digit}+)))[fFdD]?))[\\x00-\\x20]*" ) : value == null; System.out.println( condition ); return ValidationResult.fromMessageIf( control, "not a number", Severity.ERROR, condition ); } }; support.registerValidator( textfield, true, validator );
private NameTextField(ProjectFolder folder) { Objects.requireNonNull(folder); new ValidationSupport().registerValidator(nameTextField, Validator.createEmptyValidator(RESOURCE_BUNDLE.getString("MandatoryName"))); nameTextField.setText(null); fileAlreadyExistsLabel.setTextFill(Color.RED); folderUnique = name -> name == null || !folder.getChild(name).isPresent(); nameTextField.textProperty().addListener((observable, oldName, newName) -> uniqueName.setValue(folderUnique.test(newName))); nameTextField.disabledProperty().addListener((observable, oldName, newName) -> uniqueName.setValue(newName)); uniqueName.addListener((observable, oldUnique, newUnique) -> { if (newUnique || nameTextField.isDisabled()) { fileAlreadyExistsLabel.setText(null); } else { fileAlreadyExistsLabel.setText(MessageFormat.format(RESOURCE_BUNDLE.getString("FileAlreadyExistsInThisFolder"), nameTextField.getText())); } }); }
); if (mandatory) { new ValidationSupport().registerValidator(textField, Validator.createEmptyValidator(RESOURCE_BUNDLE.getString("Mandatory"))); textField.setText(null);
protected AbstractSecurityAnalysisRunnerPane(T node, Scene scene, GseContext context) { this.node = Objects.requireNonNull(node); Project project = node.getProject(); caseSelectionPane = new ProjectNodeSelectionPane<>(project, RESOURCE_BUNDLE.getString("Case"), true, scene.getWindow(), context, ProjectFile.class, ProjectCase.class); contingencyStoreSelectionPane = new ProjectNodeSelectionPane<>(project, RESOURCE_BUNDLE.getString("ContingencyStore"), true, scene.getWindow(), context, ProjectFile.class, ContingenciesProvider.class); setVgap(5); setHgap(5); setPrefWidth(450); setPrefHeight(150); ColumnConstraints column0 = new ColumnConstraints(); ColumnConstraints column1 = new ColumnConstraints(); column1.setHgrow(Priority.ALWAYS); getColumnConstraints().addAll(column0, column1); add(new Label(RESOURCE_BUNDLE.getString("Name") + ":"), 0, 0); add(nameTextField, 1, 0, 2, 1); add(caseSelectionPane.getLabel(), 0, 1); add(caseSelectionPane.getTextField(), 1, 1); add(caseSelectionPane.getButton(), 2, 1); add(contingencyStoreSelectionPane.getLabel(), 0, 2); add(contingencyStoreSelectionPane.getTextField(), 1, 2); add(contingencyStoreSelectionPane.getButton(), 2, 2); new ValidationSupport().registerValidator(nameTextField, Validator.createEmptyValidator(RESOURCE_BUNDLE.getString("MandatoryName"))); }
this.validationSupport = new ValidationSupport();
txPassword.setText(new String(initialUserInfo == null ? "" : initialUserInfo.getValue())); //$NON-NLS-1$ ValidationSupport validationSupport = new ValidationSupport(); Platform.runLater( () -> { String requiredFormat = "'%s' is required"; //$NON-NLS-1$