]> git.argeo.org Git - gpl/argeo-slc.git/blobdiff - org.argeo.slc.webapp/src/main/webapp/argeo-ria-src/class/org/argeo/ria/components/ViewPane.js
API DOCUMENTATION
[gpl/argeo-slc.git] / org.argeo.slc.webapp / src / main / webapp / argeo-ria-src / class / org / argeo / ria / components / ViewPane.js
index a239f91a41e32d846f6db0cd63e6cbf89e16df6e..0ca43f32d1d4b983820651ee46e20aff2a2a4b80 100644 (file)
@@ -19,14 +19,27 @@ qx.Class.define("org.argeo.ria.components.ViewPane",
        this.setViewId(viewId);
        this._defaultViewTitle = viewTitle;
        this.setViewTitle(viewTitle);
-       var viewSelection = new org.argeo.ria.components.ViewSelection(viewId);
-       this.setViewSelection(viewSelection);
        if(splitPaneData){
                this.setSplitPaneData(splitPaneData);
        }
+       this.setFocusable(true);
+       this.addListener("click", function(e){
+               this.fireDataEvent("changeFocus", this);
+       }, this);
        this.createGui();
   },
 
+  events : {
+       /**
+        * Trigger when the focus is changing
+        */
+       "changeFocus" : "qx.event.type.Data",
+       /**
+        * Triggered when selection of content has changed.
+        */
+       "changeSelection" : "qx.event.type.Event"
+  },
+  
   properties : 
   {
        /**
@@ -37,10 +50,6 @@ qx.Class.define("org.argeo.ria.components.ViewPane",
         * Human-readable title for this view
         */
        viewTitle : {init:"", event:"changeViewTitle"},
-       /**
-        * Selection model for this view
-        */
-       viewSelection : { nullable:false, check:"org.argeo.ria.components.ViewSelection" },
        /**
         * Has its own scrollable content 
         */
@@ -127,11 +136,33 @@ qx.Class.define("org.argeo.ria.components.ViewPane",
                */
        },
        
+       /**
+        * Get the content ViewSelection object.
+        * @return {org.argeo.ria.components.ViewSelection} The view selection
+        */
+       getViewSelection : function(){
+               if(this.getContent()){
+                       return this.getContent().getViewSelection();
+               }
+               return null;
+       },
+       /**
+        * Checks if the pane already contains a given view, identified by its instance id
+        * @param iViewId {Mixed} The instance id to check
+        * @return {Boolean}
+        */     
+       contentExists : function(iViewId){
+               if(this.getContent()){
+                       this.empty();
+               }
+               return false;
+       },
+       
        /**
         * Sets the content of this pane.
         * @param content {org.argeo.ria.components.IView} An IView implementation
         */
-       _applyContent : function(content){
+       _applyContent : function(content){              
                if(content == null) return;
                var addScrollable = (content.addScroll?content.addScroll():false);
                if(addScrollable){
@@ -142,6 +173,9 @@ qx.Class.define("org.argeo.ria.components.ViewPane",
                        this.guiContent = content;
                        this.add(this.guiContent, {flex:1});
                }
+               content.getViewSelection().addListener("changeSelection", function(e){
+                       this.fireEvent("changeSelection");
+               }, this);
        },
        /**
         * Adds a graphical component too the header of the view pane.
@@ -151,7 +185,8 @@ qx.Class.define("org.argeo.ria.components.ViewPane",
         */
        addHeaderComponent : function(component){
                this.header.setPadding(4);
-               this.header.add(component, {edge:"center"});
+               this.header.add(component, {edge:"center"});            
+               component.setTextColor("#1a1a1a");
                this.loadImage.setMargin(4);
        },
        
@@ -167,7 +202,14 @@ qx.Class.define("org.argeo.ria.components.ViewPane",
                        this.header.remove(this.loadImage);
                }
        },
-       
+
+       /**
+        * Call empty() method, since this pane can only handle one view.
+        */
+       closeCurrent : function(){
+               this.empty();
+       },
+               
        /**
         * Removes and destroy the IView content of this viewPane.
         */
@@ -181,8 +223,27 @@ qx.Class.define("org.argeo.ria.components.ViewPane",
                        org.argeo.ria.event.CommandsManager.getInstance().removeCommands(this.getCommands());
                        this.setCommands(null);
                }
+               if(this.getContent()){                  
+                       this.getContent().close();
+               }
                this.setViewTitle(this._defaultViewTitle);
                this.setContent(null);
+       },
+       /**
+        * Sets a graphical indicator that this pane has the focus. A blue border.
+        */     
+       focus : function(){
+               if(this.hasFocus) return;
+               this.setDecorator(new qx.ui.decoration.Single(1,"solid","#065fb2"));
+               this.fireEvent("changeSelection");
+               this.hasFocus = true;
+       }, 
+       /**
+        * Remove a graphical focus indicator on this pane.
+        */
+       blur : function(){
+               this.hasFocus = false;
+               this.setDecorator(new qx.ui.decoration.Single(1,"solid","#000"));
        }
 
   }