]>
git.argeo.org Git - gpl/argeo-slc.git/blob - org.argeo.slc.webapp/src/main/webapp/argeo-ria-src/class/org/argeo/ria/components/ViewPane.js
2 * A standard view container, referenced in the application by its unique id.
3 * It is managed by the ViewsManager singleton that works as the "View" part of an MVC model.
4 * @see org.argeo.ria.components.ViewsManager
7 qx
.Class
.define("org.argeo.ria.components.ViewPane",
9 extend
: qx
.ui
.container
.Composite
,
10 implement
: [org
.argeo
.ria
.components
.ILoadStatusable
],
13 * @param viewId {String} Unique id of this viewPane
14 * @param viewTitle {String} Readable Title of this viewPane
15 * @param splitPaneData {Map} Additionnal data to be used by splitpanes implementations.
17 construct : function(viewId
, viewTitle
, splitPaneData
){
19 this.setViewId(viewId
);
20 this._defaultViewTitle
= viewTitle
;
21 this.setViewTitle(viewTitle
);
23 this.setSplitPaneData(splitPaneData
);
25 this.setFocusable(true);
26 this.addListener("click", function(e
){
27 this.fireDataEvent("changeFocus", this);
33 "changeFocus" : "qx.event.type.Data",
34 "changeSelection" : "qx.event.type.Event"
40 * Unique id of the pane
44 * Human-readable title for this view
46 viewTitle
: {init
:"", event
:"changeViewTitle"},
48 * Has its own scrollable content
50 ownScrollable
: {init
: false, check
:"Boolean"},
52 * Data concerning the split pane
54 splitPaneData
: {init
: null, check
:"Map"},
56 * Map of commands definition
57 * @see org.argeo.ria.event.Command
59 commands
: {init
: null, nullable
:true, check
:"Map"},
61 * The real business content.
66 check
: "org.argeo.ria.components.IView",
67 apply
: "_applyContent"
72 *****************************************************************************
74 *****************************************************************************
80 * Creates a standard GUI for the viewPane, including a container for an IView.
82 createGui : function(){
83 this.setLayout(new qx
.ui
.layout
.VBox());
84 this.header
= new qx
.ui
.container
.Composite();
85 this.header
.setLayout(new qx
.ui
.layout
.Dock());
86 this.loadImage
= new qx
.ui
.basic
.Image('resource/slc/ajax-loader.gif');
87 this.header
.set({appearance
:"app-header", height
:34});
88 this.headerLabel
= new qx
.ui
.basic
.Label(this.getViewTitle());
89 this.header
.add(this.headerLabel
, {edge
:"west"});
90 this.addListener("changeViewTitle", function(e
){
91 var newTitle
= e
.getData();
93 this.headerLabel
.setContent(newTitle
);
94 if(e
.getOldData() == ""){
95 this.header
.add(this.headerLabel
, {edge
:"west"});
98 this.header
.remove(this.headerLabel
);
101 this.add(this.header
);
102 this.setDecorator(new qx
.ui
.decoration
.Single(1,"solid","#000"));
104 // Open close button of splitPane, not very useful at the moment.
105 if(this.getSplitPaneData()){
106 var data = this.getSplitPaneData();
107 var imgName = (data.orientation=="horizontal"?"go-left":"go-bottom");
108 var image = new qx.ui.basic.Image("resource/slc/"+imgName+".png");
109 image.addListener("click", function(e){
110 var image = e.getTarget();
111 var data = this.getSplitPaneData();
112 var functionDim = (data.orientation=="horizontal"?"Width":"Height");
113 var objectToResize = data.object || this;
114 var crtDim = objectToResize["get"+functionDim]();
115 var minimize = (data.orientation=="horizontal"?"go-right":"go-top");
116 var maximize = (data.orientation=="horizontal"?"go-left":"go-bottom");
117 if(crtDim > data.min){
118 objectToResize["set"+functionDim](data.min);
119 image.setSource("resource/slc/"+minimize+".png");
120 this.origDimension = crtDim;
122 if(this.origDimension){
123 objectToResize["set"+functionDim](this.origDimension);
124 image.setSource("resource/slc/"+maximize+".png");
128 this.header.add(image,{edge:"east"});
133 getViewSelection : function(){
134 if(this.getContent()){
135 return this.getContent().getViewSelection();
140 contentExists : function(iViewId
){
141 if(this.getContent()){
148 * Sets the content of this pane.
149 * @param content {org.argeo.ria.components.IView} An IView implementation
151 _applyContent : function(content
){
152 if(content
== null) return;
153 var addScrollable
= (content
.addScroll
?content
.addScroll():false);
155 this.setOwnScrollable(true);
156 this.scrollable
= new qx
.ui
.container
.Scroll(content
);
157 this.add(this.scrollable
, {flex
: 1});
159 this.guiContent
= content
;
160 this.add(this.guiContent
, {flex
:1});
162 content
.getViewSelection().addListener("changeSelection", function(e
){
163 this.fireEvent("changeSelection");
167 * Adds a graphical component too the header of the view pane.
168 * It is added as "center" in the dock layout, and will override the view pane title label.
169 * For example, you can add your own title, or add a switch, or buttons, etc.
170 * @param component {qx.ui.core.Widget} The graphical component to add.
172 addHeaderComponent : function(component
){
173 this.header
.setPadding(4);
174 this.header
.add(component
, {edge
:"center"});
175 component
.setTextColor("#1a1a1a");
176 this.loadImage
.setMargin(4);
180 * Implementation of the ILoadStatusable interface.
181 * @see org.argeo.ria.components.ILoadStatusable
182 * @param load {Boolean} The loading status
184 setOnLoad : function(load
){
186 this.header
.add(this.loadImage
, {edge
:"east"});
188 this.header
.remove(this.loadImage
);
193 * Removes and destroy the IView content of this viewPane.
196 if(this.getOwnScrollable() && this.scrollable
){
197 this.remove(this.scrollable
);
198 }else if(this.guiContent
){
199 this.remove(this.guiContent
);
201 if(this.getCommands()){
202 org
.argeo
.ria
.event
.CommandsManager
.getInstance().removeCommands(this.getCommands());
203 this.setCommands(null);
205 if(this.getContent()){
206 this.getContent().close();
208 this.setViewTitle(this._defaultViewTitle
);
209 this.setContent(null);
213 if(this.hasFocus
) return;
214 this.setDecorator(new qx
.ui
.decoration
.Single(1,"solid","#065fb2"));
215 this.fireEvent("changeSelection");
216 this.hasFocus
= true;
219 this.hasFocus
= false;
220 this.setDecorator(new qx
.ui
.decoration
.Single(1,"solid","#000"));