/* (non-Javadoc)
   * @see org.jboss.tools.vpe.editor.template.VpeTemplate#create(org.jboss.tools.vpe.editor.context.VpePageContext, org.w3c.dom.Node, org.mozilla.interfaces.nsIDOMDocument)
   */
  public VpeCreationData create(
      VpePageContext pageContext, Node sourceNode, nsIDOMDocument visualDocument) {
    Element sourceElement = (Element) sourceNode;
    nsIDOMElement select = visualDocument.createElement(HTML.TAG_SELECT);

    VisualDomUtil.copyAttributes(sourceElement, select, COMMON_SPRING_FORM_ATTRIBUTES_MAP);

    if (SpringConstant.VALUE_TRUE.equals(
        sourceElement.getAttribute(SpringConstant.ATTR_DISABLED))) {
      select.setAttribute(HTML.ATTR_DISABLED, HTML.ATTR_DISABLED);
    }

    if (!SpringConstant.VALUE_FALSE.equals(
        sourceElement.getAttribute(SpringConstant.ATTR_MULTIPLE))) {
      select.setAttribute(HTML.ATTR_MULTIPLE, HTML.ATTR_MULTIPLE);
    }

    if (sourceElement.hasAttribute(SpringConstant.ATTR_ITEMS)) {
      // an inner 'option' tag has to be generated
      String optionBody = sourceElement.getAttribute(SpringConstant.ATTR_ITEMS);
      if (sourceElement.hasAttribute(SpringConstant.ATTR_ITEM_LABEL)) {
        optionBody += '.' + sourceElement.getAttribute(SpringConstant.ATTR_ITEM_LABEL);
      }

      nsIDOMElement option = visualDocument.createElement(HTML.TAG_OPTION);
      option.appendChild(visualDocument.createTextNode(optionBody));
      select.appendChild(option);
    }

    return new VpeCreationData(select);
  }
  /**
   * Creates a node of the visual tree on the node of the source tree. This visual node should not
   * have the parent node This visual node can have child nodes.
   *
   * @param pageContext Contains the information on edited page.
   * @param sourceNode The current node of the source tree.
   * @param visualDocument The document of the visual tree.
   * @return The information on the created node of the visual tree.
   */
  public VpeCreationData create(
      VpePageContext pageContext, Node sourceNode, nsIDOMDocument visualDocument) {
    ComponentUtil.setCSSLink(pageContext, SPACER_CSS_FILE, "spacer"); // $NON-NLS-1$
    // convert to Element
    Element sourceElement = (Element) sourceNode;

    nsIDOMElement img = visualDocument.createElement(HTML.TAG_IMG);
    ComponentUtil.setImg(img, IMAGE_NAME);

    // set STYLE attributes
    String attrValue = ComponentUtil.getAttribute(sourceElement, RichFaces.ATTR_STYLE);
    if (attrValue.length() != 0) {
      img.setAttribute(HTML.ATTR_STYLE, attrValue);
    }
    // set CLASS attribute
    attrValue = ComponentUtil.getAttribute(sourceElement, RichFaces.ATTR_STYLE_CLASS);
    String styleClass = RICH_SPACER_STYLE;
    if (attrValue.length() != 0) {
      styleClass += Constants.WHITE_SPACE + attrValue;
    }
    img.setAttribute(HTML.ATTR_CLASS, styleClass);
    // set WIDTH attribute
    String width = ComponentUtil.getAttribute(sourceElement, HTML.ATTR_WIDTH, DEFAULT_SIZE);
    img.setAttribute(HTML.ATTR_WIDTH, width);
    // set HEIGHT attribute
    String height = ComponentUtil.getAttribute(sourceElement, HTML.ATTR_HEIGHT, DEFAULT_SIZE);
    img.setAttribute(HTML.ATTR_HEIGHT, height);

    /*
     * https://jira.jboss.org/jira/browse/JBIDE-3225
     * Component should render its children.
     */
    VpeCreationData creationData =
        VisualDomUtil.createTemplateWithTextContainer(
            sourceElement, img, HTML.TAG_SPAN, visualDocument);

    return creationData;
  }