Package org.boco.seamwebappgen.utils

Examples of org.boco.seamwebappgen.utils.CodeChunk


    return insertMultipleSelectionPopUp2Form(sourceDir, bean, rel, inPopUp, false);
  }

  private static CodeChunk insertMultipleSelectionPopUp2Form(String sourceDir, Bean bean, Relationship rel, boolean inPopUp, boolean alwaysRendered)
  {
    CodeChunk ret = new CodeChunk(0);
    String disabledCondition = "";

    if (!rel.isListBox() && !rel.isCRUD())
    {
      ret.addJavascriptCode("function openPopUp_" + rel.getName() + "()");
      ret.JavascriptNewLine();
      ret.addJavascriptCode("{");
      ret.JavascriptNewLine();
      if (inPopUp)
        ret.addJavascriptCode("\twindow.open(\"popup/" + bean.getName() + rel.getName() + "PopUp.seam?callingBean=" + bean.getName() + "InPopUp&callingConversationId=\"+document.forms[\"form\"].elements['form:parentConversationId'].value+\"&conversationIsLongRunning=true\",\"" + rel.getToBeanName() + "Window\",\"resizable=yes,menubar=no,width=850,height=550,scrollbars=yes\");");
      else
        ret.addJavascriptCode("\twindow.open(\"popup/" + bean.getName() + rel.getName() + "PopUp.seam?callingBean=" + bean.getName() + "&callingConversationId=\"+document.forms[\"form\"].elements['form:parentConversationId'].value+\"&conversationIsLongRunning=true\",\"" + rel.getToBeanName() + "Window\",\"resizable=yes,menubar=no,width=850,height=550,scrollbars=yes\");");

      ret.JavascriptNewLine();
      ret.addJavascriptCode("}");
      ret.JavascriptNewLine();
    }

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

    ret.addHtmlCode("\t<rich:panel");

    /** Gestione della visibilita': showOnEditIf ...  **/

    if (!alwaysRendered)
    {

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

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

      ret.addHtmlCode(" or ");

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

      ret.addHtmlCode(" or ");

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

      ret.addHtmlCode(" or ");

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

      ret.addHtmlCode("}\"");
    }

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

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

    ret.addHtmlCode("\t\t\t\t<td class=\"formFieldLabel\"><h:outputLabel for=\"" + Utils.makeFirstLetterLowerCase(bean.getName()) + "_" + Utils.makeFirstLetterLowerCase(rel.getName()) + "\" value=\"#{msgs.form_" + rel.ToSeamLabel() + "}\" /></td>\r\n");

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

    if (!rel.isListBox() && rel.isCRUD())
    {
      ret.addHtmlCode("\t\t\t\t\t<s:link action=\"#{" + rel.getToBeanName() + "Manager.initCreateInPopUp}\" rendered=\"false\" />\r\n");
      ret.addHtmlCode("\t\t\t\t\t<s:link action=\"#{" + rel.getToBeanName() + "Manager.initDisplayInPopUp}\" rendered=\"false\" />\r\n");
      ret.addHtmlCode("\t\t\t\t\t<s:link action=\"#{" + rel.getToBeanName() + "Manager.initEditInPopUp}\" rendered=\"false\" />\r\n");
      ret.addHtmlCode("\t\t\t\t\t<s:link action=\"#{" + rel.getToBeanName() + "Manager.initDeleteInPopUp}\" rendered=\"false\" />\r\n");

      if (rel.getPopUpCreate())
      {
        // Inserisce il pulsante per la creazione della relazione

        // Prima deve essere costrutita la condizione per la disabilitazione

        if (!rel.getDisableOnCreateIf().equals(""))
        {
          disabledCondition += "(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='CREATE' and (" + rel.getDisableOnCreateIf() + "))";
        }

        if (!rel.getDisableOnEditIf().equals(""))
        {
          if (!disabledCondition.equals(""))
            disabledCondition += " or ";

          disabledCondition += "(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='EDIT' and (" + rel.getDisableOnEditIf() + "))";
        }

        if (!disabledCondition.equals(""))
          disabledCondition = "disabled=\"#{" + disabledCondition + "}\"";

        ret.addHtmlCode("\t\t\t\t\t<a4j:commandButton id=\"popup_New" + rel.getToBeanName() + "\"     value=\"#{msgs.list_" + rel.getToBeanName() + "_new}\"  onclick=\"openCrudPopUp_" + rel.getName() + "('Create');\"  styleClass=\"formButton\" rendered=\"#{(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='CREATE') or (" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='EDIT') or (" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='SEARCH')}\" " + disabledCondition + " />\r\n");
      }

      ret.addJavascriptCode("function openCrudPopUp_" + rel.getName() + "(operation)\r\n");
      ret.addJavascriptCode("{\r\n");
      ret.addJavascriptCode("\twindow.open(\"" + bean.getName() + ".seam?conversationId=\"+document.forms[\"form\"].elements['form:parentConversationId'].value+\"&conversationIsLongRunning=true&actionMethod=" + bean.getName() + ".xhtml:" + rel.getToBeanName() + "Manager.init\"+operation+\"InPopUp&callingBean=" + bean.getName() + "&relationship=" + rel.getName() + "\",\"" + rel.getToBeanName() + "Window\",\"resizable=yes,menubar=no,width=850,height=550,scrollbars=yes\");\r\n");
      ret.addJavascriptCode("}\r\n");
    }

    if (rel.isRequired())
    {
      ret.addHtmlCode("\t\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");
    }

    if (!rel.isCRUD())
      ret.addHtmlCode("\t\t\t\t\t<a4j:commandButton id=\"popup_" + rel.getName() + "\" value=\"#{msgs.Application_buttonSelect}\" onclick=\"openPopUp_" + rel.getName() + "();\" styleClass=\"formButton\" rendered=\"#{(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='CREATE') or (" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='EDIT') or (" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='SEARCH')}\" />\r\n");

    if (rel.isRequired())
    {
      ret.addHtmlCode("\t\t\t\t\t<h:inputText id=\"" + Utils.makeFirstLetterLowerCase(bean.getName()) + "_" + Utils.makeFirstLetterLowerCase(rel.getName()) + "\" value=\"\" required=\"#{true and " + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation!='DELETE'}\" style=\"display:none;\" rendered=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation!='DISPLAY'}\" " + disabledCondition + " />\r\n");
      ret.addHtmlCode("\t\t\t\t\t<h:message for=\"" + Utils.makeFirstLetterLowerCase(bean.getName()) + "_" + Utils.makeFirstLetterLowerCase(rel.getName()) + "\" errorClass=\"rich-messages-label\" />\r\n");
    }

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

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

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

    ret.addHtmlCode("\t\t\t\t<td colspan=\"2\">\r\n");
    ret.addHtmlCode("\t\t\t\t\t<rich:dataTable id=\"tab_" + Utils.makeFirstLetterLowerCase(bean.getName()) + "_" + rel.getName() + "\" var=\"" + Utils.makeFirstLetterLowerCase(rel.getToBeanName()) + "\" value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + Utils.makeMethod2Field(rel.getName()) + "}\" width=\"100%\"\r\n");

    if (!rel.isListBox() && rel.isCRUD())
    {
      ret.addHtmlCode("\t\t\t\t\tcolumnClasses=\"dataColumnCenterAlignment," + listColumnClasses(rel.getRelatedAttributes(), false) + "\"\r\n");
      ret.addHtmlCode("\t\t\t\t\t>\r\n");

      ret.addHtmlCode("<!-- POPUP MENU COLUMN -->\r\n");
      ret.addHtmlCode("\t<rich:column width=\"1%\">\r\n");
      ret.addHtmlCode("\t\t<f:facet name=\"header\">&nbsp;</f:facet>\r\n");
      ret.addHtmlCode("\t\t<h:panelGroup>\r\n");
      ret.addHtmlCode("\t\t\t<h:graphicImage url=\"img/action.gif\" id=\"pic\" >\r\n");
      ret.addHtmlCode("\t\t\t\t<rich:componentControl event=\"onclick\" for=\"menu" + rel.getName() + "\" operation=\"show\">\r\n");
      ret.addHtmlCode("\t\t\t\t\t<f:param value=\"#{" + Utils.makeFirstLetterLowerCase(rel.getToBeanName()) + ".id}\" name=\"selectedBean\"/>\r\n");
      ret.addHtmlCode("\t\t\t\t</rich:componentControl>\r\n");
      ret.addHtmlCode("\t\t\t</h:graphicImage>\r\n");
      ret.addHtmlCode("\t\t</h:panelGroup>\r\n");
      ret.addHtmlCode("\t</rich:column>\r\n");
      ret.addHtmlCode("<!-- POPUP MENU COLUMN -->\r\n");
    }
    else
    {
      ret.addHtmlCode("\t\t\t\t\tcolumnClasses=\"" + listColumnClasses(rel.getRelatedAttributes(), false) + "\"\r\n");
      ret.addHtmlCode("\t\t\t\t\t>\r\n");
    }

    for (int i = 0; i < rel.getRelatedAttributes().size(); i++)
    {
      ShowAttribute attr = rel.getRelatedAttributes().get(i);

      ret.addHtmlCode("\t\t\t\t\t\t<rich:column");

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

      ret.addHtmlCode("\t\t\t\t\t\t\t<f:facet name=\"header\">\r\n");

      ret.addHtmlCode("\t\t\t\t\t\t\t\t<h:outputText value=\"#{msgs.form_" + bean.getName() + "_" + rel.getName());

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

      ret.addHtmlCode("_" + attr.getName() + "");

      ret.addHtmlCode("}\" />\r\n");

      ret.addHtmlCode("\t\t\t\t\t\t\t</f:facet>\r\n");

      if (attr.getRelationships().size() == 0)
      {
        ret.addHtmlCode("\t\t\t\t\t\t\t<h:outputText value=\"#{" + Utils.makeFirstLetterLowerCase(rel.getToBeanName()) + "." + attr.getName() + "}\"");

        if (attr.getImplementationType() == AttributeImplementationType.FORMATTEDTEXTAREA)
          ret.addHtmlCode(" escape=\"false\"");

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

        if (attr.getType().equals("java.util.Date"))
        {
          ret.addHtmlCode("\t\t\t\t\t\t\t\t<f:convertDateTime pattern=\"#{msgs.Application_DateFormat}\" />\r\n");
        }
        if (attr.getType().equals("java.lang.Double") && !attr.isListFormatOff())
        {
          ret.addHtmlCode("\t\t\t\t\t\t\t\t<f:converter converterId=\"DoubleConverter\" />\r\n");
        }

        if (attr.getType().equals("java.lang.Long") && !attr.isListFormatOff())
        {
          ret.addHtmlCode("\t\t\t\t\t\t\t\t<f:converter converterId=\"LongConverter\" />\r\n");
        }

        if (attr.getType().equals("java.lang.Integer") && !attr.isListFormatOff())
        {
          ret.addHtmlCode("\t\t\t\t\t\t\t\t<f:converter converterId=\"IntegerConverter\" />\r\n");
        }

        ret.addHtmlCode("\t\t\t\t\t\t\t</h:outputText >\r\n");
      }
      else
      {
        /**
         *
         * Attributo nella forma
         *
         *  [relationship.]*Atribute
         *
         */

        if (!attribute2N(attr))
        {
          ret.addHtmlCode("\t\t\t\t\t\t\t<h:outputText value=\"#{" + Utils.makeFirstLetterLowerCase(rel.getToBeanName()) + ".");

          for (int k = 0; k < attr.getRelationships().size(); k++)
          {
            if (k > 0)
              ret.addHtmlCode(".");

            ret.addHtmlCode(Utils.makeMethod2Field(attr.getRelationships().get(k).getName()));
          }

          ret.addHtmlCode("." + attr.getName());

          ret.addHtmlCode("}\"");

          if (attr.getImplementationType() == AttributeImplementationType.FORMATTEDTEXTAREA)
            ret.addHtmlCode(" escape=\"false\"");

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

          if (attr.getType().equals("java.util.Date"))
          {
            ret.addHtmlCode("\t\t\t\t<f:converter converterId=\"#{msgs.Application_DateFormat}\"  />\r\n");
          }
          if (attr.getType().equals("java.lang.Double") && !attr.isListFormatOff())
          {
            ret.addHtmlCode("\t\t\t\t<f:converter converterId=\"DoubleConverter\" />\r\n");
          }

          if (attr.getType().equals("java.lang.Long") && !attr.isListFormatOff())
          {
            ret.addHtmlCode("\t\t\t\t<f:converter converterId=\"LongConverter\" />\r\n");
          }

          if (attr.getType().equals("java.lang.Integer") && !attr.isListFormatOff())
          {
            ret.addHtmlCode("\t\t\t\t<f:converter converterId=\"IntegerConverter\" />\r\n");
          }

          ret.addHtmlCode("\t\t\t\t\t\t</h:outputText>\r\n");
        }
        else
        {
          ret.addHtmlCode("\t\t\t\t<rich:dataTable verticalGridVisible=\"false\" horizontalGridVisible=\"true\" var=\"" + Utils.makeMethod2Field(attr.getRelationship().getName()) + "\" value=\"#{" + Utils.makeFirstLetterLowerCase(rel.getToBeanName()) + ".");

          for (int k = 0; k < attr.getRelationships().size(); k++)
          {
            if (k > 0)
              ret.addHtmlCode(".");

            ret.addHtmlCode(Utils.makeMethod2Field(attr.getRelationships().get(k).getName()));
          }

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

          ret.addHtmlCode("\t\t\t\t\t<rich:column");

          if (attr.getType().contains("Double") || attr.getType().contains("Integer") || attr.getType().contains("Long"))
          {
            ret.addHtmlCode(" align=\"right\" ");
          }

          if (attr.getType().contains("String"))
          {
            ret.addHtmlCode(" align=\"left\" ");
          }

          if (attr.getType().contains("Date") || attr.getType().contains("Boolean"))
          {
            ret.addHtmlCode(" align=\"center\" ");
          }

          // Celle senza bordi
          ret.addHtmlCode(" style=\"background-color: transparent; border-left-style: none; border-right-style: none;\" >\r\n");

          ret.addHtmlCode("\t\t\t\t\t\t<h:outputText value=\"#{" + Utils.makeMethod2Field(attr.getRelationship().getName()) + attr.SeamField() + "}\"");

          if (attr.getImplementationType() == AttributeImplementationType.FORMATTEDTEXTAREA)
            ret.addHtmlCode(" escape=\"false\"");

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

          if (attr.getType().equals("java.util.Date"))
          {
            ret.addHtmlCode("\t\t\t\t\t\t\t<f:converter converterId=\"#{msgs.Application_DateFormat}\"  />\r\n");
          }
          if (attr.getType().equals("java.lang.Double"))
          {
            //ret.addHtmlCode("\t\t\t\t\t\t\t<f:convertNumber groupingUsed=\"true\" minFractionDigits=\"2\" maxFractionDigits=\"2\" locale=\"IT_it\" />\r\n");
            ret.addHtmlCode("\t\t\t\t<f:converter converterId=\"DoubleConverter\" />\r\n");
          }

          if (attr.getType().equals("java.lang.Long") && !attr.isListFormatOff())
          {
            ret.addHtmlCode("\t\t\t\t<f:converter converterId=\"LongConverter\" />\r\n");
          }

          if (attr.getType().equals("java.lang.Integer") && !attr.isListFormatOff())
          {
            ret.addHtmlCode("\t\t\t\t<f:converter converterId=\"IntegerConverter\" />\r\n");
          }

          ret.addHtmlCode("\t\t\t\t\t\t</h:outputText>\r\n");
          ret.addHtmlCode("\t\t\t\t\t</rich:column>\r\n");
          ret.addHtmlCode("\t\t\t\t</rich:dataTable>\r\n");
        }
      }

      ret.addHtmlCode("\t\t\t\t\t\t</rich:column>\r\n");
    }

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

    return ret;
  }
