[seam-commits] Seam SVN: r11710 - in branches/community/Seam_2_2/src/pdf: org/jboss/seam/pdf and 1 other directories.
seam-commits at lists.jboss.org
seam-commits at lists.jboss.org
Tue Dec 1 14:18:09 EST 2009
Author: norman.richards at jboss.com
Date: 2009-12-01 14:18:09 -0500 (Tue, 01 Dec 2009)
New Revision: 11710
Added:
branches/community/Seam_2_2/src/pdf/org/jboss/seam/pdf/ui/UIMultiColumnText.java
Modified:
branches/community/Seam_2_2/src/pdf/META-INF/faces-config.xml
branches/community/Seam_2_2/src/pdf/META-INF/seam-pdf.taglib.xml
branches/community/Seam_2_2/src/pdf/org/jboss/seam/pdf/ITextUtils.java
Log:
JBSEAM-4493
Modified: branches/community/Seam_2_2/src/pdf/META-INF/faces-config.xml
===================================================================
--- branches/community/Seam_2_2/src/pdf/META-INF/faces-config.xml 2009-12-01 10:55:16 UTC (rev 11709)
+++ branches/community/Seam_2_2/src/pdf/META-INF/faces-config.xml 2009-12-01 19:18:09 UTC (rev 11710)
@@ -168,7 +168,11 @@
<component-class>org.jboss.seam.pdf.ui.UIForm</component-class>
</component>
-
+ <component>
+ <component-type>org.jboss.seam.pdf.ui.UIMultiColumnText</component-type>
+ <component-class>org.jboss.seam.pdf.ui.UIMultiColumnText</component-class>
+ </component>
+
<!--
<render-kit>
<render-kit-id>PDF</render-kit-id>
Modified: branches/community/Seam_2_2/src/pdf/META-INF/seam-pdf.taglib.xml
===================================================================
--- branches/community/Seam_2_2/src/pdf/META-INF/seam-pdf.taglib.xml 2009-12-01 10:55:16 UTC (rev 11709)
+++ branches/community/Seam_2_2/src/pdf/META-INF/seam-pdf.taglib.xml 2009-12-01 19:18:09 UTC (rev 11710)
@@ -237,4 +237,11 @@
</component>
</tag>
+ <tag>
+ <tag-name>textcolumn</tag-name>
+ <component>
+ <component-type>org.jboss.seam.pdf.ui.UIMultiColumnText</component-type>
+ </component>
+ </tag>
+
</facelet-taglib>
Modified: branches/community/Seam_2_2/src/pdf/org/jboss/seam/pdf/ITextUtils.java
===================================================================
--- branches/community/Seam_2_2/src/pdf/org/jboss/seam/pdf/ITextUtils.java 2009-12-01 10:55:16 UTC (rev 11709)
+++ branches/community/Seam_2_2/src/pdf/org/jboss/seam/pdf/ITextUtils.java 2009-12-01 19:18:09 UTC (rev 11710)
@@ -7,6 +7,7 @@
import com.lowagie.text.ElementTags;
import com.lowagie.text.PageSize;
import com.lowagie.text.Rectangle;
+import com.lowagie.text.pdf.PdfWriter;
public class ITextUtils
{
@@ -129,4 +130,19 @@
return values;
}
+
+ public static int runDirection(String direction)
+ {
+ if (direction == null || direction.equalsIgnoreCase("default")) {
+ return PdfWriter.RUN_DIRECTION_DEFAULT;
+ } else if (direction.equalsIgnoreCase("rtl")) {
+ return PdfWriter.RUN_DIRECTION_RTL;
+ } else if (direction.equalsIgnoreCase("ltr")) {
+ return PdfWriter.RUN_DIRECTION_LTR;
+ } else if (direction.equalsIgnoreCase("no-bidi")) {
+ return PdfWriter.RUN_DIRECTION_NO_BIDI;
+ } else {
+ throw new RuntimeException("unknown run direction " + direction);
+ }
+ }
}
Added: branches/community/Seam_2_2/src/pdf/org/jboss/seam/pdf/ui/UIMultiColumnText.java
===================================================================
--- branches/community/Seam_2_2/src/pdf/org/jboss/seam/pdf/ui/UIMultiColumnText.java (rev 0)
+++ branches/community/Seam_2_2/src/pdf/org/jboss/seam/pdf/ui/UIMultiColumnText.java 2009-12-01 19:18:09 UTC (rev 11710)
@@ -0,0 +1,92 @@
+package org.jboss.seam.pdf.ui;
+
+import java.io.IOException;
+
+import javax.faces.context.FacesContext;
+
+import org.jboss.seam.pdf.ITextUtils;
+
+import com.lowagie.text.DocumentException;
+import com.lowagie.text.Element;
+import com.lowagie.text.PageSize;
+import com.lowagie.text.pdf.MultiColumnText;
+
+
+public class UIMultiColumnText
+ extends ITextComponent
+{
+
+ float left = 36;
+ float right = PageSize.LETTER.getWidth()-36;
+ String direction = "default";
+
+ MultiColumnText multiColumnText = null;
+
+
+ public float getLeft()
+ {
+ return (Float) valueBinding("left", left);
+ }
+
+ public void setLeft(float left)
+ {
+ this.left = left;
+ }
+
+ public float getRight()
+ {
+ return (Float) valueBinding("right", right);
+ }
+
+ public void setRight(float right)
+ {
+ this.right = right;
+ }
+
+ public String getDirection()
+ {
+ return (String) valueBinding("direction", direction);
+ }
+
+ public void setDirection(String direction)
+ {
+ this.direction = direction;
+ }
+
+ @Override
+ public void createITextObject(FacesContext context) throws IOException, DocumentException
+ {
+ multiColumnText = new MultiColumnText();
+
+ multiColumnText.addSimpleColumn(getLeft(), getRight());
+ multiColumnText.setRunDirection(ITextUtils.runDirection(getDirection()));
+ }
+
+ @Override
+ public Object getITextObject()
+ {
+ return multiColumnText;
+ }
+
+ @Override
+ public void handleAdd(Object other)
+ {
+ if (other instanceof Element) {
+ try {
+ multiColumnText.addElement((Element)other);
+ } catch (DocumentException e) {
+ throw new RuntimeException(e);
+ }
+ } else {
+ throw new RuntimeException("UIMultiColumnText only supports Element children");
+ }
+
+ }
+
+ @Override
+ public void removeITextObject()
+ {
+ multiColumnText = null;
+ }
+
+}
More information about the seam-commits
mailing list