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.command;
16:
17: import net.refractions.udig.project.ILayer;
18: import net.refractions.udig.project.internal.Layer;
19:
20: import org.eclipse.core.runtime.IProgressMonitor;
21:
22: /**
23: * Set the visiblity of the layer
24: * @author Jesse
25: * @since 1.1.0
26: */
27: public class SetLayerVisibilityCommand extends AbstractCommand
28: implements UndoableMapCommand {
29:
30: private final ILayer layer;
31: private final boolean newValue;
32: private boolean oldvalue;
33:
34: public SetLayerVisibilityCommand(final ILayer layer,
35: final boolean newValue) {
36: this .layer = layer;
37: this .newValue = newValue;
38: }
39:
40: public String getName() {
41: return "Set Layer Visibility";
42: }
43:
44: public void run(IProgressMonitor monitor) throws Exception {
45: this .oldvalue = layer.isVisible();
46: ((Layer) layer).setVisible(newValue);
47: }
48:
49: public void rollback(IProgressMonitor monitor) throws Exception {
50: ((Layer) layer).setVisible(oldvalue);
51: }
52:
53: }
|