001: /*
002: * uDig - User Friendly Desktop Internet GIS client http://udig.refractions.net (C) 2004,
003: * Refractions Research Inc. This library is free software; you can redistribute it and/or modify it
004: * under the terms of the GNU Lesser General Public License as published by the Free Software
005: * Foundation; version 2.1 of the License. This library is distributed in the hope that it will be
006: * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
007: * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
008: */
009: package net.refractions.udig.project.command;
010:
011: import java.net.URL;
012:
013: import net.refractions.udig.catalog.IGeoResource;
014: import net.refractions.udig.core.StaticBlockingProvider;
015: import net.refractions.udig.project.ILayer;
016: import net.refractions.udig.project.internal.Layer;
017: import net.refractions.udig.project.internal.commands.DeleteLayerCommand;
018: import net.refractions.udig.project.internal.commands.edit.CreateFeatureCommand;
019: import net.refractions.udig.project.internal.commands.edit.CreateLayerCommand;
020: import net.refractions.udig.project.internal.commands.edit.DeleteFeatureCommand;
021: import net.refractions.udig.project.internal.commands.edit.ResetEditFeatureCommand;
022: import net.refractions.udig.project.internal.commands.edit.RollbackCommand;
023: import net.refractions.udig.project.internal.commands.edit.SetAttributeCommand;
024: import net.refractions.udig.project.internal.commands.edit.SetEditFeatureCommand;
025: import net.refractions.udig.project.internal.commands.edit.SetGeometryCommand;
026: import net.refractions.udig.project.internal.commands.edit.WriteEditFeatureCommand;
027: import net.refractions.udig.project.internal.commands.selection.CommitCommand;
028:
029: import org.geotools.feature.Feature;
030:
031: import com.vividsolutions.jts.geom.Coordinate;
032: import com.vividsolutions.jts.geom.Geometry;
033:
034: /**
035: * Creates Edit commands which must be used to modify editable feature data. API internal classes
036: * are in the returned API
037: *
038: * @author jeichar
039: * @deprecated
040: * @since 0.3
041: */
042: public class EditCommandFactory {
043: /**
044: * Creates a new EditCommandFactory object
045: *
046: * @return a new EditCommandFactory object
047: */
048: public static EditCommandFactory getInstance() {
049: return instance;
050: }
051:
052: private static final EditCommandFactory instance = new EditCommandFactory();
053:
054: protected EditCommandFactory() {
055: // no op
056: }
057:
058: /**
059: * Creates a {@linkplain SetAttributeCommand}object.
060: *
061: * @param xpath xpath that identifies an attribute in the current editable Feature
062: * @param value the value that the attribute will be set to.
063: * @return a new {@linkplain SetAttributeCommand}object
064: * @see EditCommand
065: */
066: public UndoableMapCommand createSetAttributeCommand(String xpath,
067: Object value) {
068: return new SetAttributeCommand(xpath, value);
069: }
070:
071: /**
072: * Creates a {@linkplain SetGeometryCommand}object.
073: *
074: * @param xpath xpath that identifies an attribute in the current editable Feature
075: * @param geom the geom (in <b>layer </b> CRS) that the geometry will be set to.
076: * @return a new {@linkplain SetGeometryCommand}object
077: * @see EditCommand
078: * @see Geometry
079: */
080: public UndoableMapCommand createSetGeometryCommand(String xpath,
081: Geometry geom) {
082: return new SetGeometryCommand(xpath, geom);
083: }
084:
085: /**
086: * Creates a {@linkplain SetGeometryCommand}object that sets the default geometry.
087: *
088: * @param geom the geom (in <b>layer </b> CRS) that the geometry will be set to.
089: * @return a new {@linkplain SetGeometryCommand}object.
090: * @see EditCommand
091: * @see Geometry
092: */
093: public UndoableMapCommand createSetGeometryCommand(Geometry geom) {
094: return new SetGeometryCommand(SetGeometryCommand.DEFAULT, geom);
095: }
096:
097: /**
098: * Creates a {@linkplain SetEditFeatureCommand}object that sets the current editVictim victim.
099: *
100: * @param feature the feature that will be the new editable Feature.
101: * @param layer A victim Store that contains the editable Feature.
102: * @return a new {@linkplain SetEditFeatureCommand}object.
103: * @see Feature
104: * @see Layer
105: * @see UndoableMapCommand
106: */
107: public UndoableMapCommand createSetEditFeatureCommand(
108: Feature feature, ILayer layer) {
109: return new SetEditFeatureCommand(feature, layer);
110: }
111:
112: /**
113: * Create a Commit command
114: *
115: * @return a new {@linkplain CommitCommand} object that deletes the feature.
116: * @see CommitCommand
117: */
118: public MapCommand createCommitCommand() {
119: return new CommitCommand();
120: }
121:
122: /**
123: * Create a Commit command
124: *
125: * @return a new {@linkplain RollbackCommand} object that deletes the feature.
126: * @see RollbackCommand
127: */
128: public MapCommand createRollbackCommand() {
129: return new RollbackCommand();
130: }
131:
132: /**
133: * Creates a {@linkplain SetEditFeatureCommand}object that sets the current editable Feature.
134: *
135: * @param feature the feature that will be the new editable Feature.
136: * @return a new {@linkplain SetEditFeatureCommand}object.
137: * @see UndoableMapCommand
138: * @see Feature
139: */
140: public UndoableMapCommand createSetEditFeatureCommand(
141: Feature feature) {
142: return new SetEditFeatureCommand(feature);
143: }
144:
145: /**
146: * Creates a {@linkplain SetEditFeatureCommand}object that sets the current editable Feature
147: * to null.
148: *
149: * @return a new {@linkplain SetEditFeatureCommand}object that sets the current editable
150: * Feature to null..
151: * @see UndoableMapCommand
152: */
153: public UndoableMapCommand createNullEditFeatureCommand() {
154: return new SetEditFeatureCommand((Feature) null, (ILayer) null);
155: }
156:
157: /**
158: * @param coordinates the coordinates of the new feature in <b>Map </b> CRS.
159: * @return a new {@linkplain CreateFeatureCommand}object creates the feature.
160: * @see CreateFeatureCommand
161: */
162: public UndoableMapCommand createFeature(Coordinate[] coordinates) {
163: return new CreateFeatureCommand(coordinates);
164: }
165:
166: /**
167: * Create a delete layer command
168: *
169: * @param map the map containing the layer
170: * @param layer the layer to delete
171: * @return a new {@linkplain DeleteLayerCommand}object that deletes the layer.
172: * @see DeleteLayerCommand
173: */
174: public UndoableMapCommand createDeleteLayer(Layer layer) {
175: return new DeleteLayerCommand(layer);
176: }
177:
178: /**
179: * Create a Delete Feature command
180: *
181: * @param layer the layer containing the feature
182: * @param feature the feature to delete
183: * @return a new {@linkplain DeleteFeatureCommand}object that deletes the feature.
184: * @see DeleteFeatureCommand
185: */
186: public UndoableMapCommand createDeleteFeature(Feature feature,
187: ILayer layer) {
188: return new DeleteFeatureCommand(
189: new StaticBlockingProvider<Feature>(feature),
190: new StaticBlockingProvider<ILayer>(layer));
191: }
192:
193: /**
194: * Create a {@linkplain WriteEditFeatureCommand} command
195: *
196: * @return a new {@linkplain WriteEditFeatureCommand} object that deletes the feature.
197: * @see WriteEditFeatureCommand
198: */
199: public UndoableMapCommand createWriteEditFeatureCommand() {
200: return new WriteEditFeatureCommand();
201: }
202:
203: /**
204: * Create a {@linkplain CreateLayerCommand}
205: *
206: * @see CreateLayerCommand
207: */
208: public UndoableMapCommand createCreateLayerCommand(URL resourceId) {
209: return new CreateLayerCommand(resourceId);
210: }
211:
212: /**
213: * Create a {@linkplain CreateLayerCommand}
214: *
215: * @see CreateLayerCommand
216: */
217: public UndoableMapCommand createCreateLayerCommand(
218: IGeoResource resource) {
219: return new CreateLayerCommand(resource);
220: }
221:
222: /**
223: * Create a {@linkplain ResetEditFeatureCommand} command
224: *
225: * @return a new {@linkplain ResetEditFeatureCommand} object that deletes the feature.
226: * @see ResetEditFeatureCommand
227: */
228: public UndoableMapCommand createResetEditFeatureCommand() {
229: return new ResetEditFeatureCommand();
230: }
231:
232: }
|