]> git.argeo.org Git - gpl/argeo-slc.git/blob - org.argeo.slc.webapp/src/main/webapp/source/class/org/argeo/ria/components/ViewPane.js
25e8f10e6b186651ca8a6c1d3a7ff32f0668dc44
[gpl/argeo-slc.git] / org.argeo.slc.webapp / src / main / webapp / source / class / org / argeo / ria / components / ViewPane.js
1 /**
2 * @author Charles
3 */
4 /**
5 * This is the main application class of your custom application "sparta"
6 */
7 qx.Class.define("org.argeo.ria.components.ViewPane",
8 {
9 extend : qx.ui.container.Composite,
10 implement : [org.argeo.ria.components.ILoadStatusable],
11
12 construct : function(application, viewId, viewTitle, splitPaneData){
13 this.base(arguments);
14 this.setApplication(application);
15 this.setViewId(viewId);
16 this._defaultViewTitle = viewTitle;
17 this.setViewTitle(viewTitle);
18 var viewSelection = new org.argeo.ria.components.ViewSelection(viewId);
19 this.setViewSelection(viewSelection);
20 if(splitPaneData){
21 this.setSplitPaneData(splitPaneData);
22 }
23 this.createGui();
24 },
25
26 properties :
27 {
28 application : {init : null},
29 viewId : {init:""},
30 viewTitle : {init:"", event:"changeViewTitle"},
31 viewSelection : { nullable:false },
32 ownScrollable : {init: false},
33 splitPaneData : {init : null},
34 commands : {init : null, nullable:true}
35 },
36
37 /*
38 *****************************************************************************
39 MEMBERS
40 *****************************************************************************
41 */
42
43 members :
44 {
45 createGui : function(){
46 this.setLayout(new qx.ui.layout.VBox());
47 this.header = new qx.ui.container.Composite();
48 this.header.setLayout(new qx.ui.layout.Dock());
49 this.header.set({appearance:"app-header"});
50 this.headerLabel = new qx.ui.basic.Label(this.getViewTitle());
51 this.header.add(this.headerLabel, {edge:"west"});
52 this.addListener("changeViewTitle", function(e){
53 this.headerLabel.setContent(e.getData());
54 }, this);
55 this.add(this.header);
56 this.setDecorator(new qx.ui.decoration.Single(1,"solid","#000"));
57 /*
58 // Open close button of splitPane, not very useful at the moment.
59 if(this.getSplitPaneData()){
60 var data = this.getSplitPaneData();
61 var imgName = (data.orientation=="horizontal"?"go-left":"go-bottom");
62 var image = new qx.ui.basic.Image("resource/slc/"+imgName+".png");
63 image.addListener("click", function(e){
64 var image = e.getTarget();
65 var data = this.getSplitPaneData();
66 var functionDim = (data.orientation=="horizontal"?"Width":"Height");
67 var objectToResize = data.object || this;
68 var crtDim = objectToResize["get"+functionDim]();
69 var minimize = (data.orientation=="horizontal"?"go-right":"go-top");
70 var maximize = (data.orientation=="horizontal"?"go-left":"go-bottom");
71 if(crtDim > data.min){
72 objectToResize["set"+functionDim](data.min);
73 image.setSource("resource/slc/"+minimize+".png");
74 this.origDimension = crtDim;
75 }else{
76 if(this.origDimension){
77 objectToResize["set"+functionDim](this.origDimension);
78 image.setSource("resource/slc/"+maximize+".png");
79 }
80 }
81 }, this);
82 this.header.add(image,{edge:"east"});
83 }
84 */
85 },
86
87 setContent : function(content){
88 var addScrollable = (content.addScroll?content.addScroll():false);
89 if(addScrollable){
90 this.setOwnScrollable(true);
91 this.scrollable = new qx.ui.container.Scroll(content);
92 this.add(this.scrollable, {flex: 1});
93 }else{
94 this.content = content;
95 this.add(this.content, {flex:1});
96 }
97 },
98
99 setOnLoad : function(load){
100 if(!this.loadImage){
101 this.loadImage = new qx.ui.basic.Image('resource/slc/ajax-loader.gif');
102 }
103 if(load){
104 this.header.add(this.loadImage, {edge:"east"});
105 }else{
106 this.header.remove(this.loadImage);
107 }
108 },
109
110 empty: function(){
111 if(this.getOwnScrollable() && this.scrollable){
112 this.remove(this.scrollable);
113 }else if(this.content){
114 this.remove(this.content);
115 }
116 if(this.getCommands()){
117 org.argeo.ria.event.CommandsManager.getInstance().removeCommands(this.getCommands());
118 this.setCommands(null);
119 }
120 this.setViewTitle(this._defaultViewTitle);
121 }
122
123 }
124 });