]> git.argeo.org Git - gpl/argeo-slc.git/blob - org.argeo.slc.webapp/src/main/webapp/source/class/org/argeo/slc/web/components/ViewsManager.js
Huge refactoring
[gpl/argeo-slc.git] / org.argeo.slc.webapp / src / main / webapp / source / class / org / argeo / slc / web / components / ViewsManager.js
1 /**
2 * @author Charles du Jeu
3 */
4 qx.Class.define("org.argeo.slc.web.components.ViewsManager",
5 {
6 type : "singleton",
7 extend : qx.core.Object,
8
9 properties : {
10 applicationRoot : {init : null},
11 viewPanesContainer : {init: null}
12 },
13 construct : function(){
14 this.views = {};
15 },
16 members : {
17
18 initIViewClass: function(classObj, viewPaneId){
19 //var iView = eval("new "+iViewClass+"()");
20 //var classObj = qx.Class.getByName(iViewClass);
21 var iView = new classObj;
22 var viewPane = this.getViewPaneById(viewPaneId);
23 iView.init(viewPane);
24 var commands = iView.getCommands();
25 viewPane.empty();
26 if(commands){
27 viewPane.setCommands(commands);
28 org.argeo.slc.web.event.CommandsManager.getInstance().addCommands(commands, iView);
29 }
30 viewPane.setContent(iView);
31 return iView;
32 },
33
34 registerViewPane : function(viewPane){
35 this.views[viewPane.getViewId()] = viewPane;
36 viewPane.getViewSelection().addListener("changeSelection", function(e){
37 org.argeo.slc.web.event.CommandsManager.getInstance().refreshCommands(e.getData());
38 });
39 },
40 getViewPaneById : function(viewPaneId){
41 if(this.views[viewPaneId]) return this.views[viewPaneId];
42 throw new Error("Cannot find view '"+viewPaneId+"'");
43 },
44 getViewPaneSelection : function(viewPaneId){
45 return this.getViewPaneById(viewPaneId).getViewSelection();
46 },
47 setViewPaneTitle : function(viewPaneId, viewTitle){
48 this.getViewPaneById(viewPaneId).setViewTitle(viewTitle);
49 }
50 }
51 });