]>
git.argeo.org Git - gpl/argeo-slc.git/blob - org.argeo.slc.webapp/src/main/webapp/argeo-ria-src/class/org/argeo/ria/components/TabbedViewPane.js
2 * A more elaborate views container than ViewPane, as it can handle multiple contents
3 * at once via a TabView.
4 * See {@link org.argeo.ria.components.ViewPane}.
6 qx
.Class
.define("org.argeo.ria.components.TabbedViewPane",
8 extend
: qx
.ui
.container
.Composite
,
9 implement
: [org
.argeo
.ria
.components
.ILoadStatusable
],
12 * @param viewId {String} Unique id of this viewPane
13 * @param viewTitle {String} Readable Title of this viewPane
15 construct : function(viewId
, viewTitle
){
17 this.setViewId(viewId
);
18 this._defaultViewTitle
= viewTitle
;
19 this.setLayout(new qx
.ui
.layout
.Canvas());
20 this.blurredDecorator
= new qx
.ui
.decoration
.Uniform(1, "solid", "#000");
21 this.blurredDecorator
.setBackgroundImage("decoration/app-header.png");
22 this.blurredDecorator
.setBackgroundRepeat("scale");
23 this.setDecorator(this.blurredDecorator
);
25 this.focusedDecorator
= new qx
.ui
.decoration
.Uniform(1, "solid", "#065fb2");
26 this.focusedDecorator
.setBackgroundImage("decoration/app-header.png");
27 this.focusedDecorator
.setBackgroundRepeat("scale");
29 this.tabView
= new qx
.ui
.tabview
.TabView();
30 this.tabView
.setAppearance("widget");
32 this.add(this.tabView
, {top
: 7, width
:"100%", bottom
:0});
33 this.tabView
.setBackgroundColor("#fff");
34 this.tabView
.setMarginTop(27);
36 this.tabView
.addListener("changeSelected", function(){
37 this.fireEvent("changeSelection");
41 this.setFocusable(true);
42 this.addListener("click", function(e
){
43 this.fireDataEvent("changeFocus", this);
51 * Unique id of the pane
55 * Human-readable title for this view
57 viewTitle
: {init
:"", event
:"changeViewTitle"},
59 * Has its own scrollable content
61 ownScrollable
: {init
: false, check
:"Boolean"},
63 * Map of commands definition
64 * @see org.argeo.ria.event.Command
66 commands
: {init
: null, nullable
:true, check
:"Map"}
72 * Checks if the pane already contains a given view, identified by its instance id
73 * @param contentId {Mixed} The instance id to check
76 contentExists : function(contentId
){
77 if(this.pageIds
[contentId
]){
78 this.tabView
.setSelected(this.pageIds
[contentId
]);
79 return this.pageIds
[contentId
].getUserData("argeoria.iview");
83 * Sets a new instance in the tabbed pane.
84 * @param content {org.argeo.ria.components.IView} The applet to add.
86 setContent : function(content
){
87 if(!this.tabView
.getChildren().length
){
88 this.tabView
.setBackgroundColor("transparent");
89 this.tabView
.setMarginTop(0);
91 var contentId
= content
.getInstanceId();
92 var page
= new qx
.ui
.tabview
.Page(content
.getInstanceLabel());
93 this.pageIds
[contentId
] = page
;
95 page
.setLayout(new qx
.ui
.layout
.Canvas());
96 page
.add(content
, {width
:"100%", top
:0, bottom
:0});
97 this.tabView
.add(page
);
98 page
.setUserData("argeoria.iview", content
);
99 content
.getViewSelection().addListener("changeSelection", function(e
){
100 this.fireEvent("changeSelection");
102 this.tabView
.setSelected(page
);
105 * Get the currently selected tab content, if any.
106 * @return {org.argeo.ria.components.IView} The currently selected view.
108 getContent : function(){
109 if(this._getCrtPage()){
110 return this._getCrtPage().getUserData("argeoria.iview");
115 * Get the currently selected tab ViewSelection object.
116 * @return {org.argeo.ria.components.ViewSelection} The view selection object of the currently selected view.
118 getViewSelection : function(){
119 if(!this.getContent()) return null;
120 return this.getContent().getViewSelection();
123 * Return the currently selected tab Page.
124 * @return {qx.ui.tabview.Page} The page
126 _getCrtPage : function(){
127 return this.tabView
.getSelected();
130 * Closes the currently selected view and remove all tabs components (button, page).
132 closeCurrent : function(){
133 var crtPage
= this._getCrtPage();
135 var iView
= crtPage
.getUserData("argeoria.iview");
136 var iViewInstance
= iView
.getInstanceId();
138 this.tabView
.remove(crtPage
);
139 delete(this.pageIds
[iViewInstance
]);
140 if(!this.tabView
.getChildren().length
){ // No more tabs : remove commands!
141 if(this.getCommands()){
142 org
.argeo
.ria
.event
.CommandsManager
.getInstance().removeCommands(this.getCommands(), this.getViewId());
143 this.setCommands(null);
145 this.tabView
.setBackgroundColor("#fff");
146 this.tabView
.setMarginTop(27);
150 * Call closeCurrent() recursively until there is no more page.
153 var crtPage
= this._getCrtPage();
156 crtPage
= this._getCrtPage();
160 * Sets the tabView on "load" state. Nothing is done at the moment.
161 * @param load {Boolean} Load status
163 setOnLoad : function(load
){
167 * Sets a graphical indicator that this pane has the focus. A blue border.
170 if(this.hasFocus
) return;
171 this.fireEvent("changeSelection");
172 this.setDecorator(this.focusedDecorator
);
173 this.hasFocus
= true;
176 * Remove a graphical focus indicator on this pane.
179 this.hasFocus
= false;
180 this.setDecorator(this.blurredDecorator
);