use of org.netbeans.validation.api.Validator in project gephi by gephi.
the class CreateTimeIntervalUI method buildValidationPanel.
private void buildValidationPanel() {
validationPanel = new ValidationPanel();
validationPanel.setInnerComponent(this);
ValidationGroup group = validationPanel.getValidationGroup();
group.add(dateFormatComboBox, new Validator<String>() {
@Override
public boolean validate(Problems prblms, String string, String t) {
boolean valid = validateDateFormat(t);
if (!valid) {
prblms.add(NbBundle.getMessage(CreateTimeIntervalUI.class, "CreateTimeIntervalUI.invalid.dateformat"));
}
return valid;
}
});
Validator<String> emptyOrNumberValidator = new Validator<String>() {
@Override
public boolean validate(Problems prblms, String string, String t) {
boolean valid = validateNumberOrEmpty(t);
if (!valid) {
prblms.add(NbBundle.getMessage(CreateTimeIntervalUI.class, "CreateTimeIntervalUI.invalid.number"));
}
return valid;
}
};
group.add(defaultStartNumberText, emptyOrNumberValidator);
group.add(defaultEndNumberText, emptyOrNumberValidator);
validationPanel.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
refreshOkButton();
}
});
}
Aggregations