[Commits] r1853 - in sandbox/ahocevar/playground: . geoext/examples geoext/lib/GeoExt/plugins

commits at geoext.org commits at geoext.org
Sun Jan 31 19:23:58 CET 2010


Author: ahocevar
Date: 2010-01-31 19:23:57 +0100 (Sun, 31 Jan 2010)
New Revision: 1853

Added:
   sandbox/ahocevar/playground/geoext/
   sandbox/ahocevar/playground/geoext/examples/print-extent.html
   sandbox/ahocevar/playground/geoext/examples/print-form.js
   sandbox/ahocevar/playground/geoext/lib/GeoExt/plugins/PrintPageField.js
   sandbox/ahocevar/playground/geoext/lib/GeoExt/plugins/PrintProviderField.js
Removed:
   sandbox/ahocevar/playground/geoext/examples/print-extent.html
   sandbox/ahocevar/playground/geoext/examples/print-form.js
   sandbox/ahocevar/playground/geoext/lib/GeoExt/plugins/PrintPageField.js
   sandbox/ahocevar/playground/geoext/lib/GeoExt/plugins/PrintProviderField.js
   sandbox/ahocevar/playground/trunk/
   sandbox/ahocevar/playground/ux/
Modified:
   sandbox/ahocevar/playground/
Log:
changed for new ux structure


Property changes on: sandbox/ahocevar/playground
___________________________________________________________________
Name: svn:externals
   + ext http://www.geoext.org/svn/geoext/ext/2.2.1


Copied: sandbox/ahocevar/playground/geoext (from rev 1845, sandbox/ahocevar/playground/trunk/geoext)

Deleted: sandbox/ahocevar/playground/geoext/examples/print-extent.html
===================================================================
--- sandbox/ahocevar/playground/trunk/geoext/examples/print-extent.html	2010-01-31 13:39:51 UTC (rev 1845)
+++ sandbox/ahocevar/playground/geoext/examples/print-extent.html	2010-01-31 18:23:57 UTC (rev 1853)
@@ -1,35 +0,0 @@
-<html>
-    <head>
-        <title>GeoExt PrintExtent Example</title>
-
-        <script type="text/javascript" src="http://extjs.cachefly.net/ext-2.2.1/adapter/ext/ext-base.js"></script>
-        <script type="text/javascript" src="http://extjs.cachefly.net/ext-2.2.1/ext-all.js"></script>
-        <link rel="stylesheet" type="text/css" href="http://extjs.cachefly.net/ext-2.2.1/resources/css/ext-all.css" />
-        <link rel="stylesheet" type="text/css" href="http://extjs.cachefly.net/ext-2.2.1/examples/shared/examples.css" />
-        <script src="../../../trunk/openlayers/lib/OpenLayers.js"></script>
-        <script type="text/javascript" src="../lib/GeoExt.js"></script>
-
-        <script type="text/javascript" src="print-extent.js"></script>
-        
-        <!-- The script below will load the capabilities of the print service
-             and save them into the global printCapabilities variable. Instead
-             of this, the PrintProvider can be configured with a url and take
-             care of fetching the capabilities. -->
-        <script type="text/javascript" src="http://demo.opengeo.org/geoserver/pdf/info.json?var=printCapabilities"></script>
-
-    </head>
-    <body>
-        <h1>Setting the Print Extent on the Map Interactively</h1>
-        <p>This example shows the how to set the bounds of a printable PDF
-        interactively with a dynamic print extent rectangle. It requires
-        the <a href="http://trac.mapfish.org/trac/mapfish/wiki/PrintModuleInstallation">MapFish</a>
-        or <a href="http://geoserver.org/display/GEOS/Printing+2.0+HOWTO">GeoServer</a>
-        print module.</p>
-        <p>Drag one of the handles to control the scale. Grab one of the
-        corner handles at its edge to rotate the extent. Hold the SHIFT key to
-        rotate in 45° increments only. Drag the extent rectangle to change the
-        center.</p>
-        <p>The js is not minified so it is readable. See <a href="print-extent.js">print-extent.js</a>.</p>
-        <div id="content"></div>
-    </body>
-</html>

