]> git.argeo.org Git - gpl/argeo-slc.git/blob - org.argeo.slc.webapp/src/main/webapp/source/class/org/argeo/ria/components/Modal.js
2c8aef04d6f6ce9b7338f9402fa2cae82809e07d
[gpl/argeo-slc.git] / org.argeo.slc.webapp / src / main / webapp / source / class / org / argeo / ria / components / Modal.js
1 /**
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
5 */
6 qx.Class.define("org.argeo.ria.components.Modal",
7 {
8 extend : qx.ui.window.Window,
9
10 /**
11 *
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.
15 */
16 construct : function(caption, icon, text){
17 this.base(arguments);
18 this.set({
19 showMaximize : false,
20 showMinimize : false,
21 width: 200,
22 height: 150
23 });
24 this.setLayout(new qx.ui.layout.Dock());
25 var closeButton = new qx.ui.form.Button("Close");
26 closeButton.addListener("execute", function(e){
27 this.hide();
28 this.destroy();
29 }, this);
30 this.add(closeButton, {edge:'south'});
31 this.setModal(true);
32 this.center();
33 if(text){
34 this.addLabel(text);
35 }
36 },
37
38 members : {
39 /**
40 * Display text inside the popup
41 * @param text {String} A string content for the popup
42 */
43 addLabel:function(text){
44 this.add(new qx.ui.basic.Label(text), {edge:'center', width:'100%'});
45 },
46 /**
47 * Display a component (panel) in the center of the popup
48 * @param panel {qx.ui.core.Widget} A gui component (will be set at width 100%).
49 */
50 addContent: function(panel){
51 this.add(panel, {edge:'center', width:'100%'});
52 },
53 /**
54 * Automatically attach to the application root, then show.
55 */
56 attachAndShow:function(){
57 org.argeo.ria.components.ViewsManager.getInstance().getApplicationRoot().add(this);
58 this.show();
59 }
60 }
61 });