@Override
  public void layoutClick(LayoutClickEvent event) {
    final Component component = event.getComponent();

    if (!(component instanceof HorizontalLayout)) {
      LOG.error("This listener is defined only for horizontalLayout");
      return;
    }
    Component dataComponent = null;
    try {
      if ((dataComponent = ((HorizontalLayout) component).getComponent(1)) == null) {
        return;
      }
      this.labsPanel
          .getReference()
          .getApplication()
          .getMainWindow()
          .addWindow(
              new DatePickerWindow(
                  "Add investigation duration",
                  new DatePickerWindow.Callback() {

                    @Override
                    public void onDialogResult(
                        boolean resultIsOk, final DurationBean durationBean) {
                      if (resultIsOk && durationBean != null) {
                        DurationSelectionLayoutListener.this.labsInvestigationAction.setDuration(
                            durationBean);
                      }
                    }
                  }));
    } catch (IndexOutOfBoundsException e) {
      LOG.error(e.getLocalizedMessage());
    }
  }
  /**
   * Populates attributes before redirecting to a jsp.
   *
   * @param request The HttpServletRequest object
   * @param response The HttpServletReponse object
   * @throws ServletException
   * @throws IOException
   */
  @Override
  protected void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    request.setAttribute("fatalError", "");
    TachyonFS tachyonClient = TachyonFS.get(mTachyonConf);

    String filePath = request.getParameter("path");
    if (!(filePath == null || filePath.isEmpty())) {
      // Display file block info
      try {
        UiFileInfo uiFileInfo = getUiFileInfo(tachyonClient, new TachyonURI(filePath));
        request.setAttribute("fileBlocksOnTier", uiFileInfo.getBlocksOnTier());
        request.setAttribute("blockSizeByte", uiFileInfo.getBlockSizeBytes());
        request.setAttribute("path", filePath);

        getServletContext()
            .getRequestDispatcher("/worker/viewFileBlocks.jsp")
            .forward(request, response);
        return;
      } catch (FileDoesNotExistException fdne) {
        request.setAttribute("fatalError", "Error: Invalid Path " + fdne.getMessage());
        getServletContext()
            .getRequestDispatcher("/worker/blockInfo.jsp")
            .forward(request, response);
        return;
      } catch (IOException ie) {
        request.setAttribute(
            "invalidPathError", "Error: File " + filePath + " is not available " + ie.getMessage());
        getServletContext()
            .getRequestDispatcher("/worker/blockInfo.jsp")
            .forward(request, response);
        return;
      } catch (NotFoundException nfe) {
        request.setAttribute("fatalError", "Error: block not found. " + nfe.getMessage());
        getServletContext()
            .getRequestDispatcher("/worker/blockInfo.jsp")
            .forward(request, response);
        return;
      }
    }

    List<Integer> fileIds = getSortedFileIds();
    request.setAttribute("nTotalFile", fileIds.size());

    // URL can not determine offset and limit, let javascript in jsp determine and redirect
    if (request.getParameter("offset") == null && request.getParameter("limit") == null) {
      getServletContext().getRequestDispatcher("/worker/blockInfo.jsp").forward(request, response);
      return;
    }

    try {
      int offset = Integer.parseInt(request.getParameter("offset"));
      int limit = Integer.parseInt(request.getParameter("limit"));
      List<Integer> subFileIds = fileIds.subList(offset, offset + limit);
      List<UiFileInfo> uiFileInfos = new ArrayList<UiFileInfo>(subFileIds.size());
      for (int fileId : subFileIds) {
        uiFileInfos.add(getUiFileInfo(tachyonClient, fileId));
      }
      request.setAttribute("fileInfos", uiFileInfos);
    } catch (FileDoesNotExistException fdne) {
      request.setAttribute("fatalError", "Error: Invalid FileId " + fdne.getMessage());
      getServletContext().getRequestDispatcher("/worker/blockInfo.jsp").forward(request, response);
      return;
    } catch (NumberFormatException nfe) {
      request.setAttribute(
          "fatalError", "Error: offset or limit parse error, " + nfe.getLocalizedMessage());
      getServletContext().getRequestDispatcher("/worker/blockInfo.jsp").forward(request, response);
      return;
    } catch (IndexOutOfBoundsException iobe) {
      request.setAttribute(
          "fatalError",
          "Error: offset or offset + limit is out of bound, " + iobe.getLocalizedMessage());
      getServletContext().getRequestDispatcher("/worker/blockInfo.jsp").forward(request, response);
      return;
    } catch (IllegalArgumentException iae) {
      request.setAttribute("fatalError", iae.getLocalizedMessage());
      getServletContext().getRequestDispatcher("/worker/blockInfo.jsp").forward(request, response);
      return;
    } catch (NotFoundException nfe) {
      request.setAttribute("fatalError", nfe.getLocalizedMessage());
      getServletContext().getRequestDispatcher("/worker/blockInfo.jsp").forward(request, response);
      return;
    }

    getServletContext().getRequestDispatcher("/worker/blockInfo.jsp").forward(request, response);
  }