]>
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},
23 * Keeps the currently focused viewPane.
25 currentFocus
: {init
:null}
27 construct : function(){
32 * Initialize and load a given IView implementation into a viewPane.
33 * The IView itself is returned.
35 * @param classObj {Clazz} The class object to instantiate
36 * @param viewPaneId {String} The unique ID of the view pane
37 * @param data {Mixed} Any data provided by the opener.
38 * @return {org.argeo.ria.components.IView}
40 initIViewClass: function(classObj
, viewPaneId
, data
){
41 var viewPane
= this.getViewPaneById(viewPaneId
);
42 var iView
= new classObj
;
43 iView
.init(viewPane
, data
);
44 var existingView
= viewPane
.contentExists(iView
.getInstanceId());
49 var commands
= iView
.getCommands();
52 viewPane
.setCommands(commands
);
53 org
.argeo
.ria
.event
.CommandsManager
.getInstance().addCommands(commands
, "view:"+viewPaneId
, viewPaneId
);
55 viewPane
.setContent(iView
);
56 this.setViewPaneFocus(viewPane
);
61 * Registers a new viewPane
62 * @param viewPane {org.argeo.ria.components.ViewPane} The new ViewPane instance
64 registerViewPane : function(viewPane
){
65 this.views
[viewPane
.getViewId()] = viewPane
;
66 viewPane
.addListener("changeSelection", function(e
){
67 var viewSelection
= e
.getTarget().getViewSelection();
68 if(!viewSelection
) return;
69 org
.argeo
.ria
.event
.CommandsManager
.getInstance().refreshCommands(viewSelection
);
71 viewPane
.addListener("changeFocus", function(e
){
72 this.setViewPaneFocus(e
.getTarget());
76 * Sets a given viewPane as the currently focused one. Blur the others.
77 * @param viewPane {org.argeo.ria.components.ViewPane} The viewPane (or TabbedViewPane) to focus on.
79 setViewPaneFocus : function(viewPane
){
80 for(var key
in this.views
){
81 this.views
[key
].blur();
83 this.setCurrentFocus(viewPane
);
87 * Returns a viewPane by its unique id.
88 * @param viewPaneId {String} The unique id
89 * @return {org.argeo.ria.components.ViewPane}
91 getViewPaneById : function(viewPaneId
){
92 if(this.views
[viewPaneId
]) return this.views
[viewPaneId
];
93 throw new Error("Cannot find view '"+viewPaneId
+"'");
96 * Returns a viewPane current viewSelection object
97 * @param viewPaneId {String} The unique id.
98 * @return {org.argeo.ria.components.ViewSelection}
100 getViewPaneSelection : function(viewPaneId
){
101 return this.getViewPaneById(viewPaneId
).getViewSelection();
104 * Changes a viewPane title dynamically.
105 * @param viewPaneId {String} ViewPane unique Id.
106 * @param viewTitle {String} the new title for this viewPane.
108 setViewPaneTitle : function(viewPaneId
, viewTitle
){
109 this.getViewPaneById(viewPaneId
).setViewTitle(viewTitle
);