Monday, June 25, 2012

InputDialog Validation

To create a input dialog,

InputDialog fileNameDialog = new InputDialog(shell, "Rename Item", "New Name:", "", new validator());

The last parameter in the InputDialog is the object "new validator()".

class validator implements IInputValidator {
          public String isValid(String newText) {
                        if (newText==null)
return "Error Caused!";
                       }
         }

The error message is displayed while disabling the "ok" button as shown below,
   
                  

2 comments: