<%
  def rcontext = _ctx.getRequestContext() ;
  String workspaceName = uicomponent.currentWorkspaceName;
  String userRootPath =  uicomponent.rootPath;
  String restContext = uicomponent.getRestContext();
  boolean allowAddFolder = uicomponent.allowAddFolder;
  boolean allowDeleteItem = uicomponent.allowDeleteItem;
  String selectFileLink =uicomponent.event(uicomponent.SELECTFILE);
  String selectFolderLink =uicomponent.event(uicomponent.SELECTFOLDER);
  
  def jsManager = rcontext.getJavascriptManager();
  
  jsManager.addJavascript("eXo.commons.DocumentSelector.getFoldersAndFiles = '" + uicomponent.GETFOLDERSANDFILES + "';");
  jsManager.addJavascript("eXo.commons.DocumentSelector.deleteFolderOrFile = '" + uicomponent.DELETEFOLDERORFILE + "';");
  jsManager.addJavascript("eXo.commons.DocumentSelector.createFolder = '" + uicomponent.CREATEFOLDER + "';");
  jsManager.addJavascript("eXo.commons.DocumentSelector.workspaceParam = '" + uicomponent.PARAM_WORKSPACE + "';");
  jsManager.addJavascript("eXo.commons.DocumentSelector.nodePathParam = '" + uicomponent.PARAM_NODEPATH + "';");
  jsManager.addJavascript("eXo.commons.DocumentSelector.parentPathParam = '" + uicomponent.PARAM_PARENTPATH + "';");
  jsManager.addJavascript("eXo.commons.DocumentSelector.isFolderOnlyParam = '" + uicomponent.PARAM_ISFOLDERONLY + "';");
  jsManager.addJavascript("eXo.commons.DocumentSelector.folderNameParam = '" + uicomponent.PARAM_FOLDERNAME + "';");
  jsManager.addJavascript("eXo.commons.DocumentSelector.allowDeleteItem = " + allowDeleteItem + ";");
  jsManager.addJavascript("eXo.commons.DocumentSelector.dataId ='" + uicomponent.DATA_ID + "';");
  jsManager.addJavascript("eXo.commons.DocumentSelector.init('" + uicomponent.id + "','" + restContext + "','"+workspaceName +"','"+userRootPath +"');"); 
%>
<div class="UIDocumentSelector" id="$uicomponent.id">
  <% uicomponent.renderChild(uicomponent.EMPTYCOMPONENT); %>
  <a style="display:none;" href="$selectFileLink" class="SelectFile"></a>
  <a style="display:none;" href="$selectFolderLink" class="SelectFolder"></a>
  <div class="ListContainer">
    <div class="ClearFix">
      <div class="LeftWorkspace" id="LeftWorkspace">
        <!-- Navigation tree goes here -->
      </div>
      <div class="RightWorkspace" id="RightWorkspace">
        <div class=ListView>
          <table cellspacing="0" style="table-layout: fixed; width: 100%;" id="ListRecords">
            <thead>
              <tr>
                <th class="THBar"><%=_ctx.appRes(uicomponent.id + ".label.Name");%></th>
                <th class="THBar" style="width: 120px;"><%=_ctx.appRes(uicomponent.id + ".label.Date");%></th>
                <th class="THBar" style="width: 80px;"><%=_ctx.appRes(uicomponent.id + ".label.Size");%></th>
                <% if (allowDeleteItem) { %>
                <th class="THBar" style="width: 80px;"><%=_ctx.appRes(uicomponent.id + ".label.Action");%></th>
                <% } %>
              </tr>
            </thead>
            <tr>
              <td class="Item TRNoContent" colspan="3"><%=_ctx.appRes(uicomponent.id + ".label.NoFolderOrFile");%></td>
            </tr>
          </table>
        </div>
      </div>
    </div>
     <% 
        String flR="", input="";
        if (allowDeleteItem) { 
          input = "<input type=\"button\" value=\"" + _ctx.appRes(uicomponent.id + '.label.new-folder') + "\"" +  
                  " onclick=\"eXo.commons.DocumentSelector.newFolder(this)\"" + 
                  " msg_select_folder=\"" + _ctx.appRes(uicomponent.id + '.label.select-folder') + "\"" +
                  " msg_enter_folder_name=\"" + _ctx.appRes(uicomponent.id + '.label.enter-folder-name') + "\"" +
                  " msg_empty_folder_name=\"" + _ctx.appRes(uicomponent.id + '.label.empty-folder-name') + "\"/>";
          flR="style=\"float:right;\"";
        }
     %>
    <div class="ClearFix Breadcumbs">
      <a class="HomeIcon" href="javascript:void(0);" onclick="eXo.commons.DocumentSelector.actionBreadcrumbs('$userRootPath');"></a>
      <div class="BreadcumbsContainer" id="BreadcumbsContainer"></div>
      <div $flR>$input</div>
    </div>
  </div>
</div>
