Examples of CodeChunk


Examples of br.com.caelum.tubaina.chunk.CodeChunk

  @Test
  public void codeTagWithFileNameWithLanguageAndLabel() throws Exception {
    String options = "java filename=src/Main2.java label=javacode1";
    String code = publicStaticVoidMain();
    CodeChunk chunk = new CodeChunk(code, options);
    String output = getContent(chunk);

    assertTrue(output.startsWith("\\tubainaCodeLabel{javacode1}\n"));
    assertPygmentsRan(output);
  }
View Full Code Here

Examples of br.com.caelum.tubaina.chunk.CodeChunk

  @Test
  public void javascriptLangBug() throws Exception {
    String options = "javascript";
    String code = "writeTotal(3.14159);";
    CodeChunk chunk = new CodeChunk(code, options);
    String output = getContent(chunk);

    assertFalse(output.contains("javascript"));
    assertPygmentsRan(output);
  }
View Full Code Here

Examples of br.com.caelum.tubaina.chunk.CodeChunk

 
  @Test
  public void shouldUseDescription() throws Exception {
    String options = "java label=javacode1 \"description here\"";
    String code = publicStaticVoidMain();
    CodeChunk chunk = new CodeChunk(code, options);
    String output = getContent(chunk);
    assertTrue(output.contains("\\tubainaCodeLabel{javacode1}{description here}"));
  }
View Full Code Here

Examples of br.com.caelum.tubaina.chunk.CodeChunk

 
  @Test
  public void testName() throws Exception {
    String options = "php options='startinline=true'";
    String code = publicStaticVoidMain();
    CodeChunk chunk = new CodeChunk(code, options);
    String output = getContent(chunk);
    System.out.println(output);
  }
View Full Code Here

Examples of br.com.caelum.tubaina.chunk.CodeChunk

      SimpleIndentator indentator = new SimpleIndentator(4);
    int maxLineLength = Utilities.maxLineLength(indentator.indent(content)) - Utilities.getMinIndent(indentator.indent(content));
    if (maxLineLength > TubainaBuilder.getCodeLength())
      throw new TubainaException ("Chapter " + ChapterBuilder.getChaptersCount() +
                    "  -  Code has " + maxLineLength + " columns out of " + TubainaBuilder.getCodeLength() + ":\n\n" + content);
    return new CodeChunk(content, options);
  }
View Full Code Here

Examples of br.com.caelum.tubaina.chunk.CodeChunk

  @Test
  public void notNumberedGenericCode() {
    String code = "public static void main(String[] args) {\n" + "    String name = \"Gabriel\";\n"
        + "    System.out.println(\"Hello, \" + name);\n" + "}";
    CodeChunk chunk = new CodeChunk(code, "");
    String result = getContent(chunk);
    Assert.assertEquals("<pre ><div class=\"highlight\">" +
              "<pre>public static void main(String[] args) {" +
              "\n    String name = &quot;Gabriel&quot;;" +
              "\n    System.out.println(&quot;Hello, &quot; + name);" +
View Full Code Here

Examples of br.com.caelum.tubaina.chunk.CodeChunk

  @Test
  public void numberedGenericCode() {
    String code = "public static void main(String[] args) {\n" + "    String name = \"Gabriel\";\n"
        + "    System.out.println(\"Hello, \" + name);\n" + "}";
    CodeChunk chunk = new CodeChunk(code, "#");
    String result = getContent(chunk);
    Assert.assertEquals("<pre ><div class=\"highlight\">" +
              "<pre><span class=\"lineno\">1</span> " +
              "public static void main(String[] args) {" +
              "\n<span class=\"lineno\">2</span> " +
View Full Code Here

Examples of br.com.caelum.tubaina.chunk.CodeChunk

        GistResult result = retriever.retrieve(gistId, "");
       
        String content = result.getContent();
        String language = result.getLanguage();
       
        CodeChunk codeChunk = new CodeChunk(content, language + codeOptions);
    return code.parse(codeChunk);
    }
View Full Code Here

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

Examples of org.boco.seamwebappgen.utils.CodeChunk

    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
TOP
Copyright © 2018 www.massapi.com. 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.