<%
/**
 * Created by The eXo Platform SARL
 * Author : Dang Van Minh
 *          minh.dang@exoplatform.com
 * Sep 20, 2007 1:47:43 PM
 */
%>
<% 
  import org.exoplatform.ecm.webui.utils.Utils ;
  import org.exoplatform.web.application.Parameter ;
%>
<% 
  def resultList = uicomponent.getCurrentList() ; 
  if(resultList == null) return ;
  int totalPages = uicomponent.getUIPageIterator().getAvailablePage() ;
  def rcontext = _ctx.getRequestContext() ;
  rcontext.getJavascriptManager().importJavascript('eXo.ecm.UIJCRExplorer','/ecmexplorer/javascript/');
%>
<div class="UICBSearchResults" id="$uicomponent.id">
  <table class="UIGrid">
    <thead>
      <tr>
  	    <th><%=_ctx.appRes("UICBSearchResults.header.name")%></th>
  	    <th><%=_ctx.appRes("UICBSearchResults.header.path")%></th>
  	    <th><%=_ctx.appRes("UICBSearchResults.header.action")%></th>
      </tr>
    </thead>
    <tbody>
    <%
      def rowClass = null ;
 	    boolean even = true ;
 	    boolean found = false ;
 	    if(resultList != null && resultList.size() > 0) {
  	    for(node in resultList) {
  	      found = true  ;
  	      if(even) rowClass = "EvenRow" ;  
  	      else rowClass =  "OddRow" ; 
  	      even = !even ;
      %>
          <tr class="$rowClass">
            <td><div class="Text"><%=node.getName()%></div></td>
	          <%
	            String nodePath = node.getPath() ;
	            String wsName = node.getWorkspaceName();
	            if(nodePath.length() > 40 && nodePath.length() < 50) nodePath = "..." + nodePath.substring(20, nodePath.length()) ;
	            else if(nodePath.length() > 40) nodePath = "..." + nodePath.substring(30, nodePath.length()) ;
	          %>
	          <td><div class="Text" title="<%=node.getPath()%>"><%=nodePath%></div></td>
	          <td>
	          	<div class="ActionContainer">
	            	<img class="View16x16Icon" src="/eXoResources/skin/sharedImages/Blank.gif" alt="<%=_ctx.appRes("UICBSearchResults.tooltip.View")%>" onclick="<%=uicomponent.event("View", Utils.formatNodeName(node.getPath()), new Parameter("workspaceName", wsName))%>" title="<%=_ctx.appRes("UICBSearchResults.tooltip.View")%>"/>
	            	<img class="OpenFolder16x16Icon" src="/eXoResources/skin/sharedImages/Blank.gif" alt="<%=_ctx.appRes("UICBSearchResults.tooltip.Goto")%>" onclick="<%=uicomponent.event("Goto", Utils.formatNodeName(node.getPath()))%>" title="<%=_ctx.appRes("UICBSearchResults.tooltip.Goto")%>"/>
	           	</div>
	          </td>	                    
          </tr>
    <%
        }
      } else {
    %>
      <tr class="EvenRow">
        <td colspan="3" style="text-align:center;font-style:italic; color: #EF5604;"><%=_ctx.appRes("UICBSearchResults.msg.empty")%></td>
      </tr>
    <%}%>
    </tbody>
  </table>
  <% if(totalPages>1){ %>
  <div style="margin:1px 0px 20px 0px;">
    <%_ctx.renderUIComponent(uicomponent.getUIPageIterator())%>
  </div>
  <% } %>
</div>
<% if(uicomponent.getActions() != null) { %>
  <div class="$uicomponent.id">
    <div class="UIAction"> 
        <% for(action in uicomponent.getActions()) { %>
       	 <a href="javascript:void(0);" onclick="<%=uicomponent.event(action)%>" class="ActionButton LightBlueStyle"><%=_ctx.appRes(uicomponent.getId() + ".action." + action)%></a>
        <% } %>
    </div>
  </div>
<% }%>