Package org.boco.seamwebappgen.info

Examples of org.boco.seamwebappgen.info.Relationship


    }

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

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

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

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

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

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

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

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

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

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

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

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

    }

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

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

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

    /** Ordinamento dei chunck  **/

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

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

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

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

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

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

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

      start.addHtmlCode(" or ");

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

      start.addHtmlCode(" or ");

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

      start.addHtmlCode(" or ");

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

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

      int idx = getChunkIndex(chunkVector, start);

      chunkVector.add(idx, start);

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

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

      idx = getChunkIndex(chunkVector, end);

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

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

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

    /** Gestione dei campi FORMATTEDTEXTAREA **/

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

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

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

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

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

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

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

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

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

        if (javaScript.contains("loadHiddenFields"))
        {
          tmp = tmp.replace("function loadHiddenFields()", "");
          tmp = tmp.replace("{", "");

          javaScript = javaScript.replace("}", "\r\n" + tmp);
        }
        else
        {
          javaScript += tmp;
        }

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

          if (!attr.isKey() && (attr.getImplementationType() != AttributeImplementationType.HIDEINFORM) && (attr.getImplementationType() != AttributeImplementationType.READONLY))
          {
            String tmp1 = insertAttribute2Form(attr, fromBean.getName(), false).replace("id=\"", "id=\"" + rel.getFromBeanName()) + "\r\n";

            if (!hiddenAttributes.contains(tmp1))
              hiddenAttributes += tmp1;
          }
        }

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

          if (relationship.isUsed() && relationship.isListBox())
          {
            if (relationship.isToMany())
            {
              String tmp1 = insertMultipleSelectionListBox2Form(fromBean, relationship, false, false).getHtmlCode().replace("id=\"", "id=\"" + rel.getFromBeanName());

              tmp1 = tmp1.replace(fromBean.getName() + "Manager.getCallingBeanName()", bean.getName() + "Manager.getCallingBeanName()");

View Full Code Here


        String toBeanName = beanName;

        for (int m = 0; m < items.size() - 1; m++)
        {
          Relationship rel = infoReader.getRelationship(toBeanName, items.get(m));

          tmp.addRelationship(rel);

          toBeanName = rel.getToBeanName();
        }

        tmp.setType(infoReader.getBeanAttribute(tmp.getRelationship().getToBeanName(), tmp.getName()).getType());
        tmp.setImplementationType(infoReader.getBeanAttribute(toBeanName, tmp.getName()).getImplementationType());
        tmp.setFormFormatOff(infoReader.getBeanAttribute(toBeanName, tmp.getName()).isFormFormatOff());
View Full Code Here

     * 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";
          }
        }
      }
View Full Code Here

    {
      ret += "\t\t<tr:panelGroupLayout layout=\"vertical\">\r\n";

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

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

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

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

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

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

          String details = generateDetails(targetBean, sourceDir);

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

    }

    // 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]);
View Full Code Here

          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]);

View Full Code Here

    // 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
View Full Code Here

  {
    InfoReader infoReader = new InfoReader(sourceDir);

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

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

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

          // Attributi nella pagina di origine

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

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

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

          beanAttr.addAll(attributes);

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

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

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

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

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

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

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

              callingAttributes.add(attr);
            }
          }

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

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

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

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

          // Attributi nella pagina di origine

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

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

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

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

      }
    }

    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
        {
View Full Code Here

      }
    }

    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
        {
View Full Code Here

TOP

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

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.