diff org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet014WizardDialog.d @ 99:5d5bd660917f

build some databind snippets
author Frank Benoit <benoit@tionex.de>
date Wed, 22 Apr 2009 18:59:26 +0200
parents 6086085e153d
children e884642ad36e
line wrap: on
line diff
--- a/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet014WizardDialog.d	Wed Apr 22 07:30:21 2009 +0200
+++ b/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet014WizardDialog.d	Wed Apr 22 18:59:26 2009 +0200
@@ -10,7 +10,9 @@
  *     Matthew Hall - bug 260329
  *******************************************************************************/
 
-package org.eclipse.jface.examples.databinding.snippets;
+module org.eclipse.jface.examples.databinding.snippets.Snippet014WizardDialog;
+
+import java.lang.all;
 
 import java.util.Date;
 
@@ -42,120 +44,123 @@
  */
 public class Snippet014WizardDialog {
 
-	static class FirstWizardPage extends WizardPage {
-		private final class SingleDigitValidator implements IValidator {
-			public IStatus validate(Object value) {
-				Integer i = (Integer) value;
-				if (i == null) {
-					return ValidationStatus
-							.info("Please enter a value.");
-				}
-				if (i.intValue() < 0 || i.intValue() > 9) {
-					return ValidationStatus
-							.error("Value must be between 0 and 9.");
-				}
-				return ValidationStatus.ok();
-			}
-		}
+    static class FirstWizardPage extends WizardPage {
+        private final class SingleDigitValidator implements IValidator {
+            public IStatus validate(Object value) {
+                Integer i = (Integer) value;
+                if (i == null) {
+                    return ValidationStatus
+                            .info("Please enter a value.");
+                }
+                if (i.intValue() < 0 || i.intValue() > 9) {
+                    return ValidationStatus
+                            .error("Value must be between 0 and 9.");
+                }
+                return ValidationStatus.ok();
+            }
+        }
 
-		protected FirstWizardPage() {
-			super("First", "First Page", ImageDescriptor
-					.createFromImage(new Image(Display.getDefault(), 16, 16)));
-		}
+        protected FirstWizardPage() {
+            super("First", "First Page", ImageDescriptor
+                    .createFromImage(new Image(Display.getDefault(), 16, 16)));
+        }
 
-		public void createControl(Composite parent) {
-			DataBindingContext dbc = new DataBindingContext();
-			WizardPageSupport.create(this, dbc);
-			Composite composite = new Composite(parent, SWT.NONE);
-			Label label = new Label(composite, SWT.NONE);
-			label.setText("Enter a number between 0 and 9:");
-			Text text = new Text(composite, SWT.BORDER);
-			
-			dbc.bindValue(
-							SWTObservables.observeText(text, SWT.Modify),
-							((SampleWizard) getWizard()).getModel().intValue,
-							new UpdateValueStrategy().setAfterConvertValidator(new SingleDigitValidator()),
-							null);
-			
-			GridLayoutFactory.swtDefaults().numColumns(2).generateLayout(
-					composite);
-			setControl(composite);
-		}
-	}
+        public void createControl(Composite parent) {
+            DataBindingContext dbc = new DataBindingContext();
+            WizardPageSupport.create(this, dbc);
+            Composite composite = new Composite(parent, SWT.NONE);
+            Label label = new Label(composite, SWT.NONE);
+            label.setText("Enter a number between 0 and 9:");
+            Text text = new Text(composite, SWT.BORDER);
+            
+            dbc.bindValue(
+                            SWTObservables.observeText(text, SWT.Modify),
+                            ((SampleWizard) getWizard()).getModel().intValue,
+                            new UpdateValueStrategy().setAfterConvertValidator(new SingleDigitValidator()),
+                            null);
+            
+            GridLayoutFactory.swtDefaults().numColumns(2).generateLayout(
+                    composite);
+            setControl(composite);
+        }
+    }
 
-	static class SecondWizardPage extends WizardPage {
-		protected SecondWizardPage() {
-			super("Second", "Second Page", ImageDescriptor
-					.createFromImage(new Image(Display.getDefault(), 16, 16)));
-		}
+    static class SecondWizardPage extends WizardPage {
+        protected SecondWizardPage() {
+            super("Second", "Second Page", ImageDescriptor
+                    .createFromImage(new Image(Display.getDefault(), 16, 16)));
+        }
 
-		public void createControl(Composite parent) {
-			DataBindingContext dbc = new DataBindingContext();
-			WizardPageSupport.create(this, dbc);
-			Composite composite = new Composite(parent, SWT.NONE);
-			Label label = new Label(composite, SWT.NONE);
-			label.setText("Enter a date:");
-			Text text = new Text(composite, SWT.BORDER);
-			
-			dbc.bindValue(
-							SWTObservables.observeText(text, SWT.Modify),
-							((SampleWizard) getWizard()).getModel().dateValue);
+        public void createControl(Composite parent) {
+            DataBindingContext dbc = new DataBindingContext();
+            WizardPageSupport.create(this, dbc);
+            Composite composite = new Composite(parent, SWT.NONE);
+            Label label = new Label(composite, SWT.NONE);
+            label.setText("Enter a date:");
+            Text text = new Text(composite, SWT.BORDER);
+            
+            dbc.bindValue(
+                            SWTObservables.observeText(text, SWT.Modify),
+                            ((SampleWizard) getWizard()).getModel().dateValue);
 
-			GridLayoutFactory.swtDefaults().numColumns(2).generateLayout(
-					composite);
-			setControl(composite);
-		}
-	}
+            GridLayoutFactory.swtDefaults().numColumns(2).generateLayout(
+                    composite);
+            setControl(composite);
+        }
+    }
 
-	static class SampleWizardModel {
-		IObservableValue intValue = new WritableValue(null, Integer.class);
-		IObservableValue dateValue = new WritableValue(null, Date.class);
-	}
+    static class SampleWizardModel {
+        IObservableValue intValue = new WritableValue(null, Integer.class);
+        IObservableValue dateValue = new WritableValue(null, Date.class);
+    }
 
-	static class SampleWizard extends Wizard {
+    static class SampleWizard extends Wizard {
 
-		private SampleWizardModel model = new SampleWizardModel();
+        private SampleWizardModel model = new SampleWizardModel();
 
-		public void addPages() {
-			addPage(new FirstWizardPage());
-			addPage(new SecondWizardPage());
-		}
+        public void addPages() {
+            addPage(new FirstWizardPage());
+            addPage(new SecondWizardPage());
+        }
 
-		public SampleWizardModel getModel() {
-			return model;
-		}
-		
-		public String getWindowTitle() {
-			return "Data Binding Snippet014";
-		}
+        public SampleWizardModel getModel() {
+            return model;
+        }
+        
+        public String getWindowTitle() {
+            return "Data Binding Snippet014";
+        }
 
-		public boolean performFinish() {
-			return true;
-		}
+        public bool performFinish() {
+            return true;
+        }
 
-	}
+    }
 
-	public static void main(String[] args) {
-		Display display = new Display();
+    public static void main(String[] args) {
+        Display display = new Display();
 
-		// note that the "runWithDefault" will be done for you if you are using
-		// the
-		// Workbench as opposed to just JFace/SWT.
-		Realm.runWithDefault(SWTObservables.getRealm(display), new Runnable() {
-			public void run() {
-				IWizard wizard = new SampleWizard();
-				WizardDialog dialog = new WizardDialog(null, wizard);
-				dialog.open();
-				// The SWT event loop
-				Display display = Display.getCurrent();
-				while (dialog.getShell() != null
-						&& !dialog.getShell().isDisposed()) {
-					if (!display.readAndDispatch()) {
-						display.sleep();
-					}
-				}
-			}
-		});
-	}
+        // note that the "runWithDefault" will be done for you if you are using
+        // the
+        // Workbench as opposed to just JFace/SWT.
+        Realm.runWithDefault(SWTObservables.getRealm(display), new Runnable() {
+            public void run() {
+                IWizard wizard = new SampleWizard();
+                WizardDialog dialog = new WizardDialog(null, wizard);
+                dialog.open();
+                // The SWT event loop
+                Display display = Display.getCurrent();
+                while (dialog.getShell() != null
+                        && !dialog.getShell().isDisposed()) {
+                    if (!display.readAndDispatch()) {
+                        display.sleep();
+                    }
+                }
+            }
+        });
+    }
 
 }
+void main( String[] args ){
+    Snippet014WizardDialog.main(args);
+}