Package com.iizigo.validator
Class ControlValidator
- java.lang.Object
- com.iizigo.validator.ValidationAdapter
- com.iizigo.validator.ControlValidator
- All Implemented Interfaces:
IValidator
,java.util.EventListener
,org.eclipse.swt.events.FocusListener
,org.eclipse.swt.events.ModifyListener
,org.eclipse.swt.events.SelectionListener
,org.eclipse.swt.events.VerifyListener
,org.eclipse.swt.internal.SWTEventListener
public class ControlValidator extends ValidationAdapter implements org.eclipse.swt.events.ModifyListener, org.eclipse.swt.events.VerifyListener, org.eclipse.swt.events.SelectionListener, org.eclipse.swt.events.FocusListener
Control validator class for dialog boxes.- Author:
- Christopher Mindus
Field Summary
Fields Modifier and Type Field Description static int
CHECK_FOCUS_LOST
static int
LOWER_CASE
static int
MUST_BE_SPECIFIED
Flags.static int
NUMERIC_INT_RANGE
static int
NUMERIC_ONLY
static int
UPPER_CASE
Fields inherited from class com.iizigo.validator.ValidationAdapter
hasBeenModified
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
focusGained(org.eclipse.swt.events.FocusEvent e)
Sent when a control gets focus.void
focusLost(org.eclipse.swt.events.FocusEvent e)
Sent when a control loses focus.static org.eclipse.swt.graphics.Image
getImage(int type)
Gets the required image.java.lang.String
getMessage()
Gets the message.int
getMessageType()
Gets the type of message (ERROR, WARNING, INFORMATION or NONE).void
modifyText(org.eclipse.swt.events.ModifyEvent e)
Handles modifications.void
reset()
Resets the validator before performing all validations in the manager.void
setAtomNameValidator(PropCnr container, GProp<?> property, boolean allowLeadingDollar)
Assigns the callback to be an Atom Name Validator.void
setDecoratedControl(org.eclipse.swt.widgets.Control control)
Place the control decorator on this component instead of the control.java.lang.String
setErrorMessage(java.lang.String message)
Sets an error message.java.lang.String
setInformationMessage(java.lang.String message)
Sets a warning message.java.lang.String
setRequiredMessage(java.lang.String message)
Sets a required message.void
setType(int flags)
Sets the type.void
setType(java.lang.String descr, int flags)
Sets the description and flags.void
setValidatorCallback(ValidatorCallback callback)
Sets the callback validator.java.lang.String
setWarningMessage(java.lang.String message)
Sets a warning message.boolean
validate()
Performs validation.void
verifyText(org.eclipse.swt.events.VerifyEvent e)
Verifies input for for upper case and numeric only.void
widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent e)
Not processed.void
widgetSelected(org.eclipse.swt.events.SelectionEvent e)
Selection changes (spinner).Methods inherited from class com.iizigo.validator.ValidationAdapter
hasBeenModified, setModified
Field Detail
MUST_BE_SPECIFIED
public static final int MUST_BE_SPECIFIED
Flags.- See Also:
- Constant Field Values
UPPER_CASE
public static final int UPPER_CASE
- See Also:
- Constant Field Values
LOWER_CASE
public static final int LOWER_CASE
- See Also:
- Constant Field Values
NUMERIC_ONLY
public static final int NUMERIC_ONLY
- See Also:
- Constant Field Values
NUMERIC_INT_RANGE
public static final int NUMERIC_INT_RANGE
- See Also:
- Constant Field Values
CHECK_FOCUS_LOST
public static final int CHECK_FOCUS_LOST
- See Also:
- Constant Field Values
Method Detail
getImage
public static org.eclipse.swt.graphics.Image getImage(int type)
Gets the required image.- Parameters:
type
- Image type: NONE, INFORMATION, WARNING or ERROR.
setDecoratedControl
public void setDecoratedControl(org.eclipse.swt.widgets.Control control)
Place the control decorator on this component instead of the control.- Parameters:
control
- The control, if e.g. a composite is wrapping an entry field.
setValidatorCallback
public void setValidatorCallback(ValidatorCallback callback)
Sets the callback validator.
setType
public void setType(java.lang.String descr, int flags)
Sets the description and flags.
setType
public void setType(int flags)
Sets the type.
getMessage
public java.lang.String getMessage()
Gets the message.- Specified by:
getMessage
in interfaceIValidator
setRequiredMessage
public java.lang.String setRequiredMessage(java.lang.String message)
Sets a required message.
setInformationMessage
public java.lang.String setInformationMessage(java.lang.String message)
Sets a warning message.
setWarningMessage
public java.lang.String setWarningMessage(java.lang.String message)
Sets a warning message.
setErrorMessage
public java.lang.String setErrorMessage(java.lang.String message)
Sets an error message.
getMessageType
public int getMessageType()
Gets the type of message (ERROR, WARNING, INFORMATION or NONE).- Specified by:
getMessageType
in interfaceIValidator
modifyText
public void modifyText(org.eclipse.swt.events.ModifyEvent e)
Handles modifications.- Specified by:
modifyText
in interfaceorg.eclipse.swt.events.ModifyListener
verifyText
public void verifyText(org.eclipse.swt.events.VerifyEvent e)
Verifies input for for upper case and numeric only.- Specified by:
verifyText
in interfaceorg.eclipse.swt.events.VerifyListener
widgetSelected
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e)
Selection changes (spinner).- Specified by:
widgetSelected
in interfaceorg.eclipse.swt.events.SelectionListener
widgetDefaultSelected
public void widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent e)
Not processed.- Specified by:
widgetDefaultSelected
in interfaceorg.eclipse.swt.events.SelectionListener
reset
public void reset()
Resets the validator before performing all validations in the manager.- Specified by:
reset
in interfaceIValidator
validate
public boolean validate()
Performs validation.- Specified by:
validate
in interfaceIValidator
- Returns:
- true for success, false for failure.
setAtomNameValidator
public void setAtomNameValidator(PropCnr container, GProp<?> property, boolean allowLeadingDollar)
Assigns the callback to be an Atom Name Validator.- Parameters:
container
- Property container where the name must not exist, null for no check.property
- The property (name) being edited, null for none.allowLeadingDollar
- Flag indicating leading dollar is allowed or not.
focusGained
public void focusGained(org.eclipse.swt.events.FocusEvent e)
Sent when a control gets focus.- Specified by:
focusGained
in interfaceorg.eclipse.swt.events.FocusListener
- Parameters:
e
- An event containing information about the focus change.
focusLost
public void focusLost(org.eclipse.swt.events.FocusEvent e)
Sent when a control loses focus.- Specified by:
focusLost
in interfaceorg.eclipse.swt.events.FocusListener
- Parameters:
e
- An event containing information about the focus change.