Clover coverage report - Code Coverage for tapestry-contrib release 4.0-beta-12
Coverage timestamp: Sun Oct 30 2005 16:28:27 EST
file stats: LOC: 148   Methods: 6
NCLOC: 62   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
TableColumns.java 0% 0% 0% 0%
coverage
 1    // Copyright 2004, 2005 The Apache Software Foundation
 2    //
 3    // Licensed under the Apache License, Version 2.0 (the "License");
 4    // you may not use this file except in compliance with the License.
 5    // You may obtain a copy of the License at
 6    //
 7    // http://www.apache.org/licenses/LICENSE-2.0
 8    //
 9    // Unless required by applicable law or agreed to in writing, software
 10    // distributed under the License is distributed on an "AS IS" BASIS,
 11    // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12    // See the License for the specific language governing permissions and
 13    // limitations under the License.
 14   
 15    package org.apache.tapestry.contrib.table.components;
 16   
 17    import java.util.Iterator;
 18   
 19    import org.apache.tapestry.IAsset;
 20    import org.apache.tapestry.IMarkupWriter;
 21    import org.apache.tapestry.IRender;
 22    import org.apache.tapestry.IRequestCycle;
 23    import org.apache.tapestry.contrib.table.model.ITableColumn;
 24    import org.apache.tapestry.contrib.table.model.ITableColumnModel;
 25   
 26    /**
 27    * A low level Table component that renders the column headers in the table. This component must be
 28    * wrapped by {@link org.apache.tapestry.contrib.table.components.TableView}.
 29    * <p>
 30    * The component iterates over all column objects in the
 31    * {@link org.apache.tapestry.contrib.table.model.ITableColumnModel}and renders a header for each
 32    * one of them using the renderer provided by the getColumnRender() method in
 33    * {@link org.apache.tapestry.contrib.table.model.ITableColumn}. The headers are wrapped in 'th'
 34    * tags by default.
 35    * <p>
 36    * Please see the Component Reference for details on how to use this component. [ <a
 37    * href="../../../../../../../ComponentReference/contrib.TableColumns.html">Component Reference
 38    * </a>]
 39    *
 40    * @author mindbridge
 41    */
 42    public abstract class TableColumns extends AbstractTableViewComponent
 43    {
 44    public static final String TABLE_COLUMN_ARROW_UP_ATTRIBUTE = "org.apache.tapestry.contrib.table.components.TableColumns.arrowUp";
 45   
 46    public static final String TABLE_COLUMN_ARROW_DOWN_ATTRIBUTE = "org.apache.tapestry.contrib.table.components.TableColumns.arrowDown";
 47   
 48    public static final String TABLE_COLUMN_CSS_CLASS_SUFFIX = "ColumnHeader";
 49   
 50    public abstract IAsset getArrowDownAsset();
 51   
 52    public abstract IAsset getArrowUpAsset();
 53   
 54    public abstract void setColumn(ITableColumn column);
 55   
 56    // Transient
 57    private ITableColumn m_objTableColumn = null;
 58   
 59    /**
 60    * Returns the currently rendered table column. You can call this method to obtain the current
 61    * column.
 62    *
 63    * @return ITableColumn the current table column
 64    */
 65  0 public ITableColumn getTableColumn()
 66    {
 67  0 return m_objTableColumn;
 68    }
 69   
 70    /**
 71    * Sets the currently rendered table column. This method is for internal use only.
 72    *
 73    * @param tableColumn
 74    * The current table column
 75    */
 76  0 public void setTableColumn(ITableColumn tableColumn)
 77    {
 78  0 m_objTableColumn = tableColumn;
 79   
 80  0 if (isParameterBound("column"))
 81  0 setColumn(tableColumn);
 82    }
 83   
 84    /**
 85    * Get the list of all table columns to be displayed.
 86    *
 87    * @return an iterator of all table columns
 88    */
 89  0 public Iterator getTableColumnIterator()
 90    {
 91  0 ITableColumnModel objColumnModel = getTableModelSource().getTableModel().getColumnModel();
 92  0 return objColumnModel.getColumns();
 93    }
 94   
 95    /**
 96    * Returns the renderer to be used to generate the header of the current column
 97    *
 98    * @return the header renderer of the current column
 99    */
 100  0 public IRender getTableColumnRenderer()
 101    {
 102  0 return getTableColumn().getColumnRenderer(
 103    getPage().getRequestCycle(),
 104    getTableModelSource());
 105    }
 106   
 107    public abstract String getColumnClassParameter();
 108   
 109    /**
 110    * Returns the CSS class of the generated table cell. It uses the class parameter if it has been
 111    * bound, or the default value of "[column name]ColumnHeader" otherwise.
 112    *
 113    * @return the CSS class of the cell
 114    */
 115  0 public String getColumnClass()
 116    {
 117  0 if (isParameterBound("class"))
 118  0 return getColumnClassParameter();
 119   
 120  0 return getTableColumn().getColumnName() + TABLE_COLUMN_CSS_CLASS_SUFFIX;
 121    }
 122   
 123    /**
 124    * @see org.apache.tapestry.BaseComponent#renderComponent(IMarkupWriter, IRequestCycle)
 125    */
 126  0 protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle)
 127    {
 128  0 Object oldValueUp = cycle.getAttribute(TABLE_COLUMN_ARROW_UP_ATTRIBUTE);
 129  0 Object oldValueDown = cycle.getAttribute(TABLE_COLUMN_ARROW_DOWN_ATTRIBUTE);
 130   
 131  0 try
 132    {
 133  0 cycle.setAttribute(TABLE_COLUMN_ARROW_UP_ATTRIBUTE, getArrowUpAsset());
 134  0 cycle.setAttribute(TABLE_COLUMN_ARROW_DOWN_ATTRIBUTE, getArrowDownAsset());
 135   
 136  0 super.renderComponent(writer, cycle);
 137    }
 138    finally
 139    {
 140  0 cycle.setAttribute(TABLE_COLUMN_ARROW_UP_ATTRIBUTE, oldValueUp);
 141  0 cycle.setAttribute(TABLE_COLUMN_ARROW_DOWN_ATTRIBUTE, oldValueDown);
 142   
 143    // set the current column to null when the component is not active
 144  0 m_objTableColumn = null;
 145    }
 146    }
 147   
 148    }