Copied: sandbox/ahocevar/playground/geoext/examples/print-extent.html (from rev 1850, sandbox/ahocevar/playground/trunk/geoext/examples/print-extent.html)
===================================================================
--- sandbox/ahocevar/playground/geoext/examples/print-extent.html	                        (rev 0)
+++ sandbox/ahocevar/playground/geoext/examples/print-extent.html	2010-01-31 18:23:57 UTC (rev 1853)
@@ -0,0 +1,35 @@
+<html>
+    <head>
+        <title>GeoExt PrintExtent Example</title>
+
+        <script type="text/javascript" src="http://extjs.cachefly.net/ext-2.2.1/adapter/ext/ext-base.js"></script>
+        <script type="text/javascript" src="http://extjs.cachefly.net/ext-2.2.1/ext-all.js"></script>
+        <link rel="stylesheet" type="text/css" href="http://extjs.cachefly.net/ext-2.2.1/resources/css/ext-all.css" />
+        <link rel="stylesheet" type="text/css" href="http://extjs.cachefly.net/ext-2.2.1/examples/shared/examples.css" />
+        <script src="http://www.openlayers.org/dev/OpenLayers.js"></script>
+        <script type="text/javascript" src="../lib/GeoExt.js"></script>
+
+        <script type="text/javascript" src="print-extent.js"></script>
+        
+        <!-- The script below will load the capabilities of the print service
+             and save them into the global printCapabilities variable. Instead
+             of this, the PrintProvider can be configured with a url and take
+             care of fetching the capabilities. -->
+        <script type="text/javascript" src="http://demo.opengeo.org/geoserver/pdf/info.json?var=printCapabilities"></script>
+
+    </head>
+    <body>
+        <h1>Setting the Print Extent on the Map Interactively</h1>
+        <p>This example shows the how to set the bounds of a printable PDF
+        interactively with a dynamic print extent rectangle. It requires
+        the <a href="http://trac.mapfish.org/trac/mapfish/wiki/PrintModuleInstallation">MapFish</a>
+        or <a href="http://geoserver.org/display/GEOS/Printing+2.0+HOWTO">GeoServer</a>
+        print module.</p>
+        <p>Drag one of the handles to control the scale. Grab one of the
+        corner handles at its edge to rotate the extent. Hold the SHIFT key to
+        rotate in 45° increments only. Drag the extent rectangle to change the
+        center.</p>
+        <p>The js is not minified so it is readable. See <a href="print-extent.js">print-extent.js</a>.</p>
+        <div id="content"></div>
+    </body>
+</html>

Deleted: sandbox/ahocevar/playground/geoext/examples/print-form.js
===================================================================
--- sandbox/ahocevar/playground/trunk/geoext/examples/print-form.js	2010-01-31 13:39:51 UTC (rev 1845)
+++ sandbox/ahocevar/playground/geoext/examples/print-form.js	2010-01-31 18:23:57 UTC (rev 1853)
@@ -1,131 +0,0 @@
- /**
- * Copyright (c) 2008-2009 The Open Source Geospatial Foundation
- * 
- * Published under the BSD license.
- * See http://svn.geoext.org/core/trunk/geoext/license.txt for the full text
- * of the license.
- */
-
-/** api: example[print-form]
- *  Advanced Printing with a Form
- *  -----------------------------
- *  Using form fields with PrintPageField and PrintProviderField plugins to
- *  control print output.
- */
-
-var mapPanel, printPage;
-
-Ext.onReady(function() {
-    // The printProvider that connects us to the print service
-    var printProvider = new GeoExt.data.PrintProvider({
-        method: "GET", // "POST" recommended for production use
-        capabilities: printCapabilities // from the info.json script in the html
-    });
-    // Our print page. Stores scale, center and rotation and gives us a page
-    // extent feature that we can add to a layer.
-    printPage = new GeoExt.data.PrintPage({
-        printProvider: printProvider,
-        customParams: {
-            mapTitle: "Printing Demo"
-        }
-    });
-    // A layer to display the print page extent
-    var pageLayer = new OpenLayers.Layer.Vector();
-    pageLayer.addFeatures(printPage.feature);
-
-    // The map we want to print
-    mapPanel = new GeoExt.MapPanel({
-        region: "center",
-        map: {
-            eventListeners: {
-                // recenter/resize page extent after pan/zoom
-                "moveend": function(){ printPage.fit(this); }
-            }
-        },
-        layers: [
-            new OpenLayers.Layer.WMS("Tasmania", "http://demo.opengeo.org/geoserver/wms",
-                {layers: "topp:tasmania_state_boundaries"}, {singleTile: true}),
-            pageLayer
-        ],
-        center: [146.56, -41.56],
-        zoom: 6
-    });
-    // The form with fields controlling the print output
-    var formPanel = new GeoExt.form.FormPanel({
-        region: "west",
-        width: 150,
-        bodyStyle: "padding:5px",
-        labelAlign: "top",
-        defaults: {anchor: "100%"},
-        items: [{
-            xtype: "textarea",
-            name: "comment",
-            value: "",
-            fieldLabel: "Comment",
-            plugins: new GeoExt.plugins.PrintPageField({
-                printPage: printPage
-            })
-        }, {
-            xtype: "combo",
-            store: printProvider.layouts,
-            displayField: "name",
-            fieldLabel: "Layout",
-            typeAhead: true,
-            mode: "local",
-            triggerAction: "all",
-            plugins: new GeoExt.plugins.PrintProviderField({
-                printProvider: printProvider
-            })
-        }, {
-            xtype: "combo",
-            store: printProvider.dpis,
-            displayField: "name",
-            fieldLabel: "Resolution",
-            tpl: '<tpl for="."><div class="x-combo-list-item">{name} dpi</div></tpl>',
-            typeAhead: true,
-            mode: "local",
-            triggerAction: "all",
-            plugins: new GeoExt.plugins.PrintProviderField({
-                printProvider: printProvider
-            }),
-            // the plugin will work even if we modify a combo value
-            setValue: function(v) {
-                v = parseInt(v) + " dpi";
-                Ext.form.ComboBox.prototype.setValue.apply(this, arguments);
-            }
-        }, {
-            xtype: "combo",
-            store: printProvider.scales,
-            displayField: "name",
-            fieldLabel: "Scale",
-            typeAhead: true,
-            mode: "local",
-            triggerAction: "all",
-            plugins: new GeoExt.plugins.PrintPageField({
-                printPage: printPage
-            })
-        }, {
-            xtype: "textfield",
-            name: "rotation",
-            fieldLabel: "Rotation",
-            plugins: new GeoExt.plugins.PrintPageField({
-                printPage: printPage
-            })
-        }],
-        buttons: [{
-            text: "Create PDF",
-            handler: function() {
-                printProvider.print(mapPanel, printPage);
-            }
-        }]
-    });
-     
-    // The main panel
-    new Ext.Panel({
-        renderTo: "content",
-        layout: "border",
-        width: 700,
-        height: 420,
-        items: [mapPanel, formPanel]
-    });
-});

