]> git.argeo.org Git - gpl/argeo-slc.git/blob - org.argeo.slc.webapp/src/main/webapp/argeo-ria-lib/slc/class/org/argeo/slc/ria/execution/SpecEditor.js
Update activemq version
[gpl/argeo-slc.git] / org.argeo.slc.webapp / src / main / webapp / argeo-ria-lib / slc / class / org / argeo / slc / ria / execution / SpecEditor.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.slc.ria.execution.SpecEditor",
7 {
8 extend : qx.ui.window.Window,
9
10 events : {
11 /**
12 * Triggered when the user clicks the "ok" button.
13 */
14 "ok" : "qx.event.type.Event"
15 },
16 /**
17 *
18 * @param caption {String} Title of the window
19 * @param icon {String} Icon of the window
20 * @param text {String} Default content of the window.
21 */
22 construct : function(executionFlow){
23 this.base(arguments, "Spec Editor");
24 this.set({
25 showMaximize : false,
26 showMinimize : false,
27 width: parseInt(qx.bom.Viewport.getWidth()*80/100),
28 height: parseInt(qx.bom.Viewport.getHeight()*80/100)
29 });
30 this.setLayout(new qx.ui.layout.Dock());
31 this.setModal(true);
32 this.center();
33 if(executionFlow){
34 this.addContent(new qx.ui.basic.Label("Editing specs for flow : "+executionFlow.getName()));
35 }else{
36 this.addCloseButton();
37 }
38 },
39
40 members : {
41 /**
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%).
44 */
45 addContent: function(panel){
46 this.add(panel, {edge:'center', width:'100%'});
47 this.addCloseButton();
48 },
49 /**
50 * Automatically attach to the application root, then show.
51 */
52 attachAndShow:function(){
53 org.argeo.ria.components.ViewsManager.getInstance().getApplicationRoot().add(this);
54 this.show();
55 },
56 /**
57 * Adds a close button bottom-center aligned to the popup
58 */
59 addCloseButton : function(){
60 this.closeButton = new qx.ui.form.Button("Close");
61 this.closeButton.addListener("execute", this._closeAndDestroy, this);
62 this.add(this.closeButton, {edge:'south'});
63 },
64 /**
65 * Adds two buttons bottom-center aligned (Ok and Cancel).
66 * Ok button has no listener by default, Cancel will close and destroy the popup.
67 */
68 addOkCancel : function(){
69 var buttonPane = new qx.ui.container.Composite(new qx.ui.layout.HBox(5, 'right'));
70 buttonPane.setAlignX("center");
71 this.add(buttonPane, {edge:"south"});
72 this.okButton = new qx.ui.form.Button("Ok");
73 this.okButton.addListener("execute", function(e){
74 this.fireEvent("ok");
75 this._closeAndDestroy();
76 }, this);
77 this.cancelButton = new qx.ui.form.Button("Cancel");
78 this.cancelButton.addListener("execute", this._closeAndDestroy, this);
79 buttonPane.add(this.okButton);
80 buttonPane.add(this.cancelButton);
81 },
82 /**
83 * Close this modal window and destroy it.
84 */
85 _closeAndDestroy : function(){
86 this.hide();
87 this.destroy();
88 }
89 }
90 });