View Full Code Here


    String javaScript = "";
    String masterButton = "";
    String detailButton = "";
    String selectionButton = "";
    String searchButton = "";
    CodeChunk localSearch;
    String path = "";
    String details = "";
    String printButton = "";

    // 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
        createButtons = "\t\t\t<h:commandLink immediate=\"true\" value=\"#{msgs.list_" + bean.getName() + "_new}\" action=\"#{" + bean.getName() + "Manager.initCreate}\" rendered=\"#{" + listInfo.getNewMenuCondition() + "}\" style=\"text-decoration: none; color: black\" />\r\n";
    }
    else
    {
      // Nel caso questo sia un bean padre, vengono inseriti solo i menu per
      // la creazione dei bean derivati
      for (String derivedBean : derivedBeans)
      {
        createButtons += "\t\t\t<h:commandLink immediate=\"true\" value=\"#{msgs.list_" + derivedBean + "_new}\" action=\"#{" + derivedBean + "Manager.initCreate}\" style=\"text-decoration: none; color: black\" />\r\n";
      }
    }

    /** Gestione dell'opzione di stampa **/

    if (listInfo.getPrintMenuInListCondition().equals(""))
      printButton = "\t\t\t<h:commandLink immediate=\"true\" value=\"#{msgs.Application_print}\" action=\"/list/" + bean.getName() + "PrintList.seam?masterReference=true\" style=\"text-decoration: none; color: black\" />\r\n";
    else
      printButton = "\t\t\t<h:commandLink immediate=\"true\" value=\"#{msgs.Application_print}\" action=\"/list/" + bean.getName() + "PrintList.seam?masterReference=true\" rendered=\"#{" + listInfo.getPrintMenuInListCondition() + "}\" style=\"text-decoration: none; color: black\" />\r\n";

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

    tags.put("@generatorVersion", Messages.getString("WebAppGen.applicationVersion"));

    tags.put("@Javascript", javaScript);
    tags.put("@SearchButton", searchButton);
    tags.put("@Path", path);
    tags.put("@Title", listInfo.getName());
    tags.put("@CreateButtons", createButtons);
    tags.put("@ColumnClasses", columnClasses);
    tags.put("@ColumnWidths", columnWidths);
    tags.put("@MasterButton", masterButton);
    tags.put("@DetailButton", detailButton);
    tags.put("@PrintButton", printButton);
    tags.put("@Bean", bean.getName());
    tags.put("@bean", Utils.makeFirstLetterLowerCase(bean.getName()));
    tags.put("@LocalSearch", localSearch.getHtmlCode());
    tags.put("@Rows", rows);
    tags.put("@Details", details);

    Utils.SeamReplaceTagAndSave(tags, yourJavaScriptCode, yourCode, template, targetFile);
  }