Copied: sandbox/ahocevar/playground/geoext/examples/print-form.js (from rev 1852, sandbox/ahocevar/playground/trunk/geoext/examples/print-form.js)
===================================================================
--- sandbox/ahocevar/playground/geoext/examples/print-form.js	                        (rev 0)
+++ sandbox/ahocevar/playground/geoext/examples/print-form.js	2010-01-31 18:23:57 UTC (rev 1853)
@@ -0,0 +1,131 @@
+ /**
+ * Copyright (c) 2008-2009 The Open Source Geospatial Foundation
+ * 
+ * Published under the BSD license.
+ * See http://svn.geoext.org/core/trunk/geoext/license.txt for the full text
+ * of the license.
+ */
+
+/** api: example[print-form]
+ *  Advanced Printing with a Form
+ *  -----------------------------
+ *  Using form fields with PrintPageField and PrintProviderField plugins to
+ *  control print output.
+ */
+
+var mapPanel, printPage;
+
+Ext.onReady(function() {
+    // The printProvider that connects us to the print service
+    var printProvider = new GeoExt.data.PrintProvider({
+        method: "GET", // "POST" recommended for production use
+        capabilities: printCapabilities // from the info.json script in the html
+    });
+    // Our print page. Stores scale, center and rotation and gives us a page
+    // extent feature that we can add to a layer.
+    printPage = new GeoExt.data.PrintPage({
+        printProvider: printProvider,
+        customParams: {
+            mapTitle: "Printing Demo"
+        }
+    });
+    // A layer to display the print page extent
+    var pageLayer = new OpenLayers.Layer.Vector();
+    pageLayer.addFeatures(printPage.feature);
+
+    // The map we want to print
+    mapPanel = new GeoExt.MapPanel({
+        region: "center",
+        map: {
+            eventListeners: {
+                // recenter/resize page extent after pan/zoom
+                "moveend": function(){ printPage.fit(this); }
+            }
+        },
+        layers: [
+            new OpenLayers.Layer.WMS("Tasmania", "http://demo.opengeo.org/geoserver/wms",
+                {layers: "topp:tasmania_state_boundaries"}, {singleTile: true}),
+            pageLayer
+        ],
+        center: [146.56, -41.56],
+        zoom: 6
+    });
+    // The form with fields controlling the print output
+    var formPanel = new Ext.form.FormPanel({
+        region: "west",
+        width: 150,
+        bodyStyle: "padding:5px",
+        labelAlign: "top",
+        defaults: {anchor: "100%"},
+        items: [{
+            xtype: "textarea",
+            name: "comment",
+            value: "",
+            fieldLabel: "Comment",
+            plugins: new GeoExt.plugins.PrintPageField({
+                printPage: printPage
+            })
+        }, {
+            xtype: "combo",
+            store: printProvider.layouts,
+            displayField: "name",
+            fieldLabel: "Layout",
+            typeAhead: true,
+            mode: "local",
+            triggerAction: "all",
+            plugins: new GeoExt.plugins.PrintProviderField({
+                printProvider: printProvider
+            })
+        }, {
+            xtype: "combo",
+            store: printProvider.dpis,
+            displayField: "name",
+            fieldLabel: "Resolution",
+            tpl: '<tpl for="."><div class="x-combo-list-item">{name} dpi</div></tpl>',
+            typeAhead: true,
+            mode: "local",
+            triggerAction: "all",
+            plugins: new GeoExt.plugins.PrintProviderField({
+                printProvider: printProvider
+            }),
+            // the plugin will work even if we modify a combo value
+            setValue: function(v) {
+                v = parseInt(v) + " dpi";
+                Ext.form.ComboBox.prototype.setValue.apply(this, arguments);
+            }
+        }, {
+            xtype: "combo",
+            store: printProvider.scales,
+            displayField: "name",
+            fieldLabel: "Scale",
+            typeAhead: true,
+            mode: "local",
+            triggerAction: "all",
+            plugins: new GeoExt.plugins.PrintPageField({
+                printPage: printPage
+            })
+        }, {
+            xtype: "textfield",
+            name: "rotation",
+            fieldLabel: "Rotation",
+            plugins: new GeoExt.plugins.PrintPageField({
+                printPage: printPage
+            })
+        }],
+        buttons: [{
+            text: "Create PDF",
+            handler: function() {
+                printProvider.print(mapPanel, printPage);
+            }
+        }]
+    });
+     
+    // The main panel
+    new Ext.Panel({
+        renderTo: "content",
+        layout: "border",
+        width: 700,
+        height: 420,
+        items: [mapPanel, formPanel]
+    });
+});

