MOVED ALSO OTHER VALIDATORS
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/admin/rmp-common-library@67082 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
124f2e204c
commit
6d70ff47b6
|
@ -56,7 +56,6 @@ public final class CurrentStatus implements Serializable {
|
|||
currentScope = scope.trim();
|
||||
}
|
||||
Resource_support.get().getEventBus().fireEvent(new SetScopeEvent(scope));
|
||||
GWT.log("Set Scope event sent for " + scope);
|
||||
//Commands.setStatusScope(scope);
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
/****************************************************************************
|
||||
* This software is part of the gCube Project.
|
||||
* Site: http://www.gcube-system.org/
|
||||
****************************************************************************
|
||||
* The gCube/gCore software is licensed as Free Open Source software
|
||||
* conveying to the EUPL (http://ec.europa.eu/idabc/eupl).
|
||||
* The software and documentation is provided by its authors/distributors
|
||||
* "as is" and no expressed or
|
||||
* implied warranty is given for its use, quality or fitness for a
|
||||
* particular case.
|
||||
****************************************************************************
|
||||
* Filename: SelectValidator.java
|
||||
****************************************************************************
|
||||
* @author <a href="mailto:daniele.strollo@isti.cnr.it">Daniele Strollo</a>
|
||||
***************************************************************************/
|
||||
|
||||
package org.gcube.resourcemanagement.support.client.views.validators;
|
||||
|
||||
import com.extjs.gxt.ui.client.widget.form.Field;
|
||||
import com.extjs.gxt.ui.client.widget.form.Validator;
|
||||
|
||||
/**
|
||||
* @author Daniele Strollo (ISTI-CNR)
|
||||
*
|
||||
*/
|
||||
public class SelectValidator implements Validator {
|
||||
private boolean emptyAllowed = false;
|
||||
|
||||
public SelectValidator(final boolean emptyAllowed) {
|
||||
this.emptyAllowed = emptyAllowed;
|
||||
}
|
||||
|
||||
public final String validate(final Field<?> field, final String value) {
|
||||
if (!emptyAllowed && (value == null || value.trim().length() == 0)) {
|
||||
return "The field value is invalid. Empty or null value not allowed.";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
/****************************************************************************
|
||||
* This software is part of the gCube Project.
|
||||
* Site: http://www.gcube-system.org/
|
||||
****************************************************************************
|
||||
* The gCube/gCore software is licensed as Free Open Source software
|
||||
* conveying to the EUPL (http://ec.europa.eu/idabc/eupl).
|
||||
* The software and documentation is provided by its authors/distributors
|
||||
* "as is" and no expressed or
|
||||
* implied warranty is given for its use, quality or fitness for a
|
||||
* particular case.
|
||||
****************************************************************************
|
||||
* Filename: XMLValidator.java
|
||||
****************************************************************************
|
||||
* @author <a href="mailto:daniele.strollo@isti.cnr.it">Daniele Strollo</a>
|
||||
***************************************************************************/
|
||||
|
||||
package org.gcube.resourcemanagement.support.client.views.validators;
|
||||
|
||||
import com.extjs.gxt.ui.client.widget.form.Field;
|
||||
import com.extjs.gxt.ui.client.widget.form.Validator;
|
||||
|
||||
/**
|
||||
* @author Daniele Strollo (ISTI-CNR)
|
||||
*
|
||||
*/
|
||||
public class StringValidator implements Validator {
|
||||
private int maxLenght = 256;
|
||||
private boolean emptyAllowed = false;
|
||||
|
||||
public StringValidator(final int maxLenght, final boolean emptyAllowed) {
|
||||
this.maxLenght = maxLenght;
|
||||
this.emptyAllowed = emptyAllowed;
|
||||
}
|
||||
|
||||
public final String validate(final Field<?> field, final String value) {
|
||||
if (!emptyAllowed && (value == null || value.trim().length() == 0)) {
|
||||
return "The field value is invalid. Empty or null value not allowed.";
|
||||
}
|
||||
if (value != null && value.length() > this.maxLenght) {
|
||||
return "The value is too long. Limit of " + this.maxLenght + " chars exceeded.";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue