<%
/**
 * Created by The eXo Platform SARL
 * Author : Dang Van Minh
 *          minhdv@exoplatform.com
 * Sep 20, 2006
 * 3:28:26 PM 
 */
%>
<%
  import javax.jcr.Node;

  def nodeTypes = uicomponent.getNodeTypeList();
  def allNodeTypes = uicomponent.getAllNodeTypes();
  if(nodeTypes == null) return;
  int totalPages = uicomponent.getUIPageIterator().getAvailablePage();
%>
<div class="UINodeTypeList" id="$uicomponent.id">
  <% if (allNodeTypes.size() > 5) {%>
  <div style="margin:1px 0px 20px 0px;">
    <%
      uicomponent.getUIPageIterator().setUseMaxSizeSetting(false);
      _ctx.renderUIComponent(uicomponent.getUIPageIterator());
    %>
  </div>
  <%}%>
  <table class="UIGrid">
    <thead>
      <tr>
        <th><%=_ctx.appRes("UINodeTypeList.header.icon")%></th>
  	    <th><%=_ctx.appRes("UINodeTypeList.header.nodeType")%></th>
  	    <th><%=_ctx.appRes("UINodeTypeList.header.mixinType")%></th>
  	    <th><%=_ctx.appRes("UINodeTypeList.header.orderable")%></th>
  	    <th><%=_ctx.appRes("UINodeTypeList.header.description")%></th>
  	    <th><%=_ctx.appRes("UINodeTypeList.header.action")%></th>
      </tr>
    </thead>
    <tbody>
      <%
      if (nodeTypes.size() > 0) {
        def rowClass = null ;
  	    boolean even = true ;
  	    boolean found = false ;
  	    for (node in nodeTypes) {
  	      found = true  ;
  	      if(even) rowClass = "EvenRow" ;  
  	      else rowClass =  "OddRow" ; 
  	      even = !even ;
      %>
          <tr class="$rowClass">
            <%
              String nodeType = node.getName() ;
              nodeType = nodeType.replace(":", "_") ;
            %>
            <td width="40px" align="center">
              <div class="default16x16Icon ${nodeType}16x16Icon" style="margin:auto"><span></span></div>
            </td>
            <td><div class="Text"><%=node.getName()%></div></td>
            <% if (!(node instanceof Node)) { %>
              <td>
                <%
                  String booleanText ;
                  String iconType ;
                  if(node.isMixin()) {
                    booleanText = _ctx.appRes("UIMetadataList.label.true") ;
                    iconType = "True" ;
                  } else {
                    booleanText = _ctx.appRes("UIMetadataList.label.false") ;
                    iconType = "False" ;
                  }
                %>
                <div class="TrueFalseContainer">
	                <div class="Icon16x16 ${iconType}16x16Icon IconNodeType"><span></span></div>
	                <div class="Text">$booleanText</div>
	              </div>
              </td>
              <td>
                <%
                  if(node.hasOrderableChildNodes()) {
                    booleanText = _ctx.appRes("UIMetadataList.label.true") ;
                    iconType = "True" ;
                  } else {
                    booleanText = _ctx.appRes("UIMetadataList.label.false") ;
                    iconType = "False" ;
                  }
                %>
                <div class="TrueFalseContainer">
	                <div class="Icon16x16 ${iconType}16x16Icon IconNodeType" ><span></span></div>
	                <div class="Text">$booleanText</div>
	              </div>
              </td>
              <td align="center"><div class="Text"><%=_ctx.appRes("UINodeTypeList.info.description")%></div></td>
              <td>
                <a href="<%=uicomponent.event("View", node.getName())%>" title="<%=_ctx.appRes("UINodeTypeList.tooltip.View")%>">
                  <div class="View16x16Icon" style="margin:auto"><span></span></div>
                </a>
              </td>
            <% } else {%>
              <td>
                <%
                  String booleanText ;
                  String iconType ;
                  if(node.getProperty("isMixin").getBoolean()) {
                    booleanText = _ctx.appRes("UIMetadataList.label.true") ;
                    iconType = "True" ;
                  } else {
                    booleanText = _ctx.appRes("UIMetadataList.label.false") ;
                    iconType = "False" ;
                  }
                %>
                <div class="TrueFalseContainer">
	                <div class="Icon16x16 ${iconType}16x16Icon"><span></span></div>
	                <div class="Text">$booleanText</div>
	              </div>
              </td>
              <td>
                <%
                  if(node.getProperty("hasOrderableChildNodes").getBoolean()) {
                    booleanText = _ctx.appRes("UIMetadataList.label.true") ;
                    iconType = "True" ;
                  } else {
                    booleanText = _ctx.appRes("UIMetadataList.label.false") ;
                    iconType = "False" ;
                  }
                %>
                <div class="TrueFalseContainer">
                	<div class="Icon16x16 ${iconType}16x16Icon"><span></span></div>
                	<div class="Text">$booleanText</div>
                </div>
              </td>
              <td align="center"><div class="Text"><%=_ctx.appRes("UINodeTypeList.info.description")%></div></td>
              <td style="width:80px;">
                <a href="<%=uicomponent.event("Edit", node.getName())%>" title="<%=_ctx.appRes("UINodeTypeList.tooltip.Edit")%>">
                  <div class="Edit16x16Icon" style="margin-left:10px; float: left;"><span></span></div>
                </a>
                <a href="<%=uicomponent.event("Delete", node.getName())%>" title="<%=_ctx.appRes("UINodeTypeList.tooltip.Delete")%>">
                  <div class="Delete16x16Icon" style="margin-left:10px; float: left;"><span></span></div>
                </a>
              </td>	                    
            <% } %>
          </tr>
      <%  }
  	    } else {%>
      <tr class="OddRow"> 
        <td colspan="6" style="text-align:center;font-style:italic; color: #EF5604;"><%=_ctx.appRes("UINodeTypeList.msg.no-list")%></td>
      </tr>
      <%}%>
    </tbody>
  </table>
  <% if (allNodeTypes.size() > 5) {%>
  <div style="margin:1px 0px 20px 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("UINodeTypeList.action." + action)%></a>
		<% } %>
	</div>
</div>