Deleted: sandbox/ahocevar/playground/geoext/lib/GeoExt/plugins/PrintPageField.js
===================================================================
--- sandbox/ahocevar/playground/trunk/geoext/lib/GeoExt/plugins/PrintPageField.js	2010-01-31 13:39:51 UTC (rev 1845)
+++ sandbox/ahocevar/playground/geoext/lib/GeoExt/plugins/PrintPageField.js	2010-01-31 18:23:57 UTC (rev 1853)
@@ -1,180 +0,0 @@
-/**
- * Copyright (c) 2008-2009 The Open Source Geospatial Foundation
- * 
- * Published under the BSD license.
- * See http://svn.geoext.org/core/trunk/geoext/license.txt for the full text
- * of the license.
- */
-Ext.namespace("GeoExt.plugins");
-
-/** api: (define)
- *  module = GeoExt.plugins
- *  class = PrintPageField
- *  base_link = `Ext.util.Observable <http://extjs.com/deploy/dev/docs/?class=Ext.util.Observable>`_
- */
-
-/** api: example
- *  A form with a combo box for the scale and text fields for rotation and a
- *  page title. The page title is a custom parameter of the print module's
- *  page configuration:
- * 
- *  .. code-block:: javascript
- *     
- *      var printPage = new GeoExt.data.PrintPage({
- *          printProvider: new GeoExt.data.PrintProvider({
- *              capabilities: printCapabilities
- *          })
- *      });
- *      new Ext.form.FormPanel({
- *          renderTo: "form",
- *          width: 200,
- *          height: 300,
- *          items: [{
- *              xtype: "combo",
- *              displayField: "name",
- *              store: printPage.scales, // printPage.scale
- *              fieldLabel: "Scale",
- *              typeAhead: true,
- *              mode: "local",
- *              forceSelection: true,
- *              triggerAction: "all",
- *              selectOnFocus: true,
- *              plugins: new GeoExt.plugins.PrintPageField({
- *                  printPage: printPage
- *              })
- *          }, {
- *              xtype: "textfield",
- *              name: "rotation", // printPage.rotation
- *              fieldLabel: "Rotation",
- *              plugins: new GeoExt.plugins.PrintPageField({
- *                  printPage: printPage
- *              })
- *          }, {
- *              xtype: "textfield",
- *              name: "mapTitle", // printPage.customParams["mapTitle"]
- *              fieldLabel: "Map Title",
- *              plugins: new GeoExt.plugins.PrintPageField({
- *                  printPage: printPage
- *              })
- *          }]
- *      }):
- */
-
-/** api: constructor
- *  .. class:: PrintPageField
- * 
- *  A plugin for ``Ext.form.Field`` components which provides synchronization
- *  with a :class:`GeoExt.data.PrintPage`.
- */
-GeoExt.plugins.PrintPageField = Ext.extend(Ext.util.Observable, {
-    
-    /** api: config[printPage]
-     *  ``GeoExt.data.PrintPage`` The print page to synchronize with.
-     */
-
-    /** private: property[printPage]
-     *  ``GeoExt.data.PrintPage`` The print page to synchronize with.
-     *  Read-only.
-     */
-    printPage: null,
-    
-    /** private: property[target]
-     *  ``Ext.form.Field`` This plugin's target field.
-     */
-    target: null,
-    
-    /** private: method[constructor]
-     */
-    constructor: function(config) {
-        this.initialConfig = config;
-        Ext.apply(this, config);
-        
-        GeoExt.plugins.PrintPageField.superclass.constructor.apply(this, arguments);
-    },
-    
-    /** private: method[init]
-     *  :param target: ``Ext.form.Field`` The component that this plugin
-     *      extends.
-     * @param {Object} target
-     */
-    init: function(target) {
-        this.target = target;
-        onCfg = {scope: this};
-        onCfg[target instanceof Ext.form.ComboBox ? "select" : "valid"] =
-            this.onFieldChange;
-        target.on(onCfg);
-        this.printPage.on({
-            "change": this.onPageChange,
-            scope: this
-        });
-        this.printPage.printProvider.on({
-            "layoutchange": this.onLayoutChange,
-            scope: this
-        });
-    },
-
-    /** private: method[onFieldChange]
-     *  :param field: ``Ext.form.Field``
-     *  :param record: ``Ext.data.Record`` Optional.
-     *  
-     *  Handler for the target field's "valid" or "select" event.
-     */
-    onFieldChange: function(field, record) {
-        var printProvider = this.printPage.printProvider;
-        var value = field.getValue();
-        this._updating = true;
-        if(field.store === printProvider.scales) {
-            this.printPage.setScale(record);
-        } else if(field.name == "rotation") {
-            !isNaN(value) && this.printPage.setRotation(value);
-        } else {
-            this.printPage.customParams[field.name] = value;
-        }
-        delete this._updating;
-    },
-
-    /** private: method[onPageChange]
-     *  :param printPage: :class:`GeoExt.data.PrintPage`
-     *  
-     *  Handler for the "change" event for the page this plugin is configured
-     *  with.
-     */
-    onPageChange: function(printPage) {
-        if(!this._updating) {
-            var t = this.target;
-            t.suspendEvents();
-            if(t.store === printPage.printProvider.scales) {
-                t.setValue(printPage.scale.get(t.displayField));
-            } else if(t.name == "rotation") {
-                t.setValue(printPage.rotation);
-            }
-            t.resumeEvents();
-        }
-    },
-    
-    /** private: method[onPageChange]
-     *  :param printProvider: :class:`GeoExt.data.PrintProvider`
-     *  :param layout: ``Ext.Record``
-     *  
-     *  Handler for the "layoutchange" event of the printProvider.
-     */
-    onLayoutChange: function(printProvider, layout) {
-        var t = this.target;
-        t.name == "rotation" && t.setDisabled(!layout.get("rotation"));
-    },
-    
-    /** private: method[destroy]
-     */
-    destroy: function() {
-        this.target.un("select", this.onFieldChange, this);
-        this.target.un("valid", this.onFieldChange, this);
-        this.printPage.un("change", this.onPageChange, this);
-        this.printPage.printProvider.un("layoutchange", this.onLayoutChange,
-            this);
-        GeoExt.plugins.PrintPageField.superclass.destroy.apply(this, arguments);
-    }
-
-});
-
-/** api: ptype = gx_printpagefield */
-Ext.preg && Ext.preg("gx_printpagefield", GeoExt.plugins.PrintPageField);

