Revision 9781 org.gvsig.online/trunk/org.gvsig.online/org.gvsig.online.swing/org.gvsig.online.swing.impl/src/main/java/org/gvsig/online/swing/impl/simplesearch/SimpleSearchImpl.java
SimpleSearchImpl.java | ||
---|---|---|
153 | 153 |
|
154 | 154 |
@Override |
155 | 155 |
public int download() { |
156 |
return download(null); |
|
156 |
return download(null, null);
|
|
157 | 157 |
} |
158 | 158 |
|
159 | 159 |
@Override |
160 |
public int download(SimpleTaskStatus status) { |
|
160 |
public int download(Expression filter, SimpleTaskStatus status) {
|
|
161 | 161 |
if(!isSearched()){ |
162 | 162 |
return ERR_OK; |
163 | 163 |
} |
164 | 164 |
if(status == null){ |
165 | 165 |
status = SimpleTaskStatus.FAKE_STATUS; |
166 | 166 |
} |
167 |
FeatureSet set = null; |
|
167 | 168 |
try { |
168 | 169 |
IProjection proj4326 = CRSFactory.getCRS("EPSG:4326"); |
169 | 170 |
ICoordTrans ct = proj4326.getCT(this.entity.getCRSAsProjection()); |
170 | 171 |
|
171 | 172 |
this.fullEnv = GeometryLocator.getGeometryManager().createEnvelope(Geometry.SUBTYPES.GEOM2D); |
172 |
Iterator<Feature> it = feats.iterator(); |
|
173 |
Iterator<Feature> it; |
|
174 |
if( filter == null ) { |
|
175 |
it = feats.iterator(); |
|
176 |
} else { |
|
177 |
set = feats.getFeatureStore().getFeatureSet(filter); |
|
178 |
it = set.fastIterator(); |
|
179 |
} |
|
173 | 180 |
Iterator<Geometry> geoms = new Iterator<Geometry>() { |
174 | 181 |
@Override |
175 | 182 |
public boolean hasNext() { |
... | ... | |
188 | 195 |
int n = wc.download(entity.getEntityName(), geoms, status); |
189 | 196 |
|
190 | 197 |
SwingUtilities.invokeLater(() -> { |
191 |
setSelection(); |
|
198 |
setSelection(filter);
|
|
192 | 199 |
OnlineSwingServices services = OnlineSwingLocator.getOnlineSwingManager().getDefaultServices(); |
193 | 200 |
services.refreshDocument(getFeatureStore()); |
194 | 201 |
}); |
... | ... | |
197 | 204 |
} catch (Exception ex) { |
198 | 205 |
LOGGER.warn("Can't download.", ex); |
199 | 206 |
return ERR_EXCEPTION; |
207 |
} finally { |
|
208 |
DisposeUtils.dispose(set); |
|
200 | 209 |
} |
201 | 210 |
} |
202 | 211 |
|
... | ... | |
206 | 215 |
} |
207 | 216 |
|
208 | 217 |
@Override |
209 |
public Envelope getEnvelope(SimpleTaskStatus status) { |
|
210 |
if (fullEnv == null) { |
|
218 |
public Envelope getEnvelope(Expression filter, SimpleTaskStatus status) { |
|
219 |
if (fullEnv == null || filter!=null) { |
|
220 |
FeatureSet set = null; |
|
211 | 221 |
try { |
212 | 222 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
213 | 223 |
IProjection proj4326 = CRSFactory.getCRS("EPSG:4326"); |
214 | 224 |
ICoordTrans ct = proj4326.getCT(this.entity.getCRSAsProjection()); |
215 | 225 |
|
216 | 226 |
this.fullEnv = GeometryLocator.getGeometryManager().createEnvelope(Geometry.SUBTYPES.GEOM2D); |
217 |
Iterator<Feature> it = feats.iterator(); |
|
227 |
Iterator<Feature> it; |
|
228 |
if( filter == null ) { |
|
229 |
it = feats.iterator(); |
|
230 |
} else { |
|
231 |
set = feats.getFeatureStore().getFeatureSet(filter); |
|
232 |
it = set.fastIterator(); |
|
233 |
} |
|
218 | 234 |
Iterator<Geometry> geoms = new Iterator<Geometry>() { |
219 | 235 |
@Override |
220 | 236 |
public boolean hasNext() { |
... | ... | |
237 | 253 |
} |
238 | 254 |
} catch (Exception ex) { |
239 | 255 |
LOGGER.warn("Can't get envelope.", ex); |
256 |
} finally { |
|
257 |
DisposeUtils.dispose(set); |
|
240 | 258 |
} |
241 | 259 |
|
242 | 260 |
} |
... | ... | |
282 | 300 |
} |
283 | 301 |
|
284 | 302 |
@Override |
285 |
public void zoom() { |
|
286 |
this.zoom(SimpleTaskStatus.FAKE_STATUS); |
|
303 |
public void zoom(Expression filter) {
|
|
304 |
this.zoom(filter, SimpleTaskStatus.FAKE_STATUS);
|
|
287 | 305 |
} |
288 | 306 |
|
289 | 307 |
@Override |
290 |
public void zoom(SimpleTaskStatus status) { |
|
291 |
Envelope env = this.getEnvelope(status); |
|
308 |
public void zoom(Expression filter, SimpleTaskStatus status) {
|
|
309 |
Envelope env = this.getEnvelope(filter, status);
|
|
292 | 310 |
if(env == null){ |
293 | 311 |
return; |
294 | 312 |
} |
... | ... | |
315 | 333 |
} |
316 | 334 |
|
317 | 335 |
@Override |
336 |
public void setSelection(Expression filter) { |
|
337 |
if( filter == null ) { |
|
338 |
this.setSelection(); |
|
339 |
return; |
|
340 |
} |
|
341 |
FeatureSet set = null; |
|
342 |
try { |
|
343 |
set = this.getFeatureStore().getFeatureSet(filter); |
|
344 |
this.getFeatureStore().setSelection(set); |
|
345 |
} catch (DataException ex) { |
|
346 |
LOGGER.warn("Can't set selection", ex); |
|
347 |
} |
|
348 |
} |
|
349 |
|
|
350 |
@Override |
|
318 | 351 |
public Thread runSearchTask(Expression filter, Runnable postProcessingAction, MessageStatus message) { |
319 | 352 |
SimpleTaskStatus status = message.createTaskStatus("_Search"); |
320 | 353 |
message.setVisible(true); |
... | ... | |
360 | 393 |
} |
361 | 394 |
|
362 | 395 |
@Override |
363 |
public Thread runDownloadTask(Runnable postProcessingAction, MessageStatus message) { |
|
396 |
public Thread runDownloadTask(Expression filter, Runnable postProcessingAction, MessageStatus message) {
|
|
364 | 397 |
if(!isSearched()){ |
365 | 398 |
return null; |
366 | 399 |
} |
... | ... | |
370 | 403 |
Thread task = new Thread(() -> { |
371 | 404 |
this.processing = true; |
372 | 405 |
try { |
373 |
this.download(status); |
|
406 |
this.download(filter, status);
|
|
374 | 407 |
} catch (Exception ex) { |
375 | 408 |
//FIXME: |
376 | 409 |
|
... | ... | |
393 | 426 |
} |
394 | 427 |
|
395 | 428 |
@Override |
396 |
public Thread runCalculateEnvelopeTask(Runnable postProcessingAction, MessageStatus message) { |
|
429 |
public Thread runCalculateEnvelopeTask(Expression filter, Runnable postProcessingAction, MessageStatus message) {
|
|
397 | 430 |
if(!isSearched()){ |
398 | 431 |
return null; |
399 | 432 |
} |
... | ... | |
404 | 437 |
Thread task = new Thread(() -> { |
405 | 438 |
this.processing = true; |
406 | 439 |
try { |
407 |
this.getEnvelope(status); |
|
440 |
this.getEnvelope(filter, status);
|
|
408 | 441 |
message.clear(); |
409 | 442 |
} catch (Exception ex) { |
410 | 443 |
//FIXME: |
Also available in: Unified diff