List of usage examples for com.jgoodies.validation ValidationResult addError
public ValidationResult addError(String text)
From source file:org.archiviststoolkit.dialog.BatchLocationValidator.java
License:Open Source License
public ValidationResult validate() { ValidationResult result = new ValidationResult(); if (!checkForMinimumRequirements()) result.addError("Building and Coordinate1 are mandatory"); if (dialog.getRepository() == null) result.addError("Repository is mandatory"); ATFieldInfo field = ATFieldInfo.getFieldInfo(Locations.class, Locations.PROPERTYNAME_BUILDING); if (!ValidationUtils.hasMaximumLength(dialog.getBuilding(), field.getStringLengthLimit())) { result.addError(field.getFieldName() + " has a maximum length of " + field.getStringLengthLimit() + " characters"); }//w w w . j a v a2 s . c om field = ATFieldInfo.getFieldInfo(Locations.class, Locations.PROPERTYNAME_FLOOR); if (!ValidationUtils.hasMaximumLength(dialog.getFloor(), field.getStringLengthLimit())) { result.addError(field.getFieldName() + " has a maximum length of " + field.getStringLengthLimit() + " characters"); } field = ATFieldInfo.getFieldInfo(Locations.class, Locations.PROPERTYNAME_ROOM); if (!ValidationUtils.hasMaximumLength(dialog.getRoom(), field.getStringLengthLimit())) { result.addError(field.getFieldName() + " has a maximum length of " + field.getStringLengthLimit() + " characters"); } field = ATFieldInfo.getFieldInfo(Locations.class, Locations.PROPERTYNAME_AREA); if (!ValidationUtils.hasMaximumLength(dialog.getArea(), field.getStringLengthLimit())) { result.addError(field.getFieldName() + " has a maximum length of " + field.getStringLengthLimit() + " characters"); } field = ATFieldInfo.getFieldInfo(Locations.class, Locations.PROPERTYNAME_COORDINATE_1_LABEL); if (!ValidationUtils.hasMaximumLength(dialog.getCoordinate1Label(), field.getStringLengthLimit())) { result.addError(field.getFieldName() + " has a maximum length of " + field.getStringLengthLimit() + " characters"); } field = ATFieldInfo.getFieldInfo(Locations.class, Locations.PROPERTYNAME_COORDINATE_2_LABEL); if (!ValidationUtils.hasMaximumLength(dialog.getCoordinate2Label(), field.getStringLengthLimit())) { result.addError(field.getFieldName() + " has a maximum length of " + field.getStringLengthLimit() + " characters"); } field = ATFieldInfo.getFieldInfo(Locations.class, Locations.PROPERTYNAME_COORDINATE_3_LABEL); if (!ValidationUtils.hasMaximumLength(dialog.getCoordinate3Label(), field.getStringLengthLimit())) { result.addError(field.getFieldName() + " has a maximum length of " + field.getStringLengthLimit() + " characters"); } return result; }
From source file:org.archiviststoolkit.editor.rde.RapidResourceComponentDataEntryValidator.java
License:Open Source License
public ValidationResult validate() { ValidationResult result = new ValidationResult(); if (ATAbstractValidator.isFutureYear(dialog.getDateBegin())) { result.addError("Date Begin can't be in the future"); }/* w w w . j a v a 2s . com*/ if (ATAbstractValidator.isFutureYear(dialog.getDateEnd())) { result.addError("End Begin can't be in the future"); } if (ValidationUtils.isBlank(dialog.getLevel())) result.addError("Level is mandatory"); if (!checkForTitleOrDate()) result.addError("Title or Date is mandatory"); String container1Type = dialog.getContainer1Type(); String container2Type = dialog.getContainer2Type(); Double container1NumericValue = dialog.getContainer1NumericValue(); String container1AlphaNumericValue = dialog.getContainer1AlphaNumericValue(); Double container2NumericValue = dialog.getContainer2NumericValue(); String container2AlphaNumericValue = dialog.getContainer2AlphaNumericValue(); if (container2Type.length() > 0 && container1Type.length() == 0) { result.addError("You must enter container 1 if you enter container 2"); } if (isValueEntered(container1NumericValue, container1AlphaNumericValue) && container1Type.length() == 0) { result.addError("You must enter container 1 type if you enter container 1 value"); } if (isValueEntered(container2NumericValue, container2AlphaNumericValue) && container2Type.length() == 0) { result.addError("You must enter container 2 type if you enter container 2 value"); } if (!isValueEntered(container1NumericValue, container1AlphaNumericValue) && container1Type.length() > 0) { result.addError("You must enter container 1 value if you enter container 1 type"); } if (!isValueEntered(container2NumericValue, container2AlphaNumericValue) && container2Type.length() > 0) { result.addError("You must enter container 2 value if you enter container 2 type"); } if (isValueEntered(container1NumericValue, container1AlphaNumericValue) && dialog.getInstanceType().length() == 0) { result.addError("You must enter an instance type when you enter container information"); } return result; }
From source file:org.epri.pt2.dnp3proxy.DNP3ProxyConfigurationPanel.java
License:Open Source License
public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub ValidationResult validationResult = validateInput(); validationResultModel.setResult(validationResult); if (validationResultModel.hasErrors()) { controller.setEnabled(false);//w w w . java2s .c o m proxyEnabled.setSelected(false); return; } if (e.getSource().equals(proxyEnabled)) { if (proxyEnabled.isSelected()) { controller.setListenAddress(proxyAddress.getText()); controller.setListenPort(Integer.parseInt(proxyPort.getText())); try { controller.start(); } catch (Exception be) { validationResult .addError("The port is in use or an invalid hostname or IP address has been entered."); validationResultModel.setResult(validationResult); controller.setEnabled(false); ; proxyEnabled.setSelected(false); } proxyEnabled.setSelected(controller.isEnabled()); } else { controller.stop(); proxyEnabled.setSelected(controller.isEnabled()); } } }
From source file:org.epri.pt2.dnp3proxy.DNP3ProxyConfigurationPanel.java
License:Open Source License
public ValidationResult validateInput() { ValidationResult validationResult = new ValidationResult(); if (Strings.isEmpty(proxyAddress.getText())) { validationResult.addError("The proxy address field can not be blank."); } else {//from w w w . j a va 2s . c o m String address = proxyAddress.getText(); Matcher matcher = addressPattern.matcher(address); if (!matcher.matches()) { validationResult.addWarning("The proxy address field must be a valid ip address or hostname."); } } if (Strings.isEmpty(proxyPort.getText())) { validationResult.addError("The proxy port field can not be blank."); } try { if (Integer.parseInt(proxyPort.getText()) < 1) { validationResult.addError("The proxy port must be a number in the range of 1-65535."); } } catch (NumberFormatException e) { validationResult.addError("The proxy port must be a number in the range of 1-65535."); } /* * if (Strings.isEmpty(nameText.getText())) { * validationResult.addError("The name field can not be blank."); } * * if (Strings.isEmpty(descText.getText())) { validationResult * .addInfo("Please add a description to the project."); } */ return validationResult; }
From source file:org.epri.pt2.proxy.ProxyConfigurationPanel.java
License:Open Source License
public void actionPerformed(ActionEvent e) { ValidationResult validationResult = validateInput(); validationResultModel.setResult(validationResult); if (validationResultModel.hasErrors()) { controller.setEnabled(false);/*w w w .j a v a 2s.c o m*/ proxyEnabled.setSelected(false); return; } if (e.getSource().equals(proxyEnabled)) { if (proxyEnabled.isSelected()) { controller.setListenAddress(proxyAddress.getText()); controller.setListenPort(Integer.parseInt(proxyPort.getText())); try { controller.start(); } catch (Exception be) { validationResult .addError("The port is in use or an invalid hostname or IP address has been entered."); validationResultModel.setResult(validationResult); controller.setEnabled(false); ; proxyEnabled.setSelected(false); return; } proxyEnabled.setSelected(controller.isEnabled()); } else { controller.stop(); proxyEnabled.setSelected(controller.isEnabled()); } } else if (e.getSource().equals(sslEnabled)) { controller.setSSLEnabled(sslEnabled.isSelected()); } // } else if (e.getSource().equals(filtersEnabled)) { // controller.setFilteringEnabled(filtersEnabled.isSelected()); // } }
From source file:org.epri.pt2.proxy.ProxyConfigurationPanel.java
License:Open Source License
public ValidationResult validateInput() { /*/*from w ww.j a va 2 s . c o m*/ * proxyConfigPanel.add(proxyEnabledLabel); * proxyConfigPanel.add(proxyEnabled); * proxyConfigPanel.add(sslEnabledLabel); * proxyConfigPanel.add(sslEnabled); * proxyConfigPanel.add(proxyAddressLabel); * proxyConfigPanel.add(proxyAddress); * proxyConfigPanel.add(proxyPortLabel); * proxyConfigPanel.add(proxyPort); */ ValidationResult validationResult = new ValidationResult(); if (Strings.isEmpty(proxyAddress.getText())) { validationResult.addError("The proxy address field can not be blank."); } else { String address = proxyAddress.getText(); Matcher matcher = addressPattern.matcher(address); if (!matcher.matches()) { validationResult.addWarning("The proxy address field must be a valid ip address or hostname."); } } if (Strings.isEmpty(proxyPort.getText())) { validationResult.addError("The proxy port field can not be blank."); } try { if (Integer.parseInt(proxyPort.getText()) < 1) { validationResult.addError("The proxy port must be a number in the range of 1-65535."); } } catch (NumberFormatException e) { validationResult.addError("The proxy port must be a number in the range of 1-65535."); } /* * if (Strings.isEmpty(nameText.getText())) { * validationResult.addError("The name field can not be blank."); } * * if (Strings.isEmpty(descText.getText())) { validationResult * .addInfo("Please add a description to the project."); } */ return validationResult; }
From source file:se.streamsource.streamflow.client.ui.workspace.cases.general.forms.FormSubmissionWizardPageView.java
License:Apache License
private ValidationResult validatePage() { ValidationResult validationResult = new ValidationResult(); for (AbstractFieldPanel component : componentFieldMap.values()) { String value = component.getValue(); if (component.mandatory()) { if (ValidationUtils.isEmpty(value)) { validationResult.addError( i18n.text(WorkspaceResources.mandatory_field_missing) + ": " + component.title()); }//from w w w .j a va 2 s .co m } } return validationResult; }