|
|||||||||||||||||||
| 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 | |||||||||||||||
| Section.java | 41,7% | 40,7% | 44,4% | 41,7% |
|
||||||||||||||
| 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.RenderContext; |
|
| 10 |
import com.tirsen.angkor.View; |
|
| 11 |
|
|
| 12 |
import java.io.IOException; |
|
| 13 |
|
|
| 14 |
/** |
|
| 15 |
* |
|
| 16 |
* |
|
| 17 |
* <!-- $Id: Section.java,v 1.5 2002/10/09 21:37:37 tirsen Exp $ --> |
|
| 18 |
* <!-- $Author: tirsen $ --> |
|
| 19 |
* |
|
| 20 |
* @author Jon Tirsén (tirsen@users.sourceforge.net) |
|
| 21 |
* @version $Revision: 1.5 $ |
|
| 22 |
*/ |
|
| 23 |
public class Section extends Container |
|
| 24 |
{
|
|
| 25 |
private String headerLabel; |
|
| 26 |
private String background = null; |
|
| 27 |
//private String width; |
|
| 28 |
//private String height; |
|
| 29 |
|
|
| 30 | 1 |
public Section() |
| 31 |
{
|
|
| 32 |
} |
|
| 33 |
|
|
| 34 | 0 |
public Section(String headerLabel) |
| 35 |
{
|
|
| 36 | 0 |
setHeaderLabel(headerLabel); |
| 37 |
} |
|
| 38 |
|
|
| 39 | 0 |
public Section(SectionLine line) |
| 40 |
{
|
|
| 41 | 0 |
add(line); |
| 42 |
} |
|
| 43 |
|
|
| 44 | 2 |
public String getHeaderLabel() |
| 45 |
{
|
|
| 46 | 2 |
return headerLabel; |
| 47 |
} |
|
| 48 |
|
|
| 49 | 0 |
public void setHeaderLabel(String headerLabel) |
| 50 |
{
|
|
| 51 | 0 |
this.headerLabel = headerLabel; |
| 52 |
} |
|
| 53 |
|
|
| 54 |
/** |
|
| 55 |
* Can only add Sections or SectionLines to a Section, if you try to add anything else |
|
| 56 |
* it a SectionLine will be instantiated for it. |
|
| 57 |
*/ |
|
| 58 | 2 |
public void add(int index, View element) |
| 59 |
{
|
|
| 60 | 2 |
if (element instanceof Section || element instanceof SectionLine) |
| 61 |
{
|
|
| 62 | 2 |
super.add(index, element); |
| 63 |
} |
|
| 64 |
else |
|
| 65 |
{
|
|
| 66 | 0 |
super.add(index, new SectionLine(element)); |
| 67 |
} |
|
| 68 |
} |
|
| 69 |
|
|
| 70 |
/** |
|
| 71 |
* Adds a TextLabel as a string to this section on its own line. |
|
| 72 |
*/ |
|
| 73 | 0 |
public void add(String text) |
| 74 |
{
|
|
| 75 | 0 |
add(new TextLabel(text)); |
| 76 |
} |
|
| 77 |
|
|
| 78 | 0 |
public int getSectionDepth() |
| 79 |
{
|
|
| 80 | 0 |
int depth = 0; |
| 81 | 0 |
for (View container = this; container instanceof Section; depth++) |
| 82 |
{
|
|
| 83 | 0 |
container = container.getContainer(); |
| 84 |
} |
|
| 85 | 0 |
return depth; |
| 86 |
} |
|
| 87 |
|
|
| 88 | 2 |
public void render(RenderContext context) throws IOException |
| 89 |
{
|
|
| 90 | 2 |
if (isVisible()) |
| 91 |
{
|
|
| 92 | 2 |
if (getContainer() instanceof Section) |
| 93 |
{
|
|
| 94 | 0 |
context.startTag("TR");
|
| 95 | 0 |
context.startTag("TD");
|
| 96 |
} |
|
| 97 |
|
|
| 98 | 2 |
if (getHeaderLabel() != null) |
| 99 |
{
|
|
| 100 | 0 |
context.startTag("H" + getSectionDepth());
|
| 101 | 0 |
context.println(getHeaderLabel()); |
| 102 | 0 |
context.endTag("H" + getSectionDepth());
|
| 103 |
} |
|
| 104 |
|
|
| 105 | 2 |
String idAttr = " id=\"" + uniqueId(context) + "\""; |
| 106 | 2 |
context.startTag("TABLE width=\"100%\"" + background + idAttr);
|
| 107 | 2 |
renderChildren(context); |
| 108 |
|
|
| 109 | 2 |
context.endTag("TABLE");
|
| 110 | 2 |
if (getContainer() instanceof Section) |
| 111 |
{
|
|
| 112 | 0 |
context.endTag("TD");
|
| 113 | 0 |
context.endTag("TR");
|
| 114 |
} |
|
| 115 |
} |
|
| 116 |
} |
|
| 117 |
} |
|
| 118 |
|
|
||||||||||