List of usage examples for com.jgoodies.validation ValidationResult hasWarnings
public boolean hasWarnings()
Note that this method checks for warning messages only.
From source file:org.archiviststoolkit.editor.rde.RapidResourceComponentDataEntry.java
License:Open Source License
private boolean validateData() { ValidationResult validationResult = validator.validate(); if (validationResult.hasErrors()) { JGoodiesValidationUtils.showValidationMessage(this, "To save the record, please fix the following errors:", validationResult); return false; }//from w w w . j a v a 2s . c om if (validationResult.hasWarnings()) { JGoodiesValidationUtils.showValidationMessage(this, "Note: some fields are invalid.", validationResult); } return true; }
From source file:org.archiviststoolkit.editor.rde.RapidResourceComponentDataEntry2.java
License:Open Source License
private boolean validateData() { // generate resource components try {/* w w w . jav a 2s . c om*/ resourceComponent = generateComponentRecord(); ATValidator validator = null; // validate any instances Set<ArchDescriptionInstances> instances = resourceComponent.getInstances(); for (ArchDescriptionInstances adi : instances) { if (adi instanceof ArchDescriptionAnalogInstances) { validator = ValidatorFactory.getInstance().getValidator((ArchDescriptionAnalogInstances) adi); } else if (adi instanceof ArchDescriptionDigitalInstances) { DigitalObjects digitalObject = ((ArchDescriptionDigitalInstances) adi).getDigitalObject(); validator = ValidatorFactory.getInstance().getValidator(digitalObject); } else { continue; // should never get here } ValidationResult validationResult = validator.validate(); if (validationResult.hasErrors()) { JGoodiesValidationUtils.showValidationMessage(this, "To save the record, please fix the following errors:", validationResult); return false; } if (validationResult.hasWarnings()) { JGoodiesValidationUtils.showValidationMessage(this, "Note: some fields are invalid.", validationResult); } } // validate any repeating data Set<ArchDescriptionRepeatingData> repeatingData = resourceComponent.getRepeatingData(); for (ArchDescriptionRepeatingData adrd : repeatingData) { if (adrd instanceof ArchDescriptionNotes) { validator = ValidatorFactory.getInstance().getValidator((ArchDescriptionNotes) adrd); } else { continue; // only validating ArchDescription Notes for now } ValidationResult validationResult = validator.validate(); if (validationResult.hasErrors()) { JGoodiesValidationUtils.showValidationMessage(this, "To save the record, please fix the following errors:", validationResult); return false; } if (validationResult.hasWarnings()) { JGoodiesValidationUtils.showValidationMessage(this, "Note: some fields are invalid.", validationResult); } } // get resource component validator validator = ValidatorFactory.getInstance().getValidator(resourceComponent); ValidationResult validationResult = validator.validate(); if (validationResult.hasErrors()) { JGoodiesValidationUtils.showValidationMessage(this, "To save the record, please fix the following errors:", validationResult); return false; } if (validationResult.hasWarnings()) { JGoodiesValidationUtils.showValidationMessage(this, "Note: some fields are invalid.", validationResult); } } catch (RDEPopulateException e) { resourceComponent = null; return false; } return true; }
From source file:org.archiviststoolkit.mydomain.DomainObject.java
License:Open Source License
public boolean validateAndDisplayDialog(EventObject ae) { ATValidator validator = ValidatorFactory.getInstance().getValidator(this); if (validator == null) { //nothing registered so just return true return true; } else {/*from w w w. j a va 2s .com*/ ValidationResult validationResult = validator.validate(); if (validationResult.hasErrors()) { JGoodiesValidationUtils.showValidationMessage(ae, "To save the record, please fix the following errors:", validationResult); return false; } if (validationResult.hasWarnings()) { JGoodiesValidationUtils.showValidationMessage(ae, "Note: some fields are invalid.", validationResult); } return true; } }
From source file:org.archiviststoolkit.plugin.ATPluginUtils.java
License:Open Source License
/** * Method to valid a AT record. Calling this ensures that no invalid * records are saved to the database// w ww .j a v a 2 s. c o m * * @param component UI component that is requesting validation of the record * @param record The AT record to validate * @return true if the record valide, false otherwise */ public static boolean validateRecord(Component component, DomainObject record) { ATValidator validator = ValidatorFactory.getInstance().getValidator(record); if (validator == null) { //nothing registered so just return true return true; } else { ValidationResult validationResult = validator.validate(); if (validationResult.hasErrors()) { JGoodiesValidationUtils.showValidationMessage(component, "To save the record, please fix the following errors:", validationResult); return false; } if (validationResult.hasWarnings()) { JGoodiesValidationUtils.showValidationMessage(component, "Note: some fields are invalid.", validationResult); } return true; } }