[jboss-cvs] jboss-seam/src/pdf/org/jboss/seam/pdf/ui ...
Norman Richards
norman.richards at jboss.com
Sun Dec 31 19:27:49 EST 2006
User: nrichards
Date: 06/12/31 19:27:49
Modified: src/pdf/org/jboss/seam/pdf/ui
ITextComponent.java UIAnchor.java UICell.java
UIChapter.java UIDocument.java UIFont.java
UIImage.java UIList.java UIListItem.java
UIPage.java UIParagraph.java UISection.java
UITable.java
Log:
add basic facet support, use for default cell style
Revision Changes Path
1.4 +34 -9 jboss-seam/src/pdf/org/jboss/seam/pdf/ui/ITextComponent.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: ITextComponent.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/pdf/org/jboss/seam/pdf/ui/ITextComponent.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- ITextComponent.java 31 Dec 2006 06:50:05 -0000 1.3
+++ ITextComponent.java 1 Jan 2007 00:27:48 -0000 1.4
@@ -1,13 +1,15 @@
package org.jboss.seam.pdf.ui;
-
import javax.faces.*;
import javax.faces.context.*;
import javax.faces.component.*;
+
import java.io.*;
+import java.util.Collection;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
-import org.jboss.seam.pdf.ITextUtils;
import org.jboss.seam.ui.JSF;
import com.lowagie.text.*;
@@ -17,6 +19,8 @@
{
public static final String COMPONENT_FAMILY = "org.jboss.seam.pdf";
+ protected String inFacet;
+ protected Map<String,Object> facets = new HashMap<String,Object>();
/**
* get the current Itext object
@@ -32,11 +36,24 @@
* remove the itext objext
*/
abstract public void removeITextObject();
+
/**
- * subcomponents should implement this
+ * subcomponents should implement this to add child components
+ * to themselves
*/
- abstract public void add(Object other);
+ abstract public void handleAdd(Object other);
+
+ final public void add(Object other) {
+ if (inFacet != null) {
+ handleFacet(inFacet, other);
+ } else {
+ handleAdd(other);
+ }
+ }
+ public void handleFacet(String facetName, Object obj) {
+ facets.put(facetName,obj);
+ }
/**
* look up the tree for an itext font
@@ -98,6 +115,7 @@
}
+
// ------------------------------------------------------
@Override
@@ -134,6 +152,12 @@
public void encodeChildren(FacesContext context)
throws IOException
{
+ for (String name: (Collection<String>) this.getFacets().keySet()) {
+ inFacet = name;
+ encode(context, this.getFacet(name));
+ inFacet = null;
+ }
+
for (UIComponent child: (List<UIComponent>) this.getChildren()) {
// ugly hack to be able to capture facelets text
if (child.getFamily().equals("facelets.LiteralText")) {
@@ -190,6 +214,7 @@
}
+ @SuppressWarnings("unchecked")
public void encode(FacesContext context,
UIComponent component)
throws IOException,
1.3 +1 -1 jboss-seam/src/pdf/org/jboss/seam/pdf/ui/UIAnchor.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: UIAnchor.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/pdf/org/jboss/seam/pdf/ui/UIAnchor.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- UIAnchor.java 25 Dec 2006 16:17:54 -0000 1.2
+++ UIAnchor.java 1 Jan 2007 00:27:48 -0000 1.3
@@ -46,7 +46,7 @@
}
}
- public void add(Object o) {
+ public void handleAdd(Object o) {
anchor.add(o);
}
}
1.4 +16 -4 jboss-seam/src/pdf/org/jboss/seam/pdf/ui/UICell.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: UICell.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/pdf/org/jboss/seam/pdf/ui/UICell.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- UICell.java 31 Dec 2006 06:50:05 -0000 1.3
+++ UICell.java 1 Jan 2007 00:27:48 -0000 1.4
@@ -198,8 +198,12 @@
}
public void createITextObject() {
+ PdfPCell defaultCell = getDefaultCellFromTable();
+ if (defaultCell != null) {
+ cell = new PdfPCell(defaultCell);
+ } else {
cell = new PdfPCell();
-
+ }
if (horizontalAlignment != null) {
cell.setHorizontalAlignment(ITextUtils.alignmentValue(horizontalAlignment));
}
@@ -305,7 +309,15 @@
}
}
- public void add(Object o) {
+ private PdfPCell getDefaultCellFromTable() {
+ UITable parentTable = (UITable) findITextParent(this, UITable.class);
+ if (parentTable != null) {
+ return parentTable.getDefaultCellFacet();
+ }
+ return null;
+ }
+
+ public void handleAdd(Object o) {
if (o instanceof Element) {
cell.addElement((Element) o);
} else {
1.2 +1 -1 jboss-seam/src/pdf/org/jboss/seam/pdf/ui/UIChapter.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: UIChapter.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/pdf/org/jboss/seam/pdf/ui/UIChapter.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- UIChapter.java 25 Dec 2006 16:17:54 -0000 1.1
+++ UIChapter.java 1 Jan 2007 00:27:48 -0000 1.2
@@ -31,7 +31,7 @@
chapter = new Chapter("*chapter title*",1);
}
- public void add(Object o) {
+ public void handleAdd(Object o) {
chapter.add(o);
}
}
1.3 +1 -1 jboss-seam/src/pdf/org/jboss/seam/pdf/ui/UIDocument.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: UIDocument.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/pdf/org/jboss/seam/pdf/ui/UIDocument.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- UIDocument.java 25 Dec 2006 16:17:54 -0000 1.2
+++ UIDocument.java 1 Jan 2007 00:27:48 -0000 1.3
@@ -32,7 +32,7 @@
document = null;
}
- public void add(Object o) {
+ public void handleAdd(Object o) {
if (o instanceof Element) {
try {
document.add((Element) o);
1.3 +1 -1 jboss-seam/src/pdf/org/jboss/seam/pdf/ui/UIFont.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: UIFont.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/pdf/org/jboss/seam/pdf/ui/UIFont.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- UIFont.java 25 Dec 2006 16:17:54 -0000 1.2
+++ UIFont.java 1 Jan 2007 00:27:48 -0000 1.3
@@ -52,7 +52,7 @@
}
}
- public void add(Object o) {
+ public void handleAdd(Object o) {
addToITextParent(o);
}
}
1.4 +1 -1 jboss-seam/src/pdf/org/jboss/seam/pdf/ui/UIImage.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: UIImage.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/pdf/org/jboss/seam/pdf/ui/UIImage.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- UIImage.java 25 Dec 2006 16:17:54 -0000 1.3
+++ UIImage.java 1 Jan 2007 00:27:48 -0000 1.4
@@ -109,7 +109,7 @@
}
}
- public void add(Object o) {
+ public void handleAdd(Object o) {
throw new RuntimeException("can't add " + o.getClass().getName() + " to image");
//image.add(o);
}
1.4 +1 -1 jboss-seam/src/pdf/org/jboss/seam/pdf/ui/UIList.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: UIList.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/pdf/org/jboss/seam/pdf/ui/UIList.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- UIList.java 25 Dec 2006 16:17:54 -0000 1.3
+++ UIList.java 1 Jan 2007 00:27:48 -0000 1.4
@@ -81,7 +81,7 @@
}
}
- public void add(Object o) {
+ public void handleAdd(Object o) {
list.add(o);
}
}
1.3 +1 -1 jboss-seam/src/pdf/org/jboss/seam/pdf/ui/UIListItem.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: UIListItem.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/pdf/org/jboss/seam/pdf/ui/UIListItem.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- UIListItem.java 25 Dec 2006 16:17:54 -0000 1.2
+++ UIListItem.java 1 Jan 2007 00:27:48 -0000 1.3
@@ -28,7 +28,7 @@
listItem = null;
}
- public void add(Object o) {
+ public void handleAdd(Object o) {
listItem.add(o);
}
}
1.3 +1 -1 jboss-seam/src/pdf/org/jboss/seam/pdf/ui/UIPage.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: UIPage.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/pdf/org/jboss/seam/pdf/ui/UIPage.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- UIPage.java 25 Dec 2006 16:17:54 -0000 1.2
+++ UIPage.java 1 Jan 2007 00:27:48 -0000 1.3
@@ -26,7 +26,7 @@
}
- public void add(Object o) {
+ public void handleAdd(Object o) {
addToITextParent(o);
}
1.4 +1 -1 jboss-seam/src/pdf/org/jboss/seam/pdf/ui/UIParagraph.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: UIParagraph.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/pdf/org/jboss/seam/pdf/ui/UIParagraph.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- UIParagraph.java 25 Dec 2006 16:17:54 -0000 1.3
+++ UIParagraph.java 1 Jan 2007 00:27:48 -0000 1.4
@@ -113,7 +113,7 @@
}
}
- public void add(Object o) {
+ public void handleAdd(Object o) {
paragraph.add(o);
}
}
1.2 +1 -1 jboss-seam/src/pdf/org/jboss/seam/pdf/ui/UISection.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: UISection.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/pdf/org/jboss/seam/pdf/ui/UISection.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- UISection.java 25 Dec 2006 16:17:54 -0000 1.1
+++ UISection.java 1 Jan 2007 00:27:48 -0000 1.2
@@ -30,7 +30,7 @@
section.setTitle(new Paragraph("*section title*"));
}
- public void add(Object o) {
+ public void handleAdd(Object o) {
section.add(o);
}
}
1.3 +16 -3 jboss-seam/src/pdf/org/jboss/seam/pdf/ui/UITable.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: UITable.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/pdf/org/jboss/seam/pdf/ui/UITable.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- UITable.java 31 Dec 2006 06:50:05 -0000 1.2
+++ UITable.java 1 Jan 2007 00:27:48 -0000 1.3
@@ -1,5 +1,7 @@
package org.jboss.seam.pdf.ui;
+import org.jboss.seam.pdf.ITextUtils;
+
import com.lowagie.text.*;
import com.lowagie.text.pdf.*;
@@ -51,8 +53,8 @@
this.headersInEvent = headersInEvent;
}
- public void setHorizontalAlignment(Integer horizontalAlignment) {
- this.horizontalAlignment = horizontalAlignment;
+ public void setHorizontalAlignment(String horizontalAlignment) {
+ this.horizontalAlignment = ITextUtils.alignmentValue(horizontalAlignment);
}
public void setKeepTogether(Boolean keepTogether) {
@@ -170,7 +172,7 @@
return values;
}
- public void add(Object o) {
+ public void handleAdd(Object o) {
if (o instanceof PdfPCell) {
table.addCell((PdfPCell) o);
} else if (o instanceof PdfPTable) {
@@ -184,4 +186,15 @@
" to table");
}
}
+
+ public PdfPCell getDefaultCellFacet() {
+ Object facet = facets.get("defaultCell");
+ if (facet != null) {
+ if (!(facet instanceof PdfPCell)) {
+ throw new RuntimeException("UITable defaultCell facet must be a PdfPCell - found " + facet.getClass());
+ }
+ return (PdfPCell) facet;
+ }
+ return null;
+ }
}
More information about the jboss-cvs-commits
mailing list