Changeset 1274

Show
Ignore:
Timestamp:
10/31/08 15:04:37 (2 months ago)
Author:
elemoine
Message:

Make Map Fish? Client use Geo Ext? (see #282)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • sandbox/camptocamp/MapFishUnhcr/client/build/build.py

    r1046 r1274  
    4646} 
    4747 
     48configDictGeoExt = { 
     49    'GeoExt.js':                    '../mfbase/geoext/core/lib', 
     50    'GeoExt':                       '../mfbase/geoext/core/lib' 
     51} 
     52 
    4853configDictMapFish = { 
    4954    'SingleFile.js':                '../mfbase/mapfish', 
     
    6570    -o --output outputfile      Specify output file (default value: MapFish.js) 
    6671    -d --debug                  Don't compress the files 
    67     -m --mfonly                 MapFish only build (OpenLayers files not included) 
     72    -m --mfonly                 MapFish only build (OpenLayers and GeoExt files not included) 
    6873""" 
    6974    ) 
     
    97102configDictGlobal = {} 
    98103configDictGlobal.update(configDictOpenLayers) 
     104configDictGlobal.update(configDictGeoExt) 
    99105configDictGlobal.update(configDictMapFish) 
    100106 
  • sandbox/camptocamp/MapFishUnhcr/client/build/mergejs.py

    r1046 r1274  
    281281        raise SystemExit 
    282282    else: 
    283         sourceDirectory = args[1] 
    284         if not sourceDirectory
     283        sourceDirectoryOpenLayers = args[1] 
     284        if not sourceDirectoryOpenLayers
    285285            usage(sys.argv[0]) 
    286286            raise SystemExit 
    287  
    288     configDict = { 'OpenLayers': sourceDirectory } 
     287        else: 
     288            sourceDirectoryGeoExt = args[2] 
     289            if not sourceDirectoryGeoExt: 
     290                usage(sys.argv[0]) 
     291                raise SystemExit 
     292             
     293 
     294    configDict = {'OpenLayers': sourceDirectoryOpenLayers} 
     295    configDict.update({'GeoExt': sourceDirectoryGeoExt}) 
    289296 
    290297    configFile = None 
  • sandbox/camptocamp/MapFishUnhcr/client/mfbase/mapfish/tests/core/Protocol/test_MapFish.html

    r993 r1274  
    22<html debug="true"> 
    33  <head> 
    4     <link rel="stylesheet" type="text/css" href="../../../ext/resources/css/ext-all.css" /> 
    5  
    64    <script type="text/javascript" src="../../../../openlayers/lib/Firebug/firebug.js"></script> 
    75    <script type="text/javascript" src="../../../../openlayers/lib/OpenLayers.js"></script> 
     
    97    <script type="text/javascript" src="../../../../ext/adapter/ext/ext-base.js"></script> 
    108    <script type="text/javascript" src="../../../../ext/ext-all-debug.js"></script> 
     9 
     10    <script type="text/javascript" src="../../../../geoext/core/lib/GeoExt.js"></script> 
    1111 
    1212    <script type="text/javascript"> 
  • sandbox/camptocamp/MapFishUnhcr/client/mfbase/mapfish/tests/core/Protocol/test_MergeFilterDecorator.html

    r1267 r1274  
    22<html debug="true"> 
    33  <head> 
    4     <link rel="stylesheet" type="text/css" href="../../../ext/resources/css/ext-all.css" /> 
    5  
    64    <script type="text/javascript" src="../../../../openlayers/lib/Firebug/firebug.js"></script> 
    75    <script type="text/javascript" src="../../../../openlayers/lib/OpenLayers.js"></script> 
     
    97    <script type="text/javascript" src="../../../../ext/adapter/ext/ext-base.js"></script> 
    108    <script type="text/javascript" src="../../../../ext/ext-all-debug.js"></script> 
     9 
     10    <script type="text/javascript" src="../../../../geoext/core/lib/GeoExt.js"></script> 
    1111 
    1212    <script type="text/javascript"> 
  • sandbox/camptocamp/MapFishUnhcr/client/mfbase/mapfish/tests/core/Protocol/test_TriggerEventDecorator.html

    r1223 r1274  
    22<html debug="true"> 
    33  <head> 
    4     <link rel="stylesheet" type="text/css" href="../../../ext/resources/css/ext-all.css" /> 
    5  
    64    <script type="text/javascript" src="../../../../openlayers/lib/Firebug/firebug.js"></script> 
    75    <script type="text/javascript" src="../../../../openlayers/lib/OpenLayers.js"></script> 
     
    97    <script type="text/javascript" src="../../../../ext/adapter/ext/ext-base.js"></script> 
    108    <script type="text/javascript" src="../../../../ext/ext-all-debug.js"></script> 
     9 
     10    <script type="text/javascript" src="../../../../geoext/core/lib/GeoExt.js"></script> 
    1111 
    1212    <script type="text/javascript"> 
  • sandbox/camptocamp/MapFishUnhcr/client/mfbase/mapfish/tests/core/Searcher/test_Map.html

    r1190 r1274  
    22<html debug="true"> 
    33  <head> 
    4     <link rel="stylesheet" type="text/css" href="../../../ext/resources/css/ext-all.css" /> 
    5  
    64    <script type="text/javascript" src="../../../../openlayers/lib/Firebug/firebug.js"></script> 
    75    <script type="text/javascript" src="../../../../openlayers/lib/OpenLayers.js"></script> 
     
    97    <script type="text/javascript" src="../../../../ext/adapter/ext/ext-base.js"></script> 
    108    <script type="text/javascript" src="../../../../ext/ext-all-debug.js"></script> 
     9 
     10    <script type="text/javascript" src="../../../../geoext/core/lib/GeoExt.js"></script> 
    1111 
    1212    <script type="text/javascript"> 
  • sandbox/camptocamp/MapFishUnhcr/client/mfbase/mapfish/tests/core/Strategy/test_ProtocolListener.html

    r1229 r1274  
    22<html debug="true"> 
    33  <head> 
    4     <link rel="stylesheet" type="text/css" href="../../../ext/resources/css/ext-all.css" /> 
    5  
    64    <script type="text/javascript" src="../../../../openlayers/lib/Firebug/firebug.js"></script> 
    75    <script type="text/javascript" src="../../../../openlayers/lib/OpenLayers.js"></script> 
     
    97    <script type="text/javascript" src="../../../../ext/adapter/ext/ext-base.js"></script> 
    108    <script type="text/javascript" src="../../../../ext/ext-all-debug.js"></script> 
     9 
     10    <script type="text/javascript" src="../../../../geoext/core/lib/GeoExt.js"></script> 
    1111 
    1212    <script type="text/javascript"> 
  • sandbox/camptocamp/MapFishUnhcr/client/mfbase/mapfish/tests/core/test_Offline.html

    r1124 r1274  
    22<html> 
    33  <head> 
    4     <link rel="stylesheet" type="text/css" href="../../ext/resources/css/ext-all.css" /> 
    5  
    64    <script type="text/javascript" src="../../../openlayers/lib/Firebug/firebug.js"></script> 
    75    <script type="text/javascript" src="../../../openlayers/lib/OpenLayers.js"></script> 
     
    97    <script type="text/javascript" src="../../../ext/adapter/ext/ext-base.js"></script> 
    108    <script type="text/javascript" src="../../../ext/ext-all-debug.js"></script> 
     9 
     10    <script type="text/javascript" src="../../../geoext/core/lib/GeoExt.js"></script> 
    1111 
    1212    <script type="text/javascript"> 
  • sandbox/camptocamp/MapFishUnhcr/client/mfbase/mapfish/tests/core/test_PrintProtocol.html

    r907 r1274  
    77    <script type="text/javascript" src="../../../ext/adapter/ext/ext-base.js"></script> 
    88    <script type="text/javascript" src="../../../ext/ext-all-debug.js"></script> 
     9 
     10    <script type="text/javascript" src="../../../geoext/core/lib/GeoExt.js"></script> 
    911 
    1012    <script type="text/javascript"> 
  • sandbox/camptocamp/MapFishUnhcr/client/mfbase/mapfish/tests/core/test_Util.html

    r868 r1274  
    22<html debug="true"> 
    33  <head> 
    4     <link rel="stylesheet" type="text/css" href="../../ext/resources/css/ext-all.css" /> 
    5  
    64    <script type="text/javascript" src="../../../openlayers/lib/Firebug/firebug.js"></script> 
    75    <script type="text/javascript" src="../../../openlayers/lib/OpenLayers.js"></script> 
     
    97    <script type="text/javascript" src="../../../ext/adapter/ext/ext-base.js"></script> 
    108    <script type="text/javascript" src="../../../ext/ext-all-debug.js"></script> 
     9 
     10    <script type="text/javascript" src="../../../geoext/core/lib/GeoExt.js"></script> 
    1111 
    1212    <script type="text/javascript"> 
  • sandbox/camptocamp/MapFishUnhcr/client/mfbase/mapfish/tests/widgets/data/test_GridRowFeatureMediator.html

    r1230 r1274  
    22<html debug="true"> 
    33  <head> 
    4     <link rel="stylesheet" type="text/css" href="../../../../ext/resources/css/ext-all.css" /> 
    5  
    64    <script type="text/javascript" src="../../../../openlayers/lib/Firebug/firebug.js"></script> 
    75    <script type="text/javascript" src="../../../../openlayers/lib/OpenLayers.js"></script> 
     
    97    <script type="text/javascript" src="../../../../ext/adapter/ext/ext-base.js"></script> 
    108    <script type="text/javascript" src="../../../../ext/ext-all-debug.js"></script> 
     9 
     10    <script type="text/javascript" src="../../../../geoext/core/lib/GeoExt.js"></script> 
    1111 
    1212    <script type="text/javascript"> 
  • sandbox/camptocamp/MapFishUnhcr/client/mfbase/mapfish/tests/widgets/data/test_SearchStoreMediator.html

    r1190 r1274  
    22<html debug="true"> 
    33  <head> 
    4     <link rel="stylesheet" type="text/css" href="../../../../ext/resources/css/ext-all.css" /> 
    5  
    64    <script type="text/javascript" src="../../../../openlayers/lib/Firebug/firebug.js"></script> 
    75    <script type="text/javascript" src="../../../../openlayers/lib/OpenLayers.js"></script> 
     
    97    <script type="text/javascript" src="../../../../ext/adapter/ext/ext-base.js"></script> 
    108    <script type="text/javascript" src="../../../../ext/ext-all-debug.js"></script> 
     9 
     10    <script type="text/javascript" src="../../../../geoext/core/lib/GeoExt.js"></script> 
    1111 
    1212    <script type="text/javascript"> 
     
    2525            var mediator, store, protocol; 
    2626            store = new Ext.data.Store({ 
    27                 reader: new mapfish.widgets.data.FeatureReader( 
     27                reader: new GeoExt.data.FeatureReader( 
    2828                    {}, [{name: "name", type: "string"}] 
    2929                ) 
     
    4343                 "ctor correctly sets protocol"); 
    4444            t.ok(mediator.featureStoreMediator instanceof 
    45                      mapfish.widgets.data.FeatureStoreMediator, 
     45                     GeoExt.data.FeatureStoreMediator, 
    4646                 "ctor correctly creates feature store mediator"); 
    4747        } 
     
    5555            }); 
    5656            store = new Ext.data.Store({ 
    57                 reader: new mapfish.widgets.data.FeatureReader( 
     57                reader: new GeoExt.data.FeatureReader( 
    5858                    {}, [{name: "name", type: "string"}] 
    5959                ) 
     
    9494            }); 
    9595            store = new Ext.data.Store({ 
    96                 reader: new mapfish.widgets.data.FeatureReader( 
     96                reader: new GeoExt.data.FeatureReader( 
    9797                    {}, [{name: "name", type: "string"}] 
    9898                ) 
  • sandbox/camptocamp/MapFishUnhcr/client/mfbase/mapfish/tests/widgets/toolbar/Toolbar.html

    r1257 r1274  
    22<html debug="true"> 
    33  <head> 
    4     <link rel="stylesheet" type="text/css" href="../../../../ext/resources/css/ext-all.css" /> 
    5  
    64    <script type="text/javascript" src="../../../../openlayers/lib/Firebug/firebug.js"></script> 
    75    <script type="text/javascript" src="../../../../openlayers/lib/OpenLayers.js"></script> 
     
    97    <script type="text/javascript" src="../../../../ext/adapter/ext/ext-base.js"></script> 
    108    <script type="text/javascript" src="../../../../ext/ext-all-debug.js"></script> 
     9 
     10    <script type="text/javascript" src="../../../../geoext/core/lib/GeoExt.js"></script> 
    1111 
    1212    <script type="text/javascript"> 
  • sandbox/camptocamp/MapFishUnhcr/client/mfbase/mapfish/tests/widgets/tree/test_LayerTree.html

    r1242 r1274  
    22<html debug="true"> 
    33  <head> 
    4     <link rel="stylesheet" type="text/css" href="../../../../ext/resources/css/ext-all.css" /> 
    5  
    64    <script type="text/javascript" src="../../../../openlayers/lib/Firebug/firebug.js"></script> 
    75    <script type="text/javascript" src="../../../../openlayers/lib/OpenLayers.js"></script> 
     
    97    <script type="text/javascript" src="../../../../ext/adapter/ext/ext-base.js"></script> 
    108    <script type="text/javascript" src="../../../../ext/ext-all-debug.js"></script> 
     9 
     10    <script type="text/javascript" src="../../../../geoext/core/lib/GeoExt.js"></script> 
    1111 
    1212    <script type="text/javascript"> 
  • sandbox/camptocamp/MapFishUnhcr/client/mfbase/mapfish/tests/widgets/tree/test_LayerTree_separator.html

    r935 r1274  
    22<html debug="true"> 
    33  <head> 
    4     <link rel="stylesheet" type="text/css" href="../../../../ext/resources/css/ext-all.css" /> 
    5  
    64    <script type="text/javascript" src="../../../../openlayers/lib/Firebug/firebug.js"></script> 
    75    <script type="text/javascript" src="../../../../openlayers/lib/OpenLayers.js"></script> 
     
    97    <script type="text/javascript" src="../../../../ext/adapter/ext/ext-base.js"></script> 
    108    <script type="text/javascript" src="../../../../ext/ext-all-debug.js"></script> 
     9 
     10    <script type="text/javascript" src="../../../../geoext/core/lib/GeoExt.js"></script> 
    1111 
    1212    <script type="text/javascript"> 
  • sandbox/camptocamp/MapFishUnhcr/client/mfbase/mapfish/tests/widgets/tree/test_LayerTree_wmsLayerRedraw.html

    r935 r1274  
    22<html debug="true"> 
    33  <head> 
    4     <link rel="stylesheet" type="text/css" href="../../../../ext/resources/css/ext-all.css" /> 
    5  
    64    <script type="text/javascript" src="../../../../openlayers/lib/Firebug/firebug.js"></script> 
    75    <script type="text/javascript" src="../../../../openlayers/lib/OpenLayers.js"></script> 
     
    97    <script type="text/javascript" src="../../../../ext/adapter/ext/ext-base.js"></script> 
    108    <script type="text/javascript" src="../../../../ext/ext-all-debug.js"></script> 
     9 
     10    <script type="text/javascript" src="../../../../geoext/core/lib/GeoExt.js"></script> 
    1111 
    1212    <script type="text/javascript"> 
  • sandbox/camptocamp/MapFishUnhcr/client/mfbase/mapfish/widgets/data/FeatureReader.js

    r1167 r1274  
    1818 */ 
    1919 
     20/* 
     21 * @requires GeoExt/data/FeatureReader.js 
     22 */ 
     23 
    2024Ext.namespace('mapfish.widgets', 'mapfish.widgets.data'); 
    2125 
     
    2529 *      added to the store using this reader, specific fields like 
    2630 *      feature, state and fid are available. 
     31 * 
     32 * Note: this class is *deprecated*, GeoExt.data.FeatureReader should 
     33 * be used instead. 
    2734 * 
    2835 * Typical usage in a store: 
     
    4552 *      passed to {Ext.data.DataReader} constructor. 
    4653 */ 
    47 mapfish.widgets.data.FeatureReader = function(meta, recordType){ 
    48     meta = meta || {}; 
    49     mapfish.widgets.data.FeatureReader.superclass.constructor.call( 
    50         this, meta, recordType || meta.fields 
    51     ); 
    52 }; 
    53  
    54 Ext.extend(mapfish.widgets.data.FeatureReader, Ext.data.DataReader, { 
    55  
    56     /** 
    57      * APIProperty: totalRecords 
    58      * {Integer} 
    59      */ 
    60     totalRecords: null, 
    61  
    62     /** 
    63      * APIMethod: read 
    64      * This method is only used by a DataProxy which has retrieved data. 
    65      * 
    66      * Parameters: 
    67      * response - {<OpenLayers.Protocol.Response>} 
    68      * 
    69      * Returns: 
    70      * {Object} An object with two properties. The value of the property "records" 
    71      *      is the array of records corresponding to the features. The value of the 
    72      *      property "totalRecords" is the number of records in the array. 
    73      */ 
    74     read: function(response) { 
    75         return this.readRecords(response.features); 
    76     }, 
    77  
    78     /** 
    79      * APIMethod: readRecords 
    80      *      Create a data block containing Ext.data.Records from 
    81      *      an array of features. 
    82      * 
    83      * Parameters: 
    84      * features - {Array{<OpenLayers.Feature.Vector>}} 
    85      * 
    86      * Returns: 
    87      * {Object} An object with two properties. The value of the property "records" 
    88      *      is the array of records corresponding to the features. The value of the 
    89      *      property "totalRecords" is the number of records in the array. 
    90      */ 
    91     readRecords : function(features) { 
    92         var records = []; 
    93  
    94         if (features) { 
    95             var recordType = this.recordType, fields = recordType.prototype.fields; 
    96             var i, lenI, j, lenJ, feature, values, field, v; 
    97             for (i = 0, lenI = features.length; i < lenI; i++) { 
    98                 feature = features[i]; 
    99                 values = {}; 
    100                 if (feature.attributes) { 
    101                     for (j = 0, lenJ = fields.length; j < lenJ; j++){ 
    102                         field = fields.items[j]; 
    103                         v = feature.attributes[field.mapping || field.name] || 
    104                             field.defaultValue; 
    105                         v = field.convert(v); 
    106                         values[field.name] = v; 
    107                     } 
    108                 } 
    109                 values.feature = feature; 
    110                 values.state = feature.state; 
    111                 values.fid = feature.fid; 
    112  
    113                 records[records.length] = new recordType(values, feature.id); 
    114             } 
    115         } 
    116  
    117         return { 
    118             records: records, 
    119             totalRecords: this.totalRecords != null ? this.totalRecords : records.length 
    120         }; 
    121     } 
    122 }); 
     54mapfish.widgets.data.FeatureReader = GeoExt.data.FeatureReader; 
  • sandbox/camptocamp/MapFishUnhcr/client/mfbase/mapfish/widgets/data/FeatureStoreMediator.js

    r1125 r1274  
    1919 
    2020/** 
    21  * @requires widgets/data/FeatureReader.js 
     21 * @requires GeoExt/data/FeatureStoreMediator.js 
    2222 */ 
    2323 
     
    2727 * Class: mapfish.widgets.data.FeatureStoreMediator 
    2828 * This class is to be used when one wants to insert features in a store. 
     29 * 
     30 * Note: this class is *deprecated*, GeoExt.data.FeatureStoreMediator 
     31 * should be used instead. 
    2932 */ 
    3033 
     
    3336 * Create an instance of mapfish.widgets.data.FeatureStoreMediator 
    3437 */ 
    35 mapfish.widgets.data.FeatureStoreMediator = function(config){ 
    36     Ext.apply(this, config); 
    37     if (!this.store) { 
    38         OpenLayers.Console.error( 
    39             "store is missing in the config"); 
    40     } 
    41     if (!(this.store.reader instanceof mapfish.widgets.data.FeatureReader)) { 
    42         OpenLayers.Console.error( 
    43             "store does not use a FeatureReader"); 
    44     } 
    45 }; 
    46  
    47 mapfish.widgets.data.FeatureStoreMediator.prototype = { 
    48     /** 
    49      * APIProperty: store 
    50      * {Ext.data.Store} An Ext data store 
    51      */ 
    52     store: null, 
    53  
    54     /** 
    55      * APIProperty: append 
    56      * {Boolean} False if the store must be cleared before adding new 
    57      * features into it, false otherwise; defaults to true. 
    58      */ 
    59     append: true, 
    60  
    61     /** 
    62      * APIProperty: filter 
    63      * {Function} a filter function called for each feature to be 
    64      * inserted, the feature is passed as an argument to the function, 
    65      * if it returns true the feature is inserted into the store, 
    66      * otherwise the feature is not inserted. 
    67      */ 
    68     filter: null, 
    69  
    70     /** 
    71      * APIMethod: addFeatures 
    72      *      Add features to the store. 
    73      *  
    74      * Parameters: 
    75      * features - {<OpenLayers.Feature.Vector>} or 
    76      *     {Array{<OpenLayers.Feature.Vector>}} A feature or an 
    77      *     array of features to add to the store. 
    78      * config - a config object which can include the properties 
    79      *     "append" and "filter", if set these properties will 
    80      *     override that set in the object. 
    81      */ 
    82     addFeatures: function(features, config) { 
    83         if (!Ext.isArray(features)) { 
    84             features = [features]; 
    85         } 
    86         config = OpenLayers.Util.applyDefaults(config, 
    87             {append: this.append, filter: this.filter}); 
    88         var toAdd = features; 
    89         if (config.filter) { 
    90             toAdd = []; 
    91             var feature; 
    92             for (var i = 0, len = features.length; i < len; i++) { 
    93                 feature = features[i]; 
    94                 if (config.filter(feature)) { 
    95                     toAdd.push(feature); 
    96                 } 
    97             } 
    98         } 
    99         // because of a bug in Ext if config.append is false we clean 
    100         // the store ourself and always pass true to loadData, there 
    101         // are cases where passing false to loadData results in Ext 
    102         // trying to dereference an undefined value, see the unit 
    103         // tests test_ExtBug and text_addFeatures_ExtBug for  
    104         // concrete examples 
    105         if (!config.append) { 
    106             this.store.removeAll(); 
    107         } 
    108         this.store.loadData(toAdd, true); 
    109     }, 
    110  
    111     /** 
    112      * APIMethod: removeFeatures 
    113      *      Remove features from the store. 
    114      * 
    115      * Parameters: 
    116      * features - {<OpenLayers.Feature.Vector>} or 
    117      *      {Array{<OpenLayers.Feature.Vector>}} A feature or an 
    118      *      array of features to remove from the store. If null 
    119      *      all the features in the store are removed. 
    120      */ 
    121     removeFeatures: function(features) { 
    122         if (!features) { 
    123             this.store.removeAll(); 
    124         } else { 
    125             if (!Ext.isArray(features)) { 
    126                 features = [features]; 
    127             } 
    128             for (var i = 0, len = features.length; i < len; i++) { 
    129                 var feature = features[i]; 
    130                 var r = this.store.getById(feature.id); 
    131                 if (r !== undefined) { 
    132                     this.store.remove(r); 
    133                 } 
    134             } 
    135         } 
    136     } 
    137 }; 
     38mapfish.widgets.data.FeatureStoreMediator = GeoExt.data.FeatureStoreMediator; 
  • sandbox/camptocamp/MapFishUnhcr/client/mfbase/mapfish/widgets/data/LayerStoreMediator.js

    r1124 r1274  
    1919 
    2020/** 
    21  * @requires widgets/data/FeatureStoreMediator.js 
    22  * @requires OpenLayers/Layer/Vector.js 
     21 * @requires GeoExt/data/LayerStoreMediator.js 
    2322 */ 
    2423 
     
    3130 * update features in a grid as a result of features being inserted, 
    3231 * removed, modified in a vector layer. 
     32 * 
     33 * Note: this class is *deprecated*, GeoExt.data.LayerStoreMediator 
     34 * should be used instead. 
    3335 */ 
    3436 
     
    3739 * Create an instance of mapfish.widgets.data.LayerStoreMediator. 
    3840 */ 
    39 mapfish.widgets.data.LayerStoreMediator = function(config){ 
    40     var store = config.store; 
    41     // no need to place the store in the instance 
    42     delete config.store; 
    43     Ext.apply(this, config); 
    44     if (!this.layer) { 
    45         OpenLayers.Console.error( 
    46             "layer is missing in config"); 
    47     } 
    48     this.featureStoreMediator = new mapfish.widgets.data.FeatureStoreMediator({ 
    49         store: store 
    50     }); 
    51     if (this.autoActivate) { 
    52         this.activate(); 
    53     } 
    54 }; 
    55  
    56 mapfish.widgets.data.LayerStoreMediator.prototype = { 
    57     /** 
    58      * APIProperty: layer 
    59      * {<OpenLayers.Layer.Vector>} The vector layer. 
    60      */ 
    61     layer: null, 
    62  
    63     /** 
    64      * APIProperty: filter 
    65      * {Function} a filter function called for each feature to be 
    66      * inserted, the feature is passed as an argument to the function, 
    67      * if it returns true the feature is inserted into the store, 
    68      * otherwise the feature is not inserted. 
    69      */ 
    70     filter: null, 
    71  
    72     /** 
    73      * APIProperty: autoActivate 
    74      * {Boolean} True if the mediator must be activated as part of 
    75      * its creation, false otherwise; if false then the mediator must 
    76      * be explicitely activate using the activate method; defaults 
    77      * to true. 
    78      */ 
    79     autoActivate: true, 
    80  
    81     /** 
    82      * Property: active 
    83      * {Boolean} 
    84      */ 
    85     active: false, 
    86  
    87     /** 
    88      * Property: featureStoreMediator 
    89      * {<mapfish.widgets.data.featureStoreMediator>} An internal 
    90      * feature store mediator for manually adding features to the 
    91      * Ext store. 
    92      */ 
    93     featureStoreMediator: null, 
    94  
    95     /** 
    96      * APIMethod: activate 
    97      * Activate the mediator. 
    98      * 
    99      * Returns: 
    100      * {Boolean} - False if the mediator was already active, true 
    101      * otherwise. 
    102      */ 
    103     activate: function() { 
    104         if (!this.active) { 
    105             this.layer.events.on({ 
    106                 featuresadded: this.update, 
    107                 featuresremoved: this.update, 
    108                 featuremodified: this.update, 
    109                 scope: this 
    110             }); 
    111             this.active = true; 
    112             return true; 
    113         } 
    114         return false; 
    115     }, 
    116  
    117     /** 
    118      * APIMethod: deactivate 
    119      * Deactivate the mediator. 
    120      * 
    121      * Returns: 
    122      * {Boolean} - False if the mediator was already deactive, true 
    123      * otherwise. 
    124      */ 
    125     deactivate: function() { 
    126         if (this.active) { 
    127             this.layer.events.un({ 
    128                 featuresadded: this.update, 
    129                 featuresremoved: this.update, 
    130                 featuremodified: this.update, 
    131                 scope: this 
    132             }); 
    133             return true; 
    134         } 
    135         return false; 
    136     }, 
    137  
    138     /** 
    139      * Method: update 
    140      *      Called when features are added, removed or modified. This 
    141      *      function empties the store, loops over the features in 
    142      *      the layer, and for each feature calls the user-defined 
    143      *      filter function, if the return value of the filter function 
    144      *      evaluates to true the feature is added to the store. 
    145      */ 
    146     update: function() { 
    147         this.featureStoreMediator.addFeatures( 
    148             this.layer.features, 
    149             {append: false, filter: this.filter}); 
    150     } 
    151 }; 
     41mapfish.widgets.data.LayerStoreMediator = GeoExt.data.LayerStoreMediator; 
  • sandbox/camptocamp/MapFishUnhcr/client/mfbase/mapfish/widgets/data/SearchStoreMediator.js

    r1190 r1274  
    1919 
    2020/** 
    21  * @requires widgets/data/FeatureStoreMediator.js 
     21 * @requires GeoExt/data/FeatureStoreMediator.js 
    2222 * @requires core/Protocol/TriggerEventDecorator.js 
    2323 */ 
     
    8080            "TriggerEventDecorator protocol"); 
    8181    } 
    82     this.featureStoreMediator = new mapfish.widgets.data.FeatureStoreMediator({ 
     82    this.featureStoreMediator = new GeoExt.data.FeatureStoreMediator({ 
    8383        store: store 
    8484    });