private String getShortcutScript(HashMap<String, String> usedButtonShortCuts) {
   StringBuffer shortcuts = new StringBuffer();
   shortcuts.append(" function buttonListShorcuts() {\n");
   Iterator<String> ik = usedButtonShortCuts.keySet().iterator();
   Iterator<String> iv = usedButtonShortCuts.values().iterator();
   while (ik.hasNext() && iv.hasNext()) {
     shortcuts
         .append("  keyArray[keyArray.length] = new keyArrayItem(\"")
         .append(ik.next())
         .append("\", \"")
         .append(iv.next())
         .append("\", null, \"altKey\", false, \"onkeydown\");\n");
   }
   shortcuts.append(" return true;\n}");
   return shortcuts.toString();
 }
  private void printPageDataSheet(
      HttpServletResponse response,
      VariablesSecureApp vars,
      String strC_BP_Group_ID,
      TableSQLData tableSQL)
      throws IOException, ServletException {
    if (log4j.isDebugEnabled()) log4j.debug("Output: dataSheet");

    String strParamName = vars.getSessionValue(tabId + "|paramName");

    boolean hasSearchCondition = false;
    vars.removeEditionData(tabId);
    hasSearchCondition =
        (tableSQL.hasInternalFilter() && ("").equals(strParamName))
            || !(("").equals(strParamName) || ("%").equals(strParamName));
    String strOffset = vars.getSessionValue(tabId + "|offset");
    String selectedRow = "0";
    if (!strC_BP_Group_ID.equals("")) {
      selectedRow = Integer.toString(getKeyPosition(vars, strC_BP_Group_ID, tableSQL));
    }

    String[] discard = {"isNotFiltered", "isNotTest"};
    if (hasSearchCondition) discard[0] = new String("isFiltered");
    if (vars.getSessionValue("#ShowTest", "N").equals("Y")) discard[1] = new String("isTest");
    XmlDocument xmlDocument =
        xmlEngine
            .readXmlTemplate(
                "org/openbravo/erpWindows/BusinessPartnerCategory/BusinessPartnerCategory_Relation",
                discard)
            .createXmlDocument();

    boolean hasReadOnlyAccess =
        org.openbravo.erpCommon.utility.WindowAccessData.hasReadOnlyAccess(
            this, vars.getRole(), tabId);
    ToolBar toolbar =
        new ToolBar(
            this,
            true,
            vars.getLanguage(),
            "BusinessPartnerCategory",
            false,
            "document.frmMain.inpcBpGroupId",
            "grid",
            "..",
            "".equals("Y"),
            "BusinessPartnerCategory",
            strReplaceWith,
            false,
            false,
            false,
            false,
            !hasReadOnlyAccess);
    toolbar.setTabId(tabId);

    toolbar.setDeleteable(true && !hasReadOnlyAccess);
    toolbar.prepareRelationTemplate(
        "N".equals("Y"),
        hasSearchCondition,
        !vars.getSessionValue("#ShowTest", "N").equals("Y"),
        false,
        Utility.getContext(this, vars, "ShowAudit", windowId).equals("Y"));
    xmlDocument.setParameter("toolbar", toolbar.toString());

    StringBuffer orderByArray = new StringBuffer();
    vars.setSessionValue(tabId + "|newOrder", "1");
    String positions = vars.getSessionValue(tabId + "|orderbyPositions");
    orderByArray.append("var orderByPositions = new Array(\n");
    if (!positions.equals("")) {
      StringTokenizer tokens = new StringTokenizer(positions, ",");
      boolean firstOrder = true;
      while (tokens.hasMoreTokens()) {
        if (!firstOrder) orderByArray.append(",\n");
        orderByArray.append("\"").append(tokens.nextToken()).append("\"");
        firstOrder = false;
      }
    }
    orderByArray.append(");\n");
    String directions = vars.getSessionValue(tabId + "|orderbyDirections");
    orderByArray.append("var orderByDirections = new Array(\n");
    if (!positions.equals("")) {
      StringTokenizer tokens = new StringTokenizer(directions, ",");
      boolean firstOrder = true;
      while (tokens.hasMoreTokens()) {
        if (!firstOrder) orderByArray.append(",\n");
        orderByArray.append("\"").append(tokens.nextToken()).append("\"");
        firstOrder = false;
      }
    }
    orderByArray.append(");\n");
    //    }

    xmlDocument.setParameter(
        "selectedColumn", "\nvar selectedRow = " + selectedRow + ";\n" + orderByArray.toString());
    xmlDocument.setParameter("directory", "var baseDirectory = \"" + strReplaceWith + "/\";\n");
    xmlDocument.setParameter("windowId", windowId);
    xmlDocument.setParameter("KeyName", "cBpGroupId");
    xmlDocument.setParameter("language", "defaultLang=\"" + vars.getLanguage() + "\";");
    xmlDocument.setParameter("theme", vars.getTheme());
    // xmlDocument.setParameter("buttonReference", Utility.messageBD(this, "Reference",
    // vars.getLanguage()));
    try {
      WindowTabs tabs = new WindowTabs(this, vars, tabId, windowId, false);
      xmlDocument.setParameter("parentTabContainer", tabs.parentTabs());
      xmlDocument.setParameter("mainTabContainer", tabs.mainTabs());
      xmlDocument.setParameter("childTabContainer", tabs.childTabs());
      String hideBackButton = vars.getGlobalVariable("hideMenu", "#Hide_BackButton", "");
      NavigationBar nav =
          new NavigationBar(
              this,
              vars.getLanguage(),
              "BusinessPartnerCategory_Relation.html",
              "BusinessPartnerCategory",
              "W",
              strReplaceWith,
              tabs.breadcrumb(),
              hideBackButton.equals("true"));
      xmlDocument.setParameter("navigationBar", nav.toString());
      LeftTabsBar lBar =
          new LeftTabsBar(
              this, vars.getLanguage(), "BusinessPartnerCategory_Relation.html", strReplaceWith);
      xmlDocument.setParameter("leftTabs", lBar.relationTemplate());
    } catch (Exception ex) {
      throw new ServletException(ex);
    }
    {
      OBError myMessage = vars.getMessage(tabId);
      vars.removeMessage(tabId);
      if (myMessage != null) {
        xmlDocument.setParameter("messageType", myMessage.getType());
        xmlDocument.setParameter("messageTitle", myMessage.getTitle());
        xmlDocument.setParameter("messageMessage", myMessage.getMessage());
      }
    }

    xmlDocument.setParameter("grid", Utility.getContext(this, vars, "#RecordRange", windowId));
    xmlDocument.setParameter("grid_Offset", strOffset);
    xmlDocument.setParameter("grid_SortCols", positions);
    xmlDocument.setParameter("grid_SortDirs", directions);
    xmlDocument.setParameter("grid_Default", selectedRow);

    response.setContentType("text/html; charset=UTF-8");
    PrintWriter out = response.getWriter();
    out.println(xmlDocument.print());
    out.close();
  }