Copied: sandbox/ahocevar/playground/geoext/lib/GeoExt/plugins/PrintPageField.js (from rev 1852, sandbox/ahocevar/playground/trunk/geoext/lib/GeoExt/plugins/PrintPageField.js)
===================================================================
--- sandbox/ahocevar/playground/geoext/lib/GeoExt/plugins/PrintPageField.js	                        (rev 0)
+++ sandbox/ahocevar/playground/geoext/lib/GeoExt/plugins/PrintPageField.js	2010-01-31 18:23:57 UTC (rev 1853)
@@ -0,0 +1,179 @@
+/**
+ * Copyright (c) 2008-2009 The Open Source Geospatial Foundation
+ * 
+ * Published under the BSD license.
+ * See http://svn.geoext.org/core/trunk/geoext/license.txt for the full text
+ * of the license.
+ */
+Ext.namespace("GeoExt.plugins");
+
+/** api: (define)
+ *  module = GeoExt.plugins
+ *  class = PrintPageField
+ *  base_link = `Ext.util.Observable <http://extjs.com/deploy/dev/docs/?class=Ext.util.Observable>`_
+ */
+
+/** api: example
+ *  A form with a combo box for the scale and text fields for rotation and a
+ *  page title. The page title is a custom parameter of the print module's
+ *  page configuration:
+ * 
+ *  .. code-block:: javascript
+ *     
+ *      var printPage = new GeoExt.data.PrintPage({
+ *          printProvider: new GeoExt.data.PrintProvider({
+ *              capabilities: printCapabilities
+ *          })
+ *      });
+ *      new Ext.form.FormPanel({
+ *          renderTo: "form",
+ *          width: 200,
+ *          height: 300,
+ *          items: [{
+ *              xtype: "combo",
+ *              displayField: "name",
+ *              store: printPage.scales, // printPage.scale
+ *              fieldLabel: "Scale",
+ *              typeAhead: true,
+ *              mode: "local",
+ *              forceSelection: true,
+ *              triggerAction: "all",
+ *              selectOnFocus: true,
+ *              plugins: new GeoExt.plugins.PrintPageField({
+ *                  printPage: printPage
+ *              })
+ *          }, {
+ *              xtype: "textfield",
+ *              name: "rotation", // printPage.rotation
+ *              fieldLabel: "Rotation",
+ *              plugins: new GeoExt.plugins.PrintPageField({
+ *                  printPage: printPage
+ *              })
+ *          }, {
+ *              xtype: "textfield",
+ *              name: "mapTitle", // printPage.customParams["mapTitle"]
+ *              fieldLabel: "Map Title",
+ *              plugins: new GeoExt.plugins.PrintPageField({
+ *                  printPage: printPage
+ *              })
+ *          }]
+ *      }):
+ */
+
+/** api: constructor
+ *  .. class:: PrintPageField
+ * 
+ *  A plugin for ``Ext.form.Field`` components which provides synchronization
+ *  with a :class:`GeoExt.data.PrintPage`.
+ */
+GeoExt.plugins.PrintPageField = Ext.extend(Ext.util.Observable, {
+    
+    /** api: config[printPage]
+     *  ``GeoExt.data.PrintPage`` The print page to synchronize with.
+     */
+
+    /** private: property[printPage]
+     *  ``GeoExt.data.PrintPage`` The print page to synchronize with.
+     *  Read-only.
+     */
+    printPage: null,
+    
+    /** private: property[target]
+     *  ``Ext.form.Field`` This plugin's target field.
+     */
+    target: null,
+    
+    /** private: method[constructor]
+     */
+    constructor: function(config) {
+        this.initialConfig = config;
+        Ext.apply(this, config);
+        
+        GeoExt.plugins.PrintPageField.superclass.constructor.apply(this, arguments);
+    },
+    
+    /** private: method[init]
+     *  :param target: ``Ext.form.Field`` The component that this plugin
+     *      extends.
+     * @param {Object} target
+     */
+    init: function(target) {
+        this.target = target;
+        onCfg = {scope: this};
+        onCfg[target instanceof Ext.form.ComboBox ? "select" : "valid"] =
+            this.onFieldChange;
+        target.on(onCfg);
+        this.printPage.on({
+            "change": this.onPageChange,
+            scope: this
+        });
+        this.printPage.printProvider.on({
+            "layoutchange": this.onLayoutChange,
+            scope: this
+        });
+    },
+
+    /** private: method[onFieldChange]
+     *  :param field: ``Ext.form.Field``
+     *  :param record: ``Ext.data.Record`` Optional.
+     *  
+     *  Handler for the target field's "valid" or "select" event.
+     */
+    onFieldChange: function(field, record) {
+        var printProvider = this.printPage.printProvider;
+        var value = field.getValue();
+        this._updating = true;
+        if(field.store === printProvider.scales) {
+            this.printPage.setScale(record);
+        } else if(field.name == "rotation") {
+            !isNaN(value) && this.printPage.setRotation(value);
+        } else {
+            this.printPage.customParams[field.name] = value;
+        }
+        delete this._updating;
+    },
+
+    /** private: method[onPageChange]
+     *  :param printPage: :class:`GeoExt.data.PrintPage`
+     *  
+     *  Handler for the "change" event for the page this plugin is configured
+     *  with.
+     */
+    onPageChange: function(printPage) {
+        if(!this._updating) {
+            var t = this.target;
+            t.suspendEvents();
+            if(t.store === printPage.printProvider.scales) {
+                t.setValue(printPage.scale.get(t.displayField));
+            } else if(t.name == "rotation") {
+                t.setValue(printPage.rotation);
+            }
+            t.resumeEvents();
+        }
+    },
+    
+    /** private: method[onPageChange]
+     *  :param printProvider: :class:`GeoExt.data.PrintProvider`
+     *  :param layout: ``Ext.Record``
+     *  
+     *  Handler for the "layoutchange" event of the printProvider.
+     */
+    onLayoutChange: function(printProvider, layout) {
+        var t = this.target;
+        t.name == "rotation" && t.setDisabled(!layout.get("rotation"));
+    },
+    
+    /** private: method[destroy]
+     */
+    destroy: function() {
+        this.target.un("select", this.onFieldChange, this);
+        this.target.un("valid", this.onFieldChange, this);
+        this.printPage.un("change", this.onPageChange, this);
+        this.printPage.printProvider.un("layoutchange", this.onLayoutChange,
+            this);
+    }
+
+});
+
+/** api: ptype = gx_printpagefield */
+Ext.preg && Ext.preg("gx_printpagefield", GeoExt.plugins.PrintPageField);

