Package org.openbravo.wad.controls

Examples of org.openbravo.wad.controls.WADControl


    prop.setProperty("isReadOnlyDefinedTab", (isReadOnlyDefinedTab ? "Y" : "N"));
    prop.setProperty("hasParentsFields", (hasParentsFields ? "Y" : "N"));

    String classname = "org.openbravo.wad.controls.WAD"
        + FormatUtilities.replace(field.getField("referenceName"));
    WADControl _myClass = null;
    try {
      Class<?> c = Class.forName(classname);
      _myClass = (WADControl) c.newInstance();
    } catch (ClassNotFoundException ex) {
      log4j.warn("CouldnĀ“t find class: " + classname);
      _myClass = new WADControl();
    }
    _myClass.setConnection(conn);
    _myClass.setReportEngine(xmlEngine);
    _myClass.setInfo(prop);
    _myClass.initialize();
    _myClass.setConnection(null);

    return _myClass;
  }
View Full Code Here


    final StringBuffer html = new StringBuffer();
    final StringBuffer labelsHTML = new StringBuffer();
    if (data != null) {
      for (int i = 0; i < data.length; i++) {
        WADControl auxControl = null;
        try {
          auxControl = WadUtility.getControl(conn, data[i], false, (fd.columnname + fd.reference),
              "", xmlEngine, false, false, false, false);
          auxControl.setData("IsParameter", "Y");
        } catch (final Exception ex) {
          throw new ServletException(ex);
        }
        html.append(auxControl.toXml()).append("\n");

        final String labelXML = auxControl.toLabelXML();
        if (!labelXML.trim().equals(""))
          labelsHTML.append(auxControl.toLabelXML()).append("\n");
      }
    }

    xmlDocument.setParameter("column", html.toString());
    xmlDocument.setParameter("labels", labelsHTML.toString());
View Full Code Here

      final Properties javaScriptFunctions = new Properties();
      final StringBuffer validations = new StringBuffer();
      final StringBuffer onload = new StringBuffer();
      final StringBuffer html = new StringBuffer();
      for (int i = 0; i < efd.length; i++) {
        WADControl auxControl = null;
        try {
          auxControl = WadUtility.getControl(conn, efd[i], false, (fd.columnname + fd.reference),
              strLanguage, xmlEngine, false, WadUtility.isInVector(vecReloads, efd[i]
                  .getField("columnname")), false, false);
        } catch (final Exception ex) {
          throw new ServletException(ex);
        }

        html.append("<tr><td class=\"TitleCell\">").append(auxControl.toLabel().replace("\n", ""))
            .append("</td>\n");
        html.append("<td class=\"").append(auxControl.getType()).append("_ContentCell\"");
        if (Integer.valueOf(auxControl.getData("DisplayLength")).intValue() > (max_size_edition_1_columns / 2)) {
          html.append(" colspan=\"2\"");
          auxControl.setData("CssSize", "TwoCells");
        } else {
          auxControl.setData("CssSize", "OneCell");
        }
        html.append(">");
        html.append(auxControl.toString());
        html.append("</td>\n");
        if (auxControl.getData("CssSize").equals("OneCell"))
          html.append("<td></td>\n");
        html.append("<td></td>\n");
        html.append("</tr>\n");
        // Getting JavaScript
        {
          final Vector<String[]> auxJavaScript = auxControl.getJSCode();
          if (auxJavaScript != null) {
            for (int j = 0; j < auxJavaScript.size(); j++) {
              final String[] auxObj = auxJavaScript.elementAt(j);
              javaScriptFunctions.setProperty(auxObj[0], auxObj[1]);
            }
          }
        } // End getting JavaScript
        // Getting css imports
        {
          final Vector<String[]> auxCss = auxControl.getCSSImport();
          if (auxCss != null) {
            for (int j = 0; j < auxCss.size(); j++) {
              final String[] auxObj = auxCss.elementAt(j);
              importsCSS.setProperty(auxObj[0], auxObj[1]);
            }
          }
        } // End getting css imports
        // Getting js imports
        {
          final Vector<String[]> auxJs = auxControl.getImport();
          if (auxJs != null) {
            for (int j = 0; j < auxJs.size(); j++) {
              final String[] auxObj = auxJs.elementAt(j);
              importsJS.setProperty(auxObj[0], auxObj[1]);
            }
          }
        } // End getting js imports
        if (!auxControl.getValidation().equals(""))
          validations.append(auxControl.getValidation()).append("\n");
        if (!auxControl.getOnLoad().equals(""))
          onload.append(auxControl.getOnLoad()).append("\n");
      }
      xmlDocument.setParameter("fields", html.toString());
      final StringBuffer sbImportCSS = new StringBuffer();
      for (final Enumeration<?> e = importsCSS.propertyNames(); e.hasMoreElements();) {
        final String _name = (String) e.nextElement();
View Full Code Here

    }

    final StringBuffer controlsJavaSource = new StringBuffer();
    boolean needsComboTableData = false;
    for (int i = 0; i < allfields.length; i++) {
      WADControl auxControl = null;
      try {
        auxControl = WadUtility.getControl(pool, allfields[i], uiPattern.equals("RO"), tabName, "",
            xmlEngine, false, false, false, hasParentsFields);
      } catch (final Exception ex) {
        throw new ServletException(ex);
      }
      if ((!auxControl.toJava().equals("")) && (!needsComboTableData)) {
        needsComboTableData = true;
        controlsJavaSource.append("    try {\n      ComboTableData comboTableData = null;\n");
      }
      controlsJavaSource.append(auxControl.toJava()).append(
          (auxControl.toJava().equals("") ? "" : "\n"));

      if ((auxControl instanceof WADButton) && (auxControl.getData("IsDisplayed").equals("Y"))) {
        ((WADButton) auxControl).setShortcuts(shortcuts);
      }
    }

    // Shorcuts for buttons
