X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=org.argeo.slc.webapp%2Fsrc%2Fmain%2Fwebapp%2Fargeo-ria-src%2Fclass%2Forg%2Fargeo%2Fria%2Fcomponents%2FViewsManager.js;h=225bc693bca4ee9b6d7b28d1657eb5c3b5dbfe21;hb=614cd339a65450805c1684af40bba14db6a8333f;hp=689e61b356f8ee9460fbb71d933a34521498e21c;hpb=c6b00aeb38c5111dbc0532d52586a92d7e127540;p=gpl%2Fargeo-slc.git diff --git a/org.argeo.slc.webapp/src/main/webapp/argeo-ria-src/class/org/argeo/ria/components/ViewsManager.js b/org.argeo.slc.webapp/src/main/webapp/argeo-ria-src/class/org/argeo/ria/components/ViewsManager.js index 689e61b35..225bc693b 100644 --- a/org.argeo.slc.webapp/src/main/webapp/argeo-ria-src/class/org/argeo/ria/components/ViewsManager.js +++ b/org.argeo.slc.webapp/src/main/webapp/argeo-ria-src/class/org/argeo/ria/components/ViewsManager.js @@ -18,7 +18,11 @@ qx.Class.define("org.argeo.ria.components.ViewsManager", /** * The main container for the org.argeo.ria.components.ViewPane instances. */ - viewPanesContainer : {init: null} + viewPanesContainer : {init: null}, + /** + * Keeps the currently focused viewPane. + */ + currentFocus : {init :null} }, construct : function(){ this.views = {}; @@ -30,19 +34,26 @@ qx.Class.define("org.argeo.ria.components.ViewsManager", * * @param classObj {Clazz} The class object to instantiate * @param viewPaneId {String} The unique ID of the view pane + * @param data {Mixed} Any data provided by the opener. * @return {org.argeo.ria.components.IView} */ - initIViewClass: function(classObj, viewPaneId){ + initIViewClass: function(classObj, viewPaneId, data){ + var viewPane = this.getViewPaneById(viewPaneId); var iView = new classObj; - var viewPane = this.getViewPaneById(viewPaneId); - iView.init(viewPane); + iView.init(viewPane, data); + var existingView = viewPane.contentExists(iView.getInstanceId()); + if(existingView){ + delete iView; + return existingView; + } var commands = iView.getCommands(); - viewPane.empty(); + //viewPane.empty(); if(commands){ viewPane.setCommands(commands); - org.argeo.ria.event.CommandsManager.getInstance().addCommands(commands, "view:"+viewPaneId); + org.argeo.ria.event.CommandsManager.getInstance().addCommands(commands, "view:"+viewPaneId, viewPaneId); } - viewPane.setContent(iView); + viewPane.setContent(iView); + this.setViewPaneFocus(viewPane); return iView; }, @@ -52,9 +63,25 @@ qx.Class.define("org.argeo.ria.components.ViewsManager", */ registerViewPane : function(viewPane){ this.views[viewPane.getViewId()] = viewPane; - viewPane.getViewSelection().addListener("changeSelection", function(e){ - org.argeo.ria.event.CommandsManager.getInstance().refreshCommands(e.getData()); - }); + viewPane.addListener("changeSelection", function(e){ + var viewSelection = e.getTarget().getViewSelection(); + if(!viewSelection) return; + org.argeo.ria.event.CommandsManager.getInstance().refreshCommands(viewSelection); + }); + viewPane.addListener("changeFocus", function(e){ + this.setViewPaneFocus(e.getTarget()); + }, this); + }, + /** + * Sets a given viewPane as the currently focused one. Blur the others. + * @param viewPane {org.argeo.ria.components.ViewPane} The viewPane (or TabbedViewPane) to focus on. + */ + setViewPaneFocus : function(viewPane){ + for(var key in this.views){ + this.views[key].blur(); + } + this.setCurrentFocus(viewPane); + viewPane.focus(); }, /** * Returns a viewPane by its unique id.