package net.xoetrope.builder.w3c.html.tags;
import net.xoetrope.builder.w3c.html.XHtmlBuilder;
import java.util.Enumeration;
import javax.swing.text.MutableAttributeSet;
import net.xoetrope.swing.XComboBox;
import net.xoetrope.xui.XComponentFactory;
/**
* Processing for the html SELECT element
* <p> Copyright (c) Xoetrope Ltd., 2002-2006</p>
* <p> $Revision: 1.1 $</p>
* <p> License: see License.txt</p>
*/
public class Select extends XHtmlTagHandler
{
/**
* Creates a new instance of Select
*/
public Select()
{
}
/**
* 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 )
{
Select i = new Select();
i.setBuilder( builder );
i.setParent( parent );
return i;
}
/**
* 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 = new XComboBox();
parentComponent.add( comp );
//comp.setLayout( new FlowLayout());
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 );
if ( attribValue != null )
processCommonAttributes( attribName, attribValue );
}
// Reset the parent component to its state prior to this call
cf.setParentComponent( parentComponent );
}
/**
* Add a child element, possibly data such as when an option is added to a
* SELECT element.
* @param child the child element
* @return true if the item is added, false if further processing is required.
*/
public boolean addElement( XHtmlTagHandler child )
{
((XComboBox)comp).addItem( child.getContent());
return true;
}
}