package net.sf.tapestry.contrib.table.components.inserted;

import net.sf.tapestry.IAsset;
import net.sf.tapestry.contrib.table.components.TablePages;

/**
 * A simple Table component ({@link net.sf.tapestry.contrib.table.components.TablePages}) that renders the pages in the table.
 * This component must be wrapped by {@link net.sf.tapestry.contrib.table.components.TableView}.
 * <p>
 * The component generates a list of pages in the Table centered around the
 * current one and allows you to navigate to other pages.
 *
 * <p>
 * <table border=1 align="center">
 * <tr>
 *    <th>Parameter</th>
 *    <th>Type</th>
 *    <th>Direction </th>
 *    <th>Required</th>
 *    <th>Default</th>
 *    <th>Description</th>
 * </tr>
 *
 * <tr>
 *  <td>pagesDisplayed</td>
 *  <td>int</td>
 *  <td>in</td>
 *  <td>no</td>
 *  <td>7</td>
 *  <td align="left">Determines the maximum number of pages to be displayed in the page list
 *      when the table has more than one page.
 *      <p>For example, if the table has 20 pages, and 10 is the current page,
 *      pages from 7 to 13 in the page list will be shown if this parameter has
 *      a value of 7.
 *  </td>
 * </tr>
 *
 * <tr>
 *  <td>arrowSLeftAsset</td>
 *  <td>IAsset</td>
 *  <td>in</td>
 *  <td>no</td>
 *  <td>null</td>
 *  <td align="left">sets the single left arrow image<p>
 *      If this parameter is not set, the default shown link image is &quot;one green arrow&quot;
 *  </td>
 * </tr>
 *
 * <tr>
 *  <td>arrowDLeftAsset</td>
 *  <td>IAsset</td>
 *  <td>in</td>
 *  <td>no</td>
 *  <td>null</td>
 *  <td align="left">sets the double left arrow image<p>
 *      If this parameter is not set, the default shown link image is &quot;two green arrows&quot;
 *  </td>
 * </tr>
 *
 * <tr>
 *  <td>arrowSRightAsset</td>
 *  <td>IAsset</td>
 *  <td>in</td>
 *  <td>no</td>
 *  <td>null</td>
 *  <td align="left">sets the single right arrow image<p>
 *      If this parameter is not set, the default shown link image is &quot;one green arrow&quot;
 *  </td>
 * </tr>
 *
 * <tr>
 *  <td>arrowDRightAsset</td>
 *  <td>IAsset</td>
 *  <td>in</td>
 *  <td>no</td>
 *  <td>null</td>
 *  <td align="left">sets the double right arrow image<p>
 *      If this parameter is not set, the default link image is &quot;two green arrows&quot;
 *  </td>
 * </tr>
 *
 * </table>
 * <p>
 * <pre>
 * $Log$
 * </pre>
 *
 * @author <a href="mailto:shomburg@hsofttec.com">Sven Homburg</a>
 * @version $Id$
 *
 */
public class SimpleTablePages extends TablePages
{
    // Bindings (in)
    private IAsset m_objArrowSLeftAsset;
    private IAsset m_objArrowDLeftAsset;
    private IAsset m_objArrowDRightAsset;
    private IAsset m_objArrowSRightAsset;

    /**
     * gets the single left arrow image
     * @return IBinding
     */
    public IAsset getArrowSLeftAsset()
    {
        if (m_objArrowSLeftAsset == null)
            m_objArrowSLeftAsset = getAsset("imageBack");

        return m_objArrowSLeftAsset;
    }

    /**
     * sets the single left arrow image
     * @param m_objArrowSLeftAsset
     */
    public void setArrowSLeftAsset(IAsset m_objArrowSLeftAsset)
    {
        this.m_objArrowSLeftAsset = m_objArrowSLeftAsset;
    }

    /**
     * gets the double left arrow image
     * @return IBinding
     */
    public IAsset getArrowDLeftAsset()
    {
        if (m_objArrowDLeftAsset == null)
            m_objArrowDLeftAsset = getAsset("imageFirst");

        return m_objArrowDLeftAsset;
    }

    /**
     * sets the double left arrow image
     * @param m_objArrowDLeftAsset
     */
    public void setArrowDLeftAsset(IAsset m_objArrowDLeftAsset)
    {
        this.m_objArrowDLeftAsset = m_objArrowDLeftAsset;
    }

    /**
     * gets the double right arrow image
     * @return IBinding
     */
    public IAsset getArrowDRightAsset()
    {
        if (m_objArrowDRightAsset == null)
            m_objArrowDRightAsset = getAsset("imageLast");

        return m_objArrowDRightAsset;
    }

    /**
     * sets the double right arrow image
     * @param m_objArrowDRightAsset
     */
    public void setArrowDRightAsset(IAsset m_objArrowDRightAsset)
    {
        this.m_objArrowDRightAsset = m_objArrowDRightAsset;
    }

    /**
     * gets the single right arrow image
     * @return IBinding
     */
    public IAsset getArrowSRightAsset()
    {
        if (m_objArrowSRightAsset == null)
            m_objArrowSRightAsset = getAsset("imageFwd");

        return m_objArrowSRightAsset;
    }

    /**
     * sets the single right arrow image
     * @param m_objArrowSRightAsset
     */
    public void setArrowSRightAsset(IAsset m_objArrowSRightAsset)
    {
        this.m_objArrowSRightAsset = m_objArrowSRightAsset;
    }

    /**
     * returns <em>false</em> if we reach the end of table data.
     * this method returns always <em>true</em>, until this method is implemented
     * in {@link net.sf.tapestry.contrib.table.components.TablePages}
     * @return
     */
    public boolean getCondFwd()
    {
        return true; // super.getCondFwd();
    }

    /**
     * returns <em>false</em> if we reach the bottom of table data.
     * this method returns always <em>true</em>, until this method is implemented
     * in {@link net.sf.tapestry.contrib.table.components.TablePages}
     * @return
     */
    public boolean getCondBack()
    {
        return true; // super.getCondBack();
    }
}
