Eclipse SWT - WizardPage widgets validation
What is the best way to validate Text, Combo and any other SWT widget included in Eclipse Wizard? Recently, I got into a project in which there are many different wizards. I tried to add FocusListeners, ModifyListe开发者_如何学JAVAners etc. however the size of code and it's complexity was not what I expected.
Let's say there are two Text elements in WizardPage. They both cannot be empty and should contain only small letters. How to write a validator which checks if fields are empty or contain unexpected characters and display an error message in case something went wrong.
The way it has to be done must be sophisticated, elegant and useful.
I would recommend using JFace databindings (I use them myself). You will be able to add validators to particular binding and automatically show validation errors/warnings in the wizard.
In addition to Eugene I can recommend following site for a nice JFace databinding example in context with wizard pages.
http://dev.eclipse.org/viewcvs/viewvc.cgi/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet014WizardDialog.java?view=markup
But don't miss to insert those plugins into your plugin.xml
org.eclipse.core.databinding
org.eclipse.core.databinding.beans
org.eclipse.jface.databinding
org.eclipse.core.databinding.property
精彩评论