| | 236 | }, |
|---|
| | 237 | |
|---|
| | 238 | /** private: method[onLayerVisiilityChanged |
|---|
| | 239 | * handler for visibilitychanged events on the layer |
|---|
| | 240 | */ |
|---|
| | 241 | onLayerVisibilityChanged: function() { |
|---|
| | 242 | if(!this.visibilityChanging && |
|---|
| | 243 | this.attributes.checked != this.layer.getVisibility()) { |
|---|
| | 244 | this.getUI().toggleCheck(this.layer.getVisibility()); |
|---|
| | 245 | } |
|---|
| | 246 | }, |
|---|
| | 247 | |
|---|
| | 248 | /** private: method[onCheckChange] |
|---|
| | 249 | * :param node: ``GeoExt.tree.LayerNode`` |
|---|
| | 250 | * :param checked: ``Boolean`` |
|---|
| | 251 | * handler for checkchange events |
|---|
| | 252 | */ |
|---|
| | 253 | onCheckChange: function(node, checked) { |
|---|
| | 254 | if (checked && this.layer.isBaseLayer && this.layer.map) { |
|---|
| | 255 | this.layer.map.setBaseLayer(this.layer); |
|---|
| | 256 | } |
|---|
| | 257 | this.layer.setVisibility(checked); |
|---|
| 251 | | "add": function(store, records, index) { |
|---|
| 252 | | var l; |
|---|
| 253 | | for(var i=0; i<records.length; ++i) { |
|---|
| 254 | | l = records[i].get("layer"); |
|---|
| 255 | | if(this.layer == l) { |
|---|
| 256 | | this.getUI().show(); |
|---|
| 257 | | } else if (this.layer == l.name) { |
|---|
| 258 | | // layer is a string, which means the node has not yet |
|---|
| 259 | | // been rendered because the layer was not found. But |
|---|
| 260 | | // now we have the layer and can render. |
|---|
| 261 | | this.render(bulkRender); |
|---|
| 262 | | return; |
|---|
| 263 | | } |
|---|
| 264 | | } |
|---|
| 265 | | }, |
|---|
| 266 | | "remove": function(store, record, index) { |
|---|
| 267 | | if(this.layer == record.get("layer")) { |
|---|
| 268 | | this.getUI().hide(); |
|---|
| 269 | | } |
|---|
| 270 | | }, |
|---|
| | 266 | "add": this.onStoreAdd, |
|---|
| | 267 | "remove": this.onStoreRemove, |
|---|
| | 270 | }, |
|---|
| | 271 | |
|---|
| | 272 | /** private: method[onStoreAdd] |
|---|
| | 273 | * :param store: ``Ext.data.Store`` |
|---|
| | 274 | * :param records: ``Array(Ext.data.Record)`` |
|---|
| | 275 | * :param index: ``Nmber`` |
|---|
| | 276 | * handler for add events on the store |
|---|
| | 277 | */ |
|---|
| | 278 | onStoreAdd: function(store, records, index) { |
|---|
| | 279 | var l; |
|---|
| | 280 | for(var i=0; i<records.length; ++i) { |
|---|
| | 281 | l = records[i].get("layer"); |
|---|
| | 282 | if(this.layer == l) { |
|---|
| | 283 | this.getUI().show(); |
|---|
| | 284 | } else if (this.layer == l.name) { |
|---|
| | 285 | // layer is a string, which means the node has not yet |
|---|
| | 286 | // been rendered because the layer was not found. But |
|---|
| | 287 | // now we have the layer and can render. |
|---|
| | 288 | this.render(bulkRender); |
|---|
| | 289 | return; |
|---|
| | 290 | } |
|---|
| | 291 | } |
|---|
| | 292 | }, |
|---|
| | 293 | |
|---|
| | 294 | /** private: method[onStoreRemove] |
|---|
| | 295 | * :param store: ``Ext.data.Store`` |
|---|
| | 296 | * :param record: ``Ext.data.Record`` |
|---|
| | 297 | * :param index: ``Nmber`` |
|---|
| | 298 | * handler for remove events on the store |
|---|
| | 299 | */ |
|---|
| | 300 | onStoreRemove: function(store, record, index) { |
|---|
| | 301 | if(this.layer == record.get("layer")) { |
|---|
| | 302 | this.getUI().hide(); |
|---|
| | 303 | } |
|---|
| | 316 | }, |
|---|
| | 317 | |
|---|
| | 318 | /** private: method[destroy] |
|---|
| | 319 | */ |
|---|
| | 320 | destroy: function() { |
|---|
| | 321 | this.layer.events.un({ |
|---|
| | 322 | "visibilitychanged": this.onLayerVisibilityChanged, |
|---|
| | 323 | scope: this |
|---|
| | 324 | }); |
|---|
| | 325 | delete this.layer; |
|---|
| | 326 | this.layerStore.un("add", this.onStoreAdd, this); |
|---|
| | 327 | this.layerStore.un("remove", this.onStoreRemove, this); |
|---|
| | 328 | delete this.layerStore; |
|---|
| | 329 | this.un("checkchange", this.onCheckChange, this); |
|---|
| | 330 | |
|---|
| | 331 | GeoExt.tree.LayerNode.superclass.destroy.call(this); |
|---|