Deleted: sandbox/ahocevar/playground/geoext/lib/GeoExt/plugins/PrintProviderField.js
===================================================================
--- sandbox/ahocevar/playground/trunk/geoext/lib/GeoExt/plugins/PrintProviderField.js	2010-01-31 13:39:51 UTC (rev 1845)
+++ sandbox/ahocevar/playground/geoext/lib/GeoExt/plugins/PrintProviderField.js	2010-01-31 18:23:57 UTC (rev 1853)
@@ -1,172 +0,0 @@
-/**
- * Copyright (c) 2008-2009 The Open Source Geospatial Foundation
- * 
- * Published under the BSD license.
- * See http://svn.geoext.org/core/trunk/geoext/license.txt for the full text
- * of the license.
- */
-Ext.namespace("GeoExt.plugins");
-
-/** api: (define)
- *  module = GeoExt.plugins
- *  class = PrintProviderField
- *  base_link = `Ext.util.Observable <http://extjs.com/deploy/dev/docs/?class=Ext.util.Observable>`_
- */
-
-/** api: example
- *  A form with combo boxes for layout and resolution, and a text field for a
- *  map title. The latter is a custom parameter to the print module:
- * 
- *  .. code-block:: javascript
- *     
- *      var printProvider = new GeoExt.data.PrintProvider({
- *          capabilities: printCapabilities
- *      });
- *      new Ext.form.FormPanel({
- *          renderTo: "form",
- *          width: 200,
- *          height: 300,
- *          items: [{
- *              xtype: "combo",
- *              displayField: "name",
- *              store: printProvider.layouts, // printProvider.layout
- *              fieldLabel: "Layout",
- *              typeAhead: true,
- *              mode: "local",
- *              forceSelection: true,
- *              triggerAction: "all",
- *              selectOnFocus: true,
- *              plugins: new GeoExt.plugins.PrintProviderField({
- *                  printProvider: printProvider
- *              })
- *          }, {
- *              xtype: "combo",
- *              displayField: "name",
- *              store: printProvider.dpis, // printProvider.dpi
- *              fieldLabel: "Resolution",
- *              typeAhead: true,
- *              mode: "local",
- *              forceSelection: true,
- *              triggerAction: "all",
- *              selectOnFocus: true,
- *              plugins: new GeoExt.plugins.PrintProviderField({
- *                  printProvider: printProvider
- *              })
- *          }, {
- *              xtype: "textfield",
- *              name: "mapTitle", // printProvider.customParams.mapTitle
- *              fieldLabel: "Map Title",
- *              plugins: new GeoExt.plugins.PrintProviderField({
- *                  printProvider: printProvider
- *              })
- *          }]
- *      }):
- */
-
-/** api: constructor
- *  .. class:: PrintProviderField
- * 
- *  A plugin for ``Ext.form.Field`` components which provides synchronization
- *  with a :class:`GeoExt.data.PrintProvider`.
- */
-GeoExt.plugins.PrintProviderField = Ext.extend(Ext.util.Observable, {
-    
-    /** api: config[printProvider]
-     *  ``GeoExt.data.PrintProvider`` The print provider to use with this
-     *  plugin's field. Not required if set on the owner container of the
-     *  field.
-     */
-    
-    /** private: property[target]
-     *  ``Ext.form.Field`` This plugin's target field.
-     */
-    target: null,
-    
-    /** private: method[constructor]
-     */
-    constructor: function(config) {
-        this.initialConfig = config;
-        Ext.apply(this, config);
-        
-        GeoExt.plugins.PrintProviderField.superclass.constructor.apply(this, arguments);
-    },
-    
-    /** private: method[init]
-     *  :param target: ``Ext.form.Field`` The component that this plugin
-     *      extends.
-     */
-    init: function(target) {
-        this.target = target;
-        var onCfg = {
-            scope: this,
-            "render": this.onRender
-        };
-        onCfg[target instanceof Ext.form.ComboBox ? "select" : "valid"] =
-            this.onFieldChange;
-        target.on(onCfg);
-    },
-    
-    /** private: method[onRender]
-     *  :param field: ``Ext.Form.Field``
-     *  
-     *  Handler for the target field's "render" event.
-     */
-    onRender: function(field) {
-        var printProvider = this.printProvider || field.ownerCt.printProvider;
-        if(field.store === printProvider.layouts) {
-            field.setValue(printProvider.layout.get(field.displayField));
-            printProvider.on({
-                "layoutchange": this.onProviderChange,
-                scope: this
-            });
-        } else if(field.store === printProvider.dpis) {
-            field.setValue(printProvider.dpi.get(field.displayField));
-            printProvider.on({
-                "dpichange": this.onProviderChange,
-                scope: this
-            });
-        } else if(field.initialConfig.value === undefined) {
-            field.setValue(printProvider.customParams[field.name]);
-        }
-    },
-    
-    /** private: method[onFieldChange]
-     *  :param field: ``Ext.form.Field``
-     *  :param record: ``Ext.data.Record`` Optional.
-     *  
-     *  Handler for the target field's "valid" or "select" event.
-     */
-    onFieldChange: function(field, record) {
-        var printProvider = this.printProvider || field.ownerCt.printProvider;
-        var value = field.getValue();
-        this._updating = true;
-        if(record) {
-            switch(field.store) {
-                case printProvider.layouts:
-                    printProvider.setLayout(record);
-                    break;
-                case printProvider.dpis:
-                    printProvider.setDpi(record);
-            }
-        } else {
-            printProvider.customParams[field.name] = value;
-        }
-        delete this._updating;
-    },
-    
-    /** private: method[onProviderChange]
-     *  :param printProvider: :class:`GeoExt.data.PrintProvider`
-     *  :param rec: ``Ext.data.Record``
-     *  
-     *  Handler for the printProvider's dpichange and layoutchange event
-     */
-    onProviderChange: function(printProvider, rec) {
-        if(!this._updating) {
-            this.target.setValue(rec.get(this.target.displayField));
-        }
-    }
-    
-});
-
-/** api: ptype = gx_printproviderfield */
-Ext.preg && Ext.preg("gx_printproviderfield", GeoExt.plugins.PrintProviderField);

