* @param text {String} Default content of the window.\r
*/\r
construct : function(caption, icon, text){\r
- this.base(arguments);\r
+ this.base(arguments, caption, icon);\r
this.set({\r
showMaximize : false,\r
showMinimize : false,\r
height: 150\r
});\r
this.setLayout(new qx.ui.layout.Dock());\r
- var closeButton = new qx.ui.form.Button("Close");\r
- closeButton.addListener("execute", function(e){\r
- this.hide();\r
- this.destroy();\r
- }, this);\r
- this.add(closeButton, {edge:'south'});\r
this.setModal(true);\r
+ this.addCloseButton();\r
this.center();\r
if(text){\r
this.addLabel(text);\r
attachAndShow:function(){\r
org.argeo.ria.components.ViewsManager.getInstance().getApplicationRoot().add(this); \r
this.show();\r
+ },\r
+ addCloseButton : function(){\r
+ this.closeButton = new qx.ui.form.Button("Close");\r
+ this.closeButton.addListener("execute", this._closeAndDestroy, this);\r
+ this.add(this.closeButton, {edge:'south'}); \r
+ },\r
+ makePromptForm:function(questionString, validationCallback, callbackContext){\r
+ this.add(new qx.ui.basic.Label(questionString), {edge:'north'});\r
+ var textField = new qx.ui.form.TextField();\r
+ this.add(textField, {edge:'center'});\r
+ this.closeButton.removeListener("execute", this._closeAndDestroy, this);\r
+ if(callbackContext){\r
+ validationCallback = qx.lang.Function.bind(validationCallback, callbackContext);\r
+ }\r
+ this.closeButton.addListener("execute", function(e){\r
+ var valid = validationCallback(textField.getValue());\r
+ if(valid) this._closeAndDestroy();\r
+ }, this);\r
+ },\r
+ _closeAndDestroy : function(){\r
+ this.hide();\r
+ this.destroy(); \r
}\r
}\r
});
\ No newline at end of file