changeset 162:cc2a8879c8b7

InputValidator
author Frank Benoit <benoit@tionex.de>
date Mon, 01 Sep 2008 22:36:47 +0200
parents eb84f9418bbf
children 50acd3d4e0f5
files jface/user/PopUp.d
diffstat 1 files changed, 13 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/jface/user/PopUp.d	Mon Sep 01 22:24:27 2008 +0200
+++ b/jface/user/PopUp.d	Mon Sep 01 22:36:47 2008 +0200
@@ -30,6 +30,7 @@
 import dwtx.jface.dialogs.InputDialog;
 import dwtx.jface.dialogs.IMessageProvider;
 import dwtx.jface.dialogs.DialogTray;
+import dwtx.jface.dialogs.IInputValidator;
 
 import dwtx.jface.window.ApplicationWindow;
 import dwtx.core.runtime.IStatus;
@@ -115,9 +116,19 @@
         auto dlg = new InputDialog(
             getShell(),
             "Title",
-            "Dialog message",
+            "Enter a positive number",
             "42",
-            null );
+            new class() IInputValidator{
+                String isValid( String newText ){
+                    try{
+                        Integer.parseInt( newText );
+                        return null;
+                    }
+                    catch( Exception e ){
+                        return "Not a valid number";
+                    }
+                }
+            } );
         dlg.open();
     }