1 /**
2 * This file is part of the equanda project.
3 *
4 * The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at http://www.mozilla.org/MPL/
7 *
8 * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
9 * ANY KIND, either express or implied. See the License for the specific language governing rights and
10 * limitations under the License.
11 *
12 * Alternatively, the contents of this file may be used under the terms of
13 * either the GNU General Public License Version 2 or later (the "GPL"), or
14 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
15 * in which case the provisions of the GPL or the LGPL are applicable instead
16 * of those above. If you wish to allow use of your version of this file only
17 * under the terms of either the GPL or the LGPL, and not to allow others to
18 * use your version of this file under the terms of the MPL, indicate your
19 * decision by deleting the provisions above and replace them with the notice
20 * and other provisions required by the GPL or the LGPL. If you do not delete
21 * the provisions above, a recipient may use your version of this file under
22 * the terms of any one of the MPL, the GPL or the LGPL.
23 */
24
25 package org.equanda.tapestry5.components;
26
27 import org.apache.tapestry5.Block;
28 import org.apache.tapestry5.ComponentResources;
29 import org.apache.tapestry5.annotations.IncludeJavaScriptLibrary;
30 import org.apache.tapestry5.annotations.Parameter;
31 import org.apache.tapestry5.annotations.SupportsInformalParameters;
32 import org.apache.tapestry5.ioc.annotations.Inject;
33 import org.equanda.tapestry5.base.TitleContent;
34
35 /**
36 * Tabs component
37 *
38 * @author <a href="mailto:joachim@progs.be">Joachim Van der Auwera</a>
39 */
40 @IncludeJavaScriptLibrary( { "${tapestry.scriptaculous}/prototype.js",
41 "classpath:/org/equanda/tapestry5/resources/t5equanda.js" } )
42 @SupportsInformalParameters
43 public class Tabs
44 extends TitleContent
45 {
46 @Parameter
47 private Block contentAll;
48
49 @Inject
50 private ComponentResources resources;
51
52 public boolean isUsingCookies()
53 {
54 return true;
55 }
56
57 public Block getContentAll()
58 {
59 return contentAll;
60 }
61
62 public boolean hasContentAll()
63 {
64 return resources.isBound( "contentAll" );
65 }
66
67 public void setContentAll( Block contentAll )
68 {
69 this.contentAll = contentAll;
70 }
71
72 /**
73 * String index for previous tab if any
74 *
75 * @return index for previous tab as string or null
76 */
77 public String getBackward()
78 {
79 int index = getIndex();
80 if ( index == 0 ) return null;
81 return Integer.toString( index - 1 );
82 }
83
84 /**
85 * String index for next tab if any
86 *
87 * @return index for next tab as string or null
88 */
89 public String getForward()
90 {
91 int index = getIndex() + 1;
92 if ( index == getPanelCount() ) return null;
93 return Integer.toString( index );
94 }
95 }