1 20 package org.enhydra.barracuda.core.comp; 21 22 import java.util.*; 23 24 import org.apache.log4j.*; 25 import org.w3c.dom.*; 26 import org.w3c.dom.html.*; 27 28 import org.enhydra.barracuda.core.util.dom.DOMUtil; 29 import org.enhydra.barracuda.plankton.*; 30 31 32 39 public class DefaultTableView extends DefaultView implements TableView { 40 41 protected static final Logger logger = Logger.getLogger(DefaultTableView.class.getName()); 42 43 protected Element header = null; 44 protected Element body = null; 45 protected Element footer = null; 46 protected Element caption = null; 48 53 public DefaultTableView() { 54 this(null); 55 } 56 57 62 public DefaultTableView(Node node) { 63 if (node!=null) setNode(node); 64 } 65 66 73 public Element getHeaderElement() { 74 return header; 75 } 76 77 85 public Element getBodyElement() { 86 return (body!=null ? body : (Element) node); 87 } 88 89 96 public Element getFooterElement() { 97 return footer; 98 } 99 100 108 public Element getCaptionElement() { 109 return caption; 110 } 111 112 116 protected void customSearchForTemplates(Node curnode) { 117 if (header!=null && body!=null && footer!=null) return; 119 120 if (!(curnode instanceof Element)) return; 122 Element el = (Element) curnode; 123 if (logger.isDebugEnabled()) { 124 logger.debug("node [tag="+el.getTagName()+" id="+DOMUtil.getID(el)+"] implements the following interfaces:"); 125 Iterator it = Classes.getAllInterfaces(curnode).iterator(); 126 while (it.hasNext()) { 127 Object o = it.next(); 128 logger.debug(o.toString()); 129 } 130 } 131 132 if (curnode instanceof HTMLTableSectionElement) { 134 135 String tagName = el.getTagName().toUpperCase(); 136 if (tagName.equals("THEAD")) { 137 if (header==null) header = el; 138 } else if (tagName.equals("TBODY")) { 139 if (body==null) body = el; 140 } else if (tagName.equals("TFOOT")) { 141 if (footer==null) footer = el; 142 } 143 } 144 145 if (curnode instanceof HTMLTableCaptionElement){ 147 String tagName = el.getTagName().toUpperCase(); 148 if (tagName.equals("CAPTION")) { 149 if (caption==null) caption = el; 150 } 151 } 152 } 153 154 157 public String toString() { 158 return "TableView:"+getName()+" (bound to Node:"+DOMUtil.getID(node)+")"; 159 } 160 161 } | Popular Tags |