[Commits] r1790 - in sandbox/ahocevar/playground: trunk/geoext/tests/lib/GeoExt/widgets ux/Printing/examples ux/Printing/ux/widgets

commits at geoext.org commits at geoext.org
Thu Jan 21 10:15:47 CET 2010


Author: ahocevar
Date: 2010-01-21 10:15:47 +0100 (Thu, 21 Jan 2010)
New Revision: 1790

Modified:
   sandbox/ahocevar/playground/trunk/geoext/tests/lib/GeoExt/widgets/PrintExtent.html
   sandbox/ahocevar/playground/ux/Printing/examples/PrintPreview.js
   sandbox/ahocevar/playground/ux/Printing/ux/widgets/PrintPreview.js
Log:
PrintPreview api improvements; PrintExtent test fix

Modified: sandbox/ahocevar/playground/trunk/geoext/tests/lib/GeoExt/widgets/PrintExtent.html
===================================================================
--- sandbox/ahocevar/playground/trunk/geoext/tests/lib/GeoExt/widgets/PrintExtent.html	2010-01-20 19:33:51 UTC (rev 1789)
+++ sandbox/ahocevar/playground/trunk/geoext/tests/lib/GeoExt/widgets/PrintExtent.html	2010-01-21 09:15:47 UTC (rev 1790)
@@ -49,7 +49,7 @@
             t.ok(printExtent.pages[0].getCenter().equals(printExtent.map.getCenter()), "Print page centered to map center.");
             t.ok(printExtent.layer.map == mapPanel.map, "Auto-generated layer added to map.");
             t.eq(printExtent.layer.features.length, 5, "Extent and handle features added to the auto-generated layer.");
-            t.ok(printExtent.pages[0].feature.layer, printExtent.layer, "Extent feature was added to the layer.");
+            t.ok(printExtent.pages[0].feature.layer == printExtent.layer, "Extent feature was added to the layer.");
             t.ok(printExtent.control.map == mapPanel.map, "Control created and added to map.");
             
             mapPanel.remove(printExtent);
@@ -73,12 +73,14 @@
 
             var mapPanel = new GeoExt.MapPanel({
                 renderTo: "mappanel",
+                width: 256,
+                height: 256,
                 map: {controls: []},
                 center: [146.56, -41.56],
                 zoom: 7,
                 items: [printExtent]
             });
-            
+
             printExtent.destroy();
             
             t.eq(printExtent.layer, null, "layer destroyed.");
@@ -91,6 +93,5 @@
     </script>
   <body>
     <div id="mappanel"></div>
-    <div id="printmappanel"></div>
   </body>
 </html>

Modified: sandbox/ahocevar/playground/ux/Printing/examples/PrintPreview.js
===================================================================
--- sandbox/ahocevar/playground/ux/Printing/examples/PrintPreview.js	2010-01-20 19:33:51 UTC (rev 1789)
+++ sandbox/ahocevar/playground/ux/Printing/examples/PrintPreview.js	2010-01-21 09:15:47 UTC (rev 1790)
@@ -12,7 +12,7 @@
                 "http://demo.opengeo.org/geoserver/wms",
                 {layers: "topp:tasmania_water_bodies", transparent: true},
                 {buffer: 0})],
