← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3029: Reverted r 3021

 

------------------------------------------------------------
revno: 3029
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2011-03-14 20:36:08 +0100
message:
  Reverted r 3021
modified:
  dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/result/GridPdfResult.java


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/result/GridPdfResult.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/result/GridPdfResult.java	2011-03-14 05:45:16 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/result/GridPdfResult.java	2011-03-14 19:36:08 +0000
@@ -40,7 +40,6 @@
 import org.hisp.dhis.util.ContextUtils;
 
 import com.lowagie.text.Document;
-import com.lowagie.text.DocumentException;
 import com.lowagie.text.pdf.PdfPTable;
 import com.opensymphony.xwork2.ActionInvocation;
 import com.opensymphony.xwork2.Result;
@@ -60,7 +59,7 @@
     // -------------------------------------------------------------------------
 
     private Grid grid;
-
+    
     public void setGrid( Grid grid )
     {
         this.grid = grid;
@@ -79,8 +78,8 @@
         // ---------------------------------------------------------------------
 
         Grid _grid = (Grid) invocation.getStack().findValue( "grid" );
-
-        grid = _grid != null ? _grid : grid;
+        
+        grid = _grid != null ? _grid : grid; 
 
         // ---------------------------------------------------------------------
         // Configure response
@@ -90,36 +89,33 @@
 
         OutputStream out = response.getOutputStream();
 
-        String filename = CodecUtils.filenameEncode( StringUtils.defaultIfEmpty( grid.getTitle(), DEFAULT_FILENAME ) )
-            + ".pdf";
-
+        String filename = CodecUtils.filenameEncode( StringUtils.defaultIfEmpty( grid.getTitle(), DEFAULT_FILENAME ) ) + ".pdf";
+        
         ContextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_PDF, true, filename, false );
 
         // ---------------------------------------------------------------------
         // Write PDF to output stream
         // ---------------------------------------------------------------------
-
+        
         Document document = openDocument( out );
-
+        
         PdfPTable table = new PdfPTable( grid.getVisibleWidth() );
-
+        
         table.setHeaderRows( 1 );
-        table.setWidthPercentage( 100f );
-        table.setKeepTogether( false );
 
-        // TODO make wider
+        //TODO make wider
         table.addCell( getTitleCell( grid.getTitle(), grid.getVisibleWidth() ) );
         table.addCell( getEmptyCell( grid.getVisibleWidth(), 30 ) );
         table.addCell( getSubtitleCell( grid.getSubtitle(), grid.getVisibleWidth() ) );
         table.addCell( getEmptyCell( grid.getVisibleWidth(), 30 ) );
-
+        
         for ( GridHeader header : grid.getVisibleHeaders() )
         {
             table.addCell( getItalicCell( header.getName() ) );
         }
 
         table.addCell( getEmptyCell( grid.getVisibleWidth(), 10 ) );
-
+        
         for ( List<Object> row : grid.getVisibleRows() )
         {
             for ( Object col : row )
@@ -128,24 +124,8 @@
             }
         }
 
-        adjustColumnWitdh( grid, table );
-
         addTableToDocument( document, table );
 
         closeDocument( document );
     }
-
-    private void adjustColumnWitdh( Grid grid, PdfPTable table )
-        throws DocumentException
-    {
-        int numColumns = grid.getWidth();
-        float[] widths = new float[numColumns];
-        widths[0] = 2;
-
-        for ( int i = 1; i < numColumns; i++ )
-        {
-            widths[i] = 1;
-        }
-        table.setWidths( widths );
-    }
 }