View Full Code Here

        "org/openbravo/wad/Configuration_Edition").createXmlDocument();

    final StringBuffer htmlHidden = new StringBuffer();
    if (efdauxiliar != null) {
      for (int i = 0; i < efdauxiliar.length; i++) {
        final WADControl auxControl = new WADHidden(efdauxiliar[i].getField("columnname"), Sqlc
            .TransformaNombreColumna(efdauxiliar[i].getField("columnname")), "", true);
        auxControl.setReportEngine(xmlEngine);
        htmlHidden.append(auxControl.toXml()).append("\n");
      }
    }
    xmlDocument.setParameter("hiddens", htmlHidden.toString());

    final StringBuffer html = new StringBuffer();
    final StringBuffer labelsHTML = new StringBuffer();
    ArrayList<String> labels = new ArrayList<String>();

    String strFieldGroup = "";

    for (int i = 0; i < efd.length; i++) {
      WADControl auxControl = null;
      try {
        auxControl = WadUtility.getControl(pool, efd[i], isreadonly, tabName, "", xmlEngine, false,
            false, false, false, false);

      } catch (final Exception ex) {
        throw new ServletException(ex);
      }
      html.append(auxControl.toXml()).append("\n");
      auxControl.setData("AdColumnId", efd[i].getField("adColumnId"));
      final String labelXML = auxControl.toLabelXML();
      if (!labelXML.trim().equals("")) {
        String xml = auxControl.toLabelXML();
        if (!labels.contains(xml)) {
          labels.add(xml);
        }
      }

      // FieldGroups
      if (WadUtility.isNewGroup(auxControl, strFieldGroup)) {
        strFieldGroup = auxControl.getData("AD_FieldGroup_ID");
        final WADLabelControl fieldLabel = new WADLabelControl();
        fieldLabel.setLabelType(WADLabelControl.FIELD_GROUP_LABEL);
        fieldLabel.setFieldGroupId(strFieldGroup);
        fieldLabel.setColumnName(EditionFieldsData.fieldGroupName(pool, strFieldGroup));
        fieldLabel.setLinkable(false);
View Full Code Here

    final Vector<Object> vecAuxiliar = new Vector<Object>();
    final StringBuffer htmlHidden = new StringBuffer();
    if (efdauxiliar != null) {
      for (int i = 0; i < efdauxiliar.length; i++) {
        final WADControl auxControl = new WADHidden(efdauxiliar[i].getField("columnname"), Sqlc
            .TransformaNombreColumna(efdauxiliar[i].getField("columnname")), "", true);
        auxControl.setReportEngine(xmlEngine);
        htmlHidden.append(auxControl.toString()).append("\n");
        vecAuxiliar.addElement(FormatUtilities.replace(efdauxiliar[i].getField("columnname")));
      }
    }

    final FieldsData[] dataReload = FieldsData.selectValidationTab(pool, strTab);

    final Vector<Object> vecReloads = new Vector<Object>();
    if (dataReload != null && dataReload.length > 0) {
      for (int z = 0; z < dataReload.length; z++) {
        String code = dataReload[z].whereclause
            + ((!dataReload[z].whereclause.equals("") && !dataReload[z].referencevalue.equals("")) ? " AND "
                : "") + dataReload[z].referencevalue;

        if (code.equals("") && dataReload[z].type.equals("R"))
          code = "@AD_Org_ID@";
        WadUtility.getComboReloadText(code, vecFields, parentsFieldsData, vecReloads, "",
            dataReload[z].columnname);
      }
    }

    final Properties importsCSS = new Properties();
    final Properties importsJS = new Properties();
    final Properties javaScriptFunctions = new Properties();
    final StringBuffer displayLogicFunction = new StringBuffer();
    final StringBuffer readOnlyLogicFunction = new StringBuffer();
    final StringBuffer validations = new StringBuffer();
    final StringBuffer onload = new StringBuffer();
    final StringBuffer html = new StringBuffer();
    String strFieldGroup = "";
    int fieldGroupElements = 0;
    boolean fieldGroupHasDisplayLogic = false;

    StringBuffer strGroupDisplayLogic = new StringBuffer();
    int columnType = 0;
    html.append("<tr>\n");
    html.append("  <td class=\"TableEdition_OneCell_width\"></td>\n");
    html.append("  <td class=\"TableEdition_TwoCells_width\"></td>\n");
    html.append("  <td class=\"TableEdition_OneCell_width\"></td>\n");
    html.append("  <td class=\"TableEdition_TwoCells_width\"></td>\n");
    html.append("</tr>\n");
    for (int i = 0; i < efd.length; i++) {
      WADControl auxControl = null;

      try {
        auxControl = WadUtility.getControl(pool, efd[i], isreadonly, tabName, strLanguage,
            xmlEngine, (WadUtility.isInVector(vecDisplayLogic, efd[i].getField("columnname"))),
            WadUtility.isInVector(vecReloads, efd[i].getField("columnname")), WadUtility
                .isInVector(vecReadOnlyLogic, efd[i].getField("columnname")), false,
            isReadOnlyDefinedTab);
      } catch (final Exception ex) {
        throw new ServletException(ex);
      }

      if (WadUtility.isNewGroup(auxControl, strFieldGroup)) {
        if (fieldGroupHasDisplayLogic && (fieldGroupElements != 0)) {
          strGroupDisplayLogic.append(")");
          displayLogicFunction.append(WadUtility.getDisplayLogicForGroups(strFieldGroup,
              strGroupDisplayLogic));
        }
        strGroupDisplayLogic = new StringBuffer("(");
        fieldGroupElements = 0;
        fieldGroupHasDisplayLogic = true;

        strFieldGroup = auxControl.getData("AD_FieldGroup_ID");
        html.append("      <tr><td colspan=\"4\">\n");
        html
            .append("      <table border=0 cellspacing=0 cellpadding=0 class=\"FieldGroup\" id=\"fldgrp"
                + strFieldGroup + "\"><tr class=\"FieldGroup_TopMargin\"></tr>\n<tr>\n");
        html
            .append("<td class=\"FieldGroupTitle_Left\"><img src=\"../../../../../web/images/blank.gif\" class=\"FieldGroupTitle_Left_bg\" border=0/></td>");
        String strText = "";
        strText = EditionFieldsData.fieldGroupName(pool, strFieldGroup);

        final WADLabelControl fieldLabel = new WADLabelControl();
        fieldLabel.setLabelType(WADLabelControl.FIELD_GROUP_LABEL);
        fieldLabel.setFieldGroupId(strFieldGroup);
        fieldLabel.setColumnName(strText);
        fieldLabel.setLinkable(false);

        final WadControlLabelBuilder fieldGroupLabelBuilder = new WadControlLabelBuilder(fieldLabel);
        fieldGroupLabelBuilder.buildLabelControl();
        final String labelText = fieldGroupLabelBuilder.getBasicLabelText();

        html.append("<td class=\"FieldGroupTitle\">").append(labelText).append("</td>");
        html
            .append("<td class=\"FieldGroupTitle_Right\"><img src=\"../../../../../web/images/blank.gif\" class=\"FieldGroupTitle_Right_bg\" border=0/></td>");
        html
            .append("<td class=\"FieldGroupContent\">&nbsp;</td></tr>\n<tr class=\"FieldGroup_BottomMargin\"></tr></table>");
        html.append("      </td></tr>\n");

      }

      // insert display logic for field groups
      if (auxControl.getData("IsDisplayed").equals("Y") && fieldGroupHasDisplayLogic
          && !strFieldGroup.equals("")) {
        String displ = WadUtility.displayLogic(auxControl.getData("DisplayLogic"),
            new Vector<Object>(), parentsFieldsData, vecAuxiliar, vecFields, windowId,
            new Vector<Object>());
        if (displ.length() != 0) {
          displ = "(" + displ + ")";
          if (!strGroupDisplayLogic.toString().contains(displ)) {
            strGroupDisplayLogic.append((fieldGroupElements == 0 ? "" : " || ") + displ);
            fieldGroupElements++;
          }
        } else {
          fieldGroupHasDisplayLogic = false;
        }
      }

      if (log4j.isDebugEnabled())
        log4j.debug("Column: " + auxControl.getData("ColumnName") + ", col:  " + columnType);
      // hidden inputs
      if (auxControl.getData("IsDisplayed").equals("N")) {
        htmlHidden.append(auxControl.toString()).append("\n");
      } else {
        if (auxControl instanceof WADButton) {
          ((WADButton) auxControl).setShortcuts(shortcuts);
        }
        if (auxControl.getData("IsSameLine").equals("Y")) {
          columnType = COLUMN_2_OF_2;
          html.append("<td");
        } else if (i < efd.length - 1 && efd[i + 1].getField("issameline").equals("Y")
            && efd[i + 1].getField("isdisplayed").equals("Y")) {
          columnType = COLUMN_1_OF_2;
          html.append("<tr><td");
        } else {
          columnType = COLUMN_1_OF_1;
          html.append("<tr><td");
        }
        auxControl.setData("ColumnNameLabel", auxControl.getData("ColumnName"));
        auxControl.setData("AdColumnId", efd[i].getField("adColumnId"));
        WadUtility.setLabel(pool, auxControl, isSOTrx.equals("Y"), "inp"
            + Sqlc.TransformaNombreColumna(keyColumnName));
        final String label = auxControl.toLabel();
        if (!label.equals("")) {
          html.append(" class=\"TitleCell\" id=\"").append(auxControl.getData("ColumnName"))
              .append("_lbl_td\">").append(label.replace("\n", ""));
          if (columnType == COLUMN_1_OF_1)
            html.append("</td>\n<td colspan=\"3\" class=\"").append(auxControl.getType()).append(
                "_ContentCell\" id=\"").append(auxControl.getData("ColumnName")).append(
                "_inp_td\">");
          else
            html.append("</td>\n<td class=\"").append(auxControl.getType()).append(
                "_ContentCell\" id=\"").append(auxControl.getData("ColumnName")).append(
                "_inp_td\">");
        } else {
          html.append(" class=\"").append(auxControl.getType()).append("_ContentCell\" id=\"")
              .append(auxControl.getData("ColumnName")).append("_inp_td\"");
          if (columnType == COLUMN_1_OF_1)
            html.append(" colspan=\"4\">");
          else
            html.append(" colspan=\"2\">");
        }

        final boolean isCombo = (auxControl.getData("AD_Reference_ID").equals("17")
            || auxControl.getData("AD_Reference_ID").equals("18") || auxControl.getData(
            "AD_Reference_ID").equals("19"));
        if (columnType == COLUMN_1_OF_1) {
          if (Integer.valueOf(auxControl.getData("DisplayLength")).intValue() < (MAX_SIZE_EDITION_1_COLUMNS / 4)) {
            auxControl.setData("DisplayLength", Double.toString(MAX_SIZE_EDITION_1_COLUMNS
                * (isCombo ? 7.5 : 1)));
            auxControl.setData("CssSize", "OneCell");
          } else if (Integer.valueOf(auxControl.getData("DisplayLength")).intValue() > (MAX_SIZE_EDITION_1_COLUMNS / 2)) {
            auxControl.setData("DisplayLength", Double.toString(MAX_SIZE_EDITION_1_COLUMNS
                * (isCombo ? 7.5 : 1)));
            auxControl.setData("CssSize", "FiveCells");
          } else {
            auxControl.setData("DisplayLength", Double.toString((MAX_SIZE_EDITION_1_COLUMNS / 2)
                * (isCombo ? 7.5 : 1)));
            auxControl.setData("CssSize", "TwoCells");
          }
        } else {
          if (Integer.valueOf(auxControl.getData("DisplayLength")).intValue() > (MAX_SIZE_EDITION_2_COLUMNS / 2)) {
            auxControl.setData("DisplayLength", Double.toString(MAX_SIZE_EDITION_2_COLUMNS
                * (isCombo ? 7.5 : 1)));
            auxControl.setData("CssSize", "TwoCells");
          } else {
            auxControl.setData("DisplayLength", Double.toString((MAX_SIZE_EDITION_2_COLUMNS / 2)
                * (isCombo ? 7.5 : 1)));
            auxControl.setData("CssSize", "OneCell");
          }
        }
        html.append(auxControl.toString());
        // end of input tag
        html.append("</td>\n");
        if (columnType == COLUMN_1_OF_1 || columnType == COLUMN_2_OF_2)
          html.append("</tr>\n");
        // Getting JavaScript
        {
          final Vector<String[]> auxJavaScript = auxControl.getJSCode();
          if (auxJavaScript != null) {
            for (int j = 0; j < auxJavaScript.size(); j++) {
              final String[] auxObj = auxJavaScript.elementAt(j);
              javaScriptFunctions.setProperty(auxObj[0], auxObj[1]);
            }
          }
        } // End getting JavaScript
        // Getting css imports
        {
          final Vector<String[]> auxCss = auxControl.getCSSImport();
          if (auxCss != null) {
            for (int j = 0; j < auxCss.size(); j++) {
              final String[] auxObj = auxCss.elementAt(j);
              importsCSS.setProperty(auxObj[0], auxObj[1]);
            }
          }
        } // End getting css imports
        // Getting js imports
        {
          final Vector<String[]> auxJs = auxControl.getImport();
          if (auxJs != null) {
            for (int j = 0; j < auxJs.size(); j++) {
              final String[] auxObj = auxJs.elementAt(j);
              importsJS.setProperty(auxObj[0], auxObj[1]);
            }
          }
        } // End getting js imports
        if (!auxControl.getValidation().equals(""))
          validations.append(auxControl.getValidation()).append("\n");
        if (!auxControl.getOnLoad().equals(""))
          onload.append(auxControl.getOnLoad()).append("\n");
        displayLogicFunction.append(WadUtility.getDisplayLogic(auxControl, new Vector<Object>(),
            parentsFieldsData, vecAuxiliar, vecFields, windowId, new Vector<Object>(), isreadonly));
        if (!isreadonly)
          readOnlyLogicFunction.append(WadUtility.getReadOnlyLogic(auxControl,
              new Vector<Object>(), parentsFieldsData, vecAuxiliar, vecFields, windowId,
View Full Code Here

TOP

Related Classes of org.openbravo.wad.controls.WADControl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.