Package org.boco.seamwebappgen.info

Examples of org.boco.seamwebappgen.info.InfoReader


    if (targetDir.endsWith(File.separator))
      this.targetDir = targetDir;
    else
      this.targetDir = targetDir + File.separator;

    infoReader = new InfoReader(sourceDir);
    basePackage = infoReader.getPackage();

    this.messageArea = messageArea;
    this.progressBar = progressBar;
  }
View Full Code Here


    String textAreaIds = "";
    String printButton = "";
    String hiddenAttributes = "";
    String dynamicMenus = "";

    InfoReader infoReader = new InfoReader(sourceDir);

    if (!inPopUp)
    {
      template = "." + File.separator + "templates" + File.separator + "Seam_Form.xhtml";
      sourceForm = sourceDir + ".." + File.separator + "html" + File.separator + bean.getName() + ".xhtml";
      targetForm = targetDir + "html" + File.separator + bean.getName() + ".xhtml";
    }
    else
    {
      template = "." + File.separator + "templates" + File.separator + "Seam_FormInPopUp.xhtml";
      sourceForm = sourceDir + ".." + File.separator + "html" + File.separator + bean.getName() + "InPopUp.xhtml";
      targetForm = targetDir + "html" + File.separator + bean.getName() + "InPopUp.xhtml";
    }

    Vector<CodeChunk> codeChunks = new Vector<CodeChunk>();

    // Recupera il codice custom nella pagina
    LinkedList<String> yourJavaScriptCode = Utils.getYourCode(sourceForm, CustomCodeType.JAVA);
    LinkedList<String> yourCode = Utils.getYourCode(sourceForm, CustomCodeType.JSP);

    /** Predispone la lista di tutti gli attributi da inserire nel form **/
    /** I campi Transient sono gestiti in questa sezione **/
    for (int i = 0; i < bean.getAttributes().size(); i++)
    {
      Attribute attribute = bean.getAttributes().get(i);

      if (!attribute.isKey() && (attribute.getImplementationType() != AttributeImplementationType.HIDEINFORM))
      {
        CodeChunk codeChunk = new CodeChunk(attribute.getOrderInForm());

        codeChunk.addHtmlCode("\t<tr><td width=\"100%\">\r\n");

        codeChunk.addHtmlCode("\t\t<rich:panel rendered=\"#{");

        codeChunk.addHtmlCode("(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='CREATE'");
        if (!attribute.getOnCreateIf().equals(""))
          codeChunk.addHtmlCode(" and " + attribute.getOnCreateIf());
        codeChunk.addHtmlCode(")");

        codeChunk.addHtmlCode(" or ");

        codeChunk.addHtmlCode("(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='EDIT'");
        if (!attribute.getOnEditIf().equals(""))
          codeChunk.addHtmlCode(" and " + attribute.getOnEditIf());
        codeChunk.addHtmlCode(")");

        codeChunk.addHtmlCode(" or ");

        codeChunk.addHtmlCode("(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DISPLAY'");
        if (!attribute.getOnDisplayIf().equals(""))
          codeChunk.addHtmlCode(" and " + attribute.getOnDisplayIf());
        codeChunk.addHtmlCode(")");

        codeChunk.addHtmlCode(" or ");

        codeChunk.addHtmlCode("(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DELETE'");
        if (!attribute.getOnDeleteIf().equals(""))
          codeChunk.addHtmlCode(" and " + attribute.getOnDeleteIf());
        codeChunk.addHtmlCode(")");

        codeChunk.addHtmlCode("}\" >\r\n");

        codeChunk.addHtmlCode("\t\t\t<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">\r\n");
        codeChunk.addHtmlCode("\t\t\t<tr>\r\n");
        codeChunk.addHtmlCode("\t\t\t<td class=\"formFieldLabel\" >\r\n");
        codeChunk.addHtmlCode("\t\t\t\t<h:outputLabel for=\"" + attribute.getName() + "\"  value=\"#{msgs.form_" + bean.getName() + attribute.SeamLabel() + "}\" />\r\n");
        codeChunk.addHtmlCode("\t\t\t</td>\r\n");

        codeChunk.addHtmlCode("\t\t\t<td width=\"1%\">\r\n");
        if (attribute.isRequired())
          codeChunk.addHtmlCode("\t\t\t\t<h:outputText value=\"*\"  rendered=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='CREATE' or " + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='EDIT'}\" style=\"color: red; font-weight: bold;\" />\r\n");
        codeChunk.addHtmlCode("\t\t\t</td>\r\n");

        if (attribute.getImplementationType() == AttributeImplementationType.TEXTAREA || attribute.getImplementationType() == AttributeImplementationType.FORMATTEDTEXTAREA)
        {
          if (attribute.getType().equals("java.lang.String"))
          {
            codeChunk.addHtmlCode("\t\t\t<td>\r\n");
            codeChunk.addHtmlCode("\t\t\t\t" + insertAttribute2Form(attribute, bean.getName(), true));
            codeChunk.addHtmlCode("\t\t\t\t<h:outputText id=\"" + attribute.getName() + "Display\"   value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + attribute.SeamField() + "}\" rendered=\"#{");

            codeChunk.addHtmlCode("(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DISPLAY'");
            if (!attribute.getOnDisplayIf().equals(""))
              codeChunk.addHtmlCode(" and " + attribute.getOnDisplayIf());
            codeChunk.addHtmlCode(")");

            codeChunk.addHtmlCode(" or ");

            codeChunk.addHtmlCode("(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DELETE'");
            if (!attribute.getOnDeleteIf().equals(""))
              codeChunk.addHtmlCode(" and " + attribute.getOnDeleteIf());
            codeChunk.addHtmlCode(")");

            codeChunk.addHtmlCode("}\" ");

            if (attribute.getImplementationType() == AttributeImplementationType.FORMATTEDTEXTAREA)
            {
              if (!textAreaIds.equals(""))
                textAreaIds += ",";
              textAreaIds += "form:" + attribute.getName() + "";

              codeChunk.addHtmlCode(" escape=\"false\" ");
            }

            codeChunk.addHtmlCode("/>\r\n");

            codeChunk.addHtmlCode("\t\t\t\t<br />\r\n");
            codeChunk.addHtmlCode("\t\t\t\t<h:message for=\"" + attribute.getName() + "\" errorClass=\"rich-messages-label\" />\r\n");

            codeChunk.addHtmlCode("\t\t\t</td>\r\n");
          }
        }

        if (attribute.getImplementationType() == AttributeImplementationType.LISTBOX)
        {
          codeChunk.addHtmlCode("\t\t\t<td>\r\n");

          codeChunk.addHtmlCode("\t\t\t\t" + insertAttribute2Form(attribute, bean.getName(), true));
          /**         
                    codeChunk.addHtmlCode("\t\t\t\t<h:selectOneMenu id=\"" + attribute.getName() + "\" value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + attribute.getName() + "}\" styleClass=\"formField\" ");

                    codeChunk.addHtmlCode(" required=\"#{" + attribute.isRequired() + " and " + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation!=\'DELETE\'}\"");

                    codeChunk.addHtmlCode(" rendered=\"#{");

                    codeChunk.addHtmlCode("(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='CREATE'");
                    if (!attribute.getOnCreateIf().equals(""))
                      codeChunk.addHtmlCode(" and " + attribute.getOnCreateIf());
                    codeChunk.addHtmlCode(")");

                    codeChunk.addHtmlCode(" or ");

                    codeChunk.addHtmlCode("(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='EDIT'");
                    if (!attribute.getOnEditIf().equals(""))
                      codeChunk.addHtmlCode(" and " + attribute.getOnEditIf());
                    codeChunk.addHtmlCode(")");

                    codeChunk.addHtmlCode("}\" >\r\n");

                    codeChunk.addHtmlCode("\t\t\t\t\t<f:selectItem itemValue=\"\"  itemLabel=\"#{msgs.Application_noSelectionLabel}\" />\r\n");

                    for (String option : attribute.getLabels())
                    {
                      codeChunk.addHtmlCode("\t\t\t\t\t<f:selectItem itemValue=\"" + option + "\"  itemLabel=\"" + option + "\"/>\r\n");
                    }

                   
                    if (!attribute.getAjaxEvent().equals(""))
                    {
                      codeChunk.addHtmlCode("\t\t\t\t\t"+addAjaxSupport(attribute.getAjaxEvent(), attribute.getIdsToRerenderOnAjaxEvent())+"\r\n");
                    }
                   
                    codeChunk.addHtmlCode("\t\t\t\t</h:selectOneMenu>\r\n");
          **/
          codeChunk.addHtmlCode("\t\t\t\t<h:outputText id=\"" + attribute.getName() + "Display\"  value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + attribute.SeamField() + "}\" rendered=\"#{");

          codeChunk.addHtmlCode("(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DISPLAY'");
          if (!attribute.getOnDisplayIf().equals(""))
            codeChunk.addHtmlCode(" and " + attribute.getOnDisplayIf());
          codeChunk.addHtmlCode(")");

          codeChunk.addHtmlCode(" or ");

          codeChunk.addHtmlCode("(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DELETE'");
          if (!attribute.getOnDeleteIf().equals(""))
            codeChunk.addHtmlCode(" and " + attribute.getOnDeleteIf());
          codeChunk.addHtmlCode(")");

          codeChunk.addHtmlCode("}\" ");

          codeChunk.addHtmlCode("/>\r\n");

          codeChunk.addHtmlCode("\t\t\t\t<br />\r\n");
          codeChunk.addHtmlCode("\t\t\t\t<h:message for=\"" + attribute.getName() + "\" errorClass=\"rich-messages-label\" />\r\n");

          codeChunk.addHtmlCode("\t\t\t</td>\r\n");
        }

        if (attribute.getImplementationType() == AttributeImplementationType.TEXT)
        {
          if (attribute.getType().equals("java.lang.Boolean"))
          {
            codeChunk.addHtmlCode("\t\t\t<td>\r\n");
            codeChunk.addHtmlCode("\t\t\t\t" + insertAttribute2Form(attribute, bean.getName(), true) + "\r\n");

            codeChunk.addHtmlCode("\t\t\t\t<br />\r\n");
            codeChunk.addHtmlCode("\t\t\t\t<h:message for=\"" + attribute.getName() + "\" errorClass=\"rich-messages-label\" />\r\n");

            codeChunk.addHtmlCode("\t\t\t</td>\r\n");
          }

          if (attribute.getType().equals("java.lang.String"))
          {
            codeChunk.addHtmlCode("\t\t\t<td>\r\n");
            codeChunk.addHtmlCode("\t\t\t\t" + insertAttribute2Form(attribute, bean.getName(), true) + "\r\n");
            codeChunk.addHtmlCode("\t\t\t\t<h:outputText id=\"" + attribute.getName() + "Display\"  value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + attribute.SeamField() + "}\" rendered=\"#{");

            codeChunk.addHtmlCode(Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DISPLAY'");

            codeChunk.addHtmlCode(" or ");

            codeChunk.addHtmlCode(Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DELETE'");

            codeChunk.addHtmlCode("}\" ");

            codeChunk.addHtmlCode("/>\r\n");

            codeChunk.addHtmlCode("\t\t\t\t<br />\r\n");
            codeChunk.addHtmlCode("\t\t\t\t<h:message for=\"" + attribute.getName() + "\" errorClass=\"rich-messages-label\" />\r\n");

            codeChunk.addHtmlCode("\t\t\t</td>\r\n");
          }

          if (attribute.getType().equals("java.util.Date"))
          {
            codeChunk.addHtmlCode("\t\t\t<td>\r\n");

            codeChunk.addHtmlCode("\t\t" + insertAttribute2Form(attribute, bean.getName(), true) + "\r\n");

            codeChunk.addHtmlCode("\t\t\t\t<h:outputText id=\"" + attribute.getName() + "Display\"   value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + attribute.SeamField() + "}\" rendered=\"#{");

            codeChunk.addHtmlCode(Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DISPLAY'");

            codeChunk.addHtmlCode(" or ");

            codeChunk.addHtmlCode(Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DELETE'");

            codeChunk.addHtmlCode("}\" ");

            codeChunk.addHtmlCode(">\r\n");

            if (!attribute.isFormFormatOff())
              codeChunk.addHtmlCode("\t\t\t\t\t<s:convertDateTime pattern=\"#{msgs.Application_DateFormat}\"/>\r\n");

            codeChunk.addHtmlCode("\t\t\t\t</h:outputText>\r\n");

            codeChunk.addHtmlCode("\t\t\t\t<br />\r\n");
            codeChunk.addHtmlCode("\t\t\t\t<h:message for=\"" + attribute.getName() + "\" errorClass=\"rich-messages-label\" />\r\n");

            codeChunk.addHtmlCode("\t\t\t</td>\r\n");
          }

          if (attribute.getType().equals("java.lang.Double"))
          {
            codeChunk.addHtmlCode("\t\t\t<td>\r\n");
            codeChunk.addHtmlCode("\t\t\t\t" + insertAttribute2Form(attribute, bean.getName(), true) + "\r\n");
            codeChunk.addHtmlCode("\t\t\t\t<h:outputText id=\"" + attribute.getName() + "Display\"  value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + attribute.SeamField() + "}\" rendered=\"#{");

            codeChunk.addHtmlCode(Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DISPLAY'");

            codeChunk.addHtmlCode(" or ");

            codeChunk.addHtmlCode(Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DELETE'");

            codeChunk.addHtmlCode("}\" ");

            codeChunk.addHtmlCode(">\r\n");

            codeChunk.addHtmlCode("\t\t\t\t\t<f:converter converterId=\"DoubleConverter\" />\r\n");

            codeChunk.addHtmlCode("\t\t\t\t</h:outputText>\r\n");

            codeChunk.addHtmlCode("\t\t\t\t<br />\r\n");
            codeChunk.addHtmlCode("\t\t\t\t<h:message for=\"" + attribute.getName() + "\" errorClass=\"rich-messages-label\" />\r\n");

            codeChunk.addHtmlCode("\t\t\t</td>\r\n");
          }

          if (attribute.getType().equals("java.lang.Long"))
          {
            codeChunk.addHtmlCode("\t\t\t<td>\r\n");
            codeChunk.addHtmlCode("\t\t\t\t" + insertAttribute2Form(attribute, bean.getName(), true) + "\r\n");
            codeChunk.addHtmlCode("\t\t\t\t<h:outputText id=\"" + attribute.getName() + "Display\"  value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + attribute.SeamField() + "}\" rendered=\"#{");

            codeChunk.addHtmlCode(Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DISPLAY'");

            codeChunk.addHtmlCode(" or ");

            codeChunk.addHtmlCode(Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DELETE'");

            codeChunk.addHtmlCode("}\" ");

            codeChunk.addHtmlCode(">\r\n");

            if (!attribute.isFormFormatOff())
              codeChunk.addHtmlCode("\t\t\t\t<f:converter converterId=\"LongConverter\"/>\r\n");

            codeChunk.addHtmlCode("\t\t\t\t\t</h:outputText>\r\n");

            codeChunk.addHtmlCode("\t\t\t\t<br />\r\n");
            codeChunk.addHtmlCode("\t\t\t\t<h:message for=\"" + attribute.getName() + "\" errorClass=\"rich-messages-label\" />\r\n");

            codeChunk.addHtmlCode("\t\t\t</td>\r\n");
          }

          if (attribute.getType().equals("java.lang.Integer"))
          {
            codeChunk.addHtmlCode("\t\t\t<td>\r\n");
            codeChunk.addHtmlCode("\t\t\t\t" + insertAttribute2Form(attribute, bean.getName(), true) + "\r\n");
            codeChunk.addHtmlCode("\t\t\t\t<h:outputText id=\"" + attribute.getName() + "Display\"  value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + attribute.SeamField() + "}\" rendered=\"#{");

            codeChunk.addHtmlCode(Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DISPLAY'");

            codeChunk.addHtmlCode(" or ");

            codeChunk.addHtmlCode(Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DELETE'");

            codeChunk.addHtmlCode("}\" ");

            codeChunk.addHtmlCode(">\r\n");

            if (!attribute.isFormFormatOff())
              codeChunk.addHtmlCode("\t\t\t\t\t<f:converter converterId=\"IntegerConverter\" />\r\n");

            codeChunk.addHtmlCode("\t\t\t\t</h:outputText>\r\n");

            codeChunk.addHtmlCode("\t\t\t\t<br />\r\n");
            codeChunk.addHtmlCode("\t\t\t\t<h:message for=\"" + attribute.getName() + "\" errorClass=\"rich-messages-label\" />\r\n");

            codeChunk.addHtmlCode("\t\t\t</td>\r\n");
          }

          if (attribute.getType().contains("UploadedFile") || attribute.getType().contains("org.boco.seamUtility.upload.UploadedFile"))
          {
            /**
             * Gestione degli upload / download dal form
             */
            usesUpload = "enctype=\"multipart/form-data\"";

            if (bean.getRelationship(Utils.makeGet(bean.getName() + "Upload")) == null)
            {
              // Piu' allegati

              codeChunk.addHtmlCode("\t\t\t<td>\r\n");

              codeChunk.addHtmlCode("\t\t\t\t" + insertAttribute2Form(attribute, bean.getName(), true) + "\r\n");

              codeChunk.addHtmlCode("\t\t\t\t<h:dataTable var=\"" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Upload\"  value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + Utils.makeFirstLetterLowerCase(bean.getName()) + "Uploads}\" >\r\n");

              codeChunk.addHtmlCode("\t\t\t\t<h:column>\r\n");

              codeChunk.addHtmlCode("\t\t\t\t\t<h:commandButton action=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Upload." + Utils.makeFirstLetterLowerCase(attribute.getName()) + "Fm.downloadFile(facesContext)}\" image=\"img/download.png\" rendered=\"#{(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Upload!=null) and (" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Upload." + Utils.makeFirstLetterLowerCase(attribute.getName()) + "Fm!=null) and ((" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DISPLAY') or (" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DELETE'))}\" />\r\n");
              codeChunk.addHtmlCode("\t\t\t\t\t<h:outputText value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Upload." + Utils.makeFirstLetterLowerCase(attribute.getName()) + "Fm.fileName}\" rendered=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Upload." + Utils.makeFirstLetterLowerCase(attribute.getName()) + "Fm!=null}\" />\r\n");
              codeChunk.addHtmlCode("\t\t\t\t\t<h:outputLabel for=\"delete" + Utils.makeFirstLetterLowerCase(attribute.getName()) + "\" value=\"Rimuovi\" rendered=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Upload!=null and " + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='EDIT'}\" />\r\n");
              codeChunk.addHtmlCode("\t\t\t\t\t<h:selectBooleanCheckbox for=\"delete" + Utils.makeFirstLetterLowerCase(attribute.getName()) + "\" value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Upload." + Utils.makeFirstLetterLowerCase(attribute.getName()) + "Fm.checkDelete}\" rendered=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Upload!=null and " + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='EDIT'}\" />\r\n");
              codeChunk.addHtmlCode("\t\t\t\t\t<h:outputLabel for=\"update" + Utils.makeFirstLetterLowerCase(attribute.getName()) + "\" value=\"Sostituisci\" rendered=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Upload!=null and " + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='EDIT'}\" />\r\n");
              codeChunk.addHtmlCode("\t\t\t\t\t<h:selectBooleanCheckbox for=\"update" + Utils.makeFirstLetterLowerCase(attribute.getName()) + "\" value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Upload." + Utils.makeFirstLetterLowerCase(attribute.getName()) + "Fm.checkUpdate}\" rendered=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Upload!=null and " + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='EDIT'}\" />\r\n");

              codeChunk.addHtmlCode("\t\t\t\t</h:column>\r\n");

              codeChunk.addHtmlCode("\t\t\t\t</h:dataTable>\r\n");

              codeChunk.addHtmlCode("\t\t\t</td>\r\n");
            }
            else
            {
              // Un solo allegato

              codeChunk.addHtmlCode("\t\t\t<td>\r\n");

              codeChunk.addHtmlCode("\t\t\t\t" + insertAttribute2Form(attribute, bean.getName(), true) + "\r\n");

              codeChunk.addHtmlCode("\t\t\t\t<h:commandButton action=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + Utils.makeFirstLetterLowerCase(bean.getName()) + "Upload." + attribute.getName() + "Fm.downloadFile(facesContext)}\" image=\"img/download.png\" rendered=\"#{");

              codeChunk.addHtmlCode("(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + Utils.makeFirstLetterLowerCase(bean.getName()) + "Upload!=null) and (" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + Utils.makeFirstLetterLowerCase(bean.getName()) + "Upload." + attribute.getName() + "Fm!=null) and ((" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DISPLAY'");
              if (!attribute.getOnDisplayIf().equals(""))
                codeChunk.addHtmlCode(" and " + attribute.getOnDisplayIf());
              codeChunk.addHtmlCode(")");

              codeChunk.addHtmlCode(" or ");

              codeChunk.addHtmlCode("(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DELETE'");
              if (!attribute.getOnDeleteIf().equals(""))
                codeChunk.addHtmlCode(" and " + attribute.getOnDeleteIf());
              codeChunk.addHtmlCode("))");

              codeChunk.addHtmlCode("}\" ");

              codeChunk.addHtmlCode("/>\r\n");

              codeChunk.addHtmlCode("\t\t\t\t<h:outputText value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + Utils.makeFirstLetterLowerCase(bean.getName()) + "Upload." + attribute.getName() + "Fm.fileName}\" rendered=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + Utils.makeFirstLetterLowerCase(bean.getName()) + "Upload." + attribute.getName() + "Fm!=null}\" />\r\n");

              codeChunk.addHtmlCode("\t\t\t\t<h:outputLabel for=\"delete" + attribute.getName() + "\" value=\"Rimuovere\" rendered=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + Utils.makeFirstLetterLowerCase(bean.getName()) + "Upload!=null and " + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='EDIT'}\" />\r\n");
              codeChunk.addHtmlCode("\t\t\t\t<h:selectBooleanCheckbox for=\"delete" + attribute.getName() + "\" value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + Utils.makeFirstLetterLowerCase(bean.getName()) + "Upload." + attribute.getName() + "Fm.checkDelete}\" rendered=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + Utils.makeFirstLetterLowerCase(bean.getName()) + "Upload!=null and " + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='EDIT'}\" />\r\n");

              codeChunk.addHtmlCode("\t\t\t</td>\r\n");
            }
          }
        }

        /** Campi di sola visualizzazione * */

        if (attribute.getImplementationType() == AttributeImplementationType.READONLY)
        {
          if (attribute.getType().equals("java.lang.String"))
          {
            codeChunk.addHtmlCode("\t<td>\r\n");
            codeChunk.addHtmlCode("\t\t<tr:outputText id=\"" + attribute.getName() + "\"   value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + attribute.SeamField() + "}\" />\r\n");
            codeChunk.addHtmlCode("\t</td>\r\n");
          }

          if (attribute.getType().equals("java.util.Date"))
          {
            codeChunk.addHtmlCode("\t<trh:cellFormat >\r\n");

            codeChunk.addHtmlCode("\t\t<tr:outputText id=\"" + attribute.getName() + "\"   value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + attribute.SeamField() + "}\" >\r\n");

            codeChunk.addHtmlCode("\t\t\t<f:convertDateTime pattern=\"#{msgs.Application_DateFormat}\" />\r\n");

            codeChunk.addHtmlCode("\t\t</tr:outputText>\r\n");

            codeChunk.addHtmlCode("\t</trh:cellFormat>\r\n");
          }
          if (attribute.getType().equals("java.lang.Integer"))
          {
            codeChunk.addHtmlCode("\t<trh:cellFormat >\r\n");

            codeChunk.addHtmlCode("\t\t<tr:outputText id=\"" + attribute.getName() + "\"   value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + attribute.SeamField() + "}\" >\r\n");

            codeChunk.addHtmlCode("\t\t\t<f:converter converterId=\"IntegerConverter\" />\r\n");

            codeChunk.addHtmlCode("\t\t</tr:outputText>\r\n");

            codeChunk.addHtmlCode("\t</trh:cellFormat>\r\n");
          }
          if (attribute.getType().equals("java.lang.Long"))
          {
            codeChunk.addHtmlCode("\t<trh:cellFormat >\r\n");

            codeChunk.addHtmlCode("\t\t<tr:outputText id=\"" + attribute.getName() + "\"   value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + attribute.SeamField() + "}\" >\r\n");

            codeChunk.addHtmlCode("\t\t\t<f:converter converterId=\"LongConverter\" />\r\n");

            codeChunk.addHtmlCode("\t\t</tr:outputText>\r\n");

            codeChunk.addHtmlCode("\t</trh:cellFormat>\r\n");
          }
          if (attribute.getType().equals("java.lang.Double"))
          {
            codeChunk.addHtmlCode("\t<trh:cellFormat >\r\n");

            codeChunk.addHtmlCode("\t\t<tr:outputText id=\"" + attribute.getName() + "\"   value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + attribute.SeamField() + "}\" >\r\n");

            codeChunk.addHtmlCode("\t\t\t<f:converter converterId=\"DoubleConverter\" />\r\n");

            codeChunk.addHtmlCode("\t\t</tr:outputText>\r\n");

            codeChunk.addHtmlCode("\t</trh:cellFormat>\r\n");
          }
        }

        if (attribute.isHelp())
        {
          codeChunk.addHtmlCode("\t\t\t<td width=\"1%\"><h:graphicImage styleClass=\"imageLink\" url=\"img/info.gif\" onclick=\"help('help/form_" + bean.getName() + "_" + attribute.getName() + ".html');\" /></td>\r\n");
        }
        else
        {
          codeChunk.addHtmlCode("\t\t\t<td width=\"1%\"></td>\r\n");
        }

        codeChunk.addHtmlCode("\t\t\t</tr>\r\n");
        codeChunk.addHtmlCode("\t\t\t</table>\r\n");
        codeChunk.addHtmlCode("\t\t</rich:panel>\r\n");
        codeChunk.addHtmlCode("\t</td></tr>\r\n");

        codeChunks.add(codeChunk);
      }
    }

    // Inserisce gli attributi provenienti da relazioni che debbono essere
    // solo visualizzati
    for (int i = 0; i < bean.getShowInFormAttributes().size(); i++)
    {
      ShowAttribute attribute = bean.getShowInFormAttributes().get(i);

      CodeChunk codeChunk = new CodeChunk(attribute.getOrderInForm());

      if (attribute.getRelationship() != null && attribute.getRelationship().isToMany())
      {
        codeChunk.addHtmlCode("\r\n@ShowRelationshipAttributesInForm - Relazione :N non supportata - " + attribute.getRelationship().getName() + "\r\n");
      }
      else
      {
        codeChunk.addHtmlCode("\r\n\t<tr><td width=\"100%\">\r\n");

        if (!attribute.getOnCreateIf().equals("") || !attribute.getOnEditIf().equals("") || !attribute.getOnDisplayIf().equals("") || !attribute.getOnDeleteIf().equals(""))
        {
          codeChunk.addHtmlCode("\t\t<rich:panel width=\"100%\" rendered=\"#{");
          codeChunk.addHtmlCode("(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='CREATE'");
          if (!attribute.getOnCreateIf().equals(""))
            codeChunk.addHtmlCode(" and " + attribute.getOnCreateIf());
          codeChunk.addHtmlCode(")");

          codeChunk.addHtmlCode(" or ");

          codeChunk.addHtmlCode("(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='EDIT'");
          if (!attribute.getOnEditIf().equals(""))
            codeChunk.addHtmlCode(" and " + attribute.getOnEditIf());
          codeChunk.addHtmlCode(")");

          codeChunk.addHtmlCode(" or ");

          codeChunk.addHtmlCode("(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DISPLAY'");
          if (!attribute.getOnDisplayIf().equals(""))
            codeChunk.addHtmlCode(" and " + attribute.getOnDisplayIf());
          codeChunk.addHtmlCode(")");

          codeChunk.addHtmlCode(" or ");

          codeChunk.addHtmlCode("(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DELETE'");
          if (!attribute.getOnDeleteIf().equals(""))
            codeChunk.addHtmlCode(" and " + attribute.getOnDeleteIf());
          codeChunk.addHtmlCode(")");
          codeChunk.addHtmlCode("}\" >\r\n");
        }
        else
        {
          codeChunk.addHtmlCode("\t<rich:panel>\r\n");
        }

        codeChunk.addHtmlCode("\t\t<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">\r\n");

        codeChunk.addHtmlCode("\t\t<tr>\r\n");

        codeChunk.addHtmlCode("\t\t<td class=\"formFieldLabel\" >\r\n");
        codeChunk.addHtmlCode("\t\t\t<h:outputLabel value=\"#{msgs.form_" + bean.getName() + "_" + attribute.getQualifiedName().replace(".", "_") + "}\" />\r\n");
        codeChunk.addHtmlCode("\t\t</td>\r\n");

        codeChunk.addHtmlCode("\t\t<td width=\"1%\"></td>\r\n");

        codeChunk.addHtmlCode("\t\t<td>\r\n");
        codeChunk.addHtmlCode("\t\t\t<h:outputText value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + attribute.getQualifiedName() + "}\" />\r\n");
        codeChunk.addHtmlCode("\t\t</td>\r\n");

        codeChunk.addHtmlCode("\t\t</tr>\r\n");

        codeChunk.addHtmlCode("\t\t</table>\r\n");

        codeChunk.addHtmlCode("\t\t</rich:panel>\r\n");
        codeChunk.addHtmlCode("\t</td></tr>\r\n");
      }

      codeChunks.add(codeChunk);
    }

    // Inserisce gli attributi provenienti da relazioni
    for (int i = 0; i < bean.getRelationships().size(); i++)
    {
      Relationship rel = bean.getRelationships().get(i);

      if (rel.isUsed() && !rel.isMasterDetail())
      {
        CodeChunk codeChunk = null;

        //if ( infoReader.BeanCrudInPopUp(rel.getToBeanName()) )
        if (!rel.isListBox() && rel.isCRUD())
        {
          dynamicMenus += "<a4j:region>\r\n";
          dynamicMenus += "<rich:contextMenu attached=\"false\" id=\"menu" + rel.getName() + "\" submitMode=\"ajax\" >\r\n";

          dynamicMenus += "\t<rich:menuItem ajaxSingle=\"true\" value=\"#{msgs.list_" + rel.getToBeanName() + "_display}\" actionListener=\"#{" + rel.getToBeanName() + "Manager.popupMenuSelectItem}\" requestDelay=\"0\" oncomplete=\"openCrudPopUp_" + rel.getName() + "('Display');\">\r\n";
          dynamicMenus += "\t\t<a4j:actionparam name=\"selectedId\" value=\"{selectedBean}\" />\r\n";
          dynamicMenus += "\t</rich:menuItem>\r\n\r\n";

          if (rel.getPopUpEdit())
          {
            dynamicMenus += "\t<rich:menuItem ajaxSingle=\"true\" value=\"#{msgs.list_" + rel.getToBeanName() + "_edit}\" actionListener=\"#{" + rel.getToBeanName() + "Manager.popupMenuSelectItem}\" requestDelay=\"0\" oncomplete=\"openCrudPopUp_" + rel.getName() + "('Edit');\" rendered=\"#{(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='CREATE') or (" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='EDIT')}\" >\r\n";
            dynamicMenus += "\t\t<a4j:actionparam name=\"selectedId\" value=\"{selectedBean}\" />\r\n";
            dynamicMenus += "\t</rich:menuItem>\r\n\r\n";
          }

          if (rel.getPopUpDelete())
          {
            dynamicMenus += "\t<rich:menuItem ajaxSingle=\"true\" value=\"#{msgs.list_" + rel.getToBeanName() + "_delete}\" actionListener=\"#{" + rel.getToBeanName() + "Manager.popupMenuSelectItem}\" requestDelay=\"0\" oncomplete=\"openCrudPopUp_" + rel.getName() + "('Delete');\" rendered=\"#{(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='CREATE') or (" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='EDIT')}\" >\r\n";
            dynamicMenus += "\t\t<a4j:actionparam name=\"selectedId\" value=\"{selectedBean}\" />\r\n";
            dynamicMenus += "\t</rich:menuItem>\r\n\r\n";
          }

          dynamicMenus += "</rich:contextMenu>\r\n";
          dynamicMenus += "</a4j:region>\r\n";
        }

        if (!rel.isToMany())
        {
          // Relazione :1
          if (rel.isListBox())
          {
            // Relazione :1 implementata come ListBox
            codeChunk = insertSingleSelectionListBox2Form(sourceDir, bean, rel, true, false);
          }
          else
          {
            // Relazione :1 implementata come PopUp
            codeChunk = insertSingleSelectionPopUp2Form(sourceDir, bean, rel, inPopUp);
            if (rel.isRequired())
              updatePopUpRelationships += "\tupdatePopUpRelationships(\"" + Utils.makeFirstLetterLowerCase(bean.getName()) + "_" + rel.getName() + "\");\r\n";
            else
              updatePopUpRelationships += "";
          }
        }
        else
        {
          // Relazione :N
          if (rel.isListBox())
          {
            // Relazione :N implementata come ListBox
            codeChunk = insertMultipleSelectionListBox2Form(bean, rel, true, false);
          }
          else
          {
            // Relazione :N implementata come PopUp
            codeChunk = insertMultipleSelectionPopUp2Form(sourceDir, bean, rel, inPopUp);
            if (rel.isRequired())
              updatePopUpRelationships += "\tupdatePopUpRelationships(\"" + Utils.makeFirstLetterLowerCase(bean.getName()) + "_" + rel.getName() + "\");\r\n";
            else
              updatePopUpRelationships += "";
          }
        }

        codeChunk.setOrder(rel.getOrderInForm());
        codeChunks.add(codeChunk);
      }

      /** Relazioni master-detail in cui nel detail viene inserito anche una popup per la gestione del master **/
      if (rel.isUsed() && rel.isMasterDetail() && rel.getOrderInForm() != 0)
      {
        CodeChunk codeChunk = null;

        if (!rel.isToMany())
        {
          // Relazione :1 implementata come PopUp
          codeChunk = insertSingleSelectionPopUp2Form(sourceDir, bean, rel, inPopUp);
          if (rel.isRequired())
            updatePopUpRelationships += "\tupdatePopUpRelationships(\"" + Utils.makeFirstLetterLowerCase(bean.getName()) + "_" + rel.getName() + "\");\r\n";
          else
            updatePopUpRelationships += "";
        }
        else
        {
          // Relazione :N implementata come PopUp
          codeChunk = insertMultipleSelectionPopUp2Form(sourceDir, bean, rel, inPopUp);
          if (rel.isRequired())
            updatePopUpRelationships += "\tupdatePopUpRelationships(\"" + Utils.makeFirstLetterLowerCase(bean.getName()) + "_" + rel.getName() + "\");\r\n";
          else
            updatePopUpRelationships += "";
        }

        codeChunk.setOrder(rel.getOrderInForm());
        codeChunks.add(codeChunk);
      }

    }

    /** Predispone i Manager necessari per le chiamate remoting * */
    relatedManagers += bean.getName() + "Manager";

    for (int i = 0; i < bean.getRelationships().size(); i++)
    {
      Relationship rel = bean.getRelationships().get(i);

      if (rel.isUsed())
      {
        relatedManagers += "&" + rel.getToBeanName() + "Manager";
      }
    }

    /** Ordinamento dei chunck  **/

    CodeChunk chunks[] = codeChunks.toArray(new CodeChunk[0]);

    Arrays.sort(chunks, new CodeChunkComparator());

    //    for (int i = 0; i < chunks.length; i++)
    //    {
    //      javaScript += chunks[i].getJavascriptCode();
    //      rows += chunks[i].getHtmlCode();
    //    }

    Vector<CodeChunk> chunkVector = new Vector<CodeChunk>(java.util.Arrays.asList(chunks));

    /** Generazione dei grouppi di attributi **/
    for (int i = 0; i < bean.getFormFieldsGroups().size(); i++)
    {
      FormFieldsGroup group = bean.getFormFieldsGroups().get(i);

      CodeChunk start = new CodeChunk(group.getFromFieldOrder());
      start.addHtmlCode("\r\n\r\n<!-- START GROUP: " + group.getTitle() + "  -->\r\n");
      start.addHtmlCode("<rich:panel header=\"" + group.getTitle() + "\" rendered=\"#{");

      start.addHtmlCode("(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='CREATE'");
      if (!group.getShowOnCreateIf().equals(""))
        start.addHtmlCode(" and " + group.getShowOnCreateIf());
      start.addHtmlCode(")");

      start.addHtmlCode(" or ");

      start.addHtmlCode("(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='EDIT'");
      if (!group.getShowOnEditIf().equals(""))
        start.addHtmlCode(" and " + group.getShowOnEditIf());
      start.addHtmlCode(")");

      start.addHtmlCode(" or ");

      start.addHtmlCode("(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DISPLAY'");
      if (!group.getShowOnDisplayIf().equals(""))
        start.addHtmlCode(" and " + group.getShowOnDisplayIf());
      start.addHtmlCode(")");

      start.addHtmlCode(" or ");

      start.addHtmlCode("(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DELETE'");
      if (!group.getShowOnDeleteIf().equals(""))
        start.addHtmlCode(" and " + group.getShowOnDeleteIf());
      start.addHtmlCode(")");

      start.addHtmlCode("}\" >\r\n\r\n");
      start.addHtmlCode("<table width=\"100%\">\r\n");

      int idx = getChunkIndex(chunkVector, start);

      chunkVector.add(idx, start);

      CodeChunk end = new CodeChunk(group.getToFieldOrder());

      end.addHtmlCode("</table>\r\n");
      end.addHtmlCode("\r\n\r\n</rich:panel>\r\n");
      //end.addHtmlCode("<tr:spacer height=\"25\" />\r\n");
      end.addHtmlCode("<!-- END GROUP: " + group.getTitle() + "  -->\r\n\r\n");

      idx = getChunkIndex(chunkVector, end);

      chunkVector.add(idx + 1, end);
    }

    /** Finalmente scrive i chunk nel tag che viene sostituito nel template **/

    for (int i = 0; i < chunkVector.size(); i++)
    {
      javaScript += chunkVector.get(i).getJavascriptCode();
      rows += chunkVector.get(i).getHtmlCode();
    }

    /** Gestione dei campi FORMATTEDTEXTAREA **/

    if (!textAreaIds.equals(""))
    {
      String HtmlEditorJavascriptTemplate = "." + File.separator + "templates" + File.separator + "HtmlEditorJavascript.js";

      HashMap<String, String> tags = new HashMap<String, String>();

      tags.put("@TextAreaIds", textAreaIds);

      javascriptHtmlEditor = Utils.SeamReplaceTag2String(tags, null, null, HtmlEditorJavascriptTemplate);
    }

    if (bean.getPrintMenuConditionInForm().equals(""))
      printButton = "\t\t<h:commandLink immediate=\"true\" value=\"#{msgs.Application_print}\" action=\"/" + bean.getName() + "Print.seam\" rendered=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation!='CREATE'}\" style=\"text-decoration: none; color: black\" />";
    else
      printButton = "\t\t<h:commandLink immediate=\"true\" value=\"#{msgs.Application_print}\" action=\"/" + bean.getName() + "Print.seam\" rendered=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation!='CREATE' and " + bean.getPrintMenuConditionInForm() + "}\" style=\"text-decoration: none; color: black\" />";

    /** Gestione campi nascosti per CRUDInSeparatePopup **/
    if (inPopUp)
    {
      Vector<Relationship> relationships2ThisBean = infoReader.getAllRelationship2ThisBean(bean.getName());

      for (int r = 0; r < relationships2ThisBean.size(); r++)
      {
        Relationship rel = relationships2ThisBean.get(r);

        Bean fromBean = infoReader.getBean(rel.getFromBeanName());

        String tmp = generatePopUpJavascriptFunctionsInPopup(fromBean).replace("startup", "loadHiddenFields").replace("\tdocument.forms[\"form\"].elements[\"form:", "\tdocument.forms[\"form\"].elements[\"form:" + rel.getFromBeanName());
        //        tmp += "\r\n"+generatePopUpJavascriptFunctionsInPopup(fromBean).replace("startup", "loadHiddenFields");

        if (javaScript.contains("loadHiddenFields"))
View Full Code Here

    // Recupera il codice custom nella pagina
    LinkedList<String> yourJavaScriptCode = Utils.getYourCode(sourceFile, CustomCodeType.JAVA);
    LinkedList<String> yourCode = Utils.getYourCode(sourceFile, CustomCodeType.JSP);

    InfoReader infoReader = new InfoReader(sourceDir);

    /**
     * Predisposizione delle informazion relative alle relazioni MASTER-DETAIL
     * non categorizzate
     */

    for (int i = 0; i < bean.getRelationships().size(); i++)
    {
      Relationship rel = bean.getRelationships().get(i);

      if (rel.isUsed())
      {
        if (rel.isMasterDetail() && !rel.isFromMaster())
        {
          // Il bean e' un Detail in una relazione MASTER-DETAIL

          // Predispone l'indicazione del Master (PATH) se questo bean e' un Detail
          path = "<h:outputText value=\"#{" + bean.getName() + "Manager.path}\" styleClass=\"listPath\" />\r\n";

          // Inserisce il bottone di selezione del Master

          if (rel.isGoToMasterMenuItem())
          {
            masterButton += "\t\t\t<h:commandLink immediate=\"true\" value=\"#{msgs.list_" + rel.getFromBeanName() + "_" + rel.getToBeanName() + "}\" action=\"/list/" + rel.getToBeanName() + "List.seam?masterReference=true\" rendered=\"#{" + bean.getName() + "Manager.isDetailOf('" + rel.getToBeanName() + "')}\"   style=\"text-decoration: none; color: black\"  />\r\n";
          }
          else
            masterButton = "";
        }

        if (rel.isMasterDetail() && rel.isFromMaster())
        {
          // Il bean e' un Master in una relazione MASTER-DETAIL

          // Predispone i links a tutte le liste del bean DETAIL

          detailButton += "\t<rich:menuSeparator />\r\n";

          Vector<ShowList> lists = infoReader.getLists(rel.getToBeanName());
          for (int j = 0; j < lists.size(); j++)
          {
            // detailButton += "\t\t\t<tr:commandLink immediate=\"true\" value=\"#{msgs.list_" + rel.getFromBeanName() + "_" + lists.get(j).getName() + "}\" action=\"#{@BeanManager.goTo" + lists.get(j).getName() + "}\" style=\"white-space: nowrap;\" />\r\n";
            detailButton += "\t<rich:menuItem immediate=\"true\" value=\"#{msgs.list_" + rel.getFromBeanName() + "_" + lists.get(j).getName() + "}\" actionListener=\"#{@BeanManager.popupMenuSelectItem}\" action=\"#{@BeanManager.goTo" + lists.get(j).getName() + "}\" style=\"white-space: nowrap;\" >\r\n";
            detailButton += "\t\t<a4j:actionparam name=\"selectedId\" value=\"{selectedBean}\" />\r\n";
            detailButton += "\t</rich:menuItem>\r\n";
          }
        }
      }
    }

    /**
     * Predisposizione delle informazioni relative alle relazioni
     * MASTER-DETAIL categorizzate *
     */
    details += generateDetails(bean, sourceDir);

    // Prepara la lista dei campi

    columnClasses = listColumnClasses(bean.getShowAttributes(), true); // Stile delle colonne
    columnWidths = listColumnWidths(bean.getShowAttributes(), true); // Dimensioni delle colonne

    rows = listColumns(bean.getName(), bean.getShowAttributes()); // Colonne della tabella

    /** Bottone per la ricerca locale **/

    if (bean.getSearchAttributes().size() > 1)
    {
      selectionButton += "\r\n\taddMenuBarItem(new menuBarItem(\"<bean:message key=\"list." + bean.getName() + ".button.search\"/>\", \"\", \"\", \"\", \"code:doSubmit('<bean:message key=\"list." + bean.getName() + ".button.search\"/>');\"));\r\n";
    }

    /** Ricerca locale * */

    localSearch = localSearch(bean);
    javaScript += localSearch.getJavascriptCode();

    // Voce menu per ricerca

    if (bean.getSearchAttributes().size() > 1)
    {
      searchButton += "\t\t\t<h:commandLink  immediate=\"true\" value=\"#{msgs.list_" + bean.getName() + "_search}\" action=\"#{" + bean.getName() + "Manager.initSearch}\"  style=\"text-decoration: none; color: black\"  />\r\n";
    }

    // Menu creazione bean
    Vector<String> derivedBeans = infoReader.getDerivedBeans(bean.getName());
    if (derivedBeans.size() == 0)
    {
      if (listInfo.getNewMenuCondition().equals(""))
        createButtons = "\t\t\t<h:commandLink immediate=\"true\" value=\"#{msgs.list_" + bean.getName() + "_new}\" action=\"#{" + bean.getName() + "Manager.initCreate}\" style=\"text-decoration: none; color: black\"   />\r\n";
      else
View Full Code Here

        if (rel.isUsed() && rel.isMasterDetail() && rel.isFromMaster() && rel.isCategorized())
        {
          HashMap<String, String> tags = new HashMap<String, String>();

          InfoReader infoReader = new InfoReader(sourceDir);
          Bean detailBean = infoReader.getBean(rel.getToBeanName());

          rows = rows = listColumns(detailBean.getName(), detailBean.getShowAttributes());

          tags.put("@bean", Utils.makeFirstLetterLowerCase(detailBean.getName()));
          tags.put("@Bean", detailBean.getName());
          tags.put("@masterBean", Utils.makeFirstLetterLowerCase(masterBean.getName()));
          tags.put("@Relationship", Utils.makeFirstLetterLowerCase(masterBean.getName()) + "." + Utils.makeMethod2Field(rel.getName()));
          tags.put("@Rows", rows);

          Bean targetBean = infoReader.getBean(rel.getToBeanName());

          String details = generateDetails(targetBean, sourceDir);

          tags.put("@Details", details);
View Full Code Here

    //      newMenuOptionCondition = "";
    //    else
    //      newMenuOptionCondition = "rendered=\"#{" + bean.getNewMenuOptionConditionOnListSearch() + "}\"";

    // Menu creazione bean
    InfoReader infoReader = new InfoReader(sourceDir);
    Vector<String> derivedBeans = infoReader.getDerivedBeans(bean.getName());
    if (derivedBeans.size() == 0)
    {
      if (bean.getNewMenuOptionConditionOnListSearch().equals(""))
        createButtons = "\t\t<h:commandLink immediate=\"true\" value=\"#{msgs.list_" + bean.getName() + "_new}\" action=\"#{" + bean.getName() + "Manager.initCreate}\" style=\"text-decoration: none; color: black\" />\r\n";
      else
View Full Code Here

    Utils.SeamReplaceTagAndSave(tags, yourJavaScriptCode, yourCode, template, targetForm);
  }

  public static void generatePopUp(Bean bean, String sourceDir, String targetDir, String basePackage) throws Exception, FileNotFoundException, IOException, NoSuchMethodException, NamingException, ClassNotFoundException
  {
    InfoReader infoReader = new InfoReader(sourceDir);

    for (int i = 0; i < bean.getRelationships().size(); i++)
    {
      Relationship rel = bean.getRelationships().get(i);

      if (rel.isUsed() && !rel.isListBox())
      {
        // Genera la entry in pages per la pagina di PopUp
        PagesConfig.addPopUpPage(sourceDir, targetDir, rel);

        if ((!rel.isMasterDetail() || (rel.isMasterDetail() && rel.getOrderInForm() != 0)) && !rel.isToMany())
        {
          // Relazione a 1 implementata come popup

          // Attributi nella pagina di origine

          Vector<ShowAttribute> attributes = rel.getRelatedAttributes();

          Vector<ShowAttribute> beanAttr = new Vector<ShowAttribute>();

          beanAttr.add(new ShowAttribute(infoReader.getBeanKey(rel.getToBeanName())));

          beanAttr.addAll(attributes);

          // Sono aggiunti gli attributi derivanti dalle relazioni
          // implementate come ListBox
          Vector<Attribute> attributes1 = bean.getAttributes();
          Vector<ShowAttribute> callingAttributes = new Vector<ShowAttribute>();

          for (int l = 0; l < attributes1.size(); l++)
          {
            Attribute attr = attributes1.get(l);

            if (attr.getImplementationType() != AttributeImplementationType.HIDEINFORM)
              callingAttributes.add(new ShowAttribute(attributes1.get(l)));
          }

          /**
           * Nei calling attributes ci vanno
           *
           * 1) Gli attributi visualizzati del bean origine
           *
           * 2) Gli attributi visualizzati nel bean, ereditati dal
           * superbean origine (se esiste)
           *
           * 3) Gli attributi derivanti da relazioni implementate come
           * LISTBOX
           *
           * 4) Gli attributi derivanti da relazioni implementate come
           * LISTBOX ereditate dal superbean origine (se esiste)
           *
           */

          Vector<Relationship> re = bean.getRelationships();

          for (int j = 0; j < re.size(); j++)
          {
            if (re.get(j).isListBox())
            {
              Attribute a = new Attribute();
              a.setKey(false);
              a.setName(Utils.makeFirstLetterLowerCase(re.get(j).getToBeanName()));

              ShowAttribute attr = new ShowAttribute(re.get(j), a);

              callingAttributes.add(attr);
            }
          }

          Bean targetBean = infoReader.getBean(rel.getToBeanName());

          /**
           * generateSelectionPage2One(String sourceDir, String targetDir,
           * Relationship rel, Vector<ShowAttribute>
           * callingBeanAttributes, String bean, Vector<SearchAttribute>
           * localSearchAttributes, Vector<ShowAttribute>
           * targetBeanAttributes)
           */

          HTMLGenerator.generatePopUpSingleSelection(sourceDir, targetDir, bean, rel, callingAttributes, targetBean.getLocalSearchAttributes(), beanAttr);
        }

        if ((!rel.isMasterDetail() || (rel.isMasterDetail() && rel.getOrderInForm() != 0)) && rel.isToMany())
        {
          // Relazione a n implementata come popup

          // Attributi nella pagina di origine

          Vector<ShowAttribute> attributes = rel.getRelatedAttributes();

          Bean targetBean = infoReader.getBean(rel.getToBeanName());

          Vector<Attribute> tmp = new Vector<Attribute>(bean.getAttributes());
          Vector<ShowAttribute> beanAttr = new Vector<ShowAttribute>();

          for (int l = 0; l < tmp.size(); l++)
View Full Code Here

      actionEdit += "\t\t<a4j:actionparam name=\"selectedId\" value=\"{selectedBean}\" />\r\n";
      actionEdit += "\t</rich:menuItem>";
    }

    /** Ricerca locale * */
    InfoReader infoReader = new InfoReader(sourceDir);
    Bean targetBean = infoReader.getBean(rel.getToBeanName());
    localSearch = localSearch(targetBean);
    if (targetBean.getLocalSearchAttributes().size() > 0)
    {
      localSearchButton = "<h:commandButton styleClass=\"imageLink\"  image=\"../img/search.gif\" action=\"#{" + targetBean.getName() + "Manager.startLocalSearch}\"  />";
    }
View Full Code Here

      actionEdit += "\t\t<a4j:actionparam name=\"selectedId\" value=\"{selectedBean}\" />\r\n";
      actionEdit += "\t</rich:menuItem>";
    }
   
    /** Ricarca locale * */
    InfoReader infoReader = new InfoReader(sourceDir);
    Bean targetBean = infoReader.getBean(rel.getToBeanName());
    localSearch = localSearch(targetBean);
    if (targetBean.getLocalSearchAttributes().size() > 0)
    {
      localSearchButton = "<h:commandButton styleClass=\"imageLink\"  image=\"../img/search.gif\" action=\"#{" + targetBean.getName() + "Manager.startLocalSearch}\" />";
    }
View Full Code Here

    addPage(targetDir, rel.getToBeanName() + "Manager.onPopUpLoad", "/popup/" + rel.getFromBeanName() + rel.getName() + "PopUp.xhtml", "");

    // Poiche' la relazione e' ereditata anche dai bean figli, deve essere generata
    // una entry in page anche per questi

    InfoReader infoReader = new InfoReader(sourceDir);
       
    Vector<String> derivedBeans = infoReader.getDerivedBeans(rel.getToBeanName());
    for (String derivedBean : derivedBeans)
    {
      addPage(targetDir, derivedBean + "Manager.onPopUpLoad", "/popup/" + rel.getFromBeanName() + rel.getName() + "PopUp.xhtml", "");
    }
   
    derivedBeans = infoReader.getDerivedBeans(rel.getFromBeanName());
    for (String derivedBean : derivedBeans)
    {
      addPage(targetDir, rel.getToBeanName() + "Manager.onPopUpLoad", "/popup/" + derivedBean + rel.getName() + "PopUp.xhtml", "");
    }
   
View Full Code Here

    String resourcesFile = targetDir + File.separator + "html" + File.separator + "WEB-INF" + File.separator + "classes" + File.separator + "messages.properties";
    String key;

    Properties prop = PropertiesFileManager.load(resourcesFile);

    InfoReader infoReader = new InfoReader(sourceDir);

    /** Lista **/

    // Titoli della pagine list e nome delle azioni sugli item della lista
    for (int i = 0; i < bean.getLists().size(); i++)
    {
      key = "list_" + bean.getLists().get(i).getName() + "_title";
      if (!prop.containsKey(key))
      {
        prop.put(key, Utils.makeFirstLetterUpperCase(bean.getLists().get(i).getName()));
      }
    }
   
    key = "list_" + bean.getName() + "_searchTitle";
    if (!prop.containsKey(key))
    {
      prop.put(key, "Search Result " + Utils.makeFirstLetterUpperCase(bean.getName()));
    }

    key = "list_" + bean.getName() + "_new";
    if (!prop.containsKey(key))
    {
      prop.put(key, "New");
    }

    key = "list_" + bean.getName() + "_display";
    if (!prop.containsKey(key))
    {
      prop.put(key, "Details " + Utils.makeFirstLetterUpperCase(bean.getName()));
    }

    key = "list_" + bean.getName() + "_edit";
    if (!prop.containsKey(key))
    {
      prop.put(key, "Edit " + Utils.makeFirstLetterUpperCase(bean.getName()));
    }

    key = "list_" + bean.getName() + "_create";
    if (!prop.containsKey(key))
    {
      prop.put(key, "New " + Utils.makeFirstLetterUpperCase(bean.getName()));
    }

    key = "list_" + bean.getName() + "_delete";
    if (!prop.containsKey(key))
    {
      prop.put(key, "Delete " + Utils.makeFirstLetterUpperCase(bean.getName()));
    }

    key = "list_" + bean.getName() + "_search";
    if (!prop.containsKey(key))
    {
      prop.put(key, "Search");
    }

    /** Form **/

    key = "form_" + bean.getName();
    if (!prop.containsKey(key))
    {
      prop.put(key, bean.getName());
    }

    // Titoli della pagina di gestione del form
    key = "form_" + bean.getName() + "_display";
    if (!prop.containsKey(key))
    {
      //prop.put(key, "Dettagli" + Utils.makeFirstLetterUpperCase(bean.getName()));
      prop.put(key, "Details");
    }

    key = "form_" + bean.getName() + "_edit";
    if (!prop.containsKey(key))
    {
      prop.put(key, "Edit");
    }

    key = "form_" + bean.getName() + "_create";
    if (!prop.containsKey(key))
    {
      prop.put(key, "New");
    }

    key = "form_" + bean.getName() + "_delete";
    if (!prop.containsKey(key))
    {
      prop.put(key, "Delete");
    }

    key = "form_" + bean.getName() + "_search";
    if (!prop.containsKey(key))
    {
      prop.put(key, "Search");
    }

    // Attributi del bean nel form
    for (int i = 0; i < bean.getAttributes().size(); i++)
    {
      Attribute attr = bean.getAttributes().get(i);

      key = "form_" + bean.getName() + "_" + attr.getName();
      if (!prop.containsKey(key))
      {
        prop.put(key, Utils.makeFirstLetterUpperCase(attr.getName()));
      }
    }

    // Relazioni nel form
    for (int i = 0; i < bean.getRelationships().size(); i++)
    {
      Relationship rel = bean.getRelationships().get(i);

      key = "form_" + bean.getName() + "_" + rel.getName();
      if (!prop.containsKey(key))
      {
        prop.put(key, rel.getName().substring(3));
      }

      if (rel.isListBox())
      {
        ;
      }
      else
      {
        for (int j = 0; j < rel.getRelatedAttributes().size(); j++)
        {
          Attribute attr = rel.getRelatedAttributes().get(j);

          key = "form_" + bean.getName() + "_" + rel.getName();

          for (int k = 0; k < attr.getRelationships().size(); k++)
          {
            key += "_";
            key += attr.getRelationships().get(k).getName();
          }

          key += "_" + attr.getName();

          if (!prop.containsKey(key))
          {
            prop.put(key, Utils.makeFirstLetterUpperCase(attr.getName()));
          }
        }
      }
    }

    // Attributi delle relazioni da visualizzare nel form del bean
    for (int i = 0; i < bean.getShowInFormAttributes().size(); i++)
    {
      ShowAttribute attribute = bean.getShowInFormAttributes().get(i);

      key = "form_" + bean.getName() + "_" + attribute.getQualifiedName().replace(".", "_");

      if (!prop.containsKey(key))
      {
        prop.put(key, key);
      }
    }

    // Attributi del bean nella lista
    for (int i = 0; i < bean.getShowAttributes().size(); i++)
    {
      ShowAttribute attr = bean.getShowAttributes().get(i);

      if (!attr.belongsToRelationship())
      {
        key = "list_" + bean.getName() + "_" + attr.getName();
        if (!prop.containsKey(key))
        {
          prop.put(key, Utils.makeFirstLetterUpperCase(attr.getName()));
        }
      }
      else
      {
        // key = "list_" + bean.getName() + "_" + attr.getRelationship().getName() + "_" + attr.getName();

        key = "list_" + bean.getName();

        for (int k = 0; k < attr.getRelationships().size(); k++)
          key += "_" + attr.getRelationships().get(k).getName();

        key += "_" + attr.getName();

        if (!prop.containsKey(key))
        {
          prop.put(key, key);
        }
      }
    }

    // Pulsante di riferimento al master nella lista detail

    for (int i = 0; i < bean.getRelationships().size(); i++)
    {
      Relationship rel = bean.getRelationships().get(i);

      if (rel.isMasterDetail())
      {
        if (!rel.isFromMany() && !rel.isToMany() && !rel.isFromMaster())
        {
          // Relazione 1:1 Master-Detail in cui il bean e' il Detail

          key = "list_" + rel.getFromBeanName() + "_" + rel.getName() + "_OnlyOne" + rel.getFromBeanName() + "Allowed";

          if (!prop.containsKey(key))
          {
            prop.put(key, "Only one " + rel.getFromBeanName()+" allowed");
          }
        }

        // Inserisce il bottone di selezione del master o del detail a seconda del verso della relazione

        if (!rel.isFromMaster())
        {
          // Questo bean e' il Detail
          key = "list_" + rel.getFromBeanName() + "_" + rel.getToBeanName();

          if (!prop.containsKey(key))
          {
            prop.put(key, rel.getToBeanName());
          }
        }
        else
        {
          // Questo bean e' il master

          Vector<ShowList> lists = infoReader.getLists(rel.getToBeanName());

          for (ShowList list : lists)
          {
            key = "list_" + rel.getFromBeanName() + "_" + list.getName();

            if (!prop.containsKey(key))
            {
              prop.put(key, list.getName());
            }
          }
        }
      }
    }

    /** Etichette per i campi della ricerca locale **/
    for (int i = 0; i < bean.getLocalSearchAttributes().size(); i++)
    {
      ShowAttribute attr = bean.getLocalSearchAttributes().get(i);

      if (attr.getRelationship() == null)
      {
        key = "localSearch_" + bean.getName() + "_" + attr.getName();
        if (!prop.containsKey(key))
        {
          prop.put(key, Utils.makeFirstLetterUpperCase(attr.getName()));
        }
      }
      else
      {
        key = "localSearch_" + bean.getName() + "_" + attr.getRelationship().getName() + "_" + attr.getName();
        if (!prop.containsKey(key))
        {
          prop.put(key, attr.getRelationship().getName() + "_" + Utils.makeFirstLetterUpperCase(attr.getName()));
        }
      }

    }

    /** Etichette degli attributi di selezione di relazioni verso questo bean implementate come PopUp **/

    Vector<Relationship> relationships2ThisBean = infoReader.getAllRelationship2ThisBean(bean.getName());

    for (int i = 0; i < relationships2ThisBean.size(); i++)
    {
      Relationship rel = relationships2ThisBean.get(i);

View Full Code Here

TOP

Related Classes of org.boco.seamwebappgen.info.InfoReader

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.