Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Added warning and error dialogs (thanks to Fahri Sönmez)

git-svn-id: https://qooxdoo-contrib.svn.sourceforge.net/svnroot/qooxdoo-contrib@20818 09f7d036-9b2a-0410-8fbe-9cff4eb17569
  • Loading branch information...
commit e3e8ac2d5d41b3c1866361c40cd542db2469ebf0 1 parent 11ccc63
authored October 23, 2010
2  demo/default/Manifest.json
@@ -18,7 +18,7 @@
18 18
     ],
19 19
 
20 20
     "version" : "trunk",
21  
-    "qooxdoo-versions": ["1.0","1.2"]
  21
+    "qooxdoo-versions": ["1.0","1.2","1.3-pre"]
22 22
   },
23 23
   
24 24
   "provides" : 
4  demo/default/config.json
@@ -30,11 +30,11 @@
30 30
   "let" :
31 31
   {
32 32
     "APPLICATION"  : "dialog.demo",
33  
-    "QOOXDOO_PATH" : "../../../../qooxdoo/trunk",
  33
+    "QOOXDOO_PATH" : "../../../../qooxdoo/1.3-pre",
34 34
     "QXTHEME"      : "dialog.demo.theme.Theme",
35 35
     "API_EXCLUDE"  : ["qx.test.*"],
36 36
     "LOCALES"      : [ "en" ],
37  
-    "CACHE"        : "${TMPDIR}/cache",
  37
+    "CACHE"        : "${TMPDIR}/cache/1.3-pre",
38 38
     "ROOT"         : "."
39 39
   },
40 40
 
18  demo/default/source/class/dialog/demo/Application.js
@@ -66,6 +66,14 @@ qx.Class.define("dialog.demo.Application",
66 66
            method : "createAlert"
67 67
          },
68 68
          {
  69
+           label : "Warning",
  70
+           method : "createWarning"
  71
+         },
  72
+         {
  73
+           label : "Error",
  74
+           method : "createError"
  75
+         },         
  76
+         {
69 77
            label : "Confirm",
70 78
            method : "createConfirm"
71 79
          },
@@ -125,6 +133,16 @@ qx.Class.define("dialog.demo.Application",
125 133
 //      })).show();      
126 134
     },
127 135
     
  136
+    createWarning : function()
  137
+    {
  138
+      dialog.Dialog.warning( "I warned you!" );     
  139
+    },    
  140
+    
  141
+    createError : function()
  142
+    {
  143
+      dialog.Dialog.error( "Error, error, error, errr....!" );     
  144
+    },        
  145
+    
128 146
     createConfirm : function()
