[jboss-cvs] jboss-seam/src/pdf/org/jboss/seam/pdf/ui ...

Norman Richards norman.richards at jboss.com
Mon Jan 15 01:42:04 EST 2007


  User: nrichards
  Date: 07/01/15 01:42:04

  Modified:    src/pdf/org/jboss/seam/pdf/ui    UIChapter.java
                        UISection.java UITitle.java
  Log:
  sections w/titles, depth
  
  Revision  Changes    Path
  1.6       +11 -19    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.5
  retrieving revision 1.6
  diff -u -b -r1.5 -r1.6
  --- UIChapter.java	14 Jan 2007 18:14:40 -0000	1.5
  +++ UIChapter.java	15 Jan 2007 06:42:04 -0000	1.6
  @@ -4,37 +4,29 @@
   import com.lowagie.text.*;
   
   public class UIChapter
  -    extends ITextComponent
  +    extends UISection
   {
       public static final String COMPONENT_TYPE   = "org.jboss.seam.pdf.ui.UIChapter";
       
  -    Chapter chapter;
  -    
       Integer number = 1;
       
  -    public void setNumber(Integer number) { 
  -        this.number = number;
  -    }
  -    
       public Chapter getChapter() {
  -        return chapter;
  +        return (Chapter) getSection();
       }
       
  -    public Object getITextObject() {
  -        return chapter;
  +    public void setNumber(Integer number) { 
  +        this.number = number;
       }
   
  -    public void removeITextObject() {
  -        chapter = null;
  +    public Object getITextObject() {
  +        return section; 
       }
   
  +    // removeITextObject, handleAdd set by parent
       
  +    @Override
       public void createITextObject(FacesContext context) {
           number = (Integer) valueBinding(context, "number", number);               
  -        chapter = new Chapter("",number);
  -    }
  -
  -    public void handleAdd(Object o) {
  -        chapter.add(o);
  +        section = new Chapter("",number);
       }
   }
  
  
  
  1.6       +36 -9     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.5
  retrieving revision 1.6
  diff -u -b -r1.5 -r1.6
  --- UISection.java	14 Jan 2007 18:14:40 -0000	1.5
  +++ UISection.java	15 Jan 2007 06:42:04 -0000	1.6
  @@ -9,26 +9,53 @@
       public static final String COMPONENT_TYPE   = "org.jboss.seam.pdf.ui.UISection";
   
       Section section;
  +    Integer numberDepth;
  +    
  +    public void setNumberDepth(Integer numberDepth) {
  +        this.numberDepth = numberDepth;
  +    }
  +    
  +    public Section getSection() {
  +        return section;
  +    }
       
       public Object getITextObject() {
           return null; // don't add to parent - already added.
  -        //return section;
       }
   
       public void removeITextObject() {
           section = null;
       }
   
  +    public void handleAdd(Object o) {
  +        section.add(o);
  +    }
  +    
       public void createITextObject(FacesContext context) {
  -        Chapter chapter = ((UIChapter)findITextParent(this, UIChapter.class)).getChapter();
  -        if (chapter == null) {
  -            throw new RuntimeException("section must have a parent chapter");
  +        UISection uiParent = (UISection)findITextParent(getParent(), UISection.class); 
  +        
  +        Section sectionParent = uiParent.getSection();
  +        if (sectionParent == null) {
  +            throw new RuntimeException("section must have a parent chapter/section");
           }
  -        section = chapter.addSection(new Paragraph("*fake title*"), 1);
  -        section.setTitle(new Paragraph("*section title*"));
  +        
  +        numberDepth = (Integer) valueBinding(context, "numberDepth", numberDepth);
  +        if (numberDepth == null) {
  +            numberDepth = countSectionParents(this, 0);
       }
   
  -    public void handleAdd(Object o) {
  -        section.add(o);
  +        section = sectionParent.addSection(new Paragraph(""), numberDepth);
  +    }
  +
  +    private int countSectionParents(UISection component, int level) {
  +        if (component == null) {
  +           return level;
  +        }
  +        return countSectionParents((UISection)findITextParent(component.getParent(), UISection.class),
  +                                   level+1);
  +    }
  +
  +    public void setTitle(Paragraph title) {
  +        section.setTitle(title);
       }
   }
  
  
  
  1.2       +4 -4      jboss-seam/src/pdf/org/jboss/seam/pdf/ui/UITitle.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: UITitle.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/pdf/org/jboss/seam/pdf/ui/UITitle.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -b -r1.1 -r1.2
  --- UITitle.java	14 Jan 2007 18:14:40 -0000	1.1
  +++ UITitle.java	15 Jan 2007 06:42:04 -0000	1.2
  @@ -27,12 +27,12 @@
               throw new RuntimeException("title must be a paragraph");
           }
           
  -        UIChapter chapter = (UIChapter) findITextParent(this,UIChapter.class);
  -        if (chapter == null) {
  -            throw new RuntimeException("cannot find parent chapter for title");
  +        UISection section = (UISection) findITextParent(this,UISection.class);
  +        if (section == null) {
  +            throw new RuntimeException("cannot find parent chapter/section for title");
           }
           
  -        chapter.getChapter().setTitle(paragraph);
  +        section.getSection().setTitle(paragraph);
       }
   
       @Override
  
  
  



More information about the jboss-cvs-commits mailing list