View Full Code Here

    {
      Attribute attribute = bean.getAttributes().get(i);

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

        codeChunk.addHtmlCode("\t<p:cell grayFill=\".7\" horizontalAlignment=\"left\"  verticalAlignment=\"middle\" ");

        if (!attribute.getOnDisplayIf().equals(""))
        {
          codeChunk.addHtmlCode("rendered=\"#{" + attribute.getOnDisplayIf() + "}\"");
        }

        codeChunk.addHtmlCode(">");
        codeChunk.addHtmlCode("#{msgs.form_" + bean.getName() + "_" + attribute.getName() + "}</p:cell>\r\n");

        if (attribute.getImplementationType() == AttributeImplementationType.TEXTAREA)
        {
          if (attribute.getType().equals("java.lang.String"))
          {
            codeChunk.addHtmlCode("\t<p:cell               horizontalAlignment=\"justify\" verticalAlignment=\"middle\" ");

            if (!attribute.getOnDisplayIf().equals(""))
            {
              codeChunk.addHtmlCode("rendered=\"#{" + attribute.getOnDisplayIf() + "}\"");
            }

            codeChunk.addHtmlCode(">#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + attribute.getName() + "}</p:cell>\r\n");
          }
        }

        if (attribute.getImplementationType() == AttributeImplementationType.FORMATTEDTEXTAREA)
        {
          if (attribute.getType().equals("java.lang.String"))
          {
            codeChunk.addHtmlCode("\t<p:cell               horizontalAlignment=\"justify\" verticalAlignment=\"middle\" ");
            if (!attribute.getOnDisplayIf().equals(""))
            {
              codeChunk.addHtmlCode("rendered=\"#{" + attribute.getOnDisplayIf() + "}\"");
            }
            codeChunk.addHtmlCode(">\r\n");
            codeChunk.addHtmlCode("\t\t<p:text value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + attribute.getName() + "}\" >\r\n");
            codeChunk.addHtmlCode("\t\t\t<f:converter converterId=\"Html2PdfConverter\" />\r\n");
            codeChunk.addHtmlCode("\t\t</p:text>\r\n");
            codeChunk.addHtmlCode("\t</p:cell>\r\n");
          }
        }

        if (attribute.getImplementationType() == AttributeImplementationType.LISTBOX)
        {
          codeChunk.addHtmlCode("\t<p:cell grayFill=\".7\" horizontalAlignment=\"left\"  verticalAlignment=\"middle\">LIST BOX</p:cell>\r\n");
        }

        if (attribute.getImplementationType() == AttributeImplementationType.TEXT || attribute.getImplementationType() == AttributeImplementationType.READONLY)
        {
          if (attribute.getType().equals("java.lang.Boolean"))
          {
            codeChunk.addHtmlCode("\t<p:cell               horizontalAlignment=\"justify\" verticalAlignment=\"middle\" ");

            if (!attribute.getOnDisplayIf().equals(""))
            {
              codeChunk.addHtmlCode("rendered=\"#{" + attribute.getOnDisplayIf() + "}\"");
            }

            codeChunk.addHtmlCode(">#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + attribute.getName() + "}</p:cell>\r\n");
          }
          if (attribute.getType().equals("java.lang.String"))
          {
            codeChunk.addHtmlCode("\t<p:cell               horizontalAlignment=\"justify\" verticalAlignment=\"middle\" ");

            if (!attribute.getOnDisplayIf().equals(""))
            {
              codeChunk.addHtmlCode("rendered=\"#{" + attribute.getOnDisplayIf() + "}\"");
            }

            codeChunk.addHtmlCode(">#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + attribute.getName() + "}</p:cell>\r\n");
          }
          if (attribute.getType().equals("java.util.Date"))
          {
            codeChunk.addHtmlCode("\t<p:cell               horizontalAlignment=\"justify\" verticalAlignment=\"middle\" ");

            if (!attribute.getOnDisplayIf().equals(""))
            {
              codeChunk.addHtmlCode("rendered=\"#{" + attribute.getOnDisplayIf() + "}\"");
            }

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

            codeChunk.addHtmlCode("\t\t<p:text value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + attribute.getName() + "}\" >\r\n");
            codeChunk.addHtmlCode("\t\t\t<f:convertDateTime type=\"date\" pattern=\"#{msgs.Application_DateFormat}\" />\r\n");
            codeChunk.addHtmlCode("\t\t</p:text>\r\n");

            codeChunk.addHtmlCode("\t</p:cell>\r\n");
          }
          if (attribute.getType().equals("java.lang.Double"))
          {
            codeChunk.addHtmlCode("\t<p:cell               horizontalAlignment=\"justify\" verticalAlignment=\"middle\" ");

            if (!attribute.getOnDisplayIf().equals(""))
            {
              codeChunk.addHtmlCode("rendered=\"#{" + attribute.getOnDisplayIf() + "}\"");
            }

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

            codeChunk.addHtmlCode("\t\t<p:text value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + attribute.getName() + "}\" >\r\n");
            codeChunk.addHtmlCode("\t\t\t<f:converter converterId=\"DoubleConverter\" />\r\n");
            codeChunk.addHtmlCode("\t\t</p:text>\r\n");

            codeChunk.addHtmlCode("\t</p:cell>\r\n");
          }
          if (attribute.getType().equals("java.lang.Long"))
          {
            codeChunk.addHtmlCode("\t<p:cell               horizontalAlignment=\"justify\" verticalAlignment=\"middle\" ");

            if (!attribute.getOnDisplayIf().equals(""))
            {
              codeChunk.addHtmlCode("rendered=\"#{" + attribute.getOnDisplayIf() + "}\"");
            }

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

            codeChunk.addHtmlCode("\t\t<p:text value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + attribute.getName() + "}\" >\r\n");
            codeChunk.addHtmlCode("\t\t\t<f:converter converterId=\"LongConverter\"/>\r\n");
            codeChunk.addHtmlCode("\t\t</p:text>\r\n");

            codeChunk.addHtmlCode("\t</p:cell>\r\n");
          }
          if (attribute.getType().equals("java.lang.Integer"))
          {
            codeChunk.addHtmlCode("\t<p:cell               horizontalAlignment=\"justify\" verticalAlignment=\"middle\" ");

            if (!attribute.getOnDisplayIf().equals(""))
            {
              codeChunk.addHtmlCode("rendered=\"#{" + attribute.getOnDisplayIf() + "}\"");
            }

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

            codeChunk.addHtmlCode("\t\t<p:text value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + attribute.getName() + "}\" >\r\n");
            codeChunk.addHtmlCode("\t\t\t<f:converter converterId=\"IntegerConverter\" />\r\n");
            codeChunk.addHtmlCode("\t\t</p:text>\r\n");

            codeChunk.addHtmlCode("\t</p:cell>\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());

      codeChunk.addHtmlCode("\t<p:cell grayFill=\".7\" horizontalAlignment=\"left\"  verticalAlignment=\"middle\">#{msgs.form_" + bean.getName() + "_" + attribute.getQualifiedName().replace(".", "_") + "}</p:cell>\r\n");
      codeChunk.addHtmlCode("\t<p:cell               horizontalAlignment=\"justify\" verticalAlignment=\"middle\">#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + attribute.getQualifiedName() + "}</p:cell>\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 = new CodeChunk(0);

        if (!rel.isListBox())
        {
          codeChunk.addHtmlCode("\t<p:cell grayFill=\".7\" horizontalAlignment=\"left\"  verticalAlignment=\"middle\" colspan=\"2\" ");

          if (!rel.getShowOnDisplayIf().equals(""))
          {
            codeChunk.addHtmlCode("rendered=\"#{" + rel.getShowOnDisplayIf() + "}\"");
          }

          codeChunk.addHtmlCode(">#{msgs.form_" + bean.getName() + "_" + rel.getName() + "}</p:cell>\r\n");
        }
        else
        {
          codeChunk.addHtmlCode("\t<p:cell grayFill=\".7\" horizontalAlignment=\"left\"  verticalAlignment=\"middle\" colspan=\"2\" ");

          if (!rel.getShowOnDisplayIf().equals(""))
          {
            codeChunk.addHtmlCode("rendered=\"#{" + rel.getShowOnDisplayIf() + "}\"");
          }

          codeChunk.addHtmlCode(">#{msgs.form_" + bean.getName() + "_" + rel.getName() + "}</p:cell>\r\n");
        }

        codeChunk.addHtmlCode(relationshipPrint(bean.getName(), rel));

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

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

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

    for (int i = 0; i < chunks.length; i++)
    {
View Full Code Here

   */
  private static CodeChunk localSearch(Bean bean) throws IOException
  {
    Vector<CodeChunk> codeChunks = new Vector<CodeChunk>();

    CodeChunk ret = new CodeChunk(0);

    Vector<SearchAttribute> localSearchAttributes = bean.getLocalSearchAttributes();

    if (localSearchAttributes.size() == 0)
      return ret;

    ret.addHtmlCode("<!-- Local Search  -->\r\n");
    ret.addHtmlCode("<h:form>\r\n");

    ret.addHtmlCode("\t<h:panelGroup layout=\"block\" style=\"width:100%;text-align:right;\">\r\n");

    ret.addHtmlCode("\t<rich:toggleControl for=\"localSearch\" >\r\n");
    ret.addHtmlCode("\t\t<a4j:commandButton id=\"localSearchPic\" image=\"../img/search.gif\" action=\"#{" + bean.getName() + "Manager.startLocalSearch()}\" />\r\n");
    ret.addHtmlCode("\t</rich:toggleControl>\r\n");

    ret.addHtmlCode("\t</h:panelGroup>\r\n");

    ret.addHtmlCode("\t<rich:togglePanel id=\"localSearch\" switchType=\"client\" stateOrder=\"closed,opened\"  >\r\n");

    ret.addHtmlCode("\t\t<f:facet name=\"closed\">\r\n");
    ret.addHtmlCode("\t\t\t<rich:spacer height=\"1\" />\r\n");
    ret.addHtmlCode("\t\t</f:facet>\r\n");

    ret.addHtmlCode("\t\t<f:facet name=\"opened\">\r\n");

    ret.addHtmlCode("\t\t\t<rich:panel>\r\n");
    ret.addHtmlCode("\t\t\t<rich:panel>\r\n");

    ret.addHtmlCode("\t\t\t\t<h:panelGrid columns=\"" + java.lang.Math.min(6, 2 * localSearchAttributes.size()) + "\" width=\"100%\" >\r\n");

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

    /** Inserimento dei campi * */

    codeChunks.clear();

    for (int i = 0; i < localSearchAttributes.size(); i++)
    {
      SearchAttribute attr = localSearchAttributes.get(i);

      CodeChunk chunk = new CodeChunk(attr.getOrderInForm());

      if (attr.belongsToRelationship())
      {
        if (attr.getRelationship().isToMany())
        {
          // Attributo di ricerca appartiene ad una relazione :N

          chunk.HtmlNewLine();

          chunk.addHtmlCode("\t\t\t\t\t<h:outputLabel value=\"#{msgs.localSearch_" + bean.getName() + "_" + attr.getRelationship().getName() + "_" + attr.getName() + "}\" styleClass=\"formFieldLabel\" />\r\n");
          chunk.addHtmlCode("\t\t\t\t\t<h:selectManyListbox value=\"#{" + bean.getName() + "Manager." + attr.getRelationship().getFromBeanName() + "Manager.localSearch" + attr.getRelationship().getName() + Utils.makeFirstLetterUpperCase(attr.getName()) + "}\" ");

          // Inserisce gli eventuali eventi presenti
          Vector<String> events = attr.getEvents();
          Vector<String> eventFunctions = attr.getEventFunctions();

          for (int k = 0; k < events.size(); k++)
          {
            chunk.addHtmlCode(events.get(k) + "=" + "\"" + eventFunctions.get(k) + "\"");
          }

          chunk.addHtmlCode(" styleClass=\"formField\" >");

          chunk.addHtmlCode("\t\t\t\t\t\t<s:selectItems value=\"#{" + attr.getRelationship().getToBeanName() + "Manager.getSelectionItems(false," + Utils.makeFirstLetterLowerCase(bean.getName()) + ",'" + attr.getRelationship().getName() + "')}\" var=\"" + Utils.makeFirstLetterLowerCase(attr.getRelationship().getToBeanName()) + "\" ");

          chunk.addHtmlCode("label=\"");

          for (int k = 0; k < attr.getRelationship().getRelatedAttributes().size(); k++)
          {
            if (k > 0)
              chunk.addHtmlCode(" - ");

            chunk.addHtmlCode("#{" + Utils.makeFirstLetterLowerCase(attr.getRelationship().getToBeanName()) + "." + attr.getRelationship().getRelatedAttributes().get(k).getName() + "}");
          }

          chunk.addHtmlCode("\"");

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

          chunk.addHtmlCode("\t\t\t\t\t</h:selectManyListbox>\r\n");
        }
        else
        {
          // Attributo di ricerca appartiene ad una relazione :1

          chunk.HtmlNewLine();

          chunk.addHtmlCode("\t\t\t\t\t<h:outputLabel value=\"#{msgs.localSearch_" + bean.getName() + "_" + attr.getRelationship().getName() + "_" + attr.getName() + "}\" styleClass=\"formFieldLabel\" />\r\n");
          chunk.addHtmlCode("\t\t\t\t\t<h:selectOneMenu  value=\"#{" + bean.getName() + "Manager.localSearch" + attr.getRelationship().getName() + Utils.makeFirstLetterUpperCase(attr.getName()) + "}\" ");

          // Inserisce gli eventuali eventi presenti
          Vector<String> events = attr.getEvents();
          Vector<String> eventFunctions = attr.getEventFunctions();

          for (int k = 0; k < events.size(); k++)
          {
            chunk.addHtmlCode(events.get(k) + "=" + "\"" + eventFunctions.get(k) + "\"");
          }

          chunk.addHtmlCode(" styleClass=\"formField\" >\r\n");

          chunk.addHtmlCode("\t\t\t\t\t\t<s:selectItems value=\"#{" + attr.getRelationship().getToBeanName() + "Manager.getSelectionItems(false," + Utils.makeFirstLetterLowerCase(bean.getName()) + ",'" + attr.getRelationship().getName() + "')}\" var=\"" + Utils.makeFirstLetterLowerCase(attr.getRelationship().getToBeanName()) + "\" ");

          chunk.addHtmlCode("label=\"");

          for (int k = 0; k < attr.getRelationship().getRelatedAttributes().size(); k++)
          {
            ShowAttribute relatedAttribute = attr.getRelationship().getRelatedAttributes().get(k);

            if (relatedAttribute.getRelationships().size() == 0)
            {
              if (k > 0)
                chunk.addHtmlCode(" - ");

              chunk.addHtmlCode("#{" + Utils.makeFirstLetterLowerCase(attr.getRelationship().getToBeanName()) + "." + relatedAttribute.getName() + "}");
            }
            else
            {
              /** Debbono essere gestiti gli attributi provenienti da relazioni **/
            }
          }

          chunk.addHtmlCode("\"");

          chunk.addHtmlCode(" noSelectionLabel=\"#{msgs.Application_noSelectionLabel}\" hideNoSelectionLabel=\"false\" />\r\n");
          //chunk.addHtmlCode(" />\r\n");

          chunk.addHtmlCode("\t\t\t\t\t\t<s:convertEntity />\r\n");
          chunk.addHtmlCode("\t\t\t\t\t</h:selectOneMenu>\r\n");
        }
      }
      else
      {
        if (attr.getImplementationType() == AttributeImplementationType.TEXT || attr.getImplementationType() == AttributeImplementationType.TEXTAREA || attr.getImplementationType() == AttributeImplementationType.FORMATTEDTEXTAREA)
        {
          chunk.HtmlNewLine();
          chunk.addHtmlCode("\t\t\t\t\t<h:outputLabel value=\"#{msgs.localSearch_" + bean.getName() + "_" + attr.getName() + "}\" styleClass=\"formFieldLabel\" />\r\n");
          chunk.addHtmlCode("\t\t\t\t\t<h:inputText style=\"width:100%;\" value=\"#{" + bean.getName() + "Manager.localSearch" + Utils.makeFirstLetterUpperCase(attr.getName()) + "}\" styleClass=\"formField\" />");
          chunk.HtmlNewLine();
        }
        else
          chunk.addHtmlCode("TIPO DI DATO NON SUPPORTATO");
      }

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

      codeChunks.add(chunk);
View Full Code Here

    String javaScript = "";
    String masterButton = "";
    String detailButton = "";
    String selectionButton = "";
    String searchButton = "";
    CodeChunk localSearch;
    String actions = "";
    String createButtons = "";
    String columnWidths = "1%";

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

    // Predispone il link ai bean detail

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

      if (rel.isMasterDetail() && rel.isFromMaster())
      {
        detailButton += "\t\t\t<h:commandLink immediate=\"true\" value=\"#{msgs.list_" + rel.getFromBeanName() + "_" + rel.getToBeanName() + "}\" action=\"#{@BeanManager.goTo" + rel.getToBeanName() + "}\" style=\"text-decoration: none; color: black\" />\r\n";
      }
    }

    // Prepara la lista dei campi

    columnClasses = listColumnClasses(bean.getShowAttributes(), true); // Stile delle colonne
    rows = listColumns(bean.getName(), bean.getShowAttributes()); // Colonne della tabella

    if (bean.getSearchActions().size() > 0 || bean.getSearchImmediateActions().size() > 0)
    {
      String selectionColumn = "";

      selectionColumn += "<!-- SELECTION COLUMN -->\r\n";
      selectionColumn += "<rich:column>\r\n";
      selectionColumn += "\t<f:facet name=\"header\">&nbsp;</f:facet>\r\n";
      selectionColumn += "\t<h:selectBooleanCheckbox  id=\"selections\"  value=\"#{selections[" + Utils.makeFirstLetterLowerCase(bean.getName()) + "]}\"  />\r\n";
      selectionColumn += "</rich:column>\r\n\r\n";

      rows = selectionColumn + rows;

      columnWidths += ",1%";

      for (int i = 0; i < bean.getSearchActionLabels().size(); i++)
      {
        actions += "\t\t<h:commandLink immediate=\"true\" value=\"" + bean.getSearchActionLabels().get(i) + "\" action=\"#{" + bean.getName() + "Manager.init" + Utils.makeFirstLetterUpperCase(bean.getSearchActions().get(i)) + "}\" style=\"text-decoration: none; color: black\" />\r\n";
        generateSearchActionPage(sourceDir, targetDir, bean, bean.getSearchActions().get(i), bean.getSearchActionLabels().get(i));
      }

      for (int i = 0; i < bean.getSearchImmediateActionLabels().size(); i++)
      {
        actions += "\t\t<h:commandLink immediate=\"true\" value=\"" + bean.getSearchImmediateActionLabels().get(i) + "\" action=\"#{" + bean.getName() + "Manager." + bean.getSearchImmediateActions().get(i) + "}\" style=\"text-decoration: none; color: black\" />\r\n";
      }
    }

    // Predispone i bottoni di navigazione

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

      if (rel.isMasterDetail() && rel.isFromMaster() && !rel.isCategorized())
      {
        // Inserisce il bottone di selezione del dettaglio se la vista
        // non e' categorizzata
      }

      if (rel.isMasterDetail() && rel.isFromMaster() && rel.isCategorized())
      {
        // Inserisce il di creazione del dettaglio se la vista e'
        // categorizzata
      }

      if (rel.isMasterDetail() && !rel.isFromMaster())
      {
        // Inserisce il bottone di selezione del master

        masterButton = "\t\t\t\t<h:commandLink immediate=\"true\" value=\"#{msgs.list_" + rel.getFromBeanName() + "_" + rel.getToBeanName() + "}\"      action=\"/list/" + rel.getToBeanName() + "List.seam\" style=\"text-decoration: none; color: black\" />\r\n";
      }
    }

    // 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";
    }

    // javaScript += "function startup()\r\n";
    // javaScript += "{\r\n";
    // javaScript += "}\r\n";

    /** Ricarca locale * */

    localSearch = localSearch(bean);

    javaScript += localSearch.getJavascriptCode();

    // Voce menu per ricerca

    if (bean.getSearchAttributes().size() > 1)
    {
      searchButton += "\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";
    }

    //    /** Opzione Nuovo **/
    //    if (bean.getNewMenuOptionConditionOnListSearch().equals(""))
    //      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
        createButtons = "\t\t<h:commandLink immediate=\"true\" value=\"#{msgs.list_" + bean.getName() + "_new}\" action=\"#{" + bean.getName() + "Manager.initCreate}\" rendered=\"#{" + bean.getNewMenuOptionConditionOnListSearch() + "}\" style=\"text-decoration: none; color: black\" />\r\n";
    }
    else
    {
      // Nel caso questo sia un bean padre, vengono inseriti solo i menu per
      // la creazione dei bean derivati
      for (String derivedBean : derivedBeans)
      {
        createButtons += "\t\t<h:commandLink immediate=\"true\" value=\"#{msgs.list_" + derivedBean + "_new}\" action=\"#{" + derivedBean + "Manager.initCreate}\" style=\"text-decoration: none; color: black\" />\r\n";
      }
    }

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

    tags.put("@generatorVersion", Messages.getString("WebAppGen.applicationVersion"));

    tags.put("@CreateButtons", createButtons);
    tags.put("@Javascript", javaScript);
    tags.put("@SearchButton", searchButton);
    tags.put("@ColumnClasses", columnClasses);
    tags.put("@MasterButton", masterButton);
    tags.put("@DetailButton", detailButton);
    tags.put("@Actions", actions);
    tags.put("@Bean", bean.getName());
    tags.put("@bean", Utils.makeFirstLetterLowerCase(bean.getName()));
    tags.put("@LocalSearch", localSearch.getHtmlCode());
    tags.put("@ColumnWidths", columnWidths);
    tags.put("@Rows", rows);

    Utils.SeamReplaceTagAndSave(tags, yourJavaScriptCode, yourCode, template, targetFile);
  }
