<%
/**
 * Created by The eXo Platform SARL
 * Author : pham tuan
 *          phamtuanchip@yahoo.de
 * September 13, 2006
 * 10:07:15 AM
 **/
 
  import org.exoplatform.webui.core.UIComponent ;
  import org.exoplatform.ecm.jcr.model.ClipboardCommand ;
  
  String[] beanFields =  uicomponent.getBeanFields() ;
  String[] beanActions =  uicomponent.getBeanActions() ;
  String name = uicomponent.getName() ;
  def rcontext = _ctx.getRequestContext();
%>
<div class="SideBarContent">
  <div class="BarContent">
  	<div class="BarContentL">
  		<div class="BarContentR">
  			<div class="BarContentM ClearFix">
			    <div class="Title">Clipboard</div>
			  	
			  </div>
			</div>
		</div>
	</div>
  <div class="SideContent">
		<div class="UIClipboard" id="$uicomponent.id">
			<table class="UIGrid">
			  <thead>
			    <tr>
			      <%if(name != null) { %>
				      <%for(field in beanFields) { %>
				          <th><%=_ctx.appRes(name+".header."+field)%></th>
				      <%}
				        if(beanActions != null) { %>
				          <th><%=_ctx.appRes(name+".header.action")%></th>
				      <%}
			        }%>
			    </tr>
			  </thead>
			  <tbody>
			  <%if (uicomponent.getClipboardData().isEmpty()) { %>
			    <tr class="OddRow">
			      <td class="Text" colspan="3">
			      	<div class="ActionContainer">
				        <%=_ctx.appRes(name+".label.nocommand")%>
				      </div>
			      </td>
			    </tr>  
		    <%} else {
				    def rowClass = null ;
				    boolean even = true ;
				    String path, fullPath ;
				    int index = 1 ;
				    for(item in uicomponent.getClipboardData()) {
				      if(even) rowClass = "EvenRow";  
				      else rowClass =  "OddRow"; 
				      even = !even ;
				      path = fullPath = (item.getWorkspace()+ ":" + item.getSrcPath());
				      if (path.length() > 20 ) path = "..." + path.substring(path.length() - 20, path.length());
				%>
				    <tr class="$rowClass">
				      <td class="Text" title="<%=fullPath%>"><%=path%></td>
				    	<td class="Text"><%=item.getType()%></td>
				      <td>         
				        <div class="ActionContainer">
				          <%for(action in beanActions) { %>
		                <img onclick="<%=uicomponent.event(action, index.toString())%>" title = "$action" alt="$action" src="/eXoResources/skin/sharedImages/Blank.gif" class="${action}Icon" />
				          <%}%>        
				        </div>
				      </td>
				    </tr>
				    <%index++ ;
				    }%>
				  <tr class="EvenRow">
			      <td class="Text" colspan="3">
			        <div class="ClearAllBlock ClearFix" style="text-align: center">
								<a  class="Icon ScissorsEraserWarning16x16Icon" href="<%=uicomponent.event('ClearAll', 'All')%>">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
								  <%=_ctx.appRes(name+".action.clearall")%>
								</a>
							 
							</div>
			      </td>
			    </tr>  
			  <%}%>
			  </tbody>
			</table> <!--End UIGrid-->  
		</div>
  </div>
</div>