129 147
     {
130 148
       dialog.Dialog.confirm("Do you really want to erase your hard drive?", function(result){
4  source/class/dialog/Alert.js
@@ -18,7 +18,7 @@
18 18
 ************************************************************************ */
19 19
 
20 20
 /* ************************************************************************
21  
-#asset(qx.icontheme/48/status/dialog-information.png)
  21
+#asset(qx/icon/${qx.icontheme}/48/status/dialog-information.png)
22 22
 ************************************************************************ */
23 23
 
24 24
 /**
@@ -64,7 +64,7 @@ qx.Class.define("dialog.Alert",
64 64
       /*
65 65
        * add image 
66 66
        */
67  
-      this._image = new qx.ui.basic.Image("icon/48/status/dialog-information.png");
  67
+      this._image = new qx.ui.basic.Image(this.getImage() || "icon/48/status/dialog-information.png" );
68 68
       hbox.add( this._image );
69 69
       
70 70
       /*
278  source/class/dialog/Dialog.js
@@ -21,6 +21,15 @@
21 21
 #asset(qx/icon/${qx.icontheme}/22/actions/dialog-cancel.png)
22 22
 #asset(qx/icon/${qx.icontheme}/22/actions/dialog-ok.png)
23 23
 #asset(qx/icon/${qx.icontheme}/48/status/dialog-information.png)
  24
+#asset(qx/icon/${qx.icontheme}/48/status/dialog-error.png)
  25
+#asset(qx/icon/${qx.icontheme}/48/status/dialog-warning.png)
  26
+
  27
+#ignore(dialog.alert)
  28
+#ignore(dialog.error)
  29
+#ignore(dialog.warning)
  30
+#ignore(dialog.confirm)
  31
+#ignore(dialog.prompt)
  32
+#ignore(dialog.select)
24 33
 ************************************************************************ */
25 34
 
26 35
 
@@ -38,8 +47,8 @@ qx.Class.define("dialog.Dialog",
38 47
   *****************************************************************************
39 48
   */     
40 49
   statics :
41  
-  {
42  
-    
  50
+  {  
  51
+  
43 52
     /**
44 53
      * Returns a dialog instance by type
45 54
      * @param type {String}
@@ -64,6 +73,21 @@ qx.Class.define("dialog.Dialog",
64 73
     init : function()
65 74
     {
66 75
       qx.core.Init.getApplication().warn("Initializing the Dialog package is no longer necessary. Please remove calls to 'dialog.Dialog.init()', which is now deprecated.");
  76
+      var images = ["22/actions/dialog-cancel","22/actions/dialog-ok","48/status/dialog-information","48/status/dialog-error","48/status/dialog-warning"];
  77
+      var decoration = ["form/button","form/button-hovered","form/button-pressed","groupbox/groupbox","shadow/shadow-small","form/button-focused"];
  78
+      
  79
+      for(var i=0;i<images.length;i++)
  80
+      {
  81
+        var p = qx.theme.manager.Icon.getInstance().getTheme().aliases.icon;
  82
+        qx.io.ImageLoader.load("resource/" + p + "/" +images[i]+".png",null,this);
  83
+      }
  84
+      
  85
+      for(var i=0;i<decoration.length;i++)
  86
+      {
  87
+        var p = qx.theme.manager.Decoration.getInstance().getTheme().aliases.decoration;
  88
+        qx.io.ImageLoader.load("resource/" + p + "/" +decoration[i]+".png",null,this);
  89
+      }
  90
+  
67 91
     },
68 92
     
69 93
     /**
@@ -75,9 +99,30 @@ qx.Class.define("dialog.Dialog",
75 99
     alert : function( message, callback, context )
76 100
     {
77 101
       (new dialog.Alert({
78  
-        "message"     : message,
79  
-        "callback"    : callback || null,
80  
-        "context"     : context || null
  102
+        "message"   : message,
  103
+        "callback"  : callback || null,
  104
+        "context"   : context || null,
  105
+        "image"     : "icon/48/status/dialog-information.png"
  106
+      })).show();      
  107
+    },
  108
+
  109
+    error : function( message, callback, context )
  110
+    {
  111
+      (new dialog.Alert({
  112
+        "message"   : message,
  113
+        "callback"  : callback || null,
  114
+        "context"   : context || null,
  115
+        "image"     : "icon/48/status/dialog-error.png"
  116
+      })).show();      
  117
+    },
  118
+    
  119
+    warning : function( message, callback, context )
  120
+    {
  121
+      (new dialog.Alert({
  122
+        "message"   : message,
  123
+        "callback"  : callback || null,
  124
+        "context"   : context || null,
  125
+        "image"     : "icon/48/status/dialog-warning.png"
81 126
       })).show();      
82 127
     },
83 128
     
@@ -117,12 +162,13 @@ qx.Class.define("dialog.Dialog",
117 162
      * @param options {Array}
118 163
      * @param callback {Function}
119 164
      * @param context {Object} 
  165
+     * @param allowCancel {Boolean} Default: true
120 166
      */    
121  
-    select : function( message, options, callback, context )
  167
+    select : function( message, options, callback, context, allowCancel )
122 168
     {
123 169
       (new dialog.Select({
124 170
         "message"     : message,
125  
-        "allowCancel" : true,
  171
+        "allowCancel" : typeof allowCancel == "boolean" ? allowCancel : true,
126 172
         "options"     : options,
127 173
         "callback"    : callback || null,
128 174
         "context"     : context || null
@@ -145,11 +191,102 @@ qx.Class.define("dialog.Dialog",
145 191
         "callback"    : callback,
146 192
         "context"     : context || null
147 193
       })).show();            
148  
-    } 
  194
+    }
149 195
   },
150 196
   
151 197
   /*
152 198
   *****************************************************************************
  199
+     CONSTRUCTOR
  200
+  *****************************************************************************
  201
+  */   
  202
+  
  203
+  /**
  204
+   * @param properties {Map|String|undefined} If you supply a map, all the 
  205
+   * corresponding properties will be set. If a string is given, use it 
  206
+   * as to set the 'message' property.
  207
+   */
  208
+  construct: function( properties )
  209
+  {
  210
+    this.base(arguments);
  211
+    
  212
+    /*
  213
+     * basic settings
  214
+     */
  215
+    this.set({
  216
+      'visibility' : "hidden",
  217
+      'decorator'  : "shadow-popup"
  218
+    });
  219
+    this.setLayout( new qx.ui.layout.Grow() );
  220
+    
  221
+    /*
  222
+     * automatically add to application's root
  223
+     */
  224
+    var root = qx.core.Init.getApplication().getRoot();
  225
+    root.add(this);
  226
+    
  227
+    /*
  228
+     * make sure the dialog is above any opened window
  229
+     */
  230
+    var maxWindowZIndex = 1E5;
  231
+    var windows = root.getWindows();
  232
+    for (var i = 0; i < windows.length; i++) {
  233
+      var zIndex = windows[i].getZIndex();
  234
+      maxWindowZIndex = Math.max(maxWindowZIndex, zIndex);
  235
+    }
  236
+    this.setZIndex( maxWindowZIndex +1 );
  237
+    
  238
+    /*
  239
+     * make it a focus root
  240
+     */
  241
+    qx.ui.core.FocusHandler.getInstance().addRoot(this);
  242
+    
  243
+    /* 
  244
+     * resize event 
  245
+     */
  246
+    this.getApplicationRoot().addListener("resize", function(e)
  247
+    {
  248
+      var bounds = this.getBounds();
  249
+      this.set({
  250
+        marginTop: Math.round( ( qx.bom.Document.getHeight() -bounds.height ) / 2),
  251
+        marginLeft : Math.round( ( qx.bom.Document.getWidth() -bounds.width) / 2)
  252
+      });
  253
+    }, this);
  254
+    
  255
+    /* 
  256
+     * appear event 
  257
+     */
  258
+    this.addListener("appear", function(e)
  259
+    {
  260
+      var bounds = this.getBounds();
  261
+      this.set({
  262
+        marginTop: Math.round( ( qx.bom.Document.getHeight() -bounds.height ) / 2),
  263
+        marginLeft : Math.round( ( qx.bom.Document.getWidth() -bounds.width) / 2)
  264
+      });
  265
+    }, this);   
  266
+    
  267
+    /*
  268
+     * create widget content
  269
+     */
  270
+    this._createWidgetContent();
  271
+    
  272
+    /*
  273
+     * set properties if given
  274
+     */
  275
+    if ( typeof properties == "object" )
  276
+    {
  277
+      this.set(properties);
  278
+    }
  279
+    /*
  280
+     * if argument is a string, assume it is a message
  281
+     */
  282
+    else if ( typeof properties == "string" )
  283
+    {
  284
+      this.setMessage(properties);
  285
+    }
  286
+  },  
  287
+  
  288
+  /*
  289
+  *****************************************************************************
153 290
      PROPERTIES
154 291
   *****************************************************************************
155 292
   */     
@@ -241,6 +378,8 @@ qx.Class.define("dialog.Dialog",
241 378
       refine : true,
242 379
       init : true
243 380
     }
  381
+    
  382
+    
244 383
   },
245 384
   
246 385
   /*
@@ -254,109 +393,18 @@ qx.Class.define("dialog.Dialog",
254 393
     /**
255 394
      * Dispatched when user clicks on the "OK" Button
256 395
      * @type String
257  
-     */
  396
+    */
258 397
     "ok" : "qx.event.type.Event",
259  
-    
260  
-    /**
  398
+   
  399
+   /**
261 400
      * Dispatched when user clicks on the "Cancel" Button
262 401
      * @type String
263  
-     */
  402
+    */
264 403
     "cancel" : "qx.event.type.Event"
265 404
    
266 405
   },
267 406
   
268  
-  /*
269  
-  *****************************************************************************
270  
-     CONSTRUCTOR
271  
-  *****************************************************************************
272  
-  */   
273  
-  
274  
-  /**
275  
-   * @param properties {Map|String|undefined} If you supply a map, all the 
276  
-   * corresponding properties will be set. If a string is given, use it 
277  
-   * as to set the 'message' property.
278  
-   */
279  
-  construct: function( properties )
280  
-  {
281  
-    this.base(arguments);
282  
-    
283  
-    /*
284  
-     * basic settings
285  
-     */
286  
-    this.set({
287  
-      'visibility' : "hidden",
288  
-      'decorator'  : "shadow-popup"
289  
-    });
290  
-    this.setLayout( new qx.ui.layout.Grow() );
291  
-    
292  
-    /*
293  
-     * automatically add to application's root
294  
-     */
295  
-    var root = qx.core.Init.getApplication().getRoot();
296  
-    root.add(this);
297  
-    
298  
-    /*
299  
-     * make sure the dialog is above any opened window
300  
-     */
301  
-    var maxWindowZIndex = 1E5;
302  
-    var windows = root.getWindows();
303  
-    for (var i = 0; i < windows.length; i++) {
304  
-      var zIndex = windows[i].getZIndex();
305  
-      maxWindowZIndex = Math.max(maxWindowZIndex, zIndex);
306  
-    }
307  
-    this.setZIndex( maxWindowZIndex +1 );
308  
-    
309  
-    /*
310  
-     * make it a focus root
311  
-     */
312  
-    qx.ui.core.FocusHandler.getInstance().addRoot(this);
313  
-    
314  
-    /* 
315  
-     * resize event 
316  
-     */
317  
-    this.getApplicationRoot().addListener("resize", function(e)
318  
-    {
319  
-      var bounds = this.getBounds();
320  
-      this.set({
321  
-        marginTop: Math.round( ( qx.bom.Document.getHeight() -bounds.height ) / 2),
322  
-        marginLeft : Math.round( ( qx.bom.Document.getWidth() -bounds.width) / 2)
323  
-      });
324  
-    }, this);
325  
-    
326  
-    /* 
327  
-     * appear event 
328  
-     */
329  
-    this.addListener("appear", function(e)
330  
-    {
331  
-      var bounds = this.getBounds();
332  
-      this.set({
333  
-        marginTop: Math.round( ( qx.bom.Document.getHeight() -bounds.height ) / 2),
334  
-        marginLeft : Math.round( ( qx.bom.Document.getWidth() -bounds.width) / 2)
335  
-      });
336  
-    }, this);   
337  
-    
338  
-    /*
339  
-     * create widget content
340  
-     */
341  
-    this._createWidgetContent();
342  
-    
343  
-    /*
344  
-     * set properties if given
345  
-     */
346  
-    if ( typeof properties == "object" )
347  
-    {
348  
-      this.set(properties);
349  
-    }
350  
-    /*
351  
-     * if argument is a string, assume it is a message
352  
-     */
353  
-    else if ( typeof properties == "string" )
354  
-    {
355  
-      this.setMessage(properties);
356  
-    }
357  
-      
358  
-      
359  
-  },
  407
+
360 408
   
361 409
   /*
362 410
   *****************************************************************************
@@ -380,9 +428,9 @@ qx.Class.define("dialog.Dialog",
380 428
     ---------------------------------------------------------------------------
381 429
     */      
382 430
     
383  
-    _image        : null,
384  
-    _message      : null,
385  
-    _okButton     : null,
  431
+    _image : null,
  432
+    _message : null,
  433
+    _okButton : null,
386 434
     _cancelButton : null,       
387 435
     
388 436
     /*
@@ -582,12 +630,16 @@ qx.Class.define("dialog.Dialog",
582 630
   defer : function()
583 631
   {
584 632
     /*
585  
-     * create shortcut methods for backward compatibility
  633
+     * create shortcut methods for backward compatibility. This will
  634
+     * be deprecated in a future release, please use only the 
  635
+     * dialog.Dialog.* methods
586 636
      */
587  
-    dialog.alert = dialog.Dialog.alert;
588  
-    dialog.confirm = dialog.Dialog.confirm;
589  
-    dialog.prompt = dialog.Dialog.prompt;
590  
-    dialog.select = dialog.Dialog.select;
591  
-    dialog.form = dialog.Dialog.form;
  637
+    dialog.alert    = dialog.Dialog.alert;
  638
+    dialog.error    = dialog.Dialog.error;
  639
+    dialog.warning  = dialog.Dialog.warning;
  640
+    dialog.confirm  = dialog.Dialog.confirm;
  641
+    dialog.prompt   = dialog.Dialog.prompt;
  642
+    dialog.select   = dialog.Dialog.select;
  643
+    dialog.form     = dialog.Dialog.form;
592 644
   }
593 645
 });
2  source/class/dialog/Form.js
@@ -568,7 +568,7 @@ qx.Class.define("dialog.Form",
568 568
               var func = eval("("+fieldData.events[type]+")"); // eval is evil, I know.
569 569
               if ( ! qx.lang.Type.isFunction(func) )
570 570
               {
571  
-                throw new Exception();
  571
+                throw new Error();
572 572
               }
573 573
               formElement.addListener(type,func,formElement);
574 574
             }
2  source/class/dialog/Prompt.js
@@ -144,5 +144,5 @@ qx.Class.define("dialog.Prompt",
144 144
         this.getCallback().call( this.getContext(), this.getValue() );
145 145
       }
146 146
     } 
147  
-  }
  147
+  }    
148 148
 });

0 notes on commit e3e8ac2

Please sign in to comment.
Something went wrong with that request. Please try again.