Copied: sandbox/ahocevar/playground/geoext/lib/GeoExt/plugins/PrintProviderField.js (from rev 1852, sandbox/ahocevar/playground/trunk/geoext/lib/GeoExt/plugins/PrintProviderField.js)
===================================================================
--- sandbox/ahocevar/playground/geoext/lib/GeoExt/plugins/PrintProviderField.js	                        (rev 0)
+++ sandbox/ahocevar/playground/geoext/lib/GeoExt/plugins/PrintProviderField.js	2010-01-31 18:23:57 UTC (rev 1853)
@@ -0,0 +1,185 @@
+/**
+ * Copyright (c) 2008-2009 The Open Source Geospatial Foundation
+ * 
+ * Published under the BSD license.
+ * See http://svn.geoext.org/core/trunk/geoext/license.txt for the full text
+ * of the license.
+ */
+Ext.namespace("GeoExt.plugins");
+
+/** api: (define)
+ *  module = GeoExt.plugins
+ *  class = PrintProviderField
+ *  base_link = `Ext.util.Observable <http://extjs.com/deploy/dev/docs/?class=Ext.util.Observable>`_
+ */
+
+/** api: example
+ *  A form with combo boxes for layout and resolution, and a text field for a
+ *  map title. The latter is a custom parameter to the print module, which is
+ *  a default for all print pages. For setting custom parameters on the page
+ *  level, use :class:`GeoExt.plugins.PrintPageField`):
+ * 
+ *  .. code-block:: javascript
+ *     
+ *      var printProvider = new GeoExt.data.PrintProvider({
+ *          capabilities: printCapabilities
+ *      });
+ *      new Ext.form.FormPanel({
+ *          renderTo: "form",
+ *          width: 200,
+ *          height: 300,
+ *          items: [{
+ *              xtype: "combo",
+ *              displayField: "name",
+ *              store: printProvider.layouts, // printProvider.layout
+ *              fieldLabel: "Layout",
+ *              typeAhead: true,
+ *              mode: "local",
+ *              forceSelection: true,
+ *              triggerAction: "all",
+ *              selectOnFocus: true,
+ *              plugins: new GeoExt.plugins.PrintProviderField({
+ *                  printProvider: printProvider
+ *              })
+ *          }, {
+ *              xtype: "combo",
+ *              displayField: "name",
+ *              store: printProvider.dpis, // printProvider.dpi
+ *              fieldLabel: "Resolution",
+ *              typeAhead: true,
+ *              mode: "local",
+ *              forceSelection: true,
+ *              triggerAction: "all",
+ *              selectOnFocus: true,
+ *              plugins: new GeoExt.plugins.PrintProviderField({
+ *                  printProvider: printProvider
+ *              })
+ *          }, {
+ *              xtype: "textfield",
+ *              name: "mapTitle", // printProvider.customParams.mapTitle
+ *              fieldLabel: "Map Title",
+ *              plugins: new GeoExt.plugins.PrintProviderField({
+ *                  printProvider: printProvider
+ *              })
+ *          }]
+ *      }):
+ */
+
+/** api: constructor
+ *  .. class:: PrintProviderField
+ * 
+ *  A plugin for ``Ext.form.Field`` components which provides synchronization
+ *  with a :class:`GeoExt.data.PrintProvider`.
+ */
+GeoExt.plugins.PrintProviderField = Ext.extend(Ext.util.Observable, {
+    
+    /** api: config[printProvider]
+     *  ``GeoExt.data.PrintProvider`` The print provider to use with this
+     *  plugin's field. Not required if set on the owner container of the
+     *  field.
+     */
+    
+    /** private: property[target]
+     *  ``Ext.form.Field`` This plugin's target field.
+     */
+    target: null,
+    
+    /** private: method[constructor]
+     */
+    constructor: function(config) {
+        this.initialConfig = config;
+        Ext.apply(this, config);
+        
+        GeoExt.plugins.PrintProviderField.superclass.constructor.apply(this, arguments);
+    },
+    
+    /** private: method[init]
+     *  :param target: ``Ext.form.Field`` The component that this plugin
+     *      extends.
+     */
+    init: function(target) {
+        this.target = target;
+        var onCfg = {
+            scope: this,
+            "render": this.onRender
+        };
+        onCfg[target instanceof Ext.form.ComboBox ? "select" : "valid"] =
+            this.onFieldChange;
+        target.on(onCfg);
+    },
+    
+    /** private: method[onRender]
+     *  :param field: ``Ext.Form.Field``
+     *  
+     *  Handler for the target field's "render" event.
+     */
+    onRender: function(field) {
+        var printProvider = this.printProvider || field.ownerCt.printProvider;
+        if(field.store === printProvider.layouts) {
+            field.setValue(printProvider.layout.get(field.displayField));
+            printProvider.on({
+                "layoutchange": this.onProviderChange,
+                scope: this
+            });
+        } else if(field.store === printProvider.dpis) {
+            field.setValue(printProvider.dpi.get(field.displayField));
+            printProvider.on({
+                "dpichange": this.onProviderChange,
+                scope: this
+            });
+        } else if(field.initialConfig.value === undefined) {
+            field.setValue(printProvider.customParams[field.name]);
+        }
+    },
+    
+    /** private: method[onFieldChange]
+     *  :param field: ``Ext.form.Field``
+     *  :param record: ``Ext.data.Record`` Optional.
+     *  
+     *  Handler for the target field's "valid" or "select" event.
+     */
+    onFieldChange: function(field, record) {
+        var printProvider = this.printProvider || field.ownerCt.printProvider;
+        var value = field.getValue();
+        this._updating = true;
+        if(record) {
+            switch(field.store) {
+                case printProvider.layouts:
+                    printProvider.setLayout(record);
+                    break;
+                case printProvider.dpis:
+                    printProvider.setDpi(record);
+            }
+        } else {
+            printProvider.customParams[field.name] = value;
+        }
+        delete this._updating;
+    },
+    
+    /** private: method[onProviderChange]
+     *  :param printProvider: :class:`GeoExt.data.PrintProvider`
+     *  :param rec: ``Ext.data.Record``
+     *  
+     *  Handler for the printProvider's dpichange and layoutchange event
+     */
+    onProviderChange: function(printProvider, rec) {
+        if(!this._updating) {
+            this.target.setValue(rec.get(this.target.displayField));
+        }
+    },
+    
+    /** private: method[destroy]
+     */
+    destroy: function() {
+        this.target.un("render", this.onRender, this);
+        this.target.un("select", this.onFieldChange, this);
+        this.target.un("valid", this.onFieldChange, this);
+        this.printProvider.un("layoutchange", this.onProviderChange, this);
+        this.printProvider.un("dpichange", this.onProviderChange,
+            this);
+    }
+
+});
+
+/** api: ptype = gx_printproviderfield */
+Ext.preg && Ext.preg("gx_printproviderfield", GeoExt.plugins.PrintProviderField);



More information about the Commits mailing list