]>
git.argeo.org Git - gpl/argeo-slc.git/blob - org.argeo.slc.webapp/src/main/webapp/source/class/org/argeo/ria/components/ViewPane.js
485a264c028bce0b7fb79c747c1f0b448c843911
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
);
22 var viewSelection
= new org
.argeo
.ria
.components
.ViewSelection(viewId
);
23 this.setViewSelection(viewSelection
);
25 this.setSplitPaneData(splitPaneData
);
33 * Unique id of the pane
37 * Human-readable title for this view
39 viewTitle
: {init
:"", event
:"changeViewTitle"},
41 * Selection model for this view
43 viewSelection
: { nullable
:false, check
:"org.argeo.ria.components.ViewSelection" },
45 * Has its own scrollable content
47 ownScrollable
: {init
: false, check
:"Boolean"},
49 * Data concerning the split pane
51 splitPaneData
: {init
: null, check
:"Map"},
53 * Map of commands definition
54 * @see org.argeo.ria.event.Command
56 commands
: {init
: null, nullable
:true, check
:"Map"}
60 *****************************************************************************
62 *****************************************************************************
68 * Creates a standard GUI for the viewPane, including a container for an IView.
70 createGui : function(){
71 this.setLayout(new qx
.ui
.layout
.VBox());
72 this.header
= new qx
.ui
.container
.Composite();
73 this.header
.setLayout(new qx
.ui
.layout
.Dock());
74 this.header
.set({appearance
:"app-header"});
75 this.headerLabel
= new qx
.ui
.basic
.Label(this.getViewTitle());
76 this.header
.add(this.headerLabel
, {edge
:"west"});
77 this.addListener("changeViewTitle", function(e
){
78 this.headerLabel
.setContent(e
.getData());
80 this.add(this.header
);
81 this.setDecorator(new qx
.ui
.decoration
.Single(1,"solid","#000"));
83 // Open close button of splitPane, not very useful at the moment.
84 if(this.getSplitPaneData()){
85 var data = this.getSplitPaneData();
86 var imgName = (data.orientation=="horizontal"?"go-left":"go-bottom");
87 var image = new qx.ui.basic.Image("resource/slc/"+imgName+".png");
88 image.addListener("click", function(e){
89 var image = e.getTarget();
90 var data = this.getSplitPaneData();
91 var functionDim = (data.orientation=="horizontal"?"Width":"Height");
92 var objectToResize = data.object || this;
93 var crtDim = objectToResize["get"+functionDim]();
94 var minimize = (data.orientation=="horizontal"?"go-right":"go-top");
95 var maximize = (data.orientation=="horizontal"?"go-left":"go-bottom");
96 if(crtDim > data.min){
97 objectToResize["set"+functionDim](data.min);
98 image.setSource("resource/slc/"+minimize+".png");
99 this.origDimension = crtDim;
101 if(this.origDimension){
102 objectToResize["set"+functionDim](this.origDimension);
103 image.setSource("resource/slc/"+maximize+".png");
107 this.header.add(image,{edge:"east"});
113 * Sets the content of this pane.
114 * @param content {org.argeo.ria.components.IView} An IView implementation
116 setContent : function(content
){
117 var addScrollable
= (content
.addScroll
?content
.addScroll():false);
119 this.setOwnScrollable(true);
120 this.scrollable
= new qx
.ui
.container
.Scroll(content
);
121 this.add(this.scrollable
, {flex
: 1});
123 this.content
= content
;
124 this.add(this.content
, {flex
:1});
129 * Implementation of the ILoadStatusable interface.
130 * @see org.argeo.ria.components.ILoadStatusable
131 * @param load {Boolean} The loading status
133 setOnLoad : function(load
){
135 this.loadImage
= new qx
.ui
.basic
.Image('resource/slc/ajax-loader.gif');
138 this.header
.add(this.loadImage
, {edge
:"east"});
140 this.header
.remove(this.loadImage
);
145 * Removes and destroy the IView content of this viewPane.
148 if(this.getOwnScrollable() && this.scrollable
){
149 this.remove(this.scrollable
);
150 }else if(this.content
){
151 this.remove(this.content
);
153 if(this.getCommands()){
154 org
.argeo
.ria
.event
.CommandsManager
.getInstance().removeCommands(this.getCommands());
155 this.setCommands(null);
157 this.setViewTitle(this._defaultViewTitle
);