View Full Code Here

    String hiddenAttributes = "";
    String actionCreate = "";
    String actionEdit = "";
    String actionDelete = "";

    CodeChunk localSearch;
    String localSearchButton;

    String relatedEJB = rel.getToBeanName();
    // Vector<ShowAttribute> relatedAttributes = rel.getRelatedAttributes();

    String template = "." + File.separator + "templates" + File.separator + "Seam_FormPopUp.xhtml";
    String sourceFile = sourceDir + ".." + File.separator + "html" + File.separator + "popup" + File.separator + bean.getName() + rel.getName() + "PopUp.xhtml";
    String targetFile = targetDir + "html" + File.separator + "popup" + File.separator + bean.getName() + rel.getName() + "PopUp.xhtml";

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

    /** Funzione di inizializzazione dei campi nascosti **/

    javaScript += generatePopUpJavascriptFunctionsInPopup(bean);

    javaScript += "function onlyOneSelection(thisObj, event)\r\n";
    javaScript += "{\r\n";
    javaScript += "}\r\n";

    columnClasses = listColumnClasses(rel.getRelatedAttributes(), true); // Stile delle colonne
    columnClasses = "columnCenter," + columnClasses;

    rows = listColumns(rel.getToBeanName(), rel.getRelatedAttributes()); // Colonne della tabella

    /** Inserimento campi nascosti * */

    for (int i = 0; i < bean.getAttributes().size(); i++)
    {
      Attribute attr = bean.getAttributes().get(i);

      if (!attr.isKey() && (attr.getImplementationType() != AttributeImplementationType.HIDEINFORM) && (attr.getImplementationType() != AttributeImplementationType.READONLY))
      {
        hiddenAttributes += insertAttribute2Form(attr, bean.getName(), false) + "\r\n";
      }
    }

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

      if (relationship.isUsed() && relationship.isListBox())
      {
        if (relationship.isToMany())
        {
          hiddenAttributes += insertMultipleSelectionListBox2Form(bean, relationship, false, true).getHtmlCode();
        }
        else
        {
          hiddenAttributes += insertSingleSelectionListBox2Form(sourceDir, bean, relationship, false, true).getHtmlCode();
        }

      }
    }

    /** Inserimento azioni previste * */

    if (rel.getPopUpCreate())
    {
      actionCreate += "\t\t<h:commandLink immediate=\"true\" value=\"#{msgs.list_" + relatedEJB + "_new}\" action=\"#{" + relatedEJB + "Manager.initCreate}\" style=\"text-decoration: none; color: black\" />";
    }

    if (rel.getPopUpDelete())
    {
      actionDelete += "\t<rich:menuItem immediate=\"true\" value=\"#{msgs.list_" + relatedEJB + "_delete}\" action=\"#{" + relatedEJB + "Manager.initDelete}\" actionListener=\"#{@BeanManager.popupMenuSelectItem}\" >\r\n";
      actionDelete += "\t\t<a4j:actionparam name=\"selectedId\" value=\"{selectedBean}\" />\r\n";
      actionDelete += "\t</rich:menuItem>";
    }

    if (rel.getPopUpEdit())
    {
      actionEdit += "\t<rich:menuItem immediate=\"true\" value=\"#{msgs.list_" + relatedEJB + "_edit}\" action=\"#{" + relatedEJB + "Manager.initEdit}\" actionListener=\"#{@BeanManager.popupMenuSelectItem}\" >\r\n";
      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}\"  />";
    }
    else
    {
      localSearchButton = "&nbsp;";
    }

    javaScript += localSearch.getJavascriptCode();

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

    if (rel.isPopUpSelectItems())
    {
      tags.put("@DisableSelection", "false");
    }
    else
    {
      tags.put("@DisableSelection", "true");
    }

    tags.put("@generatorVersion", Messages.getString("WebAppGen.applicationVersion"));

    tags.put("@PopupName", "form_" + bean.getName() + "_" + rel.getName());
    tags.put("@Javascript", javaScript);
    tags.put("@Bean", relatedEJB);
    tags.put("@bean", Utils.makeFirstLetterLowerCase(relatedEJB));
    tags.put("@ColumnClasses", columnClasses);
    tags.put("@Rows", rows);
    tags.put("@HiddenAttributes", hiddenAttributes);
    tags.put("@ActionCreate", actionCreate);
    tags.put("@ActionEdit", actionEdit);
    tags.put("@ActionDelete", actionDelete);
    //    tags.put("@LocalSearchIcon", localSearchButton);
    tags.put("@LocalSearch", localSearch.getHtmlCode());

    Utils.SeamReplaceTagAndSave(tags, yourJavaScriptCode, yourCode, template, targetFile);
  }
View Full Code Here

    String hiddenAttributes = "";
    String actionCreate = "";
    String actionEdit = "";
    String actionDelete = "";

    CodeChunk localSearch;
    String localSearchButton = "";

    String relatedEJB = rel.getToBeanName();

    String template = "." + File.separator + "templates" + File.separator + "Seam_FormPopUp.xhtml";
    String sourceFile = sourceDir + ".." + File.separator + "html" + File.separator + "popup" + File.separator + bean.getName() + rel.getName() + "PopUp.xhtml";
    String targetFile = targetDir + "html" + File.separator + "popup" + File.separator + bean.getName() + rel.getName() + "PopUp.xhtml";

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

    /** Funzione di inizializzazione dei campi nascosti **/

    javaScript += generatePopUpJavascriptFunctionsInPopup(bean);

    javaScript += "function onlyOneSelection(thisObj, event)\r\n";
    javaScript += "{\r\n";
    javaScript += "\tidx = 0;\r\n";
    javaScript += "\t\r\n";
    javaScript += "\tvar element =  document.getElementById(\"form:" + Utils.makeFirstLetterLowerCase(rel.getToBeanName()) + ":\"+idx+\":selections\");\r\n";
    javaScript += "\t\r\n";
    javaScript += "\twhile(element != null)\r\n";
    javaScript += "\t{\r\n";
    javaScript += "\t\tif (element != thisObj && element.checked)\r\n";
    javaScript += "\t\t{\r\n";
    javaScript += "\t\t\telement.checked = false;\r\n";
    javaScript += "\t\t}\r\n";
    javaScript += "\t\tidx++;\r\n";
    javaScript += "\t\telement =  document.getElementById(\"form:" + Utils.makeFirstLetterLowerCase(rel.getToBeanName()) + ":\"+idx+\":selections\");\r\n";
    javaScript += "\t}\r\n";
    javaScript += "}\r\n";

    columnClasses = listColumnClasses(rel.getRelatedAttributes(), true); // Stile delle colonne
    rows = listColumns(rel.getToBeanName(), rel.getRelatedAttributes()); // Colonne della tabella

    /** Inserimento campi nascosti * */
    for (int i = 0; i < bean.getAttributes().size(); i++)
    {
      Attribute attr = bean.getAttributes().get(i);

      if (!attr.isKey() && (attr.getImplementationType() != AttributeImplementationType.HIDEINFORM) && (attr.getImplementationType() != AttributeImplementationType.READONLY))
      {
        hiddenAttributes += insertAttribute2Form(attr, bean.getName(), false) + "\r\n";
      }
    }

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

      if (relationship.isUsed() && relationship.isListBox())
      {
        if (relationship.isToMany())
        {
          hiddenAttributes += insertMultipleSelectionListBox2Form(bean, relationship, false, true).getHtmlCode();
        }
        else
        {
          hiddenAttributes += insertSingleSelectionListBox2Form(sourceDir, bean, relationship, false, true).getHtmlCode();
        }

      }
    }

    /** Inserimento azioni previste * */

    if (rel.getPopUpCreate())
    {
      actionCreate += "\t\t\t<h:commandLink immediate=\"true\" value=\"#{msgs.list_" + relatedEJB + "_new}\" action=\"#{" + relatedEJB + "Manager.initCreate}\" style=\"text-decoration: none; color: black\" />";
    }

    if (rel.getPopUpDelete())
    {
      actionDelete += "\t<rich:menuItem immediate=\"true\" value=\"#{msgs.list_" + relatedEJB + "_delete}\" action=\"#{" + relatedEJB + "Manager.initDelete}\" actionListener=\"#{@BeanManager.popupMenuSelectItem}\" >\r\n";
      actionDelete += "\t\t<a4j:actionparam name=\"selectedId\" value=\"{selectedBean}\" />\r\n";
      actionDelete += "\t</rich:menuItem>";
    }

    if (rel.getPopUpEdit())
    {
      actionEdit += "\t<rich:menuItem immediate=\"true\" value=\"#{msgs.list_" + relatedEJB + "_edit}\" action=\"#{" + relatedEJB + "Manager.initEdit}\" actionListener=\"#{@BeanManager.popupMenuSelectItem}\" >\r\n";
      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}\" />";
    }
    else
    {
      localSearchButton = "&nbsp;";
    }

    javaScript += localSearch.getJavascriptCode();

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

    if (rel.isPopUpSelectItems())
    {
      tags.put("@DisableSelection", "false");
    }
    else
    {
      tags.put("@DisableSelection", "true");
    }

    tags.put("@generatorVersion", Messages.getString("WebAppGen.applicationVersion"));

    tags.put("@PopupName", "form_" + bean.getName() + "_" + rel.getName());
    tags.put("@Javascript", javaScript);
    tags.put("@Bean", relatedEJB);
    tags.put("@bean", Utils.makeFirstLetterLowerCase(relatedEJB));
    tags.put("@ColumnClasses", columnClasses);
    tags.put("@Rows", rows);
    tags.put("@HiddenAttributes", hiddenAttributes);
    tags.put("@ActionCreate", actionCreate);
    tags.put("@ActionEdit", actionEdit);
    tags.put("@ActionDelete", actionDelete);
    //    tags.put("@LocalSearchIcon", localSearchButton);
    tags.put("@LocalSearch", localSearch.getHtmlCode());

    Utils.SeamReplaceTagAndSave(tags, yourJavaScriptCode, yourCode, template, targetFile);
  }
