Opened 8 years ago

Closed 6 years ago

#235 closed enhancement (fixed)

Gray out layers nodes based on min/maxResolution

Reported by: fredj Owned by: mpriour
Priority: major Milestone: 1.2
Component: GeoExt.tree Version: trunk
Keywords: Cc:
State: Complete

Description

See http://www.geoext.org/pipermail/users/2009-December/000413.html

Gray out layers that are invisible due to min/maxResolution constraints but don't disable checkbox or radio.

Attachments (5)

235.0.patch (1.2 KB) - added by fredj 8 years ago.
onStoreUpdate, call LayerNodeUI.onInRangeChange to set a new css class on the node. absolutely untested patch.
autoDisableLayerNode.patch (2.7 KB) - added by mpriour 7 years ago.
Patch without tests to automatically enable / disable any LayerNode with a layer whose 'inRange' property is false. Doesn't attempt to enable/disable nodes with base layers or alwaysInRange layers
autoDisableLayerNode.2.patch (6.3 KB) - added by mpriour 7 years ago.
autoDisable nodes patch with tests for max/min resolution. Also this patch will respect a specified attribute of 'autoDisable:false' regardless of the node's layer's parameters
geoext-AutoDisablePlugin.patch (11.1 KB) - added by mpriour 7 years ago.
geoext-235.patch (10.7 KB) - added by ahocevar 7 years ago.

Download all attachments as: .zip

Change History (19)

Changed 8 years ago by fredj

onStoreUpdate, call LayerNodeUI.onInRangeChange to set a new css class on the node. absolutely untested patch.

comment:1 Changed 7 years ago by ahocevar

  • Milestone changed from 1.0 to 1.1

Changed 7 years ago by mpriour

Patch without tests to automatically enable / disable any LayerNode with a layer whose 'inRange' property is false. Doesn't attempt to enable/disable nodes with base layers or alwaysInRange layers

Changed 7 years ago by mpriour

autoDisable nodes patch with tests for max/min resolution. Also this patch will respect a specified attribute of 'autoDisable:false' regardless of the node's layer's parameters

comment:2 Changed 7 years ago by mpriour

Updated original autoDisableLayerNode patch and added it to the ticket as 'autoDisableLayerNode.2.patch'. This patch against the trunk contains tests for autoDisabling layers based on layer's max/minResolution, isBaseLayer, and alwaysInRange properties. It also test that layer node is never autoDisabled if 'autoDisable:false' was specified for the node.

comment:3 Changed 7 years ago by mpriour

  • State changed from None to Review

comment:4 Changed 7 years ago by ahocevar

  • State changed from Review to Needs more work

@mpriour: the flesh of the patch is good, but what do you think about making this a tree plugin? Then it would also work for LayerParamNodes:

GeoExt.plugins.TreeNodeAutoDisable = function() {};
GeoExt.plugins.TreeNodeAutoDisable.prototype = {
    init: function(tree) {
        tree.on("rendernode", this.onRenderNode, this);
    },
    
    onRenderNode: function(node) {
        if(node.layer && node.layer instanceof OpenLayers.Layer) {
            node.layer.map.events.register("moveend", this, function() {
                node.layer.inRange ? node.enable() : node.disable();
            });
        }
    }    
};

Also, please make sure that your editor uses 4 spaces for indentation.

comment:5 Changed 7 years ago by mpriour

@ahocevar: Making it into a tree plugin is OK, too. I got the feeling that people wanted it as default behavior. So I'll add a plug-in patch and then people can decide which way makes more sense.

Also, I'll make sure to fix the tab/space & # of spaces issue. Thanks for the reminder on that.

comment:6 Changed 7 years ago by ahocevar

@mpriour: I agree that there is value in making this the default behavior. But in this case, we will not not need an autoDisable option.

comment:7 Changed 7 years ago by ahocevar

  • State changed from Needs more work to Review

The above patch adds a new non-API mixin with shared code for TreeNode subclasses that have to deal with layers. So this works now for both LayerNode and LayerParamNode. There is no autoDisable option any more, because after discussions on the list we seem to agree that we want to have this behavior by default.

Tests for LayerNode are basically taken from mpriour's patch.

Tests pass in Safari5. Thanks for any review.

comment:8 Changed 7 years ago by mpriour

I did not see the actual content of the file "GeoExt/widgets/tree/TreeNodeLayerMixin.js" in the geoext-235.patch

comment:9 Changed 7 years ago by ahocevar

Updated patch, now with the missing TreeNodeLayerMixin.js file.

Changed 7 years ago by mpriour

comment:10 Changed 7 years ago by mpriour

Here is the patch for the plugin approach. This plugin for the tree automatically extends any node's ui to include the TreeNodeUIEventMixin events. It then registers the rendernode listener to enable/disable the node if appropriate.

I think I prefer your mixin method the best. However, I still think it would be nice to be able to allow people the option of turning off the autoDisable functionality. In my patch you would not normally need to ever use the autoDisable property, but if you really wanted to turn it off for a single node or group of nodes, then you could.

comment:11 Changed 7 years ago by ahocevar

@mpriour: the problem with attachment:geoext-AutoDisablePlugin.patch I see is that it also adds the TreeNodeUIEventMixin to UIs that have it already. And I'm not sure if the sequence you use for the uiClass is correct.

Changed 7 years ago by ahocevar

comment:12 Changed 6 years ago by mpriour

  • Owner changed from ahocevar to mpriour
  • State changed from Review to Needs more work
  • Status changed from new to assigned

comment:13 Changed 6 years ago by ahocevar

  • Milestone changed from 1.1 to 1.2

Batch move of tickets to finish the 1.1 milestone.

comment:14 Changed 6 years ago by ahocevar

  • Resolution set to fixed
  • State changed from Needs more work to Complete
  • Status changed from assigned to closed
Note: See TracTickets for help on using tickets.