if(!map.getEditManager().containsListener(selectedLayerListener))
map.getEditManager().addListener(selectedLayerListener);
for( ToolCategory cat : categories ) {
for( ModalItem item : cat ) {
OpFilter enablesFor = item.getEnablesFor();
ILayer selectedLayer = map.getEditManager().getSelectedLayer();
// JG: I don't trust asserts in production code!
// assert enablesFor instanceof LazyOpFilter;
if( !(enablesFor instanceof LazyOpFilter) ){
enablesFor = new LazyOpFilter(item, enablesFor);
}
boolean accept = enablesFor.accept(selectedLayer);
item.setEnabled(accept);
}
}
}