/*
 * Copyright (c) 2008-2013 The Open Source Geospatial Foundation
 * 
 * Published under the BSD license.
 * See https://github.com/geoext/geoext2/blob/master/license.txt for the full
 * text of the license.
 */

Ext.require([
    'Ext.Window',
    'GeoExt.panel.Map',
    'GeoExt.data.MapfishPrintProvider',
    'GeoExt.panel.PrintMap'
]);

var mapPanel, printDialog, printProvider;


Ext.application({
    name: 'PrintPreviewGeoExt2',
    
    launch: function() {

	    // The PrintProvider that connects us to the print service
	    printProvider = Ext.create('GeoExt.data.MapfishPrintProvider', {
	        method: "GET", // "POST" recommended for production use
	        capabilities: printCapabilities, // provide url instead for lazy loading
	        customParams: {
	            mapTitle: "GeoExt Printing Demo",
	            comment: "This demo shows how to use GeoExt.PrintMapPanel"
	        }
	    });
	    
	    // A MapPanel with a "Print..." button
	    mapPanel = Ext.create('GeoExt.panel.Map', {
	        renderTo: "content",
	        width: 500,
	        height: 350,
	        map: {
	            maxExtent: new OpenLayers.Bounds(
	                143.835, -43.648,
	                148.479, -39.574
	            ),
	            maxResolution: 0.018140625,
	            projection: "EPSG:4326",
	            units: 'degrees'
	        },
	        layers: [new OpenLayers.Layer.WMS("Tasmania State Boundaries",
	            "http://demo.opengeo.org/geoserver/wms",
	            {layers: "topp:tasmania_state_boundaries"},
	            {singleTile: true
	             , numZoomLevels: 8
	            	})],
	        center: [146.56, -41.56],
	        zoom: 0,
	        bbar: [{
	            text: "Print...",
	            handler: function(){
	                // A window with the PrintMapPanel, which we can use to adjust
	                // the print extent before creating the pdf.
	                printDialog = Ext.create('Ext.Window', {
	                    title: "Print Preview",
	                    layout: "fit",
	                    width: 350,
	                    autoHeight: true,
	                    items: [{
	                        xtype: "gx_printmappanel",
	                        sourceMap: mapPanel,
	                        printProvider: printProvider
	                    }],
	                    bbar: [{
	                        text: "Create PDF",
	                        handler: function(){ printDialog.items.get(0).print(); }
	                    }]
	                });
	                printDialog.show();
	            }
	        }]
	    });
    }
});

@@ -908,21 +908,1173 @@
     %7D);%0A
-%09    
+%0A    var style = %7B%0A            strokeColor: '#000000',%0A            strokeWidth: 2,%0A            strokeOpacity: 1,%0A            fillColor: '#ee0000',%0A            fillOpacity: 1,%0A            pointRadius: 6,%0A            graphicName: 'circle',%0A        %7D,%0A        vecLayer = new OpenLayers.Layer.Vector(%22A Vector Layer%22, %7B%0A            styleMap: new OpenLayers.StyleMap(%7B%0A                %22default%22: style%0A            %7D)%0A        %7D),%0A        // Both Burnie and Devonport (cities in Tasmania) are styled throgh the%0A        // above stylemap%0A        burnie = new OpenLayers.Feature.Vector(%0A            new OpenLayers.Geometry.Point(145.875278, -41.063611)%0A        ),%0A        devonport = new OpenLayers.Feature.Vector(%0A            new OpenLayers.Geometry.Point(146.333333, -41.166667)%0A        ),%0A        // Hobart (the capital) gets inline style, this will also be printable%0A        hobart = new OpenLayers.Feature.Vector(%0A            new OpenLayers.Geometry.Point(147.325, -42.880556),%0A            null,%0A            Ext.applyIf(%7BgraphicName: 'square'%7D, style)%0A        );%0A        // Add the cities to the layer%0A        vecLayer.addFeatures(%5Bburnie, devonport, hobart%5D);%0A
 %0A%09    //
@@ -2519,16 +2519,30 @@
 ayers: %5B
+%0A%09            
 new Open
@@ -2558,16 +2558,34 @@
 yer.WMS(
+%0A%09                
 %22Tasmani
@@ -2618,16 +2618,20 @@
         
+   
+ 
 %22http://
@@ -2676,17 +2676,22 @@
         
-%7B
+    %7B 
 layers: 
@@ -2722,18 +2722,18 @@
 ndaries%22
+ 
 %7D
-,
 %0A%09      
@@ -2742,58 +2742,32 @@
     
-%7BsingleTile: true%0A%09             , numZoomLevels: 8
+),%0A%09            vecLayer
 %0A%09  
@@ -2776,15 +2776,8 @@
     
-    %09%7D)
 %5D,%0A%09
@@ -3156,16 +3156,16 @@
 eview%22,%0A
-
 %09       
@@ -3188,24 +3188,60 @@
 out: %22fit%22,%0A
+%09                    border: false,%0A
 %09           

Add a vector layer to printpreview example.