]>
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
);
52 this.setViewPaneFocus(viewPane
);
57 * Registers a new viewPane
58 * @param viewPane {org.argeo.ria.components.ViewPane} The new ViewPane instance
60 registerViewPane : function(viewPane
){
61 this.views
[viewPane
.getViewId()] = viewPane
;
62 viewPane
.addListener("changeSelection", function(e
){
63 var viewSelection
= e
.getTarget().getViewSelection();
64 if(!viewSelection
) return;
65 org
.argeo
.ria
.event
.CommandsManager
.getInstance().refreshCommands(viewSelection
);
67 viewPane
.addListener("changeFocus", function(e
){
68 this.setViewPaneFocus(e
.getTarget());
71 setViewPaneFocus : function(viewPane
){
72 for(var key
in this.views
){
73 this.views
[key
].blur();
75 this.setCurrentFocus(viewPane
);
79 * Returns a viewPane by its unique id.
80 * @param viewPaneId {String} The unique id
81 * @return {org.argeo.ria.components.ViewPane}
83 getViewPaneById : function(viewPaneId
){
84 if(this.views
[viewPaneId
]) return this.views
[viewPaneId
];
85 throw new Error("Cannot find view '"+viewPaneId
+"'");
88 * Returns a viewPane current viewSelection object
89 * @param viewPaneId {String} The unique id.
90 * @return {org.argeo.ria.components.ViewSelection}
92 getViewPaneSelection : function(viewPaneId
){
93 return this.getViewPaneById(viewPaneId
).getViewSelection();
96 * Changes a viewPane title dynamically.
97 * @param viewPaneId {String} ViewPane unique Id.
98 * @param viewTitle {String} the new title for this viewPane.
100 setViewPaneTitle : function(viewPaneId
, viewTitle
){
101 this.getViewPaneById(viewPaneId
).setViewTitle(viewTitle
);