| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| Tabs |
|
| 0.0;0 |
| 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.*; | |
| 28 | import org.apache.tapestry5.annotations.*; | |
| 29 | import org.apache.tapestry5.ioc.annotations.Inject; | |
| 30 | import org.equanda.tapestry5.base.TitleContent; | |
| 31 | ||
| 32 | /** | |
| 33 | * Tabs component | |
| 34 | * | |
| 35 | * @author <a href="mailto:joachim@progs.be">Joachim Van der Auwera</a> | |
| 36 | */ | |
| 37 | @SupportsInformalParameters | |
| 38 | 0 | public class Tabs |
| 39 | extends TitleContent | |
| 40 | { | |
| 41 | private static final int CURRENT = 0; | |
| 42 | @Inject | |
| 43 | @Path( "${tapestry.scriptaculous}/prototype.js" ) | |
| 44 | private Asset prototype; | |
| 45 | ||
| 46 | @Inject | |
| 47 | @Path( "classpath:/org/equanda/tapestry5/resources/tabs.js" ) | |
| 48 | private Asset script; | |
| 49 | ||
| 50 | @Parameter | |
| 51 | private Block contentAll; | |
| 52 | ||
| 53 | @Environmental | |
| 54 | private RenderSupport renderSupport; | |
| 55 | ||
| 56 | @Inject | |
| 57 | private ComponentResources resources; | |
| 58 | ||
| 59 | @BeginRender | |
| 60 | void doBeginRender( MarkupWriter writer ) | |
| 61 | { | |
| 62 | 0 | renderSupport.addScriptLink( prototype, script ); |
| 63 | 0 | } |
| 64 | ||
| 65 | public Block getContentAll() | |
| 66 | { | |
| 67 | 0 | return contentAll; |
| 68 | } | |
| 69 | ||
| 70 | public boolean hasContentAll() | |
| 71 | { | |
| 72 | 0 | return resources.isBound( "contentAll" ); |
| 73 | } | |
| 74 | ||
| 75 | public void setContentAll( Block contentAll ) | |
| 76 | { | |
| 77 | 0 | this.contentAll = contentAll; |
| 78 | 0 | } |
| 79 | ||
| 80 | /** | |
| 81 | * String index for previous tab if any | |
| 82 | * | |
| 83 | * @return index for previous tab as string or null | |
| 84 | */ | |
| 85 | public String getBackward() | |
| 86 | { | |
| 87 | 0 | int index = getIndex(); |
| 88 | 0 | if ( index == 0 ) return null; |
| 89 | 0 | return Integer.toString( index - 1 ); |
| 90 | } | |
| 91 | ||
| 92 | /** | |
| 93 | * String index for next tab if any | |
| 94 | * | |
| 95 | * @return index for next tab as string or null | |
| 96 | */ | |
| 97 | public String getForward() | |
| 98 | { | |
| 99 | 0 | int index = getIndex() + 1; |
| 100 | 0 | if ( index == getPanelCount() ) return null; |
| 101 | 0 | return Integer.toString( index ); |
| 102 | } | |
| 103 | ||
| 104 | /** | |
| 105 | * Indication (class) of whether this is the active tab. | |
| 106 | * | |
| 107 | * @return style for active tab title | |
| 108 | */ | |
| 109 | public String getActive() | |
| 110 | { | |
| 111 | 0 | if ( getIndex() == CURRENT ) return "equandaTabsActive equandaTraverseSkip"; |
| 112 | 0 | return ""; |
| 113 | } | |
| 114 | ||
| 115 | /** | |
| 116 | * display method, depending on "current" panel | |
| 117 | * | |
| 118 | * @return "block" or "none" | |
| 119 | */ | |
| 120 | public String getDisplay() | |
| 121 | { | |
| 122 | 0 | if ( getIndex() == CURRENT ) return "block"; |
| 123 | 0 | return "none"; |
| 124 | } | |
| 125 | } |