View Javadoc

1   /*
2    * EL4J, the Extension Library for the J2EE, adds incremental enhancements to
3    * the spring framework, http://el4j.sf.net
4    * Copyright (C) 2005 by ELCA Informatique SA, Av. de la Harpe 22-24,
5    * 1000 Lausanne, Switzerland, http://www.elca.ch
6    *
7    * EL4J is published under the GNU Lesser General Public License (LGPL)
8    * Version 2.1. See http://www.gnu.org/licenses/
9    *
10   * This program is distributed in the hope that it will be useful,
11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13   * GNU Lesser General Public License for more details.
14   *
15   * For alternative licensing, please contact info@elca.ch
16   */
17  package ch.elca.el4j.services.gui.swing.cookswing.designgridlayout;
18  
19  import org.w3c.dom.Element;
20  
21  import ch.elca.el4j.services.gui.swing.cookswing.binding.NoAddValueHolder;
22  
23  import net.java.dev.designgridlayout.DesignGridLayout;
24  import net.java.dev.designgridlayout.IRow;
25  
26  import cookxml.core.DecodeEngine;
27  import cookxml.core.interfaces.Creator;
28  
29  
30  /**
31   * A cookSwing creator for <row>s, rows inside a designgridlayout.
32   *
33   * @svnLink $Revision: 3883 $;$Date: 2009-08-04 15:35:01 +0200 (Di, 04. Aug 2009) $;$Author: swismer $;$URL: https://el4j.svn.sourceforge.net/svnroot/el4j/branches/el4j_3_1/el4j/framework/modules/swing/src/main/java/ch/elca/el4j/services/gui/swing/cookswing/designgridlayout/RowCreator.java $
34   *
35   * @author Stefan Wismer (SWI)
36   */
37  public class RowCreator implements Creator {
38  
39  	/** {@inheritDoc} */
40  	public Object create(String parentNS, String parentTag, Element elm,
41  		Object parentObj, DecodeEngine decodeEngine) throws Exception {
42  		
43  		if (parentObj == null || !(parentObj instanceof DesignGridLayout)) {
44  			return null;
45  		}
46  		
47  		// search for align attribute, which is required for row construction
48  		String align = elm.getAttribute("align");
49  		IRow row = null;
50  		if (align.equals("left")) {
51  			row = ((DesignGridLayout) parentObj).row().left();
52  		} else if (align.equals("right")) {
53  			row = ((DesignGridLayout) parentObj).row().right();
54  		} else if (align.equals("center")) {
55  			row = ((DesignGridLayout) parentObj).row().center();
56  		} else {
57  			// align="grid" or not set
58  			row = ((DesignGridLayout) parentObj).row().grid();
59  		}
60  		return new NoAddValueHolder<IRow>(row);
61  	}
62  
63  	/** {@inheritDoc} */
64  	public Object editFinished(String parentNS, String parentTag, Element elm,
65  		Object parentObj, Object obj, DecodeEngine decodeEngine)
66  		throws Exception {
67  		
68  		return obj;
69  	}
70  
71  }