#*
Copyright 2004 The Apache Software Foundation

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*#

#**

@author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
@version $Id: database-browser-portlet.vm,v 1.14 2004/08/29 22:27:27 jford Exp $

*#

#set ($MESSAGES = $portletConfig.getResourceBundle($renderRequest.Locale))

#if ($statusMsg)
#parse ('/WEB-INF/view/status-include.vm')
#end

<table cellpadding=0 cellspacing=1 border=0 width="100%">
  <tbody>
  <tr>
    #foreach ($column in $title)
	  #set ($columnLink = $renderResponse.createRenderURL())
	  $columnLink.setParameter("js_dbcolumn",$column)
      <td align=CENTER class="jetdbHead" width="43" nowrap onClick="window.location.href='$columnLink'">
        <div align="center">$column</div>
      </td>
    #end
    #if ($rowLinks)
        #if ($rowLinks.size() > 0)
            <td align=CENTER width="43" class="jetdbHead"></td>
        #end
    #end
  </tr>
  #foreach ( $row in $table )
  <tr>
     #if ($velocityCount % 2 == 0)
       #set ($rowstyle = "jetdbEven")
	 #else
      #set ($rowstyle = "jetdbOdd")
	 #end   
    #foreach ( $entry in $row )
      #if ($velocityCount == 1)
        #set ($rowid = $entry)
      #end
      <td nowrap class="$rowstyle" width="23">
        <div class="$rowstyle" align="center">$entry</div>
      </td>
    #end
    #if ($rowLinks)
        #if ($rowLinks.size() > 0)
            <td class="listCell" nowrap width="100">
            #foreach ($rowLink in $rowLinks)
                #set ($rName = $MESSAGES.get($rowLink.Name))
                #if($rowLink.Type=="pane")
                    #set ($link1 = $jslink.setPaneByName($rowLink.Action).addQueryData("js_rowid",$rowid).addQueryData("js_mode",$rName))
                #else
                    #set ($link1 = $jslink.setPage($rowLink.Page).addQueryData("js_rowid",$rowid).addQueryData("js_mode",$rName))
                #end
                <a class="listCell" href='$link1'>$rName</a>&nbsp;
            #end
            </td>
        #end
    #end
  </tr>
  #end
  #if ($tableLinks)
    #if ($tableLinks.size() > 0)
      <tr>
        <td>&nbsp;
        </td>
      </tr>
      <tr>
        #foreach ($tableLink in $tableLinks)
            #set ($tName = $MESSAGES.get($tableLink.Name) )
            #if ($tableLink.Type == "pane")
                #set ($link2 = $jslink.setPaneByName($tableLink.Action).addQueryData("js_mode",$tName))
            #else
                #set ($link2 = $jslink.setPage($tableLink.Page).addQueryData("js_mode",$tName))
            #end
            <td><a href='$link2'>$tName</a></td>
        #end
      </tr>
    #end
  #end
  </tbody>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr bgcolor="#6868AB">
    <td>&nbsp;
    </td>
  </tr>
</table>
<table width="200" border="0" cellspacing="0" cellpadding="0" align="center">
  <tr>
    #if ($prev)
      <td valign="middle" height="30">
        <div align="center">
          <form action="$renderResponse.createActionURL()" method="post">
          	<input type='hidden' name='db.browser.action' value='first'/>                    
            <input class="jetdbButton" type="submit" value="<<">
            <input type="hidden" name="start" value="0">
          </form>
        </div>
      </td>  
      <td valign="middle" height="30">
        <div align="center">
          <form action="$renderResponse.createActionURL()" method="post">
          	<input type='hidden' name='db.browser.action' value='prev'/>                    
            <input class="jetdbButton" type="submit" value="<">
            <input type="hidden" name="start" value="$prev">
          </form>
        </div>
      </td>
    #end
    #if ($tableSize > 0)
      <form action="$renderResponse.createActionURL()" method="post">
      <td valign="middle" height="30">
        <div align="center">
          	<input type='hidden' name='db.browser.action' value='change'/>                    
            <input type="input" name='start' size='5' value="$start">
        </div>
      </td>  
      <td valign="middle" height="30">
        <div align="center">
            <input type="input" readonly size='10' value="of $tableSize">            
        </div>
      </td>  
      <td valign="middle" height="30">
        <div align="center">
            <input class="jetdbButton" type="submit" value="Go">            
        </div>
      </td>  

      </form>

      
    #end    
    #if ($next)
      <td valign="middle">
        <div align="center">
          <form action="$renderResponse.createActionURL()" method="post">
          	<input type='hidden' name='db.browser.action' value='next'/>          
            <input class="jetdbButton" type="submit" value=">">
            <input type="hidden" name="start" value="$next">
          </form>
        </div>
      </td>
      <td valign="middle" height="30">
        <div align="center">
          <form action="$renderResponse.createActionURL()" method="post">
          	<input type='hidden' name='db.browser.action' value='last'/>                    
            <input class="jetdbButton" type="submit" value=">>">
            <input type="hidden" name="start" value="$tableSize">
          </form>
        </div>
      </td>  
    #end
    #if ($tableSize > 0)
      <td valign="middle">
        <div align="center">
          <form action="$renderResponse.createActionURL()" method="post">
          	<input type='hidden' name='db.browser.action' value='refresh'/>
            <input class="jetdbButton" type="submit" name="eventSubmit_doRefresh" value="$MESSAGES.getString('dbrefresh')" />
          </form>
        </div>
      </td>
    #end
  </tr>
</table>
