org.metawidget.statically.jsp.html.layout.HtmlTableLayout Maven / Gradle / Ivy
// Metawidget
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package org.metawidget.statically.jsp.html.layout;
import java.util.Map;
import org.metawidget.layout.iface.AdvancedLayout;
import org.metawidget.layout.iface.LayoutException;
import org.metawidget.statically.StaticXmlMetawidget;
import org.metawidget.statically.StaticXmlStub;
import org.metawidget.statically.StaticXmlWidget;
import org.metawidget.statically.jsp.html.widgetbuilder.HtmlTag;
/**
* Layout to arrange widgets using an HTML table.
*
* @author Richard Kennard
*/
public class HtmlTableLayout
implements AdvancedLayout {
//
// Public methods
//
public void onStartBuild( StaticXmlMetawidget metawidget ) {
// Do nothing
}
public void startContainerLayout( StaticXmlWidget container, StaticXmlMetawidget metawidget ) {
try {
HtmlTag table = new HtmlTag( "table" );
container.getChildren().add( table );
} catch ( Exception e ) {
throw LayoutException.newException( e );
}
}
public void layoutWidget( StaticXmlWidget widget, String elementName, Map attributes, StaticXmlWidget container, StaticXmlMetawidget metawidget ) {
try {
// Ignore stubs
if ( widget instanceof StaticXmlStub ) {
return;
}
HtmlTag table = (HtmlTag) container.getChildren().get( 0 );
table.getChildren().add( widget );
} catch ( Exception e ) {
throw LayoutException.newException( e );
}
}
public void endContainerLayout( StaticXmlWidget container, StaticXmlMetawidget metawidget ) {
// Do nothing
}
public void onEndBuild( StaticXmlMetawidget metawidget ) {
// Do nothing
}
}