Bienvenue sur PostGIS.fr

Bienvenue sur PostGIS.fr , le site de la communauté des utilisateurs francophones de PostGIS.

PostGIS ajoute le support d'objets géographique à la base de données PostgreSQL. En effet, PostGIS "spatialise" le serverur PostgreSQL, ce qui permet de l'utiliser comme une base de données SIG.

Maintenu à jour, en fonction de nos disponibilités et des diverses sorties des outils que nous testons, nous vous proposons l'ensemble de nos travaux publiés en langue française.

source: trunk/workshop-routing-foss4g/web/GeoExt/lib/GeoExt/plugins/PrintPageField.js @ 76

Revision 76, 6.4 KB checked in by djay, 12 years ago (diff)

Ajout du répertoire web

  • Property svn:executable set to *
Line 
1/**
2 * Copyright (c) 2008-2010 The Open Source Geospatial Foundation
3 *
4 * Published under the BSD license.
5 * See http://svn.geoext.org/core/trunk/geoext/license.txt for the full text
6 * of the license.
7 */
8Ext.namespace("GeoExt.plugins");
9
10/** api: (define)
11 *  module = GeoExt.plugins
12 *  class = PrintPageField
13 *  base_link = `Ext.util.Observable <http://dev.sencha.com/deploy/dev/docs/?class=Ext.util.Observable>`_
14 */
15
16/** api: example
17 *  A form with a combo box for the scale and text fields for rotation and a
18 *  page title. The page title is a custom parameter of the print module's
19 *  page configuration:
20 *
21 *  .. code-block:: javascript
22 *     
23 *      var printPage = new GeoExt.data.PrintPage({
24 *          printProvider: new GeoExt.data.PrintProvider({
25 *              capabilities: printCapabilities
26 *          })
27 *      });
28 *      new Ext.form.FormPanel({
29 *          renderTo: "form",
30 *          width: 200,
31 *          height: 300,
32 *          items: [{
33 *              xtype: "combo",
34 *              displayField: "name",
35 *              store: printPage.scales, // printPage.scale
36 *              name: "scale",
37 *              fieldLabel: "Scale",
38 *              typeAhead: true,
39 *              mode: "local",
40 *              forceSelection: true,
41 *              triggerAction: "all",
42 *              selectOnFocus: true,
43 *              plugins: new GeoExt.plugins.PrintPageField({
44 *                  printPage: printPage
45 *              })
46 *          }, {
47 *              xtype: "textfield",
48 *              name: "rotation", // printPage.rotation
49 *              fieldLabel: "Rotation",
50 *              plugins: new GeoExt.plugins.PrintPageField({
51 *                  printPage: printPage
52 *              })
53 *          }, {
54 *              xtype: "textfield",
55 *              name: "mapTitle", // printPage.customParams["mapTitle"]
56 *              fieldLabel: "Map Title",
57 *              plugins: new GeoExt.plugins.PrintPageField({
58 *                  printPage: printPage
59 *              })
60 *          }]
61 *      });
62 */
63
64/** api: constructor
65 *  .. class:: PrintPageField
66 *
67 *  A plugin for ``Ext.form.Field`` components which provides synchronization
68 *  with a :class:`GeoExt.data.PrintPage`. The field name has to match the
69 *  respective property of the printPage (e.g. ``scale``, ``rotation``).
70 */
71GeoExt.plugins.PrintPageField = Ext.extend(Ext.util.Observable, {
72   
73    /** api: config[printPage]
74     *  ``GeoExt.data.PrintPage`` The print page to synchronize with.
75     */
76
77    /** private: property[printPage]
78     *  ``GeoExt.data.PrintPage`` The print page to synchronize with.
79     *  Read-only.
80     */
81    printPage: null,
82   
83    /** private: property[target]
84     *  ``Ext.form.Field`` This plugin's target field.
85     */
86    target: null,
87   
88    /** private: method[constructor]
89     */
90    constructor: function(config) {
91        this.initialConfig = config;
92        Ext.apply(this, config);
93       
94        GeoExt.plugins.PrintPageField.superclass.constructor.apply(this, arguments);
95    },
96   
97    /** private: method[init]
98     *  :param target: ``Ext.form.Field`` The component that this plugin
99     *      extends.
100     * @param {Object} target
101     */
102    init: function(target) {
103        this.target = target;
104        var onCfg = {
105            "beforedestroy": this.onBeforeDestroy,
106            scope: this
107        };
108        var eventName = target instanceof Ext.form.ComboBox ?
109                            "select" : target instanceof Ext.form.Checkbox ?
110                                "check" : "valid";
111        onCfg[eventName] = this.onFieldChange;
112        target.on(onCfg);
113        this.printPage.on({
114            "change": this.onPageChange,
115            scope: this
116        });
117        this.printPage.printProvider.on({
118            "layoutchange": this.onLayoutChange,
119            scope: this
120        });
121        this.setValue(this.printPage);
122    },
123
124    /** private: method[onFieldChange]
125     *  :param field: ``Ext.form.Field``
126     *  :param record: ``Ext.data.Record`` Optional.
127     * 
128     *  Handler for the target field's "valid" or "select" event.
129     */
130    onFieldChange: function(field, record) {
131        var printProvider = this.printPage.printProvider;
132        var value = field.getValue();
133        this._updating = true;
134        if(field.store === printProvider.scales || field.name === "scale") {
135            this.printPage.setScale(record);
136        } else if(field.name == "rotation") {
137            !isNaN(value) && this.printPage.setRotation(value);
138        } else {
139            this.printPage.customParams[field.name] = value;
140        }
141        delete this._updating;
142    },
143
144    /** private: method[onPageChange]
145     *  :param printPage: :class:`GeoExt.data.PrintPage`
146     * 
147     *  Handler for the "change" event for the page this plugin is configured
148     *  with.
149     */
150    onPageChange: function(printPage) {
151        if(!this._updating) {
152            this.setValue(printPage);
153        }
154    },
155   
156    /** private: method[onPageChange]
157     *  :param printProvider: :class:`GeoExt.data.PrintProvider`
158     *  :param layout: ``Ext.Record``
159     * 
160     *  Handler for the "layoutchange" event of the printProvider.
161     */
162    onLayoutChange: function(printProvider, layout) {
163        var t = this.target;
164        t.name == "rotation" && t.setDisabled(!layout.get("rotation"));
165    },
166
167    /** private: method[setValue]
168     *  :param printPage: :class:`GeoExt.data.PrintPage`
169     *
170     *  Sets the value in the target field.
171     */
172    setValue: function(printPage) {
173        var t = this.target;
174        t.suspendEvents();
175        if(t.store === printPage.printProvider.scales || t.name === "scale") {
176            if(printPage.scale) {
177                t.setValue(printPage.scale.get(t.displayField));
178            }
179        } else if(t.name == "rotation") {
180            t.setValue(printPage.rotation);
181        }
182        t.resumeEvents();
183    },
184
185    /** private: method[onBeforeDestroy]
186     */
187    onBeforeDestroy: function() {
188        this.target.un("beforedestroy", this.onBeforeDestroy, this);
189        this.target.un("select", this.onFieldChange, this);
190        this.target.un("valid", this.onFieldChange, this);
191        this.printPage.un("change", this.onPageChange, this);
192        this.printPage.printProvider.un("layoutchange", this.onLayoutChange,
193            this);
194    }
195
196});
197
198/** api: ptype = gx_printpagefield */
199Ext.preg("gx_printpagefield", GeoExt.plugins.PrintPageField);
Note: See TracBrowser for help on using the repository browser.