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.provider;
16:
17: import java.io.IOException;
18:
19: import net.refractions.udig.core.IBlockingProvider;
20: import net.refractions.udig.project.IMap;
21: import net.refractions.udig.project.command.MapCommand;
22:
23: import org.eclipse.core.runtime.IProgressMonitor;
24: import org.geotools.data.FeatureStore;
25:
26: /**
27: * Obtains the feature store from the current edit layer.
28: * @author Jesse
29: * @since 1.1.0
30: */
31: public class EditLayerFeatureStoreProvider implements
32: IBlockingProvider<FeatureStore> {
33:
34: private IMap map;
35: private MapCommand command;
36:
37: public EditLayerFeatureStoreProvider(IMap map) {
38: this .map = map;
39: }
40:
41: public EditLayerFeatureStoreProvider(MapCommand command) {
42: this .command = command;
43: }
44:
45: public FeatureStore get(IProgressMonitor monitor)
46: throws IOException {
47: if (map == null)
48: map = command.getMap();
49: return map.getEditManager().getEditLayer().getResource(
50: FeatureStore.class, monitor);
51: }
52:
53: }
|