]>
git.argeo.org Git - gpl/argeo-slc.git/blob - org.argeo.slc.webapp/src/main/webapp/argeo-ria-src/class/org/argeo/ria/components/Modal.js
2 * Generic modal popup window.
3 * It is layed out with a dock layout. When adding components to it, they are added as "center".
4 * @author Charles du Jeu
6 qx
.Class
.define("org.argeo.ria.components.Modal",
8 extend
: qx
.ui
.window
.Window
,
12 * @param caption {String} Title of the window
13 * @param icon {String} Icon of the window
14 * @param text {String} Default content of the window.
16 construct : function(caption
, icon
, text
){
17 this.base(arguments
, caption
, icon
);
24 this.setLayout(new qx
.ui
.layout
.Dock());
34 * Display text inside the popup
35 * @param text {String} A string content for the popup
37 addLabel:function(text
){
38 this.add(new qx
.ui
.basic
.Label(text
), {edge
:'center', width
:'100%'});
39 this.addCloseButton();
42 * Display a component (panel) in the center of the popup
43 * @param panel {qx.ui.core.Widget} A gui component (will be set at width 100%).
45 addContent: function(panel
){
46 this.add(panel
, {edge
:'center', width
:'100%'});
47 this.addCloseButton();
50 * Automatically attach to the application root, then show.
52 attachAndShow:function(){
53 org
.argeo
.ria
.components
.ViewsManager
.getInstance().getApplicationRoot().add(this);
56 addCloseButton : function(){
57 this.closeButton
= new qx
.ui
.form
.Button("Close");
58 this.closeButton
.addListener("execute", this._closeAndDestroy
, this);
59 this.add(this.closeButton
, {edge
:'south'});
61 addOkCancel : function(){
62 var buttonPane
= new qx
.ui
.container
.Composite(new qx
.ui
.layout
.HBox(5, 'right'));
63 buttonPane
.setAlignX("center");
64 this.add(buttonPane
, {edge
:"south"});
65 this.okButton
= new qx
.ui
.form
.Button("Ok");
66 this.cancelButton
= new qx
.ui
.form
.Button("Cancel");
67 this.cancelButton
.addListener("execute", this._closeAndDestroy
, this);
68 buttonPane
.add(this.cancelButton
);
69 buttonPane
.add(this.okButton
);
71 makePromptForm:function(questionString
, validationCallback
, callbackContext
){
72 this.add(new qx
.ui
.basic
.Label(questionString
), {edge
:'north'});
73 var textField
= new qx
.ui
.form
.TextField();
74 textField
.setMarginTop(20);
75 this.add(textField
, {edge
:'center'});
78 validationCallback
= qx
.lang
.Function
.bind(validationCallback
, callbackContext
);
80 this.okButton
.addListener("execute", function(e
){
81 var valid
= validationCallback(textField
.getValue());
82 if(valid
) this._closeAndDestroy();
85 _closeAndDestroy : function(){