]> git.argeo.org Git - gpl/argeo-slc.git/blobdiff - org.argeo.slc.webapp/src/main/webapp/argeo-ria-lib/slc/class/org/argeo/slc/ria/execution/SpecEditor.js
Data model for batch entry, spec editor basis.
[gpl/argeo-slc.git] / org.argeo.slc.webapp / src / main / webapp / argeo-ria-lib / slc / class / org / argeo / slc / ria / execution / SpecEditor.js
diff --git a/org.argeo.slc.webapp/src/main/webapp/argeo-ria-lib/slc/class/org/argeo/slc/ria/execution/SpecEditor.js b/org.argeo.slc.webapp/src/main/webapp/argeo-ria-lib/slc/class/org/argeo/slc/ria/execution/SpecEditor.js
new file mode 100644 (file)
index 0000000..f302c3d
--- /dev/null
@@ -0,0 +1,90 @@
+/**\r
+ * Generic modal popup window.\r
+ * It is layed out with a dock layout. When adding components to it, they are added as "center".\r
+ * @author Charles du Jeu\r
+ */\r
+qx.Class.define("org.argeo.slc.ria.execution.SpecEditor",\r
+{\r
+       extend : qx.ui.window.Window,\r
+  \r
+       events : {\r
+               /**\r
+                * Triggered when the user clicks the "ok" button. \r
+                */\r
+               "ok" : "qx.event.type.Event"\r
+       },\r
+       /**\r
+        * \r
+        * @param caption {String} Title of the window\r
+        * @param icon {String} Icon of the window\r
+        * @param text {String} Default content of the window.\r
+        */\r
+       construct : function(executionFlow){\r
+               this.base(arguments, "Spec Editor");\r
+               this.set({\r
+                       showMaximize : false,\r
+                       showMinimize : false,\r
+                       width: parseInt(qx.bom.Viewport.getWidth()*80/100),\r
+                       height: parseInt(qx.bom.Viewport.getHeight()*80/100)\r
+               });\r
+               this.setLayout(new qx.ui.layout.Dock());\r
+               this.setModal(true);\r
+               this.center();\r
+               if(executionFlow){\r
+                       this.addContent(new qx.ui.basic.Label("Editing specs for flow : "+executionFlow.getName()));\r
+               }else{\r
+                       this.addCloseButton();\r
+               }\r
+       },\r
+       \r
+       members : {\r
+               /**\r
+                * Display a component (panel) in the center of the popup\r
+                * @param panel {qx.ui.core.Widget} A gui component (will be set at width 100%).\r
+                */\r
+               addContent: function(panel){\r
+                       this.add(panel, {edge:'center', width:'100%'});\r
+                       this.addCloseButton();\r
+               },\r
+               /**\r
+                * Automatically attach to the application root, then show.\r
+                */\r
+               attachAndShow:function(){\r
+                       org.argeo.ria.components.ViewsManager.getInstance().getApplicationRoot().add(this);                     \r
+                       this.show();\r
+               },\r
+               /**\r
+                * Adds a close button bottom-center aligned to the popup\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
+               /**\r
+                * Adds two buttons bottom-center aligned (Ok and Cancel). \r
+                * Ok button has no listener by default, Cancel will close and destroy the popup.\r
+                */\r
+               addOkCancel : function(){\r
+                       var buttonPane = new qx.ui.container.Composite(new qx.ui.layout.HBox(5, 'right'));\r
+                       buttonPane.setAlignX("center");\r
+                       this.add(buttonPane, {edge:"south"});\r
+                       this.okButton = new qx.ui.form.Button("Ok");\r
+                       this.okButton.addListener("execute", function(e){\r
+                               this.fireEvent("ok");\r
+                               this._closeAndDestroy();\r
+                       }, this);\r
+                       this.cancelButton = new qx.ui.form.Button("Cancel");\r
+                       this.cancelButton.addListener("execute", this._closeAndDestroy, this);\r
+                       buttonPane.add(this.okButton);\r
+                       buttonPane.add(this.cancelButton);\r
+               },\r
+               /**\r
+                * Close this modal window and destroy it.\r
+                */\r
+               _closeAndDestroy : function(){\r
+                       this.hide();\r
+                       this.destroy();                 \r
+               }\r
+       }\r
+});
\ No newline at end of file