<%
/**
 * Created by The eXo Platform SARL
 * Author : Dang Van Minh
 *          minh.dang@exoplatform.com
 * Aug 30, 2007
 * 9:21:26 AM 
 */
%>
<%
  import org.exoplatform.ecm.webui.utils.Utils ;
  import org.exoplatform.services.jcr.RepositoryService;  
  
  RepositoryService rService = uicomponent.getApplicationComponent(RepositoryService.class) ;
  String repository = rService.getCurrentRepository().getConfiguration().getName() ;    
  int totalItems = uicomponent.getDrives().size();
%>
<div class="UIDriveList" id="$uicomponent.id">
  <% if (totalItems > 5) { %>
  <div style="margin:1px 0px 5px 0px;">
    <%
      uicomponent.getUIPageIterator().setUseMaxSizeSetting(true);
      _ctx.renderUIComponent(uicomponent.getUIPageIterator());
    %>
  </div>
  <% } %>
<div class = "FixTableSize">
  <table class="UIGrid">
    <thead>
      <tr>
  	    <th><%=_ctx.appRes("UIDriveList.header.icon")%></th>
  	    <th><%=_ctx.appRes("UIDriveList.header.name")%></th>
  	    <th><%=_ctx.appRes("UIDriveList.header.workspace")%></th>
  	    <th><%=_ctx.appRes("UIDriveList.header.homePath")%></th>
  	    <th><%=_ctx.appRes("UIDriveList.header.permissions")%></th>
  	    <th><%=_ctx.appRes("UIDriveList.header.views")%></th>
  	    <th><%=_ctx.appRes("UIDriveList.header.action")%></th>
      </tr>
    </thead>
    <tbody>
      <%
        def rowClass = null ;
  	    boolean even = true ;
  	    for (drive in uicomponent.getDriveList()) {
  	      if(even) rowClass = "EvenRow" ;  
  	      else rowClass =  "OddRow" ; 
  	      even = !even ;
      %>
          <tr class="$rowClass">
            <td>
            <%
              if(drive.getIcon() != null && drive.getIcon().length() > 0) {
                String[] iconPath = drive.getIcon().split(":/") ;
            %>
                <img src="/${uicomponent.getPortalName()}/rest/jcr/${repository}/${iconPath[0]}/${iconPath[1]}" alt="" width="20px" height="20px" />
            <%} else {%>
              <span></span>
            <%}%>
            </td>
            <td><div class="Text" title="<%=drive.getName().replace("|", " | ")%>"><%=drive.getName().replace("|", " | ")%></div></td>
            <td><div class="Text" title="$drive.workspace">$drive.workspace</div></td>
            <td><div class="Text" title="<%=drive.getHomePath().replace("/", " /")%>"><%=drive.getHomePath().replace("/", " /")%></div></td>
            <td><div class="Text" title="$drive.permissions">$drive.permissions</div></td>
            <td><div class="Text" title="$drive.views">$drive.views</div></td>
	          <td>
	          	<div class="ActionContainer">
	              <img src="/eXoResources/skin/sharedImages/Blank.gif" onclick="<%=uicomponent.event("EditInfo", Utils.formatNodeName(drive.getName()))%>" title="<%=_ctx.appRes("UIDriveList.tooltip.EditInfo")%>" alt="" class="Edit16x16Icon" />
	              <img src="/eXoResources/skin/sharedImages/Blank.gif" onclick="<%=uicomponent.event("Delete", Utils.formatNodeName(drive.getName()))%>" title="<%=_ctx.appRes("UIDriveList.tooltip.Delete")%>" alt="" class="Delete16x16Icon" />
			        </div>
	          </td>	                    
          </tr>
      <%}%>  
    </tbody>
  </table>
  </div>
  <% if (totalItems > 5) { %>
  <div style="margin:1px 0px 5px 0px;">
    <%
      uicomponent.getUIPageIterator().setUseMaxSizeSetting(false);
      _ctx.renderUIComponent(uicomponent.getUIPageIterator());
    %>
  </div>
  <% } %>
  <div class="UIAction">
	  <% for(action in uicomponent.getActions()) { %>
			<a onclick="<%=uicomponent.event(action)%>" class="ActionButton LightBlueStyle" href="javascript:void(0);"><%=_ctx.appRes("UIDriveList.action." + action)%></a>
	  <% } %>
    </div>
</div>
