|
|||||||||||||||||||
| Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover. | |||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| SectionLine.java | 57,1% | 94,7% | 75% | 78,4% |
|
||||||||||||||
| 1 |
/* |
|
| 2 |
* Angkor Web Framework |
|
| 3 |
* |
|
| 4 |
* Distributable under LGPL license. |
|
| 5 |
* See terms of license at gnu.org. |
|
| 6 |
*/ |
|
| 7 |
package com.tirsen.angkor.widget; |
|
| 8 |
|
|
| 9 |
import com.tirsen.angkor.Debug; |
|
| 10 |
import com.tirsen.angkor.RenderContext; |
|
| 11 |
import com.tirsen.angkor.View; |
|
| 12 |
import org.apache.log4j.Category; |
|
| 13 |
|
|
| 14 |
import java.io.IOException; |
|
| 15 |
import java.util.Iterator; |
|
| 16 |
|
|
| 17 |
/** |
|
| 18 |
* |
|
| 19 |
* |
|
| 20 |
* <!-- $Id: SectionLine.java,v 1.5 2002/10/09 21:37:37 tirsen Exp $ --> |
|
| 21 |
* <!-- $Author: tirsen $ --> |
|
| 22 |
* |
|
| 23 |
* @author Jon Tirsén (tirsen@users.sourceforge.net) |
|
| 24 |
* @version $Revision: 1.5 $ |
|
| 25 |
*/ |
|
| 26 |
public class SectionLine extends Container |
|
| 27 |
{
|
|
| 28 |
private static final Category logger = Debug.getCategory(); |
|
| 29 |
|
|
| 30 | 0 |
public SectionLine() |
| 31 |
{
|
|
| 32 |
} |
|
| 33 |
|
|
| 34 | 2 |
public SectionLine(View singleElement) |
| 35 |
{
|
|
| 36 | 2 |
add(singleElement); |
| 37 |
} |
|
| 38 |
|
|
| 39 | 2 |
public void setContainer(View container) |
| 40 |
{
|
|
| 41 | 2 |
if (!(container instanceof Section)) |
| 42 | 0 |
throw new IllegalArgumentException("Can only add SectionLines to Section.");
|
| 43 | 2 |
super.setContainer(container); |
| 44 |
} |
|
| 45 |
|
|
| 46 | 4 |
public void render(RenderContext context) throws IOException |
| 47 |
{
|
|
| 48 | 4 |
if (isVisible()) |
| 49 |
{
|
|
| 50 | 4 |
if (getChildren() != null) |
| 51 |
{
|
|
| 52 | 4 |
boolean firstVisible = true; |
| 53 |
|
|
| 54 | 4 |
Iterator iterator = getChildren().iterator(); |
| 55 | 4 |
while (iterator.hasNext()) |
| 56 |
{
|
|
| 57 | 4 |
View view = (View) iterator.next(); |
| 58 | 4 |
if (view.isVisible()) |
| 59 |
{
|
|
| 60 |
// output only start-tag if and when we encounter the first visible |
|
| 61 | 4 |
if (firstVisible) |
| 62 |
{
|
|
| 63 | 4 |
context.startTag("TR");
|
| 64 | 4 |
firstVisible = false; |
| 65 |
} |
|
| 66 | 4 |
context.startTag("TD");
|
| 67 | 4 |
view.render(context); |
| 68 | 4 |
context.endTag("TD");
|
| 69 |
} |
|
| 70 |
} |
|
| 71 |
// output only start-tag if we encounterd a visible element |
|
| 72 | 4 |
if (!firstVisible) |
| 73 |
{
|
|
| 74 | 4 |
context.endTag("TR");
|
| 75 |
} |
|
| 76 |
} |
|
| 77 |
} |
|
| 78 |
} |
|
| 79 |
} |
|
| 80 |
|
|
||||||||||