Revision 2616 org.gvsig.vectorediting/trunk/org.gvsig.vectorediting/org.gvsig.vectorediting.lib/org.gvsig.vectorediting.lib.prov/org.gvsig.vectorediting.lib.prov.remove/src/main/java/org/gvsig/vectorediting/lib/prov/remove/RemoveEditingProvider.java
RemoveEditingProvider.java | ||
---|---|---|
28 | 28 |
import java.util.HashMap; |
29 | 29 |
import java.util.List; |
30 | 30 |
import java.util.Map; |
31 |
|
|
32 | 31 |
import org.gvsig.fmap.dal.exception.DataException; |
33 | 32 |
import org.gvsig.fmap.dal.feature.Feature; |
34 | 33 |
import org.gvsig.fmap.dal.feature.FeatureSelection; |
... | ... | |
36 | 35 |
import org.gvsig.fmap.geom.Geometry; |
37 | 36 |
import org.gvsig.fmap.geom.primitive.Point; |
38 | 37 |
import org.gvsig.tools.ToolsLocator; |
39 |
import org.gvsig.tools.dispose.DisposeUtils; |
|
40 | 38 |
import org.gvsig.tools.dynobject.DynObject; |
41 | 39 |
import org.gvsig.tools.exception.BaseException; |
42 | 40 |
import org.gvsig.tools.service.spi.ProviderServices; |
43 |
import org.gvsig.tools.visitor.VisitCanceledException; |
|
44 |
import org.gvsig.tools.visitor.Visitor; |
|
45 | 41 |
import org.gvsig.vectorediting.lib.api.DrawingStatus; |
46 | 42 |
import org.gvsig.vectorediting.lib.api.EditingServiceParameter; |
47 | 43 |
import org.gvsig.vectorediting.lib.api.EditingServiceParameter.TYPE; |
... | ... | |
63 | 59 |
public class RemoveEditingProvider extends AbstractEditingProvider implements |
64 | 60 |
EditingProvider { |
65 | 61 |
|
66 |
private EditingServiceParameter selection; |
|
62 |
private final EditingServiceParameter selection;
|
|
67 | 63 |
|
68 |
private FeatureStore featureStore; |
|
64 |
private final FeatureStore featureStore;
|
|
69 | 65 |
|
70 | 66 |
private Map<EditingServiceParameter, Object> values; |
71 | 67 |
|
... | ... | |
91 | 87 |
|
92 | 88 |
} |
93 | 89 |
|
90 |
@Override |
|
94 | 91 |
public EditingServiceParameter next() { |
95 | 92 |
if (values.get(selection) == null) { |
96 | 93 |
return selection; |
... | ... | |
98 | 95 |
return null; |
99 | 96 |
} |
100 | 97 |
|
98 |
@Override |
|
101 | 99 |
public DrawingStatus getDrawingStatus(Point mousePosition) |
102 | 100 |
throws DrawServiceException { |
103 | 101 |
return null; |
104 | 102 |
} |
105 | 103 |
|
104 |
@Override |
|
106 | 105 |
public void stop() throws StopServiceException { |
107 | 106 |
if (values != null) { |
108 | 107 |
values.clear(); |
109 | 108 |
} |
110 | 109 |
} |
111 | 110 |
|
111 |
@Override |
|
112 | 112 |
public List<EditingServiceParameter> getParameters() { |
113 | 113 |
List<EditingServiceParameter> parameters = |
114 |
new ArrayList<EditingServiceParameter>();
|
|
114 |
new ArrayList<>(); |
|
115 | 115 |
parameters.add(selection); |
116 | 116 |
return parameters; |
117 | 117 |
} |
... | ... | |
121 | 121 |
validateAndInsertValue(parameter, value); |
122 | 122 |
} |
123 | 123 |
|
124 |
@Override |
|
124 | 125 |
public void setValue(Object value) throws InvalidEntryException { |
125 | 126 |
EditingServiceParameter parameter = next(); |
126 | 127 |
validateAndInsertValue(parameter, value); |
... | ... | |
138 | 139 |
} |
139 | 140 |
} |
140 | 141 |
|
142 |
@Override |
|
141 | 143 |
public Geometry finish() throws FinishServiceException { |
142 | 144 |
return null; |
143 | 145 |
} |
144 | 146 |
|
147 |
@Override |
|
145 | 148 |
public void finishAndStore() throws FinishServiceException { |
146 | 149 |
|
147 | 150 |
if (values != null) { |
... | ... | |
152 | 155 |
|
153 | 156 |
|
154 | 157 |
try { |
155 |
featureSelection.accept(new Visitor() { |
|
156 |
|
|
157 |
public void visit(Object obj) |
|
158 |
throws VisitCanceledException, BaseException { |
|
159 |
final Feature feature = (Feature) obj; |
|
160 |
|
|
161 |
((EditingProviderServices) getProviderServices()) |
|
158 |
featureSelection.accept((Object obj) -> { |
|
159 |
final Feature feature = (Feature) obj; |
|
160 |
|
|
161 |
((EditingProviderServices) getProviderServices()) |
|
162 | 162 |
.deleteFeatureFromFeatureSet(feature, |
163 |
featureStore, featureSelection); |
|
164 |
} |
|
163 |
featureStore, featureSelection); |
|
165 | 164 |
}); |
166 | 165 |
|
167 | 166 |
featureSelection.deselectAll(); |
... | ... | |
172 | 171 |
} |
173 | 172 |
} |
174 | 173 |
|
174 |
@Override |
|
175 | 175 |
public void start() throws StartServiceException, InvalidEntryException { |
176 |
values = new HashMap<EditingServiceParameter, Object>();
|
|
176 |
values = new HashMap<>(); |
|
177 | 177 |
FeatureSelection selected = null; |
178 | 178 |
if (featureStore != null) { |
179 | 179 |
try { |
... | ... | |
189 | 189 |
} |
190 | 190 |
} |
191 | 191 |
|
192 |
@Override |
|
192 | 193 |
public String getName() { |
193 | 194 |
return RemoveEditingProviderFactory.PROVIDER_NAME; |
194 | 195 |
} |
Also available in: Unified diff