01: /* uDig - User Friendly Desktop Internet GIS client
02: * http://udig.refractions.net
03: * (C) 2004, Refractions Research Inc.
04: *
05: * This library is free software; you can redistribute it and/or
06: * modify it under the terms of the GNU Lesser General Public
07: * License as published by the Free Software Foundation;
08: * version 2.1 of the License.
09: *
10: * This library is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: * Lesser General Public License for more details.
14: */
15: package net.refractions.udig.tool.select.internal;
16:
17: import net.refractions.udig.project.ILayer;
18: import net.refractions.udig.project.ILayerListener;
19: import net.refractions.udig.project.LayerEvent;
20: import net.refractions.udig.ui.operations.AbstractPropertyValue;
21:
22: import org.geotools.filter.Filter;
23:
24: /**
25: * Returns true if the layer has a selection. (layer's filter!=Filter.all)
26: * @author Jesse
27: * @since 1.1.0
28: */
29: public class LayerHasSelectionProperty extends
30: AbstractPropertyValue<ILayer> {
31:
32: private ILayerListener listener = new ILayerListener() {
33:
34: public void refresh(LayerEvent event) {
35: if (event.getType() == LayerEvent.EventType.FILTER) {
36: notifyListeners(event.getSource());
37: }
38: }
39:
40: };
41:
42: public boolean canCacheResult() {
43: return false;
44: }
45:
46: public boolean isBlocking() {
47: return false;
48: }
49:
50: public boolean isTrue(ILayer layer, String value) {
51: layer.addListener(listener);
52: return layer.getFilter() != Filter.ALL;
53: }
54:
55: }
|