Package smilehouse.tools.template

Examples of smilehouse.tools.template.Template


            String guiHtml;

            // Use template if the component provides one
            String templateStr = ((GUIConfigurationIF) component).getGUITemplate();
            if(templateStr != null) {
                Template template = Template.createTemplate(templateStr);
                guiContext.writeEditors(fields, template)
                template.write();
                guiHtml = template.toString();
            }
            // Else just print them...
            else {
                guiHtml = new String();
                for(Iterator i = fields.values().iterator(); i.hasNext();) {
View Full Code Here


            if(parameters.getInt(ACTION) != ACTION_CANCEL) {
        generalFieldsContext.commitFields(generalFields);
        pers.update(pipe);
            }
        }
        Template generalFieldsTemplate = Template.createTemplate(GENERAL_FIELDS_LAYOUT);

        generalFieldsContext.writeEditors(generalFields, generalFieldsTemplate);

        generalFieldsTemplate.write();
        ElementContainer content = new ElementContainer().addElement(
                generalFieldsTemplate.toString()).addElement(new BR()).addElement(new BR());
        Form form = getForm("PipeSettings", content.toString(), labels, false, true).addElement(
                parameters.getInput(Input.HIDDEN, PIPE_ID));
        return form.toString();
  }
View Full Code Here

                    new TD().setRowSpan(1).setVAlign(AlignType.MIDDLE).addElement(new B(labels.getLabel("editorstatus")+":")))
                .addElement(
                    new TD().setRowSpan(2).setVAlign(AlignType.MIDDLE).addElement(pipe.getLastStatus()));
        }
       
        Template generalFieldsTemplate = Template.createTemplate(GENERAL_FIELDS_LAYOUT);

        generalFieldsContext.writeEditors(generalFields, generalFieldsTemplate);

        generalFieldsTemplate.write();

        ElementContainer content = new ElementContainer().addElement(new H1(pipe.getName())).addElement(
            generalFieldsTemplate.toString()).addElement(new BR()).addElement(new BR()).addElement(
            componentTable).addElement(new BR()).addElement(infoTable);

       
        Form form = getForm("EditPipe", content.toString(), labels, false, true).addElement(
            parameters.getInput(Input.HIDDEN, PIPE_ID)).addElement(
View Full Code Here

                "Editor hasn't been coded properly, problem getting a property that should be always available.");
        }
    }

    public String getEditor(EditorResources editorResources) {
        Template template = baseTemplate.copyStructure();
        return this.getEditor(editorResources, template);
    }
View Full Code Here

        if(this.hasEditValue(editorResources)) {
            Collection errors = editorResources.validate();

            if(!errors.isEmpty()) {
                template.setVariable("cssClass", "error");
                Template errBlock = template.getBlock("errors");
                for(Iterator iter = errors.iterator(); iter.hasNext();) {
                    Template err = errBlock.getBlock("error");
                    err.setVariable("message", ((String) iter.next()));
                    err.write();
                }
                errBlock.write();
            }
        }
    }
View Full Code Here

    public Object getEditValue(EditorResources editorResources) throws FormatterException {
        return editorResources.getModelValue(); // We don't have an edit value
    }

    public String getEditor(EditorResources editorResources) {
        Template template = baseTemplate.copyStructure();

        Object valueObject = null;
        valueObject = editorResources.getModelValue();

        if(valueObject != null) {
            String value = valueObject.toString();
            // TODO: URL encode value
            template.setVariable("value", value);
        }
        template.setVariable("href", href);
        template.setVariable("parameterName", parameterName);
        template.setVariable("buttonText", editorResources.getDescription());
        template.setVariable("target", target);

        template.write();
        return template.toString();
    }
