]> git.argeo.org Git - gpl/argeo-slc.git/blobdiff - org.argeo.slc.webapp/src/main/webapp/source/class/org/argeo/ria/components/ViewPane.js
Show info in a little popup
[gpl/argeo-slc.git] / org.argeo.slc.webapp / src / main / webapp / source / class / org / argeo / ria / components / ViewPane.js
index 485a264c028bce0b7fb79c747c1f0b448c843911..e04970c4388420c54df81b805e1dcc7c55a6950b 100644 (file)
@@ -53,7 +53,16 @@ qx.Class.define("org.argeo.ria.components.ViewPane",
         * Map of commands definition
         * @see org.argeo.ria.event.Command 
         */
-       commands : {init : null, nullable:true, check:"Map"}
+       commands : {init : null, nullable:true, check:"Map"},
+       /**
+        * The real business content. 
+        */
+       content : {
+               init: null,
+               nullable : true,
+               check : "org.argeo.ria.components.IView",
+               apply : "_applyContent"
+       }
   },
   
   /*
@@ -71,11 +80,20 @@ qx.Class.define("org.argeo.ria.components.ViewPane",
                this.setLayout(new qx.ui.layout.VBox());
                this.header = new qx.ui.container.Composite();
                this.header.setLayout(new qx.ui.layout.Dock());
-               this.header.set({appearance:"app-header"});
+               this.loadImage = new qx.ui.basic.Image('resource/slc/ajax-loader.gif');
+               this.header.set({appearance:"app-header", height:34});
                this.headerLabel = new qx.ui.basic.Label(this.getViewTitle()); 
                this.header.add(this.headerLabel, {edge:"west"});
                this.addListener("changeViewTitle", function(e){
-                       this.headerLabel.setContent(e.getData());
+                       var newTitle = e.getData();
+                       if(newTitle != ""){
+                               this.headerLabel.setContent(newTitle);
+                               if(e.getOldData() == ""){
+                                       this.header.add(this.headerLabel, {edge:"west"});
+                               }
+                       }else{
+                               this.header.remove(this.headerLabel);
+                       }
                }, this);
                this.add(this.header);
                this.setDecorator(new qx.ui.decoration.Single(1,"solid","#000"));
@@ -113,17 +131,24 @@ qx.Class.define("org.argeo.ria.components.ViewPane",
         * Sets the content of this pane.
         * @param content {org.argeo.ria.components.IView} An IView implementation
         */
-       setContent : function(content){
+       _applyContent : function(content){
+               if(content == null) return;
                var addScrollable = (content.addScroll?content.addScroll():false);
                if(addScrollable){
                        this.setOwnScrollable(true);
                        this.scrollable = new qx.ui.container.Scroll(content);
                        this.add(this.scrollable, {flex: 1});
                }else{
-                       this.content = content;
-                       this.add(this.content, {flex:1});
+                       this.guiContent = content;
+                       this.add(this.guiContent, {flex:1});
                }
        },
+               
+       addHeaderComponent : function(component){
+               this.header.setPadding(4);
+               this.header.add(component, {edge:"center"});
+               this.loadImage.setMargin(4);
+       },
        
        /**
         * Implementation of the ILoadStatusable interface.
@@ -131,9 +156,6 @@ qx.Class.define("org.argeo.ria.components.ViewPane",
         * @param load {Boolean} The loading status
         */
        setOnLoad : function(load){
-               if(!this.loadImage){
-                       this.loadImage = new qx.ui.basic.Image('resource/slc/ajax-loader.gif');
-               }
                if(load){
                        this.header.add(this.loadImage, {edge:"east"});
                }else{
@@ -147,14 +169,15 @@ qx.Class.define("org.argeo.ria.components.ViewPane",
        empty: function(){
                if(this.getOwnScrollable() && this.scrollable){
                        this.remove(this.scrollable);
-               }else if(this.content){
-                       this.remove(this.content);
+               }else if(this.guiContent){
+                       this.remove(this.guiContent);
                }
                if(this.getCommands()){
                        org.argeo.ria.event.CommandsManager.getInstance().removeCommands(this.getCommands());
                        this.setCommands(null);
                }
                this.setViewTitle(this._defaultViewTitle);
+               this.setContent(null);
        }
 
   }