List of usage examples for com.jgoodies.validation Severity WARNING
Severity WARNING
To view the source code for com.jgoodies.validation Severity WARNING.
Click Source Link
From source file:gov.nih.nci.cacore.workbench.portal.panel.DeployTypeSettingsPanel.java
License:BSD License
public ValidationResult validateInput() { ValidationResult result = new ValidationResult(); //Project Directory Setting Validation if (ValidationUtils.isBlank(this.getProjectDirField().getText())) { result.add(/* w w w. jav a 2 s. co m*/ new SimpleValidationMessage(PROJECT_DIR + " must not be blank.", Severity.ERROR, PROJECT_DIR)); } else { File file = new File(this.getProjectDirField().getText()); if (file.exists()) { result.add(new SimpleValidationMessage( PROJECT_DIR + " already exists. The output directory will be overwritten.", Severity.WARNING, PROJECT_DIR)); } } //Deploy Type Setting Validation String deployType = getDeployTypeComboBox().getSelectedItem().toString(); if (deployType == null || deployType == "") { result.add( new SimpleValidationMessage(DEPLOY_TYPE + " must be selected.", Severity.ERROR, DEPLOY_TYPE)); } if (deployType.equalsIgnoreCase(REMOTE)) { String remoteDeployEnv = getRemoteDeployEnvComboBox().getSelectedItem().toString(); if (remoteDeployEnv == null || remoteDeployEnv == "") { result.add(new SimpleValidationMessage(REMOTE_DEPLOY_ENV + " must be selected.", Severity.ERROR, REMOTE_DEPLOY_ENV)); } } return result; }
From source file:gov.nih.nci.cacore.workbench.portal.panel.LogViewerPanel.java
License:BSD License
public ValidationResult validateInput() { ValidationResult result = new ValidationResult(); //Log File Validation if (ValidationUtils.isBlank(this.getLogFileField().getText())) { result.add(new SimpleValidationMessage(LOG_FILE + " must not be blank.", Severity.ERROR, LOG_FILE)); } else {/*from ww w . j a v a 2 s .c o m*/ File file = new File(this.getLogFileField().getText()); if (!file.exists()) { result.add(new SimpleValidationMessage( LOG_FILE + " does not exist. Please select an existing log file", Severity.WARNING, LOG_FILE)); } } return result; }
From source file:gov.nih.nci.cacore.workbench.portal.panel.ProjectDirSettingsPanel.java
License:BSD License
public ValidationResult validateInput() { ValidationResult result = new ValidationResult(); //Project Directory Setting Validation if (ValidationUtils.isBlank(this.getProjectGenDirField().getText())) { result.add(new SimpleValidationMessage(PROJECT_GEN_DIR + " must not be blank", Severity.ERROR, PROJECT_GEN_DIR));//w w w .ja v a 2s . co m } else { File file = new File(this.getProjectGenDirField().getText()); if (file.exists()) { result.add(new SimpleValidationMessage( PROJECT_GEN_DIR + " already exists. The output directory will be overwritten.", Severity.WARNING, PROJECT_GEN_DIR)); } else { result.add(new SimpleValidationMessage( PROJECT_GEN_DIR + " does not exist. Please select the Home directory of an existing directory.", Severity.ERROR, PROJECT_GEN_DIR)); } } return result; }
From source file:gov.nih.nci.cacore.workbench.portal.panel.ProjectSettingsPanel.java
License:BSD License
public ValidationResult validateInput() { ValidationResult result = new ValidationResult(); //Panel Settings Validation if (ValidationUtils.isBlank(this.getProjectDirField().getText())) { result.add(/*w ww . j a v a 2 s . c om*/ new SimpleValidationMessage(PROJECT_DIR + " must not be blank.", Severity.ERROR, PROJECT_DIR)); } else { File file = new File(this.getProjectDirField().getText()); if (file.exists()) { result.add(new SimpleValidationMessage( PROJECT_DIR + " already exists. The output directory will be overwritten.", Severity.WARNING, PROJECT_DIR)); } } if (ValidationUtils.isBlank(this.getSdkInstallDirField().getText())) { result.add(new SimpleValidationMessage(SDK_INSTALL_DIR + " must not be blank.", Severity.ERROR, SDK_INSTALL_DIR)); } else { File file = new File(this.getSdkInstallDirField().getText()); if (!file.exists()) { result.add(new SimpleValidationMessage(SDK_INSTALL_DIR + " does not exist. Please select the Home directory of an existing SDK Installation.", Severity.ERROR, SDK_INSTALL_DIR)); } } if (ValidationUtils.isNotBlank(this.getProjectDirField().getText()) && ValidationUtils.isNotBlank(this.getSdkInstallDirField().getText()) && this.getProjectDirField().getText().equalsIgnoreCase(this.getSdkInstallDirField().getText())) { result.add(new SimpleValidationMessage(PROJECT_DIR + " and " + SDK_INSTALL_DIR + " must be different.", Severity.ERROR, PROJECT_DIR)); result.add(new SimpleValidationMessage(PROJECT_DIR + " and " + SDK_INSTALL_DIR + " must be different.", Severity.ERROR, SDK_INSTALL_DIR)); } if (ValidationUtils.isBlank(this.getProjectNameField().getText())) { result.add(new SimpleValidationMessage(PROJECT_NAME + " must not be blank.", Severity.ERROR, PROJECT_NAME)); } if (ValidationUtils.isBlank(this.getNamespacePrefixField().getText())) { result.add(new SimpleValidationMessage(NAMESPACE_PREFIX + " must not be blank.", Severity.ERROR, NAMESPACE_PREFIX)); } if (ValidationUtils.isBlank(this.getWebServiceNameField().getText())) { result.add(new SimpleValidationMessage(WEBSERVICE_NAME + " must not be blank.", Severity.ERROR, WEBSERVICE_NAME)); } return result; }
From source file:org.archiviststoolkit.util.ATPropertyValidationSupport.java
License:Open Source License
public void addSimpleWarning(String text) { getResult().add(new SimpleValidationMessage(text, Severity.WARNING)); }
From source file:org.metawidget.swing.widgetprocessor.validator.jgoodies.JGoodiesValidatorProcessorTest.java
License:LGPL
public void testValidator() throws Exception { // Inspect//w ww . j a v a2 s . co m SwingMetawidget metawidget = new SwingMetawidget(); metawidget.setInspector(new CompositeInspector(new CompositeInspectorConfig() .setInspectors(new MetawidgetAnnotationInspector(), new PropertyTypeInspector()))); metawidget.setToInspect(new Foo()); metawidget.addWidgetProcessor(new JGoodiesValidatorProcessor()); // Initial validation JTextField textField1 = (JTextField) metawidget.getComponent(1); assertEquals(null, ValidationComponentUtils.getMessageKeys(textField1)); assertTrue(ValidationComponentUtils.isMandatory(textField1)); assertEquals(ValidationComponentUtils.getMandatoryBorder(), textField1.getBorder()); assertEquals(ValidationComponentUtils.getMandatoryBackground(), textField1.getBackground()); JTextField textField2 = (JTextField) metawidget.getComponent(3); assertEquals(null, ValidationComponentUtils.getMessageKeys(textField2)); assertFalse(ValidationComponentUtils.isMandatory(textField2)); // Validation after a keypress textField1.setText("Not empty"); textField1.getKeyListeners()[0].keyReleased(null); assertEquals(ValidationComponentUtils.getMandatoryBorder(), textField1.getBorder()); assertFalse(ValidationComponentUtils.getMandatoryBackground().equals(textField1.getBackground())); // Validation after deleting contents textField1.setText(""); textField1.getKeyListeners()[0].keyReleased(null); assertEquals(ValidationComponentUtils.getMandatoryBorder(), textField1.getBorder()); assertEquals(ValidationComponentUtils.getMandatoryBackground(), textField1.getBackground()); // Custom validator metawidget.setInspector(new CompositeInspector(new CompositeInspectorConfig() .setInspectors(new MetawidgetAnnotationInspector(), new PropertyTypeInspector()))); metawidget.setToInspect(new Foo()); metawidget.setWidgetProcessors((WidgetProcessor<JComponent, SwingMetawidget>[]) null); metawidget.addWidgetProcessor(new JGoodiesValidatorProcessor() { @Override protected Validator<?> getValidator(final JComponent component, final Map<String, String> attributes, String path, SwingMetawidget theMetawidget) { return new Validator<String>() { public ValidationResult validate(String validationTarget) { if ("error".equals(validationTarget)) { ValidationMessage message = new SimpleValidationMessage("MyJGoodiesValidator error", Severity.ERROR, attributes.get(NAME)); ValidationResult validationResult = new ValidationResult(); validationResult.add(message); return validationResult; } if ("warning".equals(validationTarget)) { ValidationMessage message = new SimpleValidationMessage("MyJGoodiesValidator warning", Severity.WARNING, attributes.get(NAME)); ValidationResult validationResult = new ValidationResult(); validationResult.add(message); return validationResult; } return null; } }; } }); textField1 = (JTextField) metawidget.getComponent(1); assertEquals("bar", ValidationComponentUtils.getMessageKeys(textField1)[0]); textField1.setText("error"); textField1.getKeyListeners()[0].keyReleased(null); assertEquals(ValidationComponentUtils.getErrorBackground(), textField1.getBackground()); textField1.setText("warning"); textField1.getKeyListeners()[0].keyReleased(null); assertEquals(ValidationComponentUtils.getWarningBackground(), textField1.getBackground()); textField1.setText("all good"); textField1.getKeyListeners()[0].keyReleased(null); assertFalse(ValidationComponentUtils.getErrorBackground().equals(textField1.getBackground())); assertFalse(ValidationComponentUtils.getWarningBackground().equals(textField1.getBackground())); assertFalse(ValidationComponentUtils.getMandatoryBackground().equals(textField1.getBackground())); }