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.project.internal.commands.selection;
16:
17: import net.refractions.udig.project.ILayer;
18: import net.refractions.udig.project.command.AbstractCommand;
19: import net.refractions.udig.project.command.UndoableMapCommand;
20: import net.refractions.udig.project.internal.Layer;
21: import net.refractions.udig.project.internal.Messages;
22:
23: import org.eclipse.core.runtime.IProgressMonitor;
24: import org.geotools.filter.Filter;
25:
26: /**
27: * Set an arbitrary selection filter on a layer.
28: *
29: * @author chorner
30: * @since 1.0.1
31: */
32: public class SelectCommand extends AbstractCommand implements
33: UndoableMapCommand {
34: private ILayer layer;
35: private Filter newfilter;
36: private Filter oldfilter;
37:
38: public SelectCommand(ILayer layer, Filter filter) {
39: this .layer = layer;
40: newfilter = filter;
41: }
42:
43: public void run(IProgressMonitor monitor) throws Exception {
44: Layer target = (Layer) layer;
45: oldfilter = target.getFilter();
46: target.setFilter(newfilter);
47: }
48:
49: public String getName() {
50: return Messages.SelectCommand_name + layer.getName();
51: }
52:
53: public void rollback(IProgressMonitor monitor) throws Exception {
54: Layer target = (Layer) layer;
55: target.setFilter(oldfilter);
56: }
57:
58: }
|