]>
git.argeo.org Git - gpl/argeo-slc.git/blob - org.argeo.slc.webapp/src/main/webapp/argeo-ria-src/class/org/argeo/ria/components/ViewsManager.js
2 * The main "view" manager (in a standard MVC conception) of the application.
3 * It register various containers org.argeo.ria.components.viewPane and feed them with org.argeo.ria.components.IView implementations.
4 * It is a singleton and can thus be called by any part of the application.
6 * @author Charles du Jeu
8 qx
.Class
.define("org.argeo.ria.components.ViewsManager",
11 extend
: qx
.core
.Object
,
15 * The application root (like Application.getRoot()), used to attach and show modal windows.
17 applicationRoot
: {init
: null},
19 * The main container for the org.argeo.ria.components.ViewPane instances.
21 viewPanesContainer
: {init
: null},
22 currentFocus
: {init
:null}
24 construct : function(){
29 * Initialize and load a given IView implementation into a viewPane.
30 * The IView itself is returned.
32 * @param classObj {Clazz} The class object to instantiate
33 * @param viewPaneId {String} The unique ID of the view pane
34 * @return {org.argeo.ria.components.IView}
36 initIViewClass: function(classObj
, viewPaneId
, data
){
37 var viewPane
= this.getViewPaneById(viewPaneId
);
38 var iView
= new classObj
;
39 iView
.init(viewPane
, data
);
40 var existingView
= viewPane
.contentExists(iView
.getInstanceId());
45 var commands
= iView
.getCommands();
48 viewPane
.setCommands(commands
);
49 org
.argeo
.ria
.event
.CommandsManager
.getInstance().addCommands(commands
, "view:"+viewPaneId
, viewPaneId
);
51 viewPane
.setContent(iView
);
56 * Registers a new viewPane
57 * @param viewPane {org.argeo.ria.components.ViewPane} The new ViewPane instance
59 registerViewPane : function(viewPane
){
60 this.views
[viewPane
.getViewId()] = viewPane
;
61 viewPane
.addListener("changeSelection", function(e
){
62 var viewSelection
= e
.getTarget().getViewSelection();
63 if(!viewSelection
) return;
64 org
.argeo
.ria
.event
.CommandsManager
.getInstance().refreshCommands(viewSelection
);
66 viewPane
.addListener("changeFocus", function(e
){
67 for(var key
in this.views
){
68 this.views
[key
].blur();
71 this.setCurrentFocus(viewPane
);
75 * Returns a viewPane by its unique id.
76 * @param viewPaneId {String} The unique id
77 * @return {org.argeo.ria.components.ViewPane}
79 getViewPaneById : function(viewPaneId
){
80 if(this.views
[viewPaneId
]) return this.views
[viewPaneId
];
81 throw new Error("Cannot find view '"+viewPaneId
+"'");
84 * Returns a viewPane current viewSelection object
85 * @param viewPaneId {String} The unique id.
86 * @return {org.argeo.ria.components.ViewSelection}
88 getViewPaneSelection : function(viewPaneId
){
89 return this.getViewPaneById(viewPaneId
).getViewSelection();
92 * Changes a viewPane title dynamically.
93 * @param viewPaneId {String} ViewPane unique Id.
94 * @param viewTitle {String} the new title for this viewPane.
96 setViewPaneTitle : function(viewPaneId
, viewTitle
){
97 this.getViewPaneById(viewPaneId
).setViewTitle(viewTitle
);