View Full Code Here

      /**
       * I campi della ricerca non sono mai required
       */
      attribute.setRequired(false);

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

      if (!attribute.isKey())
      {
        if (!attribute.belongsToRelationship())
        {
          codeChunk.addHtmlCode("\t<tr><td width=\"100%\">\r\n");
          codeChunk.addHtmlCode("\t\t<rich:panel>\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");

          if (attribute.getType().equals("java.lang.Boolean"))
          {
            codeChunk.addHtmlCode("\r\n<trh:rowLayout width=\"100%\" >\r\n");
            codeChunk.addHtmlCode("\r\n<trh:cellFormat>\r\n");
            codeChunk.addHtmlCode("\r\nBOOLEAN NON SUPPORTATO\r\n");
            codeChunk.addHtmlCode("\r\n</trh:cellFormat>\r\n");
            codeChunk.addHtmlCode("\r\n</trh:rowLayout>\r\n");
          }
          if (attribute.getType().equals("java.util.Date"))
          {
            codeChunk.addHtmlCode("\r\n<trh:rowLayout width=\"100%\" >\r\n");
            codeChunk.addHtmlCode("\r\n<trh:cellFormat>\r\n");
            codeChunk.addHtmlCode("\r\nDATE NON SUPPORTATO\r\n");
            codeChunk.addHtmlCode("\r\n</trh:cellFormat>\r\n");
            codeChunk.addHtmlCode("\r\n</trh:rowLayout>\r\n");
          }
          if (attribute.getImplementationType() == AttributeImplementationType.TEXTAREA)
          {
            codeChunk.addHtmlCode("\r\n<trh:rowLayout width=\"100%\">\r\n");
            codeChunk.addHtmlCode("\r\n<trh:cellFormat>\r\n");
            codeChunk.addHtmlCode("\r\nTEXT AREA NON SUPPORTATO\r\n");
            codeChunk.addHtmlCode("\r\n</trh:cellFormat>\r\n");
            codeChunk.addHtmlCode("\r\n</trh:rowLayout>\r\n");
          }
          if (attribute.getImplementationType() == AttributeImplementationType.FORMATTEDTEXTAREA)
          {
            codeChunk.addHtmlCode("\r\n<trh:rowLayout width=\"100%\">\r\n");
            codeChunk.addHtmlCode("\r\n<trh:cellFormat>\r\n");
            codeChunk.addHtmlCode("\r\nFORMATTEDTEXT AREA NON SUPPORTATO\r\n");
            codeChunk.addHtmlCode("\r\n</trh:cellFormat>\r\n");
            codeChunk.addHtmlCode("\r\n</trh:rowLayout>\r\n");
          }
          if (attribute.getImplementationType() == AttributeImplementationType.LISTBOX)
          {
            codeChunk.addHtmlCode("\r\n<trh:rowLayout width=\"100%\" >\r\n");
            codeChunk.addHtmlCode("\r\n<trh:cellFormat>\r\n");
            codeChunk.addHtmlCode("\r\nLIST BOX NON SUPPORTATO\r\n");
            codeChunk.addHtmlCode("\r\n</trh:cellFormat>\r\n");
            codeChunk.addHtmlCode("\r\n</trh:rowLayout>\r\n");
          }
          if (attribute.getImplementationType() == AttributeImplementationType.TEXT)
          {
            codeChunk.addHtmlCode("\t\t\t<td>\r\n");
            codeChunk.addHtmlCode("\t\t\t\t" + insertAttribute2Form(attribute, bean.getName(), true, 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");
          }

          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);
        }
        else
        {
          // Attributo di ricerca appartenente ad una relazione
          Relationship firstRelationship = attribute.getRelationship();

          /**
           * I campi della ricerca non sono mai required
           */
          firstRelationship.setRequired(false);

          if (attribute.getRelationships().size() == 1)
          {
            // L'attributo e' nella forma relazione.attributo

            if (firstRelationship.isIgnoreImplementation())
            {
              // Gli attributi debbono essere inseriti come Text

              if (attribute.getType().equals("java.util.Date"))
              {
                codeChunk.addHtmlCode("\r\n<trh:rowLayout width=\"100%\" >\r\n");
                codeChunk.addHtmlCode("\t<trh:cellFormat styleClass=\"formFieldLabel\" ><tr:outputLabel value=\"#{msgs.form_" + bean.getName() + "_search" + attribute.SeamLabel() + "}\" /></trh:cellFormat>\r\n");

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

                if (firstRelationship.isToMany())
                {
                  /** Relazione :N **/
                  String singularRelationshipName = Utils.makeMethod2SingularField(firstRelationship.getName());

                  codeChunk.addHtmlCode("\t\t<rich:dataTable id=\"tab_" + singularRelationshipName + "_" + attribute.getName() + "\" var=\"" + singularRelationshipName + "\" value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + Utils.makeMethod2Field(firstRelationship.getName()) + "}\" width=\"100%\" >\r\n");

                  codeChunk.addHtmlCode("\t\t\t<rich:column");

                  if (attribute.getType().contains("Double") || attribute.getType().contains("Integer") || attribute.getType().contains("Long"))
                  {
                    codeChunk.addHtmlCode(" align=\"right\" ");
                  }

                  if (attribute.getType().contains("String"))
                  {
                    codeChunk.addHtmlCode(" align=\"left\" ");
                  }

                  if (attribute.getType().contains("Date") || attribute.getType().contains("Boolean"))
                  {
                    codeChunk.addHtmlCode(" align=\"center\" ");
                  }

                  codeChunk.addHtmlCode(">\r\n");
                  codeChunk.addHtmlCode("\t\t\t\t<f:facet name=\"header\">\r\n");
                  codeChunk.addHtmlCode("\t\t\t\t</f:facet>\r\n");
                  codeChunk.addHtmlCode("\t\t\t\t<tr:inputDate id=\"" + attribute.getName() + "\" value=\"#{" + singularRelationshipName + "." + attribute.getName() + "}\" >\r\n");
                  codeChunk.addHtmlCode("\t\t\t\t\t<f:convertDateTime type=\"date\" pattern=\"#{msgs.Application_DateFormat}\" />\r\n");
                  codeChunk.addHtmlCode("\t\t\t\t</tr:inputDate>\r\n");
                  codeChunk.addHtmlCode("\t\t\t</rich:column>\r\n");
                  codeChunk.addHtmlCode("\t\t</rich:dataTable>\r\n");
                }
                else
                {
                  /** Relazione :1 **/
                  if (attribute.getType().equals("java.util.Date"))
                  {
                    codeChunk.addHtmlCode("\t\t<tr:inputDate id=\"" + attribute.getName() + "\" value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + Utils.makeMethod2Field(attribute.getRelationship().getName()) + "." + attribute.getName() + "}\" >\r\n");
                    codeChunk.addHtmlCode("\t\t\t<f:convertDateTime type=\"date\" pattern=\"#{msgs.Application_DateFormat}\" />\r\n");
                    codeChunk.addHtmlCode("\t\t</tr:inputDate>\r\n");
                  }
                  else
                    codeChunk.addHtmlCode("\t\t\t\tTipo non supportato nella ricerca\r\n");
                }

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

              }
              else
              {
                codeChunk.addHtmlCode("\r\n<trh:rowLayout width=\"100%\" >\r\n");
                codeChunk.addHtmlCode("\t<trh:cellFormat styleClass=\"formFieldLabel\" ><tr:outputLabel value=\"#{msgs.form_" + bean.getName() + "_search" + attribute.SeamLabel() + "}\" /></trh:cellFormat>\r\n");

                codeChunk.addHtmlCode("\t<trh:cellFormat width=\"100%\" >\r\n");
                codeChunk.addHtmlCode("\t\t<h:inputText id=\"" + attribute.getName() + "\" value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + Utils.makeMethod2Field(firstRelationship.getName()) + attribute.SeamField() + "}\" />\r\n");
                codeChunk.addHtmlCode("\t</trh:cellFormat>\r\n");
                codeChunk.addHtmlCode("</trh:rowLayout>\r\n");
              }
            }
            else
            {
              if (firstRelationship.isListBox())
              {
                // Gli attributi debbono essere inseriti come listbox

                if (firstRelationship.isToMany())
                {
                  codeChunk = insertMultipleSelectionListBox2Form(bean, firstRelationship, true, true);
                }
                else
                {
                  codeChunk = insertSingleSelectionListBox2Form(sourceDir, bean, firstRelationship, true, true);
                }
              }
              else
              {
                // Gli attributi debbono essere inseriti come popup
                if (firstRelationship.isToMany())
                {
                  codeChunk.addJavascriptCode("function openPopUp_" + firstRelationship.getName() + "()");
                  codeChunk.JavascriptNewLine();
                  codeChunk.addJavascriptCode("{");
                  codeChunk.JavascriptNewLine();
                  codeChunk.addJavascriptCode("\twindow.open(\"popup/" + bean.getName() + firstRelationship.getName() + "PopUp.seam?parentConversationId=\"+document.forms[\"form\"].elements['parentConversationId'].value+\"&conversationIsLongRunning=true\",\"" + firstRelationship.getToBeanName() + "Window\",\"resizable=yes,menubar=no,width=850,height=550,scrollbars=yes\");");
                  codeChunk.JavascriptNewLine();
                  codeChunk.addJavascriptCode("}");
                  codeChunk.JavascriptNewLine();

                  codeChunk.addHtmlCode("\r\n<trh:rowLayout width=\"100%\" >\r\n");

                  codeChunk.addHtmlCode("\t<trh:cellFormat styleClass=\"formFieldLabel\" >\r\n");

                  codeChunk.addHtmlCode("\t\t<tr:outputLabel for=\"" + Utils.makeFirstLetterLowerCase(bean.getName()) + "_" + Utils.makeFirstLetterLowerCase(firstRelationship.getName()) + "\" value=\"#{msgs.form_search_" + firstRelationship.ToSeamLabel() + "}\" />\r\n");
                  codeChunk.addHtmlCode("\t</trh:cellFormat>\r\n");

                  codeChunk.addHtmlCode("\t<trh:cellFormat><trh:tableLayout><trh:rowLayout width=\"100%\" ><trh:cellFormat>\r\n");

                  // BOB: Genera id sui pulsanti di selezione
                  codeChunk.addHtmlCode("\t\t<tr:goLink id=\"popup_" + firstRelationship.getName() + "\" value=\"Seleziona\" onclick=\"openPopUp_" + firstRelationship.getName() + "();\" styleClass=\"button\" rendered=\"#{(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='CREATE') or (" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='EDIT') or (" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='SEARCH')}\" />\r\n");

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

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

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

                  codeChunk.addHtmlCode("\r\n<trh:rowLayout width=\"100%\" >\r\n");
                  codeChunk.addHtmlCode("\t<trh:cellFormat columnSpan=\"2\">\r\n");
                  codeChunk.addHtmlCode("\t\t<rich:dataTable id=\"tab_" + Utils.makeFirstLetterLowerCase(bean.getName()) + "_" + firstRelationship.getName() + "\" var=\"" + Utils.makeFirstLetterLowerCase(firstRelationship.getToBeanName()) + "\" value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + Utils.makeMethod2Field(firstRelationship.getName()) + "}\" width=\"100%\" rowBandingInterval=\"1\" verticalGridVisible=\"true\" horizontalGridVisible=\"false\" >\r\n");

                  for (int m = 0; m < firstRelationship.getRelatedAttributes().size(); m++)
                  {
                    ShowAttribute attr = firstRelationship.getRelatedAttributes().get(m);

                    codeChunk.addHtmlCode("\t\t\t<rich:column");

                    if (attr.getType().contains("Double") || attr.getType().contains("Integer") || attr.getType().contains("Long"))
                    {
                      codeChunk.addHtmlCode(" align=\"right\" ");
                    }

                    if (attr.getType().contains("String"))
                    {
                      codeChunk.addHtmlCode(" align=\"left\" ");
                    }

                    if (attr.getType().contains("Date") || attr.getType().contains("Boolean"))
                    {
                      codeChunk.addHtmlCode(" align=\"center\" ");
                    }

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

                    codeChunk.addHtmlCode("\t\t\t\t<f:facet name=\"header\">\r\n");

                    codeChunk.addHtmlCode("\t\t\t\t\t<h:outputText value=\"#{msgs.form_" + bean.getName());

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

                    codeChunk.addHtmlCode("_" + attr.getName() + "");

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

                    codeChunk.addHtmlCode("\t\t\t\t</f:facet>\r\n");

                    if (attr.getRelationships().size() == 0)
                    {
                      codeChunk.addHtmlCode("\t\t\t\t<tr:outputText value=\"#{" + Utils.makeFirstLetterLowerCase(firstRelationship.getToBeanName()) + "." + attr.getName() + "}\" />\r\n");
                    }
                    else
                    {
                      codeChunk.addHtmlCode("\t\t\t\t<tr:outputText value=\"#{" + Utils.makeFirstLetterLowerCase(firstRelationship.getToBeanName()) + ".");

                      for (int k = 1; k < attr.getRelationships().size(); k++)
                      {
                        if (k > 1)
                          codeChunk.addHtmlCode(".");
                        codeChunk.addHtmlCode(Utils.makeMethod2Field(attr.getRelationships().get(k).getName()));
                      }

                      codeChunk.addHtmlCode("." + attr.getName());

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

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

                  codeChunk.addHtmlCode("\t\t</rich:dataTable>\r\n");
                  codeChunk.addHtmlCode("\t</trh:cellFormat>\r\n");
                  codeChunk.addHtmlCode("</trh:rowLayout>\r\n");
                }
                else
                {
                  codeChunk = insertSingleSelectionPopUp2Form(sourceDir, bean, firstRelationship, false, true);
                }
              }
            }
          }
          else
          {
            // Attributo nella forma [relazione.]*Attributo
            if (attribute.getRelationships().get(0).isIgnoreImplementation())
            {
              // Gli attributi debbono essere inseriti come Text
              codeChunk.addHtmlCode("\r\n<trh:rowLayout width=\"100%\" >\r\n");
              codeChunk.addHtmlCode("\t<trh:cellFormat styleClass=\"formFieldLabel\" >");
              codeChunk.addHtmlCode("<tr:outputLabel value=\"#{msgs.form_" + bean.getName());

              codeChunk.addHtmlCode("_" + attribute.getRelationships().get(0).getName());
              codeChunk.addHtmlCode(attribute.SeamLabel() + "}\" /></trh:cellFormat>\r\n");
              codeChunk.addHtmlCode("\t<trh:cellFormat  >\r\n");

              codeChunk.addHtmlCode("\t\t<tr:inputText value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()));

              for (Relationship rel : attribute.getRelationships())
              {
                codeChunk.addHtmlCode("." + Utils.makeMethod2Field(rel.getName()));
              }
              codeChunk.addHtmlCode("." + attribute.getName() + "}\" />\r\n");

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

              codeChunk.setOrder(attribute.getOrderInForm());
            }
            else
            {
              // codeChunk.setOrder(attribute.getOrderInForm());
              // codeChunk.addHtmlCode("\r\n<trh:rowLayout>\r\n");
              // codeChunk.addHtmlCode("\t<trh:cellFormat>NON SO
              // !</trh:cellFormat>\r\n");
              // codeChunk.addHtmlCode("\t\t<trh:cellFormat>NON SO
              // !</trh:cellFormat>\r\n");
              // codeChunk.addHtmlCode("</trh:rowLayout>\r\n");
            }

          }

          // System.out.println(codeChunks.getHtmlCode());
          // System.out.println(codeChunk.getHtmlCode());

          if (!codeChunks.getHtmlCode().contains(codeChunk.getHtmlCode()))
          {
            codeChunk.setOrder(attribute.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";
      }
    }

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

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

    for (int i = 0; i < chunks.length; i++)
    {
View Full Code Here

  /**
   * Genera un list box a selezione multipla
   */
  private static CodeChunk insertMultipleSelectionListBox2Form(Bean bean, Relationship rel, boolean visible, boolean alwaysRendered)
  {
    CodeChunk ret = new CodeChunk(0);
    String disabledCondition = "";

    if (!visible)
    {
      if (rel.isOptions())
        ret.addHtmlCode("\t\t<h:selectManyCheckbox id=\"" + rel.getName() + "\" value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + Utils.makeMethod2Field(rel.getName()) + "}\" styleClass=\"formField\" ");
      else
        ret.addHtmlCode("\t\t<h:selectManyListbox id=\"" + rel.getName() + "\" value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + Utils.makeMethod2Field(rel.getName()) + "}\" styleClass=\"formField\" ");

      ret.addHtmlCode(" style=\"display:none;\" ");

      if (!alwaysRendered)
      {
        ret.addHtmlCode(" rendered=\"#{" + bean.getName() + "Manager.getCallingBeanName().contains('" + bean.getName() + "')}\" ");
      }

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

      ret.addHtmlCode("\t\t\t<s:selectItems value=\"#{" + rel.getToBeanName() + "Manager.getSelectionItems(true," + Utils.makeFirstLetterLowerCase(bean.getName()) + ",'" + rel.getName() + "')}\" var=\"" + Utils.makeFirstLetterLowerCase(rel.getToBeanName()) + "\" ");

      ret.addHtmlCode("label=\"");

      for (int i = 0; i < rel.getRelatedAttributes().size(); i++)
      {
        if (i > 0)
          ret.addHtmlCode(" - ");

        ret.addHtmlCode("#{" + Utils.makeFirstLetterLowerCase(rel.getToBeanName()) + "." + rel.getRelatedAttributes().get(i).getName() + "}");
      }

      ret.addHtmlCode("\"");

      // ret.addHtmlCode(" noSelectionLabel=\"Selezionare...\" hideNoSelectionLabel=\"" + rel.isRequired() + "\"");
      ret.addHtmlCode("/>\r\n");

      ret.addHtmlCode("\t\t\t\t\t<s:convertEntity />\r\n");

      if (rel.isOptions())
        ret.addHtmlCode("\t\t</h:selectManyCheckbox>\r\n");
      else
        ret.addHtmlCode("\t\t</h:selectManyListbox>\r\n");

      return ret;
    }

    ret.addHtmlCode("\r\n");

    ret.addHtmlCode("\t<tr><td width=\"100%\">\r\n");
    ret.addHtmlCode("\t\t<rich:panel rendered=\"#{");

    /** Gestione della visibilita': showOnEditIf ...  **/

    if (alwaysRendered)
    {
      ret.addHtmlCode("true");
    }
    else
    {
      ret.addHtmlCode("(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='CREATE'");
      if (!rel.getShowOnCreateIf().equals(""))
        ret.addHtmlCode(" and " + rel.getShowOnCreateIf());
      ret.addHtmlCode(")");

      ret.addHtmlCode(" or ");

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

      ret.addHtmlCode(" or ");

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

      ret.addHtmlCode(" or ");

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

    if (!rel.getDisableOnCreateIf().equals(""))
    {
      disabledCondition += "(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='CREATE' and (" + rel.getDisableOnCreateIf() + "))";
    }

    if (!rel.getDisableOnEditIf().equals(""))
    {
      if (!disabledCondition.equals(""))
        disabledCondition += " or ";

      disabledCondition += "(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='EDIT' and (" + rel.getDisableOnEditIf() + "))";
    }

    if (!disabledCondition.equals(""))
      disabledCondition = " disabled=\"#{" + disabledCondition + "}\" ";

    ret.addHtmlCode("}\"" + disabledCondition + ">\r\n");

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

    ret.addHtmlCode("\t\t\t<tr>\r\n");
    ret.addHtmlCode("\t\t\t<td  class=\"formFieldLabel\">\r\n");
    ret.addHtmlCode("\t\t\t\t<h:outputLabel for=\"" + rel.getName() + "\" value=\"#{msgs.form_" + rel.ToSeamLabel() + "}\" />\r\n");
    ret.addHtmlCode("\t\t\t</td>\r\n");

    ret.addHtmlCode("\t\t\t<td width=\"1%\">\r\n");
    if (rel.isRequired())
      ret.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");
    ret.addHtmlCode("\t\t\t</td>\r\n");

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

    if (!rel.getAjaxEvent().equals(""))
    {
      ret.addHtmlCode("<a4j:region>\r\n");
    }

    if (rel.isOptions())
      ret.addHtmlCode("\t\t\t\t<h:selectManyCheckbox required=\"#{" + rel.isRequired() + " and " + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation!='DELETE'}\" id=\"" + rel.getName() + "\" value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + Utils.makeMethod2Field(rel.getName()) + "}\" styleClass=\"formField\" ");
    else
      ret.addHtmlCode("\t\t\t\t<h:selectManyListbox required=\"#{" + rel.isRequired() + " and " + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation!='DELETE'}\" id=\"" + rel.getName() + "\" value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + Utils.makeMethod2Field(rel.getName()) + "}\" styleClass=\"formField\"");

    if (!alwaysRendered)
      ret.addHtmlCode(" rendered=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation!='DISPLAY' and " + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation!='DELETE'}\" ");

    // Inserisce gli eventuali eventi presenti
    Vector<String> events = rel.getEvents();
    Vector<String> eventFunctions = rel.getEventFunctions();

    for (int i = 0; i < events.size(); i++)
    {
      ret.addHtmlCode(events.get(i) + "=" + "\"" + eventFunctions.get(i) + "\"");
    }

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

    ret.addHtmlCode("\t\t\t\t\t<s:selectItems value=\"#{" + rel.getToBeanName() + "Manager.getSelectionItems(true," + Utils.makeFirstLetterLowerCase(bean.getName()) + ",'" + rel.getName() + "')}\" var=\"" + Utils.makeFirstLetterLowerCase(rel.getToBeanName()) + "\" ");
    ret.addHtmlCode("label=\"");

    for (int i = 0; i < rel.getRelatedAttributes().size(); i++)
    {
      if (i > 0)
        ret.addHtmlCode(" - ");

      ret.addHtmlCode("#{" + Utils.makeFirstLetterLowerCase(rel.getToBeanName()) + "." + rel.getRelatedAttributes().get(i).getName() + "}");
    }

    ret.addHtmlCode("\"");

    //ret.addHtmlCode(" noSelectionLabel=\"Selezionare...\" hideNoSelectionLabel=\""+rel.isRequired()+"\" />\r\n");     
    ret.addHtmlCode(" />\r\n");
    ret.addHtmlCode("\t\t\t\t\t<s:convertEntity />\r\n");

    if (!rel.getAjaxEvent().equals(""))
    {
      //      String ids = "";
      //
      //      for (int i = 0; i < rel.getIdsToRerenderOnAjaxEvent().size(); i++)
      //      {
      //        if (i > 0)
      //          ids += ",";
      //
      //        ids += rel.getIdsToRerenderOnAjaxEvent().get(i);
      //      }
      //
      //      ret.addHtmlCode("\t\t\t\t\t<a4j:support event=\"" + rel.getAjaxEvent() + "\" reRender=\"" + ids + "\" limitToList=\"true\" />\r\n");
      ret.addHtmlCode("\t\t\t\t\t" + addAjaxSupport(rel.getAjaxEvent(), rel.getIdsToRerenderOnAjaxEvent()) + "\r\n");
    }

    if (rel.isOptions())
      ret.addHtmlCode("\t\t\t\t</h:selectManyCheckbox>\r\n");
    else
      ret.addHtmlCode("\t\t\t\t</h:selectManyListbox>\r\n");

    if (!rel.getAjaxEvent().equals(""))
    {
      ret.addHtmlCode("</a4j:region>\r\n");
    }

    if (!alwaysRendered)
    {
      ret.addHtmlCode("\t\t\t\t<rich:dataTable var=\"" + Utils.makeFirstLetterLowerCase(rel.getToBeanName()) + "\" value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + Utils.makeMethod2Field(rel.getName()) + "}\" rendered=\"#{(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DISPLAY' or " + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DELETE') and (" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + Utils.makeMethod2Field(rel.getName()) + "!=null)}\" >\r\n");

      for (int i = 0; i < rel.getRelatedAttributes().size(); i++)
      {
        if (i > 0)
        {
          ret.addHtmlCode("\t\t\t\t\t<rich:column>\r\n");
          ret.addHtmlCode("\t\t\t\t\t\t<tr:outputText value=\"-\"/>\r\n");
          ret.addHtmlCode("\t\t\t\t\t</rich:column>\r\n");
        }

        ret.addHtmlCode("\t\t\t\t\t<rich:column");

        if (rel.getRelatedAttributes().get(i).getType().contains("Double") || rel.getRelatedAttributes().get(i).getType().contains("Integer") || rel.getRelatedAttributes().get(i).getType().contains("Long"))
        {
          ret.addHtmlCode(" align=\"right\" ");
        }

        if (rel.getRelatedAttributes().get(i).getType().contains("String"))
        {
          ret.addHtmlCode(" align=\"left\" ");
        }

        if (rel.getRelatedAttributes().get(i).getType().contains("Date") || rel.getRelatedAttributes().get(i).getType().contains("Boolean"))
        {
          ret.addHtmlCode(" align=\"center\" ");
        }

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

        ret.addHtmlCode("\t\t\t\t\t\t<h:outputText value=\"#{" + Utils.makeFirstLetterLowerCase(rel.getToBeanName()) + "." + rel.getRelatedAttributes().get(i).getName() + "}\"/>\r\n");
        ret.addHtmlCode("\t\t\t\t\t</rich:column>\r\n");
      }

      ret.addHtmlCode("\t\t\t\t</rich:dataTable>\r\n");

      //ret.addHtmlCode("\t\t<h:outputText value=\"\" rendered=\"#{(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DISPLAY' or " + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DELETE') and (" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + Utils.makeMethod2Field(rel.getName()) + "==null)}\" />\r\n");
    }

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

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

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

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

    return ret;
  }
