Changeset 1274
- Timestamp:
- 10/31/08 15:04:37 (2 months ago)
- Files:
-
- sandbox/camptocamp/MapFishUnhcr/client/build/build.py (modified) (3 diffs)
- sandbox/camptocamp/MapFishUnhcr/client/build/mergejs.py (modified) (1 diff)
- sandbox/camptocamp/MapFishUnhcr/client/mfbase/mapfish/tests/core/Protocol/test_MapFish.html (modified) (2 diffs)
- sandbox/camptocamp/MapFishUnhcr/client/mfbase/mapfish/tests/core/Protocol/test_MergeFilterDecorator.html (modified) (2 diffs)
- sandbox/camptocamp/MapFishUnhcr/client/mfbase/mapfish/tests/core/Protocol/test_TriggerEventDecorator.html (modified) (2 diffs)
- sandbox/camptocamp/MapFishUnhcr/client/mfbase/mapfish/tests/core/Searcher/test_Map.html (modified) (2 diffs)
- sandbox/camptocamp/MapFishUnhcr/client/mfbase/mapfish/tests/core/Strategy/test_ProtocolListener.html (modified) (2 diffs)
- sandbox/camptocamp/MapFishUnhcr/client/mfbase/mapfish/tests/core/test_Offline.html (modified) (2 diffs)
- sandbox/camptocamp/MapFishUnhcr/client/mfbase/mapfish/tests/core/test_PrintProtocol.html (modified) (1 diff)
- sandbox/camptocamp/MapFishUnhcr/client/mfbase/mapfish/tests/core/test_Util.html (modified) (2 diffs)
- sandbox/camptocamp/MapFishUnhcr/client/mfbase/mapfish/tests/widgets/data/test_FeatureReader.html (deleted)
- sandbox/camptocamp/MapFishUnhcr/client/mfbase/mapfish/tests/widgets/data/test_FeatureStoreMediator.html (deleted)
- sandbox/camptocamp/MapFishUnhcr/client/mfbase/mapfish/tests/widgets/data/test_GridRowFeatureMediator.html (modified) (2 diffs)
- sandbox/camptocamp/MapFishUnhcr/client/mfbase/mapfish/tests/widgets/data/test_LayerStoreMediator.html (deleted)
- sandbox/camptocamp/MapFishUnhcr/client/mfbase/mapfish/tests/widgets/data/test_SearchStoreMediator.html (modified) (6 diffs)
- sandbox/camptocamp/MapFishUnhcr/client/mfbase/mapfish/tests/widgets/toolbar/Toolbar.html (modified) (2 diffs)
- sandbox/camptocamp/MapFishUnhcr/client/mfbase/mapfish/tests/widgets/tree/test_LayerTree.html (modified) (2 diffs)
- sandbox/camptocamp/MapFishUnhcr/client/mfbase/mapfish/tests/widgets/tree/test_LayerTree_separator.html (modified) (2 diffs)
- sandbox/camptocamp/MapFishUnhcr/client/mfbase/mapfish/tests/widgets/tree/test_LayerTree_wmsLayerRedraw.html (modified) (2 diffs)
- sandbox/camptocamp/MapFishUnhcr/client/mfbase/mapfish/widgets/data/FeatureReader.js (modified) (3 diffs)
- sandbox/camptocamp/MapFishUnhcr/client/mfbase/mapfish/widgets/data/FeatureStoreMediator.js (modified) (3 diffs)
- sandbox/camptocamp/MapFishUnhcr/client/mfbase/mapfish/widgets/data/LayerStoreMediator.js (modified) (3 diffs)
- sandbox/camptocamp/MapFishUnhcr/client/mfbase/mapfish/widgets/data/SearchStoreMediator.js (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
sandbox/camptocamp/MapFishUnhcr/client/build/build.py
r1046 r1274 46 46 } 47 47 48 configDictGeoExt = { 49 'GeoExt.js': '../mfbase/geoext/core/lib', 50 'GeoExt': '../mfbase/geoext/core/lib' 51 } 52 48 53 configDictMapFish = { 49 54 'SingleFile.js': '../mfbase/mapfish', … … 65 70 -o --output outputfile Specify output file (default value: MapFish.js) 66 71 -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) 68 73 """ 69 74 ) … … 97 102 configDictGlobal = {} 98 103 configDictGlobal.update(configDictOpenLayers) 104 configDictGlobal.update(configDictGeoExt) 99 105 configDictGlobal.update(configDictMapFish) 100 106 sandbox/camptocamp/MapFishUnhcr/client/build/mergejs.py
r1046 r1274 281 281 raise SystemExit 282 282 else: 283 sourceDirectory = args[1]284 if not sourceDirectory :283 sourceDirectoryOpenLayers = args[1] 284 if not sourceDirectoryOpenLayers: 285 285 usage(sys.argv[0]) 286 286 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}) 289 296 290 297 configFile = None sandbox/camptocamp/MapFishUnhcr/client/mfbase/mapfish/tests/core/Protocol/test_MapFish.html
r993 r1274 2 2 <html debug="true"> 3 3 <head> 4 <link rel="stylesheet" type="text/css" href="../../../ext/resources/css/ext-all.css" />5 6 4 <script type="text/javascript" src="../../../../openlayers/lib/Firebug/firebug.js"></script> 7 5 <script type="text/javascript" src="../../../../openlayers/lib/OpenLayers.js"></script> … … 9 7 <script type="text/javascript" src="../../../../ext/adapter/ext/ext-base.js"></script> 10 8 <script type="text/javascript" src="../../../../ext/ext-all-debug.js"></script> 9 10 <script type="text/javascript" src="../../../../geoext/core/lib/GeoExt.js"></script> 11 11 12 12 <script type="text/javascript"> sandbox/camptocamp/MapFishUnhcr/client/mfbase/mapfish/tests/core/Protocol/test_MergeFilterDecorator.html
r1267 r1274 2 2 <html debug="true"> 3 3 <head> 4 <link rel="stylesheet" type="text/css" href="../../../ext/resources/css/ext-all.css" />5 6 4 <script type="text/javascript" src="../../../../openlayers/lib/Firebug/firebug.js"></script> 7 5 <script type="text/javascript" src="../../../../openlayers/lib/OpenLayers.js"></script> … … 9 7 <script type="text/javascript" src="../../../../ext/adapter/ext/ext-base.js"></script> 10 8 <script type="text/javascript" src="../../../../ext/ext-all-debug.js"></script> 9 10 <script type="text/javascript" src="../../../../geoext/core/lib/GeoExt.js"></script> 11 11 12 12 <script type="text/javascript"> sandbox/camptocamp/MapFishUnhcr/client/mfbase/mapfish/tests/core/Protocol/test_TriggerEventDecorator.html
r1223 r1274 2 2 <html debug="true"> 3 3 <head> 4 <link rel="stylesheet" type="text/css" href="../../../ext/resources/css/ext-all.css" />5 6 4 <script type="text/javascript" src="../../../../openlayers/lib/Firebug/firebug.js"></script> 7 5 <script type="text/javascript" src="../../../../openlayers/lib/OpenLayers.js"></script> … … 9 7 <script type="text/javascript" src="../../../../ext/adapter/ext/ext-base.js"></script> 10 8 <script type="text/javascript" src="../../../../ext/ext-all-debug.js"></script> 9 10 <script type="text/javascript" src="../../../../geoext/core/lib/GeoExt.js"></script> 11 11 12 12 <script type="text/javascript"> sandbox/camptocamp/MapFishUnhcr/client/mfbase/mapfish/tests/core/Searcher/test_Map.html
r1190 r1274 2 2 <html debug="true"> 3 3 <head> 4 <link rel="stylesheet" type="text/css" href="../../../ext/resources/css/ext-all.css" />5 6 4 <script type="text/javascript" src="../../../../openlayers/lib/Firebug/firebug.js"></script> 7 5 <script type="text/javascript" src="../../../../openlayers/lib/OpenLayers.js"></script> … … 9 7 <script type="text/javascript" src="../../../../ext/adapter/ext/ext-base.js"></script> 10 8 <script type="text/javascript" src="../../../../ext/ext-all-debug.js"></script> 9 10 <script type="text/javascript" src="../../../../geoext/core/lib/GeoExt.js"></script> 11 11 12 12 <script type="text/javascript"> sandbox/camptocamp/MapFishUnhcr/client/mfbase/mapfish/tests/core/Strategy/test_ProtocolListener.html
r1229 r1274 2 2 <html debug="true"> 3 3 <head> 4 <link rel="stylesheet" type="text/css" href="../../../ext/resources/css/ext-all.css" />5 6 4 <script type="text/javascript" src="../../../../openlayers/lib/Firebug/firebug.js"></script> 7 5 <script type="text/javascript" src="../../../../openlayers/lib/OpenLayers.js"></script> … … 9 7 <script type="text/javascript" src="../../../../ext/adapter/ext/ext-base.js"></script> 10 8 <script type="text/javascript" src="../../../../ext/ext-all-debug.js"></script> 9 10 <script type="text/javascript" src="../../../../geoext/core/lib/GeoExt.js"></script> 11 11 12 12 <script type="text/javascript"> sandbox/camptocamp/MapFishUnhcr/client/mfbase/mapfish/tests/core/test_Offline.html
r1124 r1274 2 2 <html> 3 3 <head> 4 <link rel="stylesheet" type="text/css" href="../../ext/resources/css/ext-all.css" />5 6 4 <script type="text/javascript" src="../../../openlayers/lib/Firebug/firebug.js"></script> 7 5 <script type="text/javascript" src="../../../openlayers/lib/OpenLayers.js"></script> … … 9 7 <script type="text/javascript" src="../../../ext/adapter/ext/ext-base.js"></script> 10 8 <script type="text/javascript" src="../../../ext/ext-all-debug.js"></script> 9 10 <script type="text/javascript" src="../../../geoext/core/lib/GeoExt.js"></script> 11 11 12 12 <script type="text/javascript"> sandbox/camptocamp/MapFishUnhcr/client/mfbase/mapfish/tests/core/test_PrintProtocol.html
r907 r1274 7 7 <script type="text/javascript" src="../../../ext/adapter/ext/ext-base.js"></script> 8 8 <script type="text/javascript" src="../../../ext/ext-all-debug.js"></script> 9 10 <script type="text/javascript" src="../../../geoext/core/lib/GeoExt.js"></script> 9 11 10 12 <script type="text/javascript"> sandbox/camptocamp/MapFishUnhcr/client/mfbase/mapfish/tests/core/test_Util.html
r868 r1274 2 2 <html debug="true"> 3 3 <head> 4 <link rel="stylesheet" type="text/css" href="../../ext/resources/css/ext-all.css" />5 6 4 <script type="text/javascript" src="../../../openlayers/lib/Firebug/firebug.js"></script> 7 5 <script type="text/javascript" src="../../../openlayers/lib/OpenLayers.js"></script> … … 9 7 <script type="text/javascript" src="../../../ext/adapter/ext/ext-base.js"></script> 10 8 <script type="text/javascript" src="../../../ext/ext-all-debug.js"></script> 9 10 <script type="text/javascript" src="../../../geoext/core/lib/GeoExt.js"></script> 11 11 12 12 <script type="text/javascript"> sandbox/camptocamp/MapFishUnhcr/client/mfbase/mapfish/tests/widgets/data/test_GridRowFeatureMediator.html
r1230 r1274 2 2 <html debug="true"> 3 3 <head> 4 <link rel="stylesheet" type="text/css" href="../../../../ext/resources/css/ext-all.css" />5 6 4 <script type="text/javascript" src="../../../../openlayers/lib/Firebug/firebug.js"></script> 7 5 <script type="text/javascript" src="../../../../openlayers/lib/OpenLayers.js"></script> … … 9 7 <script type="text/javascript" src="../../../../ext/adapter/ext/ext-base.js"></script> 10 8 <script type="text/javascript" src="../../../../ext/ext-all-debug.js"></script> 9 10 <script type="text/javascript" src="../../../../geoext/core/lib/GeoExt.js"></script> 11 11 12 12 <script type="text/javascript"> sandbox/camptocamp/MapFishUnhcr/client/mfbase/mapfish/tests/widgets/data/test_SearchStoreMediator.html
r1190 r1274 2 2 <html debug="true"> 3 3 <head> 4 <link rel="stylesheet" type="text/css" href="../../../../ext/resources/css/ext-all.css" />5 6 4 <script type="text/javascript" src="../../../../openlayers/lib/Firebug/firebug.js"></script> 7 5 <script type="text/javascript" src="../../../../openlayers/lib/OpenLayers.js"></script> … … 9 7 <script type="text/javascript" src="../../../../ext/adapter/ext/ext-base.js"></script> 10 8 <script type="text/javascript" src="../../../../ext/ext-all-debug.js"></script> 9 10 <script type="text/javascript" src="../../../../geoext/core/lib/GeoExt.js"></script> 11 11 12 12 <script type="text/javascript"> … … 25 25 var mediator, store, protocol; 26 26 store = new Ext.data.Store({ 27 reader: new mapfish.widgets.data.FeatureReader(27 reader: new GeoExt.data.FeatureReader( 28 28 {}, [{name: "name", type: "string"}] 29 29 ) … … 43 43 "ctor correctly sets protocol"); 44 44 t.ok(mediator.featureStoreMediator instanceof 45 mapfish.widgets.data.FeatureStoreMediator,45 GeoExt.data.FeatureStoreMediator, 46 46 "ctor correctly creates feature store mediator"); 47 47 } … … 55 55 }); 56 56 store = new Ext.data.Store({ 57 reader: new mapfish.widgets.data.FeatureReader(57 reader: new GeoExt.data.FeatureReader( 58 58 {}, [{name: "name", type: "string"}] 59 59 ) … … 94 94 }); 95 95 store = new Ext.data.Store({ 96 reader: new mapfish.widgets.data.FeatureReader(96 reader: new GeoExt.data.FeatureReader( 97 97 {}, [{name: "name", type: "string"}] 98 98 ) sandbox/camptocamp/MapFishUnhcr/client/mfbase/mapfish/tests/widgets/toolbar/Toolbar.html
r1257 r1274 2 2 <html debug="true"> 3 3 <head> 4 <link rel="stylesheet" type="text/css" href="../../../../ext/resources/css/ext-all.css" />5 6 4 <script type="text/javascript" src="../../../../openlayers/lib/Firebug/firebug.js"></script> 7 5 <script type="text/javascript" src="../../../../openlayers/lib/OpenLayers.js"></script> … … 9 7 <script type="text/javascript" src="../../../../ext/adapter/ext/ext-base.js"></script> 10 8 <script type="text/javascript" src="../../../../ext/ext-all-debug.js"></script> 9 10 <script type="text/javascript" src="../../../../geoext/core/lib/GeoExt.js"></script> 11 11 12 12 <script type="text/javascript"> sandbox/camptocamp/MapFishUnhcr/client/mfbase/mapfish/tests/widgets/tree/test_LayerTree.html
r1242 r1274 2 2 <html debug="true"> 3 3 <head> 4 <link rel="stylesheet" type="text/css" href="../../../../ext/resources/css/ext-all.css" />5 6 4 <script type="text/javascript" src="../../../../openlayers/lib/Firebug/firebug.js"></script> 7 5 <script type="text/javascript" src="../../../../openlayers/lib/OpenLayers.js"></script> … … 9 7 <script type="text/javascript" src="../../../../ext/adapter/ext/ext-base.js"></script> 10 8 <script type="text/javascript" src="../../../../ext/ext-all-debug.js"></script> 9 10 <script type="text/javascript" src="../../../../geoext/core/lib/GeoExt.js"></script> 11 11 12 12 <script type="text/javascript"> sandbox/camptocamp/MapFishUnhcr/client/mfbase/mapfish/tests/widgets/tree/test_LayerTree_separator.html
r935 r1274 2 2 <html debug="true"> 3 3 <head> 4 <link rel="stylesheet" type="text/css" href="../../../../ext/resources/css/ext-all.css" />5 6 4 <script type="text/javascript" src="../../../../openlayers/lib/Firebug/firebug.js"></script> 7 5 <script type="text/javascript" src="../../../../openlayers/lib/OpenLayers.js"></script> … … 9 7 <script type="text/javascript" src="../../../../ext/adapter/ext/ext-base.js"></script> 10 8 <script type="text/javascript" src="../../../../ext/ext-all-debug.js"></script> 9 10 <script type="text/javascript" src="../../../../geoext/core/lib/GeoExt.js"></script> 11 11 12 12 <script type="text/javascript"> sandbox/camptocamp/MapFishUnhcr/client/mfbase/mapfish/tests/widgets/tree/test_LayerTree_wmsLayerRedraw.html
r935 r1274 2 2 <html debug="true"> 3 3 <head> 4 <link rel="stylesheet" type="text/css" href="../../../../ext/resources/css/ext-all.css" />5 6 4 <script type="text/javascript" src="../../../../openlayers/lib/Firebug/firebug.js"></script> 7 5 <script type="text/javascript" src="../../../../openlayers/lib/OpenLayers.js"></script> … … 9 7 <script type="text/javascript" src="../../../../ext/adapter/ext/ext-base.js"></script> 10 8 <script type="text/javascript" src="../../../../ext/ext-all-debug.js"></script> 9 10 <script type="text/javascript" src="../../../../geoext/core/lib/GeoExt.js"></script> 11 11 12 12 <script type="text/javascript"> sandbox/camptocamp/MapFishUnhcr/client/mfbase/mapfish/widgets/data/FeatureReader.js
r1167 r1274 18 18 */ 19 19 20 /* 21 * @requires GeoExt/data/FeatureReader.js 22 */ 23 20 24 Ext.namespace('mapfish.widgets', 'mapfish.widgets.data'); 21 25 … … 25 29 * added to the store using this reader, specific fields like 26 30 * feature, state and fid are available. 31 * 32 * Note: this class is *deprecated*, GeoExt.data.FeatureReader should 33 * be used instead. 27 34 * 28 35 * Typical usage in a store: … … 45 52 * passed to {Ext.data.DataReader} constructor. 46 53 */ 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 }); 54 mapfish.widgets.data.FeatureReader = GeoExt.data.FeatureReader; sandbox/camptocamp/MapFishUnhcr/client/mfbase/mapfish/widgets/data/FeatureStoreMediator.js
r1125 r1274 19 19 20 20 /** 21 * @requires widgets/data/FeatureReader.js21 * @requires GeoExt/data/FeatureStoreMediator.js 22 22 */ 23 23 … … 27 27 * Class: mapfish.widgets.data.FeatureStoreMediator 28 28 * 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. 29 32 */ 30 33 … … 33 36 * Create an instance of mapfish.widgets.data.FeatureStoreMediator 34 37 */ 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 }; 38 mapfish.widgets.data.FeatureStoreMediator = GeoExt.data.FeatureStoreMediator; sandbox/camptocamp/MapFishUnhcr/client/mfbase/mapfish/widgets/data/LayerStoreMediator.js
r1124 r1274 19 19 20 20 /** 21 * @requires widgets/data/FeatureStoreMediator.js 22 * @requires OpenLayers/Layer/Vector.js 21 * @requires GeoExt/data/LayerStoreMediator.js 23 22 */ 24 23 … … 31 30 * update features in a grid as a result of features being inserted, 32 31 * removed, modified in a vector layer. 32 * 33 * Note: this class is *deprecated*, GeoExt.data.LayerStoreMediator 34 * should be used instead. 33 35 */ 34 36 … … 37 39 * Create an instance of mapfish.widgets.data.LayerStoreMediator. 38 40 */ 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 }; 41 mapfish.widgets.data.LayerStoreMediator = GeoExt.data.LayerStoreMediator; sandbox/camptocamp/MapFishUnhcr/client/mfbase/mapfish/widgets/data/SearchStoreMediator.js
r1190 r1274 19 19 20 20 /** 21 * @requires widgets/data/FeatureStoreMediator.js21 * @requires GeoExt/data/FeatureStoreMediator.js 22 22 * @requires core/Protocol/TriggerEventDecorator.js 23 23 */ … … 80 80 "TriggerEventDecorator protocol"); 81 81 } 82 this.featureStoreMediator = new mapfish.widgets.data.FeatureStoreMediator({82 this.featureStoreMediator = new GeoExt.data.FeatureStoreMediator({ 83 83 store: store 84 84 });