comparison org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet027ExternalValidator.d @ 100:e884642ad36e

more work on examples
author Frank Benoit <benoit@tionex.de>
date Thu, 23 Apr 2009 00:02:38 +0200
parents 5d5bd660917f
children
comparison
equal deleted inserted replaced
99:5d5bd660917f 100:e884642ad36e
42 /** 42 /**
43 * This snippet demonstrates how to integrate an external validator 43 * This snippet demonstrates how to integrate an external validator
44 * 44 *
45 * @since 3.5 45 * @since 3.5
46 */ 46 */
47 public class Snippet027ExternalValidator extends WizardPage { 47 public class Snippet027ExternalValidator : WizardPage {
48 48
49 private Text nameValue; 49 private Text nameValue;
50 private Text emailValue; 50 private Text emailValue;
51 private Text phoneNumberValue; 51 private Text phoneNumberValue;
52 52
82 propertyChangeSupport.firePropertyChange(propertyName, oldValue, 82 propertyChangeSupport.firePropertyChange(propertyName, oldValue,
83 newValue); 83 newValue);
84 } 84 }
85 } 85 }
86 86
87 static class Contact extends AbstractModelObject { 87 static class Contact : AbstractModelObject {
88 String name; 88 String name;
89 String email; 89 String email;
90 String phoneNumber; 90 String phoneNumber;
91 91
92 public Contact(String name, String email, String number) { 92 public Contact(String name, String email, String number) {
124 this.phoneNumber = number; 124 this.phoneNumber = number;
125 firePropertyChange("phoneNumber", oldValue, number); 125 firePropertyChange("phoneNumber", oldValue, number);
126 } 126 }
127 127
128 public IStatus validate() { 128 public IStatus validate() {
129 if (name.indexOf(' ') == -1) { 129 if (name.indexOf(' ') is -1) {
130 return ValidationStatus 130 return ValidationStatus
131 .error("Please enter both first and last name separated by a space."); 131 .error("Please enter both first and last name separated by a space.");
132 } 132 }
133 if (email.indexOf('@') == -1) { 133 if (email.indexOf('@') is -1) {
134 return ValidationStatus 134 return ValidationStatus
135 .error("Please enter a valid email address containing '@'."); 135 .error("Please enter a valid email address containing '@'.");
136 } 136 }
137 if (!phoneNumber.startsWith("+")) { 137 if (!phoneNumber.startsWith("+")) {
138 return ValidationStatus 138 return ValidationStatus
223 dbc.addValidationStatusProvider(validator); 223 dbc.addValidationStatusProvider(validator);
224 224
225 WizardPageSupport.create(this, dbc); 225 WizardPageSupport.create(this, dbc);
226 } 226 }
227 227
228 static class ExternalValidationWizard extends Wizard { 228 static class ExternalValidationWizard : Wizard {
229 public void addPages() { 229 public void addPages() {
230 addPage(new Snippet027ExternalValidator()); 230 addPage(new Snippet027ExternalValidator());
231 } 231 }
232 232
233 public String getWindowTitle() { 233 public String getWindowTitle() {
248 WizardDialog dialog = new WizardDialog(null, wizard); 248 WizardDialog dialog = new WizardDialog(null, wizard);
249 dialog.open(); 249 dialog.open();
250 250
251 // The SWT event loop 251 // The SWT event loop
252 Display display = Display.getCurrent(); 252 Display display = Display.getCurrent();
253 while (dialog.getShell() != null 253 while (dialog.getShell() !is null
254 && !dialog.getShell().isDisposed()) { 254 && !dialog.getShell().isDisposed()) {
255 if (!display.readAndDispatch()) { 255 if (!display.readAndDispatch()) {
256 display.sleep(); 256 display.sleep();
257 } 257 }
258 } 258 }