List of usage examples for com.jgoodies.validation ValidationResult add
public ValidationResult add(ValidationMessage validationMessage)
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.ModelSettingsPanel.java
License:BSD License
public ValidationResult validateInput() { ValidationResult result = new ValidationResult(); //Model Settings Validation if (ValidationUtils.isBlank(this.getModelFileField().getText())) { result.add(new SimpleValidationMessage(MODEL_FILE_PATH + " path must not be blank.", Severity.ERROR, MODEL_FILE_PATH));/*ww w. j av a2 s . co m*/ } else { File file = new File(this.getModelFileField().getText()); if (!file.exists()) { result.add(new SimpleValidationMessage(MODEL_FILE_PATH + " does not exist. Please select or enter a valid absolute path to the model file.", Severity.ERROR, MODEL_FILE_PATH)); } if (!this.getModelFileField().getText().endsWith("xmi") && !this.getModelFileField().getText().endsWith("uml")) { result.add(new SimpleValidationMessage( MODEL_FILE_PATH + " must refer to an XMI (*.xmi) or Argo UML (*.uml) file.", Severity.ERROR, MODEL_FILE_PATH)); } } if (ValidationUtils.isBlank(this.getLogicalModelField().getText())) { result.add(new SimpleValidationMessage(LOGICAL_MODEL_PACKAGE_NAME + " must not be blank.", Severity.ERROR, LOGICAL_MODEL_PACKAGE_NAME)); } if (ValidationUtils.isBlank(this.getDataModelField().getText())) { result.add(new SimpleValidationMessage(DATA_MODEL_PACKAGE_NAME + " must not be blank.", Severity.ERROR, DATA_MODEL_PACKAGE_NAME)); } if (ValidationUtils.isBlank(this.getIncludePackageField().getText())) { result.add(new SimpleValidationMessage(INCLUDE_PACKAGE_REGEX + " must not be blank.", Severity.ERROR, INCLUDE_PACKAGE_REGEX)); } 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 ww . j a v a2 s . c o 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( new SimpleValidationMessage(PROJECT_DIR + " must not be blank.", Severity.ERROR, PROJECT_DIR)); } else {/*from w ww . j av a 2 s . c o m*/ 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:gov.nih.nci.cacore.workbench.portal.panel.RemoteSshSettingsPanel.java
License:BSD License
public ValidationResult validateInput() { ValidationResult result = new ValidationResult(); if (parentContainer.isRemoteDeployment()) { if (ValidationUtils.isBlank(this.getSshServerUsernameField().getText())) { result.add(new SimpleValidationMessage(SSH_SERVER_USERNAME + " must not be blank.", Severity.ERROR, SSH_SERVER_USERNAME)); }/*from ww w .j a v a 2 s. co m*/ if (ValidationUtils.isBlank(this.getSshServerHostnameField().getText())) { result.add(new SimpleValidationMessage(SSH_SERVER_HOSTNAME + " must not be blank.", Severity.ERROR, SSH_SERVER_HOSTNAME)); } String sshPort = getSshPortField().getText(); if (ValidationUtils.isBlank(this.getSshPortField().getText())) { result.add(new SimpleValidationMessage(SSH_PORT + " must not be blank.", Severity.ERROR, SSH_PORT)); } if (!ValidationUtils.isNumeric(sshPort)) { result.add(new SimpleValidationMessage(SSH_PORT + " must be numeric.", Severity.ERROR, SSH_PORT)); } if (ValidationUtils.isBlank(this.getSshKeyFileField().getText())) { result.add(new SimpleValidationMessage(SSH_KEY_FILE + " must not be blank.", Severity.ERROR, SSH_KEY_FILE)); } else { File file = new File(this.getSshKeyFileField().getText()); if (!file.exists()) { result.add(new SimpleValidationMessage( SSH_KEY_FILE + " does not exist. Please select or enter a valid absolute path to the file.", Severity.ERROR, SSH_KEY_FILE)); } } if (ValidationUtils.isBlank(this.getSshTempDirField().getText())) { result.add(new SimpleValidationMessage(SSH_TEMP_DIR + " must not be blank.", Severity.ERROR, SSH_TEMP_DIR)); } else { // Cannot validate if it is a valid directory as it is remote. // File file = new File(this.getSshTempDirField().getText()); // if(!file.exists()){ // result.add(new SimpleValidationMessage(SSH_TEMP_DIR + " does not exist. Please select or enter a valid absolute path to the directory.", Severity.ERROR, SSH_TEMP_DIR)); // } } } return result; }
From source file:gov.nih.nci.cacore.workbench.portal.panel.SdkInstallSettingsPanel.java
License:BSD License
public ValidationResult validateInput() { ValidationResult result = new ValidationResult(); //Sdk Install Panel Settings Validation if (ValidationUtils.isBlank(this.getSdkInstallDirField().getText())) { result.add(new SimpleValidationMessage(SDK_INSTALL_DIR + " must not be blank.", Severity.ERROR, SDK_INSTALL_DIR));/* w ww. j av a 2s .c om*/ } 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)); } } return result; }
From source file:gov.nih.nci.cacore.workbench.portal.panel.SecuritySettingsPanel.java
License:BSD License
public ValidationResult validateInput() { ValidationResult result = new ValidationResult(); //Security setting Validation if (getEnableSecurityCheckBox().isSelected()) { if (ValidationUtils.isBlank(this.getCsmProjectNameField().getText())) { result.add(new SimpleValidationMessage(CSM_PROJECT_NAME + " must not be blank.", Severity.ERROR, CSM_PROJECT_NAME));/* w w w .j a v a 2s. c o m*/ } //caGrid Auth Setting Validation if (getEnableCaGridLoginModuleCheckBox().isSelected()) { if (ValidationUtils.isBlank(this.getCaGridLoginModuleNameField().getText())) { result.add(new SimpleValidationMessage(CAGRID_LOGIN_MODULE_NAME + " must not be blank.", Severity.ERROR, CAGRID_LOGIN_MODULE_NAME)); } if (ValidationUtils.isBlank(this.getSdkGridLoginSvcNameField().getText())) { result.add(new SimpleValidationMessage(SDK_GRID_LOGIN_SERVICE_NAME + " must not be blank.", Severity.ERROR, SDK_GRID_LOGIN_SERVICE_NAME)); } } } return result; }
From source file:gov.nih.nci.cacore.workbench.portal.panel.WritableApiSettingsPanel.java
License:BSD License
public ValidationResult validateInput() { ValidationResult result = new ValidationResult(); //Writable API Settings Validation if (getEnableWritableApiExtensionCheckBox().isSelected()) { if (ValidationUtils.isBlank(this.getIdentityGeneratorTagField().getText())) { result.add(new SimpleValidationMessage(IDENTITY_GENERATOR_TAG + " must not be blank.", Severity.ERROR, IDENTITY_GENERATOR_TAG)); }// w w w. j av a2s . com if (getEnableCommonLoggingModuleCheckBox().isSelected()) { if (ValidationUtils.isBlank(this.getClmProjectNameField().getText())) { result.add(new SimpleValidationMessage(CLM_PROJECT_NAME + " must not be blank.", Severity.ERROR, CLM_PROJECT_NAME)); } } } return result; }
From source file:org.metawidget.swing.widgetprocessor.validator.jgoodies.JGoodiesValidatorProcessorTest.java
License:LGPL
public void testValidator() throws Exception { // Inspect/*from w w w.j a va 2 s. com*/ 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())); }