01: /*
02: * uDig - User Friendly Desktop Internet GIS client http://udig.refractions.net (C) 2004,
03: * Refractions Research Inc. This library is free software; you can redistribute it and/or modify it
04: * under the terms of the GNU Lesser General Public License as published by the Free Software
05: * Foundation; version 2.1 of the License. This library is distributed in the hope that it will be
06: * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
07: * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
08: */
09: package net.refractions.udig.project.internal.commands.edit;
10:
11: import net.refractions.udig.core.IBlockingProvider;
12: import net.refractions.udig.project.ILayer;
13: import net.refractions.udig.project.command.UndoableCommand;
14:
15: import org.eclipse.core.runtime.IProgressMonitor;
16: import org.geotools.feature.Feature;
17:
18: import com.vividsolutions.jts.geom.Geometry;
19:
20: /**
21: * Sets the geometry attribute of a feature.
22: *
23: * @author jeichar
24: * @since 0.7
25: */
26: public class SetGeometryCommand extends SetAttributeCommand implements
27: UndoableCommand {
28: /** The id for the DefaultGeometry */
29: public static final String DEFAULT = "DEFAULT_GEOMETRY"; //$NON-NLS-1$
30:
31: /**
32: * Creates a new instance of SetGeomteryCommand.
33: * @param layer
34: * @param feature
35: *
36: * @param xpath the xpath which identifies the geometry to change. if <code>DEFAULT</code> the
37: * default geometry will be set.
38: * @param geom the new geometry in the layer CRS.
39: */
40: public SetGeometryCommand(IBlockingProvider<Feature> feature,
41: IBlockingProvider<ILayer> layer, String xpath, Geometry geom) {
42: super (feature, layer, xpath, geom);
43: }
44:
45: /**
46: * Creates a new instance of SetGeomteryCommand.
47: * @param evaluationObject
48: * @param feature
49: *
50: * @param xpath the xpath which identifies the geometry to change. if <code>DEFAULT</code> the
51: * default geometry will be set.
52: * @param geom the new geometry in the layer CRS.
53: */
54: public SetGeometryCommand(String xpath, Geometry geom) {
55: super (xpath, geom);
56: }
57:
58: /**
59: * @param featureID
60: * @param layer
61: * @param default2
62: * @param geom
63: */
64: public SetGeometryCommand(String featureID,
65: IBlockingProvider<ILayer> layer, String xpath, Geometry geom) {
66: super (featureID, layer, xpath, geom);
67: }
68:
69: /**
70: * @see net.refractions.udig.project.internal.command.MapCommand#run()
71: */
72: public void run(IProgressMonitor monitor) throws Exception {
73: if (xpath.equals(DEFAULT))
74: xpath = editLayer.get(monitor).getSchema()
75: .getDefaultGeometry().getName();
76: super.run(monitor);
77: }
78:
79: }
|