View Full Code Here

     *
     * @return the html-representation of this editor.
     * 
     */
    public String getEditor(EditorResources editorResources) {
        Template template = baseTemplate.copyStructure();
        template.setVariable("description", editorResources.getDescription());


        Collection columnFields = getColumnFields(editorResources);
        int cols = columnFields.size();
        if(delete)
            cols++;
        if(move)
            cols++;
        if(clone)
          cols++;
        template.setVariable("cols", "" + cols);

        //write headers
        Template header = template.getBlock("header");
        Template headerColumn = header.getBlock("column");
        for(Iterator iter = columnFields.iterator(); iter.hasNext();) {
            FieldImpl column = (FieldImpl) iter.next();
            headerColumn.setVariable("description", column.getDescription());
            headerColumn.write();
        }
        if(move) {
            headerColumn.setVariable("description", editorResources.getResource().getLabel(
                this.moveLabel));
            headerColumn.write();
        }
        if(delete) {
            headerColumn.setVariable("description", editorResources.getResource().getLabel(
                this.deleteLabel));
            headerColumn.write();
        }
        if(clone) {
          headerColumn.setVariable("description", editorResources.getResource().getLabel(
                    this.cloneLabel));
            headerColumn.write();
        }
        header.write();




        //write field editors
        ContainingFieldIterator allFields = getAllFields(editorResources);
        int rowNum = 0;
        String rowClass = "ttrow1";
        Template row = template.getBlock("row");
        Template rowColumn = row.getBlock("column");
        while(allFields.hasNext()) {
            FieldImpl column = (FieldImpl) allFields.next();

            // set css zeebra-class
            rowColumn.setVariable("rowClass", rowClass);

            //set editor
            rowColumn.setVariable("field", column.getEditor());
            rowColumn.write();
            //System.err.println("column id; "+column.getId());
            //      System.err.println("column readId: "+column.getReadId());
            //      System.err.println("column writeId: "+column.getWriteId());
            //      System.err.println("");

           
            //do row change
            if(allFields.lastColumnInRow()) {
             
                if(move) {
                    rowColumn.setVariable("rowClass", rowClass);
                    Template buttonB = rowColumn.getBlock("button");
                    if(rowNum != 0) {
                        buttonB.setVariable("id", editorResources.getWriteId() + "_up_" + rowNum);
                        buttonB.setVariable("src", this.upImgSrc);
                        buttonB.setVariable("description", ""
                                + editorResources.getResource().getLabel(this.upImgAltLabel));
                        buttonB.write();
                    }
                    if(!allFields.lastRow()) {
                        buttonB.setVariable("id", editorResources.getWriteId() + "_down_" + rowNum);
                        buttonB.setVariable("src", this.doImgSrc);
                        buttonB.setVariable("description", ""
                                + editorResources.getResource().getLabel(this.doImgAltLabel));
                        buttonB.write();
                    }
                    rowColumn.write();
                }
                if(delete) {
                    //write delete button: TODO: support for changing the buttons...
                    rowColumn.setVariable("rowClass", rowClass);
                    Template buttonB = rowColumn.getBlock("deletebutton");
                    buttonB.setVariable("id", editorResources.getWriteId() + "_delete_" + rowNum);
                    buttonB.setVariable("description", ""
                            + editorResources.getResource().getLabel(this.deleteLabel));
                    // Add a confirmation popup too if there's a label for it.
                    if(confirmLabel != null) {
                        Template confirmB = buttonB.getBlock("deleteconfirm");
                        confirmB.setVariable("confirmMessage", ""
                                + editorResources.getResource().getLabel(this.confirmLabel));
                        confirmB.write();
                    }

                    buttonB.write();
                    rowColumn.write();
                }
                if(clone){
                  rowColumn.setVariable("rowClass", rowClass);
                    Template buttonB = rowColumn.getBlock("deletebutton");
                    buttonB.setVariable("id", editorResources.getWriteId() + "_clone_" + rowNum);
                    buttonB.setVariable("description", ""
                            + editorResources.getResource().getLabel(this.cloneLabel));

                    buttonB.write();
                    rowColumn.write();
                }
               
                row.write();
                rowNum++;
                //set zeebra, note that we are counting from zero
               
                if(rowNum % 2 == 0)
                    rowClass = "ttrow1";
                else
                    rowClass = "ttrow2";
               
               
               
               
               
            }
        }
        //the last row must be written too
        row.write();

        //write possible add-button too
        if(add) {
            Template addB = template.getBlock("add");
            addB.setVariable("cols", "" + cols);
            addB.setVariable("id", editorResources.getWriteId() + "Add");
            addB.setVariable("description", editorResources.getResource().getLabel(this.addLabel));
            addB.write();
        }




View Full Code Here

  
   /**
     * @return The html-representation of the editor.
     */
   public String getEditor(EditorResources editorResources) {
          Template template = baseTemplate.copyStructure();
          template.setVariable("description", editorResources.getDescription());


          Collection columnFields = getColumnFields(editorResources);
          int cols = columnFields.size();
          if(delete)
              cols++;
          if(move)
              cols++;
          if(clone)
            cols++;
          template.setVariable("cols", "" + cols);

          Object o=editorResources.getModelValue();
          RecallingList pipeList=null;
          if(o instanceof RecallingList){
            pipeList= (RecallingList) editorResources.getModelValue();
          }

          //write headers
          Template header = template.getBlock("header");
          Template headerColumn = header.getBlock("column");
          for(Iterator iter = columnFields.iterator(); iter.hasNext();) {
              FieldImpl column = (FieldImpl) iter.next();
              headerColumn.setVariable("description", column.getDescription());
              headerColumn.write();
          }
          if(move) {
              headerColumn.setVariable("description", editorResources.getResource().getLabel(
                  this.moveLabel));
              headerColumn.write();
          }
          if(delete) {
              headerColumn.setVariable("description", editorResources.getResource().getLabel(
                  this.deleteLabel));
              headerColumn.write();
          }
          if(clone) {
            headerColumn.setVariable("description", editorResources.getResource().getLabel(
                      this.cloneLabel));
              headerColumn.write();
          }
          header.write();




          //write field editors
          ContainingFieldIterator allFields = getAllFields(editorResources);
          int rowNum = 0;
          String rowClass = "ttrow1";
          Template row = template.getBlock("row");
          Template rowColumn = row.getBlock("column");
          while(allFields.hasNext()) {
              FieldImpl column = (FieldImpl) allFields.next();
              if (this.pipeSet != null && pipeList != null) {
          Pipe p = ( Pipe ) pipeList.get( rowNum );
          if (this.pipeSet.contains( p ))
            rowClass = "ttrow3";
            }
              // set css zeebra-class
              rowColumn.setVariable("rowClass", rowClass);

              //set editor
              rowColumn.setVariable("field", column.getEditor());
              rowColumn.write();
              //System.err.println("column id; "+column.getId());
              //      System.err.println("column readId: "+column.getReadId());
              //      System.err.println("column writeId: "+column.getWriteId());
              //      System.err.println("");

             
              //do row change
              if(allFields.lastColumnInRow()) {
               
                  if(move) {
                      rowColumn.setVariable("rowClass", rowClass);
                      Template buttonB = rowColumn.getBlock("button");
                      if(rowNum != 0) {
                          buttonB.setVariable("id", editorResources.getWriteId() + "_up_" + rowNum);
                          buttonB.setVariable("src", this.upImgSrc);
                          buttonB.setVariable("description", ""
                                  + editorResources.getResource().getLabel(this.upImgAltLabel));
                          buttonB.write();
                      }
                      if(!allFields.lastRow()) {
                          buttonB.setVariable("id", editorResources.getWriteId() + "_down_" + rowNum);
                          buttonB.setVariable("src", this.doImgSrc);
                          buttonB.setVariable("description", ""
                                  + editorResources.getResource().getLabel(this.doImgAltLabel));
                          buttonB.write();
                      }
                      rowColumn.write();
                  }
                  if(delete) {
                      //write delete button: TODO: support for changing the buttons...
                      rowColumn.setVariable("rowClass", rowClass);
                      Template buttonB = rowColumn.getBlock("deletebutton");
                      buttonB.setVariable("id", editorResources.getWriteId() + "_delete_" + rowNum);
                      buttonB.setVariable("description", ""
                              + editorResources.getResource().getLabel(this.deleteLabel));
                      // Add a confirmation popup too if there's a label for it.
                      if(confirmLabel != null) {
                          Template confirmB = buttonB.getBlock("deleteconfirm");
                          confirmB.setVariable("confirmMessage", ""
                                  + editorResources.getResource().getLabel(this.confirmLabel));
                          confirmB.write();
                      }

                      buttonB.write();
                      rowColumn.write();
                  }
                  if(clone){
                    rowColumn.setVariable("rowClass", rowClass);
                      Template buttonB = rowColumn.getBlock("deletebutton");
                      buttonB.setVariable("id", editorResources.getWriteId() + "_clone_" + rowNum);
                      buttonB.setVariable("description", ""
                              + editorResources.getResource().getLabel(this.cloneLabel));

                      buttonB.write();
                      rowColumn.write();
                  }
                 
                  row.write();
                  rowNum++;
                  //set zeebra, note that we are counting from zero
                 
                  if(rowNum % 2 == 0)
                      rowClass = "ttrow1";
                  else
                      rowClass = "ttrow2";
                 
                 
                 
                 
                 
              }
          }
          //the last row must be written too
          row.write();

          //write possible add-button too
          if(add) {
              Template addB = template.getBlock("add");
              addB.setVariable("cols", "" + cols);
              addB.setVariable("id", editorResources.getWriteId() + "Add");
              addB.setVariable("description", editorResources.getResource().getLabel(this.addLabel));
              addB.write();
          }




View Full Code Here

    public Object getEditValue(EditorResources editorResources) throws FormatterException {
        return editorResources.getModelValue(); // We don't have an edit value
    }

    public String getEditor(EditorResources editorResources) {
        Template template = baseTemplate.copyStructure();

        Object valueObject = null;
        valueObject = editorResources.getModelValue();

        if(valueObject != null) {
            String value = valueObject.toString();
            // TODO: URL encode value
            template.setVariable("value", value);
        }
        template.setVariable("href", href);
        template.setVariable("parameterName", parameterName);
        template.setVariable("linkText", editorResources.getDescription());
        template.setVariable("target", target);

        template.write();
        return template.toString();
    }
View Full Code Here

    public Object getEditValue(EditorResources editorResources) throws FormatterException {
        return editorResources.getModelValue(); // We DON'T HAVE an edit value! Ever! GO AWAY!
    }

    public String getEditor(EditorResources editorResources) {
        Template template = baseTemplate.copyStructure();

        Object valueObject = null;

        valueObject = editorResources.getModelValue();

        if(valueObject != null) {

            Map params = (HashMap) valueObject;

            for(Iterator iter = params.entrySet().iterator(); iter.hasNext();) {
                Map.Entry entry = (Map.Entry) iter.next();
                String key = (String) entry.getKey();
                String value = (String) entry.getValue();
                try {
                    template.setVariable(URLEncoder.encode(key, PARAMETER_ENCODING),
                                 URLEncoder.encode(value, PARAMETER_ENCODING));
                } catch (UnsupportedEncodingException e) {
                    throw new RuntimeException(
                        "Internal error: Unable to encode servlet parameters with "
                                + PARAMETER_ENCODING);
                }
            }
        }
        template.setVariable("href", href);
        template.setVariable("buttonText", editorResources.getDescription());
        template.setVariable("target", target);

        template.write();
        return template.toString();
    }
View Full Code Here

TOP

Related Classes of smilehouse.tools.template.Template

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.