-        center: [146.56, -41.56],
+        center: [146.56, -41.7],
         zoom: 6,
         bbar: [{
             text: "Print...",
@@ -45,6 +45,7 @@
         resizable: false,
         width: 360,
         items: new GeoExt.ux.PrintPreview({
+            bodyStyle: "padding:5px",
             printProvider: {
                 // using get for remote service access without same origin
                 // restriction. For async requests, we would set method to "POST".
@@ -59,7 +60,6 @@
             },
             includeLegend: true,
             mapTitle: "PrintMapPanel Demo",
-            bodyStyle: "padding:5px",
             sourceMap: mapPanel,
             legend: legendPanel
         })

Modified: sandbox/ahocevar/playground/ux/Printing/ux/widgets/PrintPreview.js
===================================================================
--- sandbox/ahocevar/playground/ux/Printing/ux/widgets/PrintPreview.js	2010-01-20 19:33:51 UTC (rev 1789)
+++ sandbox/ahocevar/playground/ux/Printing/ux/widgets/PrintPreview.js	2010-01-21 09:15:47 UTC (rev 1790)
@@ -41,7 +41,9 @@
     
     /** api: config[printProvider]
      *  :class:`GeoExt.data.PrintProvider`|``Object`` Instance or
-     *  configuration for the PrintProvider that this dialog will use.
+     *  configuration for the PrintProvider that this dialog will use. Not
+     *  required if provided with the
+     *  :ref:`GeoExt.ux.PrintPreview.printMapPanel`.
      */
     
     /** private: property[printProvider]
@@ -51,7 +53,8 @@
     
     /** api: config[sourceMap]
      *  :class:`GeoExt.MapPanel`|``OpenLayers.Map`` The map to copy layers and
-     *  extent from for printing.
+     *  extent from for printing. Not required if provided with the
+     *  :ref:`GeoExt.ux.PrintPreview.printMapPanel`.
      */
 
     /** private: property[sourceMap]
@@ -59,6 +62,21 @@
      */
     sourceMap: null,
     
+    /** api: config[printMapPanel]
+     *  :class:`GeoExt.PrintMapPanel`:``Object`` Optional. Useful e.g.
+     *  for adding a ZoomSlider (via ``items``) or setting map options (like
+     *  configuring custom controls or filtering out unsupported layers with
+     *  a preaddlayer listener via ``map``).
+     *  
+     *  .. note:: If provided as :class:`GeoExt.PrintMapPanel`, this has to be
+     *       configured with ``printProvider`` and ``sourceMap``.
+     */
+    
+    /** api: property[printMapPanel]
+     *  class:`GeoExt.PrintMapPanel` The print preview map. Read-only.
+     */
+    printMapPanel: null,
+    
     /** api: config[mapTitleField]
      *  ``String`` The custom field of the print service for the map title
      */
@@ -93,13 +111,6 @@
      */
     comment: null,
     
-    /** api: config[mapOptions]
-     *  ``Object`` Configuration object for the preview map. Useful e.g. for
-     *  configuring custom controls, or filtering out unsupported layers with
-     *  a preaddlayer listener.
-     */
-    mapOptions: null,
-    
     /** api: config[addMapOverlay]
      *  ``Boolean`` Set to false if no map overlay with scale, scale selector
      *  and north arrow should be added. Default is true.
@@ -117,11 +128,6 @@
      */
     busyMask: null,
 
-    /** api: property[printMapPanel]
-     *  class:`GeoExt.PrintMapPanel` The print preview map.
-     */
-    printMapPanel: null,
-    
     /** private: property[form]
      *  ``Ext.form.FormPanel`` The form for this dialog.
      */
@@ -135,16 +141,21 @@
             cls: "x-panel-body"
         }, this.bodyCfg);
         
-        this.printMapPanel = new GeoExt.PrintMapPanel({
-            map: this.mapOptions,
+        var printMapPanelOptions = {
             sourceMap: this.sourceMap,
-            printProvider: this.printProvider,
-            listeners: {
-                "resize": this.updateSize,
-                scope: this
+            printProvider: this.printProvider
+        };
+        if(this.printMapPanel) {
+            if(!(this.printMapPanel instanceof GeoExt.PrintMapPanel)) {
+                printMapPanelOptions.xtype = "gx_printmappanel"
+                this.printMapPanel = new GeoExt.PrintMapPanel(
+                    Ext.applyIf(this.printMapPanel, printMapPanelOptions));
             }
-        });
-        this.sourceMap = this.printProvider.sourceMap;
+        } else {
+            this.printMapPanel = new GeoExt.PrintMapPanel(
+                printMapPanelOptions);
+        }
+        this.sourceMap = this.printMapPanel.sourceMap;
         this.printProvider = this.printMapPanel.printProvider;
         
         this.form = this.createForm();
@@ -156,6 +167,10 @@
         this.add(this.printMapPanel);
         this.addMapOverlay && this.printMapPanel.add(this.createMapOverlay());
 
+        this.printMapPanel.on({
+            "resize": this.updateSize,
+            scope: this
+        });
         this.on({
             "render": function() {
                 if (!this.busyMask) {
@@ -376,6 +391,7 @@
     beforeDestroy: function() {
         this.printProvider.un("beforeprint", this.busyMask.show, this.busyMask);
         this.printProvider.un("print", this.busyMask.hide, this.busyMask);
+        this.printMapPanel.un("resize", this.updateSize, this);
         GeoExt.ux.PrintPreview.superclass.beforeDestroy.apply(this, arguments);
     }
     



More information about the Commits mailing list