View Full Code Here

    String securityCreate = "";
    String securityEdit = "";
    String securityDelete = "";
    String securitySearch = "";

    CodeChunk detailsReference[];
    String categorizedRelationshipToMaster = "";

    String editDerivateBeans = "";
    String displayDerivateBeans = "";
    String deleteDerivateBeans = "";

    String masterDetail1To1Check = "";
    String sons = "";

    InfoReader infoReader = new InfoReader(sourceDir);

    CodeChunk listMethods = new CodeChunk(0);

    Vector<ShowAttribute> attrs = bean.getShowAttributes();

    attrs.add(bean.getKey());

    /** **************************** */
    /** Genera interfaccia Remota * */
    /** **************************** */
    String template = "." + File.separator + "templates" + File.separator + "Seam_ManagerInterfaceRemote.java";
    String sourceFile = sourceDir + ".." + File.separator + "src" + File.separator + basePackage + File.separator + "manager/managerInterface" + File.separator + "remote" + File.separator + bean.getName() + "ManagerRemote.java";
    String targetFile = targetDir + "src" + File.separator + basePackage + File.separator + "manager/managerInterface" + File.separator + "remote" + File.separator + bean.getName() + "ManagerRemote.java";

    LinkedList<String> yourCode = Utils.getYourCode(sourceFile, CustomCodeType.JAVA);

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

    tags.put("@basePackage", basePackage);
    tags.put("@Bean", bean.getName());
    tags.put("@bean", Utils.makeFirstLetterLowerCase(bean.getName()));

    Utils.SeamReplaceTagAndSave(tags, yourCode, template, targetFile);

    /** **************************** */
    /** Genera interfaccia Locale * */
    /** **************************** */

    template = "." + File.separator + "templates" + File.separator + "Seam_ManagerInterface.java";
    sourceFile = sourceDir + ".." + File.separator + "src" + File.separator + basePackage + File.separator + "manager/managerInterface" + File.separator + bean.getName() + "Manager.java";
    targetFile = targetDir + "src" + File.separator + basePackage + File.separator + "manager/managerInterface" + File.separator + bean.getName() + "Manager.java";

    yourCode = Utils.getYourCode(sourceFile, CustomCodeType.JAVA);

    /** Metodi per ordinamento **/

    orderingFunctions = generateBeanManagerInterface_OrderingFunctions(attrs);

    /** Metodi per la alimentazione dei listbox * */
    /*************************************************************************
     * Sono interessate le relazioni :1 ed :n verso questo bean, implementate
     * come list box i campi di ricerca implementati come listBox
     *
     ************************************************************************/
    Vector<Relationship> relationships2ThisBean = infoReader.getAllRelationship2ThisBean(bean.getName());

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

      if (rel.isUsed() || belongs2SearchAttribute(infoReader.getBean(rel.getFromBeanName()), rel))
      {
        if (rel.isListBox() || belongs2SearchAttribute(infoReader.getBean(rel.getFromBeanName()), rel))
        {
          String relatedAttributes = "";
          for (int k = 0; k < rel.getRelatedAttributes().size(); k++)
          {
            relatedAttributes += Utils.makeFirstLetterUpperCase(rel.getRelatedAttributes().get(k).getName());
          }

          CodeChunk tmp = new CodeChunk(0);

          tmp.addJavaCode("\tpublic HashMap<String, " + bean.getName() + "> get" + bean.getName() + "List");
          tmp.addJavaCode(relatedAttributes);
          tmp.addJavaCode("() throws SecurityException, IllegalArgumentException, NoSuchMethodException, IllegalAccessException, InvocationTargetException;\r\n\r\n");

          if (!listMethods.getJavaCode().contains(tmp.getJavaCode()))
          {
            // listMethods.addJavaCode(tmp.getJavaCode());
          }
        }

        if (rel.isMasterDetail() && !rel.isFromMaster())
        {
          Vector<ShowList> lists = infoReader.getLists(rel.getFromBeanName());
          for (ShowList list : lists)
          {
            goToDetails += "public String goTo" + list.getName() + "();\r\n";
          }
        }
      }
    }

    /**
     * Inserimento funzione getPath se il bean e' master o detail in almeno una
     * relazione *
     */
    boolean getPath = false;
    String getPathFunction = "";
    for (int i = 0; i < bean.getRelationships().size(); i++)
    {
      Relationship relationship = bean.getRelationships().get(i);
      if (relationship.isUsed() && relationship.isMasterDetail())
        getPath = true;
    }
    if (getPath)
    {
      getPathFunction += "\r\n";
      getPathFunction += "\tpublic String getPath();\r\n";
    }

    /** Gestione della local search * */
    localSearch += "";
    localSearch += "\tpublic boolean isLocalSearch();\r\n";
    localSearch += "\tpublic void setLocalSearch(boolean search);\r\n";
    localSearch += "\tpublic void startLocalSearch();\r\n";
    localSearch += "\tpublic void stopLocalSearch();\r\n\r\n";

    // Getter e Setter per gli attributi di ricerca locale

    for (int i = 0; i < bean.getLocalSearchAttributes().size(); i++)
    {
      SearchAttribute attr = bean.getLocalSearchAttributes().get(i);

      if (attr.getImplementationType() == AttributeImplementationType.TEXT || attr.getImplementationType() == AttributeImplementationType.TEXTAREA)
      {
        localSearch += "\tpublic String getLocalSearch" + Utils.makeFirstLetterUpperCase(attr.getName()) + "();\r\n";
        localSearch += "\tpublic void setLocalSearch" + Utils.makeFirstLetterUpperCase(attr.getName()) + "(String localSearch" + Utils.makeFirstLetterUpperCase(attr.getName()) + ");\r\n";
      }
      else
      {
        if (attr.belongsToRelationship())
        {
          if (attr.getRelationship().isToMany())
          {
            localSearch += "\tpublic List<" + attr.getRelationship().getToBeanName() + "> getLocalSearch" + attr.getRelationship().getName() + Utils.makeFirstLetterUpperCase(attr.getName()) + "();\r\n";
            localSearch += "\tpublic void setLocalSearch" + attr.getRelationship().getName() + Utils.makeFirstLetterUpperCase(attr.getName()) + "(List<" + attr.getRelationship().getToBeanName() + "> localSearch" + attr.getRelationship().getName() + Utils.makeFirstLetterUpperCase(attr.getName()) + ");\r\n";
          }
          else
          {
            localSearch += "\tpublic " + attr.getRelationship().getToBeanName() + " getLocalSearch" + attr.getRelationship().getName() + Utils.makeFirstLetterUpperCase(attr.getName()) + "();\r\n";
            localSearch += "\tpublic void setLocalSearch" + attr.getRelationship().getName() + Utils.makeFirstLetterUpperCase(attr.getName()) + "(" + attr.getRelationship().getToBeanName() + " localSearch" + attr.getRelationship().getName() + Utils.makeFirstLetterUpperCase(attr.getName()) + ");\r\n";
          }
        }
      }
    }

    //    /** Gettere e Setter degli attributi della ricerca locale relativi a listbox e per i quali non funziona la injection **/
    //   
    //    for (int i = 0; i < bean.getLocalSearchAttributes().size(); i++)
    //    {
    //     
    //    }

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

    tags.put("@basePackage", basePackage);
    tags.put("@Bean", bean.getName());
    tags.put("@bean", Utils.makeFirstLetterLowerCase(bean.getName()));
    tags.put("@ListMethods", listMethods.getJavaCode());
    tags.put("@OrderingFunctions", orderingFunctions);
    tags.put("@GetPath", getPathFunction);
    tags.put("@GoToDetails", goToDetails);
    tags.put("@LocalSearch", localSearch);

    Utils.SeamReplaceTagAndSave(tags, yourCode, template, targetFile);

    /** ************** */
    /** ************** */
    /** ************** */
    /** ************** */
    /** ************** */
    /** ************** */
    /** ************** */
    /** Genera bean * */
    /** ************** */
    /** ************** */
    /** ************** */
    /** ************** */
    /** ************** */
    /** ************** */
    /** ************** */

    goToDetails = "";

    template = "." + File.separator + "templates" + File.separator + "Seam_ManagerBean.java";
    sourceFile = sourceDir + ".." + File.separator + "src" + File.separator + basePackage + File.separator + "manager" + File.separator + bean.getName() + "ManagerBean.java";
    targetFile = targetDir + "src" + File.separator + basePackage + File.separator + "manager" + File.separator + bean.getName() + "ManagerBean.java";

    yourCode = Utils.getYourCode(sourceFile, CustomCodeType.JAVA);

    findAll = generateFindAllBody(infoReader, bean, relationships2ThisBean);

    /**
     * Gestione scope del Manager
     */
    scope = bean.getScope();

    /**
     * Gestione Search
     */
    search += "@Factory(\"" + Utils.makeFirstLetterLowerCase(bean.getName()) + "SearchList\")\r\n";
    search += "\t@Begin(join = true)\r\n";
    search += "\tpublic void search() throws Exception\r\n";
    search += "\t{\r\n";

    search += "\t\tlog.info(\"search\");\r\n";

    search += "\t\tif(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Search == null)\r\n";
    search += "\t\t\treturn;\r\n\r\n";

    search += "\t\tString customFilter = \"\";\r\n";
    search += "\t\tQueryBuilder qb = new QueryBuilder(entityManager);\r\n\r\n";

    search += "\t\tqb.addSelect(\"o\");\r\n";
    search += "\t\tqb.addFrom(\"" + bean.getName() + " o\");\r\n";

    search += "\r\n";

    search += "\t\tqb.addTextWhere(customFilter,customFilter);\r\n\r\n";

    search += "\t\tswitch (order)\r\n";
    search += "\t\t{\r\n";

    int orderIndex = 1;
    String defaultOrdering = "";
    for (int i = 0; i < attrs.size(); i++)
    {
      ShowAttribute attr = attrs.get(i);

      if (!attr.isKey())
      {
        if (!attr.belongsToRelationship())
        {
          if (!attr.isTrans())
          {
            search += "\t\t\tcase " + orderIndex + ":\r\n";
            search += "\t\t\t\tqb.addOrderBy(\"o." + attr.getName() + " desc\");\r\n";
            search += "\t\t\t\tbreak;\r\n";
            orderIndex++;

            search += "\t\t\tcase " + orderIndex + ":\r\n";
            search += "\t\t\t\tqb.addOrderBy(\"o." + attr.getName() + " asc\");\r\n";
            search += "\t\t\t\tbreak;\r\n\r\n";
            orderIndex++;

            if (attr.getDefaultOrderingAttribute().equals("Asc"))
              defaultOrdering += "qb.addOrderBy(\"o." + attr.getName() + " asc\")";

            if (attr.getDefaultOrderingAttribute().equals("Desc"))
              defaultOrdering += "qb.addOrderBy(\"o." + attr.getName() + " desc\")";
          }
          else
          {
            orderIndex += 2;
          }
        }
        else
        {
          if (!attr.getRelationship().isToMany())
          {
            //            search += "\t\t\tcase " + orderIndex + ":\r\n";
            //            search += "\t\t\t\tqb.addOrderBy(\"o." + Utils.makeMethod2Field(attr.getRelationship().getName()) + "." + attr.getName() + " desc\");\r\n";
            //            search += "\t\t\t\tbreak;\r\n";
            //            orderIndex++;
            //
            //            search += "\t\t\tcase " + orderIndex + ":\r\n";
            //            search += "\t\t\t\tqb.addOrderBy(\"o." + Utils.makeMethod2Field(attr.getRelationship().getName()) + "." + attr.getName() + " asc\");\r\n";
            //            search += "\t\t\t\tbreak;\r\n\r\n";
            //            orderIndex++;
            //
            //            if (attr.getDefaultOrderingAttribute().equals("Asc"))
            //              defaultOrdering += "qb.addOrderBy(\"o." + Utils.makeMethod2Field(attr.getRelationship().getName()) + "." + attr.getName() + " asc\")";
            //
            //            if (attr.getDefaultOrderingAttribute().equals("Desc"))
            //              defaultOrdering += "qb.addOrderBy(\"o." + Utils.makeMethod2Field(attr.getRelationship().getName()) + "." + attr.getName() + " desc\")";

            search += "\t\t\tcase " + orderIndex + ":\r\n";
            search += "\t\t\t\tqb.addOrderBy(\"o.";

            for (int j = 0; j < attr.getRelationships().size(); j++)
            {
              search += Utils.makeMethod2Field(attr.getRelationships().get(j).getName()) + ".";
            }

            search += attr.getNameForOrdering() + " desc\");\r\n";
            search += "\t\t\t\tbreak;\r\n";
            orderIndex++;

            search += "\t\t\tcase " + orderIndex + ":\r\n";
            search += "\t\t\t\tqb.addOrderBy(\"o.";

            for (int j = 0; j < attr.getRelationships().size(); j++)
            {
              search += Utils.makeMethod2Field(attr.getRelationships().get(j).getName()) + ".";
            }

            search += attr.getNameForOrdering() + " asc\");\r\n";

            search += "\t\t\t\tbreak;\r\n\r\n";
            orderIndex++;

            if (attr.getDefaultOrderingAttribute().equals("Asc"))
              defaultOrdering += "qb.addOrderBy(\"o." + Utils.makeMethod2Field(attr.getRelationship().getName()) + "." + attr.getNameForOrdering() + " asc\")";

            if (attr.getDefaultOrderingAttribute().equals("Desc"))
              defaultOrdering += "qb.addOrderBy(\"o." + Utils.makeMethod2Field(attr.getRelationship().getName()) + "." + attr.getNameForOrdering() + " desc\")";
          }
        }
      }
    }

    search += "\t\t\tdefault:\r\n";
    if (defaultOrdering.equals(""))
      search += "\t\t\t\tqb.addOrderBy(\"o.id desc\");\r\n";
    else
      search += "\t\t\t\t" + defaultOrdering + ";\r\n";

    search += "\t\t}\r\n\r\n";

    /** Condizioni della ricerca **/
   
    for (int i = 0; i < bean.getSearchAttributes().size(); i++)
    {
      SearchAttribute attr = bean.getSearchAttributes().get(i);

      if (!attr.belongsToRelationship())
      {
        /** Non appartiene ad una relazione **/
        if (attr.getImplementationType().equals(AttributeImplementationType.TEXT))
        {
          if (attr.getType().equals("java.lang.String"))
          {
            search += "\t\tqb.addTextWhere(\"upper(o." + attr.getName() + ") like upper('%\"+" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Search." + Utils.makeGet(attr.getName()) + "()+\"%')\", " + Utils.makeFirstLetterLowerCase(bean.getName()) + "Search." + Utils.makeGet(attr.getName()) + "());\r\n";
          }
          else
          {
            search += "\t\tqb.addTextWhere(\"o." + attr.getName() + " = ?"+i+"\", " + Utils.makeFirstLetterLowerCase(bean.getName()) + "Search." + Utils.makeGet(attr.getName()) + "());\r\n";           
          }
        }
      }
      else
      {
        /** Non appartiene ad una relazione **/
      }

    }

    search += "\r\n";
    search += "// YOUR CODE GOES HERE\r\n";
    search += "@YourCode";
    search += "// END OF YOUR CODE\r\n\r\n";

   
    /** Parametri Condizioni della ricerca **/
   
    for (int i = 0; i < bean.getSearchAttributes().size(); i++)
    {
      SearchAttribute attr = bean.getSearchAttributes().get(i);

      if (!attr.belongsToRelationship())
      {
        /** Non appartiene ad una relazione **/
        if (attr.getImplementationType().equals(AttributeImplementationType.TEXT))
        {
          if (attr.getType().equals("java.lang.String"))
          {
          }
          else
          {
            search += "\t\tqb.setParameter(\""+i+"\", " + Utils.makeFirstLetterLowerCase(bean.getName()) + "Search." + Utils.makeGet(attr.getName()) + "());\r\n";
          }
        }
      }
      else
      {
        /** Non appartiene ad una relazione **/
      }

    }
   
    search += "\r\n";
    search += "// YOUR CODE GOES HERE\r\n";
    search += "@YourCode";
    search += "// END OF YOUR CODE\r\n\r\n";
   
    search += "\t\tentityManager.clear();\r\n";
    search += "\r\n";
    search += "\t\t" + Utils.makeFirstLetterLowerCase(bean.getName()) + "SearchList = qb.getEjbQuery().getResultList();\r\n";
    search += "\r\n";

    /** Gestione dell'ordinamento dei campi transient **/

    search += "\t\tswitch (order)\r\n";
    search += "\t\t{\r\n";

    orderIndex = 1;

    for (int i = 0; i < attrs.size(); i++)
    {
      ShowAttribute attr = attrs.get(i);

      if (!attr.isKey())
      {
        if (!attr.belongsToRelationship())
        {
          // Attributo del bean

          if (attr.isTrans())
          {
            search += "\t\t\tcase " + orderIndex + ":\r\n";
            search += "\t\t\t\t" + Utils.makeFirstLetterLowerCase(bean.getName()) + "SearchList = SeamUtility.orderBy(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "SearchList, \"" + attr.getNameForOrdering() + "\", GenericFieldComparator.OrderType.DESC);\r\n";
            search += "\t\t\t\tbreak;\r\n";
            orderIndex++;

            search += "\t\t\tcase " + orderIndex + ":\r\n";
            search += "\t\t\t\t" + Utils.makeFirstLetterLowerCase(bean.getName()) + "SearchList = SeamUtility.orderBy(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "SearchList, \"" + attr.getNameForOrdering() + "\", GenericFieldComparator.OrderType.ASC);\r\n";
            search += "\t\t\t\tbreak;\r\n\r\n";
            orderIndex++;
          }
          else
          {
            orderIndex += 2;
          }
        }
        else
        {
          // Attributo di una relazione
          orderIndex += 2;
        }
      }
    }
    search += "\t\t}\r\n\r\n";

    if (bean.getSearchActions().size() > 0 || bean.getSearchImmediateActions().size() > 0)
    {
      search += "\t\tselections.clear();\r\n";
      search += "\t\tfor(" + bean.getName() + " item : " + Utils.makeFirstLetterLowerCase(bean.getName()) + "SearchList)\r\n";
      search += "\t\t{\r\n";
      search += "\t\t\tselections.put(item, true);\r\n";
      search += "\t\t}\r\n";
    }

    search += "\t}\r\n";

    orderingFunctions = "";
    orderIndex = 1;
    for (int i = 0; i < attrs.size(); i++)
    {
      ShowAttribute attr = attrs.get(i);

      if (!attr.isKey())
      {
        if (!attr.belongsToRelationship())
        {
          orderingFunctions += "\tpublic void orderBy" + (i + 1) + "A()\r\n";
          orderingFunctions += "\t{\r\n";
          orderingFunctions += "\t\torder = " + orderIndex + ";\r\n";
          orderingFunctions += "\t\tfindAll();\r\n";
          orderingFunctions += "\t}\r\n";
          orderIndex++;

          orderingFunctions += "\tpublic void orderBy" + (i + 1) + "D()\r\n";
          orderingFunctions += "\t{\r\n";
          orderingFunctions += "\t\torder = " + orderIndex + ";\r\n";
          orderingFunctions += "\t\tfindAll();\r\n";
          orderingFunctions += "\t}\r\n";
          orderIndex++;
        }
        else
        {
          if (!attr.getRelationship().isToMany())
          {
            orderingFunctions += "\tpublic void orderBy" + (i + 1) + "A()\r\n";
            orderingFunctions += "\t{\r\n";
            orderingFunctions += "\t\torder = " + orderIndex + ";\r\n";
            orderingFunctions += "\t\tfindAll();\r\n";
            orderingFunctions += "\t}\r\n";
            orderIndex++;

            orderingFunctions += "\tpublic void orderBy" + (i + 1) + "D()\r\n";
            orderingFunctions += "\t{\r\n";
            orderingFunctions += "\t\torder = " + orderIndex + ";\r\n";
            orderingFunctions += "\t\tfindAll();\r\n";
            orderingFunctions += "\t}\r\n";
            orderIndex++;
          }
        }
      }
    }

    /** Metodi per la alimentazione dei listbox * */
    /**
     * Sono interessate le relazioni :1 ed :n verso questo bean, implementate
     * come list box *
     */

    // listMethods = generateBeanManager_ListBoxFunctions(infoReader, bean, relationships2ThisBean);
    listMethods = new CodeChunk(0);

    /** Riferimenti ai bean che utilizzano questo bean come popup * */
    Vector<Relationship> relationshipToThisBean = infoReader.getAllRelationship2ThisBean(bean.getName());
    for (Relationship rel : relationshipToThisBean)
    {
View Full Code Here

TOP

Related Classes of org.boco.seamwebappgen.utils.CodeChunk

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.