Package net.xoetrope.builder.w3c.html.tags

Source Code of net.xoetrope.builder.w3c.html.tags.Form

package net.xoetrope.builder.w3c.html.tags;

import net.xoetrope.builder.w3c.html.XHtmlBuilder;
import net.xoetrope.builder.w3c.html.XHtmlFormLayout;
import java.util.Enumeration;
import javax.swing.JComponent;
import javax.swing.text.MutableAttributeSet;
import javax.swing.text.html.HTML;
import net.xoetrope.xui.XComponentFactory;

/**
* Processing for the html form element
* <p> Copyright (c) Xoetrope Ltd., 2002-2006</p>
* <p> $Revision: 1.2 $</p>
* <p> License: see License.txt</p>
*/
public class Form extends XHtmlTagHandler
  /**
   * Creates a new instance of Form
   */
  public Form()
  {
  }
 
/**
   * Create a new instance of this object
   * @param builder the html builder and processor for the document
   * @param parent the parent handler
   * @return the new handler
   */
  public XHtmlTagHandler newInstance( XHtmlBuilder builder, XHtmlTagHandler parent )
  {
    Form i = new Form();
    i.setBuilder( builder );
    i.setParent( parent );
    return i;
  }

  /**
   * Process the element text
   * @param cf the component factory to use for the creation of individual components
   * @param text the content
   */
  public void processText( XComponentFactory cf, String text )
  {   
    if ( text.length() > 0 )
      cf.addComponent( "Label", null, text );
  }
 
  /**
   * Process the opening html P tag/element
   * @param builder the xui builder instance that is processing the html file
   * @param cf the component factory to use for the creation of individual components
   * @param as the attributes of this html tag.
   */
  public void startProcessing( XHtmlBuilder builder, XComponentFactory cf, MutableAttributeSet as )
  {
    super.startProcessing( builder, cf, as );

    comp = (JComponent)cf.addComponent( "Panel", null, "" );
    XHtmlFormLayout fl = new XHtmlFormLayout( builder );
    fl.setAlignment( "center" );
    comp.setLayout( fl );
    comp.setOpaque( false );
    if ( XHtmlBuilder.isDebugLayout())
      comp.setBorder( new javax.swing.border.LineBorder( java.awt.Color.yellow, 2 ));
    cf.setParentComponent( comp );
  }
   
  /**
   * The closing tag has been parsed and now the element can calulate its complete setup
   * should it be dependant on its children for any information. In the case of a table,
   * the table determines the row and column count from the child elements and
   * cannot calculate its layout till all the children have been initially processed.
   * @param cf the component factory to use for the creation of individual components
   */
  public void endProcessing( XComponentFactory cf )
  {
    super.endProcessing( cf );
       
    Enumeration attribNames = attribSet.getAttributeNames();
    while ( attribNames.hasMoreElements()) {
      Object key = attribNames.nextElement();
      String attribName = key.toString();
      Object attribValue = attribSet.getAttribute( key );
     
      processCommonAttributes( attribName, attribValue );
    }
   
    // Force the form to fill the content area
    if ( attribSet.getAttribute( HTML.Attribute.WIDTH ) == null)
      attribSet.addAttribute( HTML.Attribute.WIDTH, "100%" );

    // Reset the parent component to its state prior to this call
    cf.setParentComponent( parentComponent );
  }
 
  /**
   * Does this tag break the flow?
   * @return true if the flow is broken, otherwsie false
   */
  public boolean breaksFlow()
  {
    return HTML.Tag.FORM.breaksFlow();
  }
}
TOP

Related Classes of net.xoetrope.builder.w3c.html.tags.Form

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.