Revision 38417
branches/v2_0_0_prep/libraries/libFMap_mapcontext/src/org/gvsig/fmap/mapcontext/layers/vectorial/impl/DefaultGraphicLayer.java | ||
---|---|---|
26 | 26 |
*/ |
27 | 27 |
package org.gvsig.fmap.mapcontext.layers.vectorial.impl; |
28 | 28 |
|
29 |
import java.awt.Graphics2D; |
|
29 | 30 |
import java.awt.geom.Point2D; |
31 |
import java.awt.image.BufferedImage; |
|
30 | 32 |
import java.util.Iterator; |
31 | 33 |
|
32 | 34 |
import org.cresques.cts.ICoordTrans; |
... | ... | |
50 | 52 |
import org.gvsig.fmap.geom.GeometryLocator; |
51 | 53 |
import org.gvsig.fmap.geom.exception.CreateEnvelopeException; |
52 | 54 |
import org.gvsig.fmap.geom.primitive.Envelope; |
55 |
import org.gvsig.fmap.mapcontext.ViewPort; |
|
53 | 56 |
import org.gvsig.fmap.mapcontext.exceptions.LegendLayerException; |
54 | 57 |
import org.gvsig.fmap.mapcontext.exceptions.LoadLayerException; |
55 | 58 |
import org.gvsig.fmap.mapcontext.exceptions.ReprojectLayerException; |
... | ... | |
60 | 63 |
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol; |
61 | 64 |
import org.gvsig.tools.dispose.DisposableIterator; |
62 | 65 |
import org.gvsig.tools.exception.BaseException; |
66 |
import org.gvsig.tools.task.Cancellable; |
|
63 | 67 |
import org.slf4j.Logger; |
64 | 68 |
import org.slf4j.LoggerFactory; |
65 | 69 |
|
... | ... | |
85 | 89 |
private int labelIndex; |
86 | 90 |
private int tagIndex; |
87 | 91 |
private int priorityIndex; |
88 |
|
|
89 |
public DefaultGraphicLayer() { |
|
90 |
super(); |
|
91 |
} |
|
92 |
|
|
92 |
|
|
93 | 93 |
public void initialize(IProjection projection) throws ValidateDataParametersException, DataException, LoadLayerException { |
94 | 94 |
store = dataManager.createMemoryStore(FEATURE_ATTR_PRIORITY); |
95 | 95 |
store.edit(); |
... | ... | |
134 | 134 |
|
135 | 135 |
setName("Graphic Layer"); |
136 | 136 |
} |
137 |
|
|
137 |
|
|
138 | 138 |
public void addGraphic(String groupId, Geometry geom, int idsym) { |
139 | 139 |
addGraphic(groupId, geom, idsym, null, null, DEFAULT_PRIORITY); |
140 | 140 |
} |
... | ... | |
155 | 155 |
Object tag, int priority) { |
156 | 156 |
|
157 | 157 |
try{ |
158 |
if (!store.isEditing()){ |
|
159 |
store.edit(FeatureStore.MODE_APPEND); |
|
158 |
store.beginComplexNotification(); |
|
159 |
// Just in case another thread is going to read from the store |
|
160 |
synchronized (store) { |
|
161 |
if (!store.isEditing()){ |
|
162 |
store.edit(FeatureStore.MODE_APPEND); |
|
163 |
} |
|
164 |
insertGeometry(groupId, geom, idsym, label, tag, priority); |
|
165 |
store.finishEditing(); |
|
160 | 166 |
} |
161 |
insertGeometry(groupId, geom, idsym, label, tag, priority); |
|
162 |
store.finishEditing(); |
|
167 |
store.endComplexNotification(); |
|
163 | 168 |
} catch (DataException e) { |
164 | 169 |
logger.error("Error adding a geometry to the graphic layer", e); |
165 | 170 |
} |
... | ... | |
193 | 198 |
public void addGraphics(String groupId, Iterator geoms, int idsym, |
194 | 199 |
String label, Object tag, int priority) { |
195 | 200 |
try { |
196 |
if (!store.isEditing()) { |
|
197 |
store.edit(FeatureStore.MODE_APPEND); |
|
198 |
} |
|
199 |
for (; geoms.hasNext();) { |
|
200 |
Geometry geom = (Geometry) geoms.next(); |
|
201 |
insertGeometry(groupId, geom, idsym, label, tag, priority); |
|
202 |
} |
|
203 |
store.finishEditing(); |
|
201 |
// Just in case another thread is going to read from the store |
|
202 |
synchronized (store) { |
|
203 |
if (!store.isEditing()) { |
|
204 |
store.edit(FeatureStore.MODE_APPEND); |
|
205 |
} |
|
206 |
store.disableNotifications(); |
|
207 |
for (; geoms.hasNext();) { |
|
208 |
Geometry geom = (Geometry) geoms.next(); |
|
209 |
insertGeometry(groupId, geom, idsym, label, tag, priority); |
|
210 |
} |
|
211 |
store.enableNotifications(); |
|
212 |
store.finishEditing(); |
|
213 |
} |
|
204 | 214 |
} catch (DataException e) { |
205 | 215 |
logger.error("Error adding a geometry to the graphic layer", e); |
206 | 216 |
} |
... | ... | |
256 | 266 |
DisposableIterator iterator = null; |
257 | 267 |
FeatureSet featureSet = null; |
258 | 268 |
try{ |
269 |
store.beginComplexNotification(); |
|
259 | 270 |
if (!store.isEditing()){ |
260 | 271 |
store.edit(); |
261 | 272 |
} |
262 | 273 |
featureSet = store.getFeatureSet(); |
274 |
store.beginEditingGroup(groupId); |
|
263 | 275 |
for (iterator = featureSet.fastIterator(); iterator.hasNext();) { |
264 | 276 |
Feature feature = (Feature) iterator.next(); |
265 | 277 |
if (feature.get(FEATURE_ATTR_GROUPID).equals(groupId)) { |
266 | 278 |
featureSet.delete(feature); |
267 | 279 |
} |
268 | 280 |
} |
281 |
store.endEditingGroup(); |
|
269 | 282 |
store.finishEditing(); |
283 |
store.endComplexNotification(); |
|
270 | 284 |
} catch (DataException e) { |
271 | 285 |
logger.error("Error clearing all the geometry of the graphic layer", e); |
272 | 286 |
} finally { |
... | ... | |
287 | 301 |
} |
288 | 302 |
} |
289 | 303 |
|
290 |
/* (non-Javadoc) |
|
291 |
* @see org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect#setLegend(org.gvsig.fmap.mapcontext.rendering.legend.IVectorLegend) |
|
292 |
*/ |
|
293 | 304 |
public void setLegend(IVectorLegend legend) throws LegendLayerException { |
294 | 305 |
if (legend instanceof IVectorialUniqueValueLegend){ |
295 | 306 |
super.setLegend(legend); |
... | ... | |
301 | 312 |
} |
302 | 313 |
|
303 | 314 |
public Envelope getFullEnvelope() throws ReadException { |
304 |
// Change parent implementation which creates an envelop by default |
|
305 | 315 |
Envelope rAux; |
306 | 316 |
try { |
307 | 317 |
rAux = getFeatureStore().getEnvelope(); |
branches/v2_0_0_prep/libraries/libFMap_dal/src/org/gvsig/fmap/dal/feature/impl/DefaultFeatureStore.java | ||
---|---|---|
343 | 343 |
|
344 | 344 |
public Envelope getEnvelope() throws DataException { |
345 | 345 |
if (this.mode == MODE_FULLEDIT) { |
346 |
return this.spatialManager.getEnvelope(); |
|
346 |
// Just in case another thread tries to write in the store |
|
347 |
synchronized (this) { |
|
348 |
return this.spatialManager.getEnvelope(); |
|
349 |
} |
|
347 | 350 |
} |
348 | 351 |
if (hasDynValue(DataStore.METADATA_ENVELOPE)){ |
349 | 352 |
return (Envelope)getDynValue(DataStore.METADATA_ENVELOPE); |
branches/v2_0_0_prep/libraries/libFMap_dal/src/org/gvsig/fmap/dal/feature/impl/featureset/DefaultFeatureSet.java | ||
---|---|---|
332 | 332 |
|
333 | 333 |
protected void checkSourceStoreModified() { |
334 | 334 |
if (sourceStoreModified) { |
335 |
throw new ConcurrentDataModificationException(store.getName()); |
|
335 |
throw new ConcurrentDataModificationException(store == null ? "" |
|
336 |
: store.getName()); |
|
336 | 337 |
} |
337 | 338 |
} |
338 | 339 |
|
branches/v2_0_0_prep/libraries/libFMap_dal/src/org/gvsig/fmap/dal/feature/impl/IndexFeatureSet.java | ||
---|---|---|
226 | 226 |
|
227 | 227 |
public void accept(Visitor visitor, long firstValueIndex) |
228 | 228 |
throws BaseException { |
229 |
DisposableIterator iterator = fastIterator(firstValueIndex); |
|
230 |
|
|
231 |
if (iterator != null) { |
|
232 |
try { |
|
233 |
while (iterator.hasNext()) { |
|
234 |
Feature feature = (Feature) iterator.next(); |
|
235 |
visitor.visit(feature); |
|
229 |
synchronized (store.getFeatureStore()) { |
|
230 |
DisposableIterator iterator = fastIterator(firstValueIndex); |
|
231 |
|
|
232 |
if (iterator != null) { |
|
233 |
try { |
|
234 |
while (iterator.hasNext()) { |
|
235 |
Feature feature = (Feature) iterator.next(); |
|
236 |
visitor.visit(feature); |
|
237 |
} |
|
238 |
} finally { |
|
239 |
iterator.dispose(); |
|
236 | 240 |
} |
237 |
} finally { |
|
238 |
iterator.dispose(); |
|
239 | 241 |
} |
240 | 242 |
} |
241 | 243 |
} |
branches/v2_0_0_prep/libraries/libFMap_dal/src/org/gvsig/fmap/dal/feature/paging/FeaturePagingHelper.java | ||
---|---|---|
63 | 63 |
Feature[] getCurrentPageFeatures(); |
64 | 64 |
|
65 | 65 |
/** |
66 |
* Returns the FeatureSet used to fetch the data. |
|
67 |
* |
|
68 |
* @return the FeatureSet |
|
69 |
*/ |
|
70 |
FeatureSet getFeatureSet(); |
|
71 |
|
|
72 |
/** |
|
73 | 66 |
* Returns the FeatureStore used to fetch the data. |
74 | 67 |
* |
75 | 68 |
* @return the FeatureStore |
branches/v2_0_0_prep/libraries/libFMap_dal/src/org/gvsig/fmap/dal/feature/paging/impl/FeaturePagingHelperImpl.java | ||
---|---|---|
40 | 40 |
import org.gvsig.fmap.dal.feature.impl.featureset.DynObjectFeatureFacade; |
41 | 41 |
import org.gvsig.fmap.dal.feature.paging.FeaturePagingHelper; |
42 | 42 |
import org.gvsig.tools.dynobject.DynObject; |
43 |
import org.gvsig.tools.dynobject.DynObjectSet; |
|
43 | 44 |
import org.gvsig.tools.dynobject.impl.DefaultDynObjectPagingHelper; |
44 | 45 |
import org.gvsig.tools.exception.BaseException; |
45 | 46 |
import org.gvsig.tools.visitor.VisitCanceledException; |
... | ... | |
64 | 65 |
|
65 | 66 |
private FeatureQuery query; |
66 | 67 |
|
67 |
private FeatureSet featureSet; |
|
68 |
|
|
69 | 68 |
private FeatureStore featureStore; |
70 | 69 |
|
71 | 70 |
/** If the selected Features must be returned as the first ones. **/ |
... | ... | |
138 | 137 |
this.featureStore = featureStore; |
139 | 138 |
this.query = query; |
140 | 139 |
this.query.setPageSize(pageSize); |
141 |
loadFeatureSet(); |
|
142 | 140 |
|
143 | 141 |
if (LOG.isDebugEnabled()) { |
144 | 142 |
LOG.debug("FeaturePagingHelperImpl created with {} pages, " |
145 | 143 |
+ "and a page size of {}", new Long(getCalculator() |
146 | 144 |
.getNumPages()), new Integer(pageSize)); |
147 | 145 |
} |
146 |
|
|
147 |
setDefaultCalculator(new Sizeable() { |
|
148 |
public long getSize() { |
|
149 |
FeatureSet featureSet = getFeatureSet(); |
|
150 |
try { |
|
151 |
return featureSet.getSize(); |
|
152 |
} catch (BaseException e) { |
|
153 |
LOG.error("Error getting the size of the FeatureSet: " |
|
154 |
+ featureSet, e); |
|
155 |
return 0l; |
|
156 |
} |
|
157 |
} |
|
158 |
}, pageSize); |
|
148 | 159 |
} |
149 | 160 |
|
150 | 161 |
/** |
... | ... | |
200 | 211 |
return features; |
201 | 212 |
} |
202 | 213 |
|
203 |
public FeatureSet getFeatureSet() { |
|
204 |
return featureSet; |
|
214 |
private FeatureSet getFeatureSet() { |
|
215 |
try { |
|
216 |
FeatureStore featureStore = getFeatureStore(); |
|
217 |
synchronized (featureStore) { |
|
218 |
return featureStore.getFeatureSet(getFeatureQuery()); |
|
219 |
} |
|
220 |
} catch (DataException e) { |
|
221 |
throw new RuntimeException("Error getting a feature set with the query " + getFeatureQuery()); |
|
222 |
} |
|
205 | 223 |
} |
224 |
|
|
225 |
public DynObjectSet getDynObjectSet() { |
|
226 |
return getFeatureSet().getDynObjectSet(); |
|
227 |
} |
|
206 | 228 |
|
207 | 229 |
public void reloadCurrentPage() throws BaseException { |
208 | 230 |
setSelectionUp(false); |
... | ... | |
212 | 234 |
} |
213 | 235 |
|
214 | 236 |
public void reload() throws BaseException { |
215 |
loadFeatureSet(); |
|
237 |
setDefaultCalculator(new Sizeable() { |
|
238 |
public long getSize() { |
|
239 |
FeatureSet featureSet = getFeatureSet(); |
|
240 |
try { |
|
241 |
return featureSet.getSize(); |
|
242 |
} catch (BaseException e) { |
|
243 |
LOG.error("Error getting the size of the FeatureSet: " |
|
244 |
+ featureSet, e); |
|
245 |
return 0l; |
|
246 |
} |
|
247 |
} |
|
248 |
}, getCalculator().getMaxPageSize()); |
|
216 | 249 |
reloadCurrentPage(); |
217 | 250 |
} |
218 | 251 |
|
... | ... | |
255 | 288 |
throws BaseException { |
256 | 289 |
FeatureSelection selection = initialSelection; |
257 | 290 |
|
258 |
OneSubsetOneSetPagingCalculator twoSetsCalculator = null; |
|
259 |
if (getCalculator() instanceof OneSubsetOneSetPagingCalculator) { |
|
260 |
twoSetsCalculator = |
|
261 |
(OneSubsetOneSetPagingCalculator) getCalculator(); |
|
262 |
} else { |
|
263 |
twoSetsCalculator = |
|
264 |
new OneSubsetOneSetPagingCalculator( |
|
265 |
new FeatureSetSizeableDelegate(selection), |
|
266 |
new FeatureSetSizeableDelegate(getFeatureSet()), |
|
267 |
getMaxPageSize(), getCalculator().getCurrentPage()); |
|
268 |
setCalculator(twoSetsCalculator); |
|
291 |
FeatureSet set = getFeatureSet(); |
|
292 |
try { |
|
293 |
OneSubsetOneSetPagingCalculator twoSetsCalculator = null; |
|
294 |
if (getCalculator() instanceof OneSubsetOneSetPagingCalculator) { |
|
295 |
twoSetsCalculator = |
|
296 |
(OneSubsetOneSetPagingCalculator) getCalculator(); |
|
297 |
} else { |
|
298 |
twoSetsCalculator = |
|
299 |
new OneSubsetOneSetPagingCalculator( |
|
300 |
new FeatureSetSizeableDelegate(selection), |
|
301 |
new FeatureSetSizeableDelegate(set), |
|
302 |
getMaxPageSize(), getCalculator().getCurrentPage()); |
|
303 |
setCalculator(twoSetsCalculator); |
|
304 |
} |
|
305 |
|
|
306 |
// First load values from the selection, if the current page has |
|
307 |
// elements from it |
|
308 |
if (twoSetsCalculator.hasCurrentPageAnyValuesInFirstSet()) { |
|
309 |
loadDataFromFeatureSet(values, 0, selection, |
|
310 |
twoSetsCalculator.getFirstSetInitialIndex(), |
|
311 |
twoSetsCalculator.getFirstSetHowMany(), null); |
|
312 |
} |
|
313 |
// Next, load values from the FeatureSet if the current page has values |
|
314 |
// from it |
|
315 |
if (twoSetsCalculator.hasCurrentPageAnyValuesInSecondSet()) { |
|
316 |
loadDataFromFeatureSet( |
|
317 |
values, |
|
318 |
// The cast will work as that size will be <= maxpagesize, |
|
319 |
// which is an int |
|
320 |
(int) twoSetsCalculator.getFirstSetHowMany(), set, |
|
321 |
twoSetsCalculator.getSecondSetInitialIndex(), |
|
322 |
twoSetsCalculator.getSecondSetHowMany(), selection); |
|
323 |
} |
|
324 |
} finally { |
|
325 |
set.dispose(); |
|
269 | 326 |
} |
270 |
|
|
271 |
// First load values from the selection, if the current page has |
|
272 |
// elements from it |
|
273 |
if (twoSetsCalculator.hasCurrentPageAnyValuesInFirstSet()) { |
|
274 |
loadDataFromFeatureSet(values, 0, selection, |
|
275 |
twoSetsCalculator.getFirstSetInitialIndex(), |
|
276 |
twoSetsCalculator.getFirstSetHowMany(), null); |
|
277 |
} |
|
278 |
// Next, load values from the FeatureSet if the current page has values |
|
279 |
// from it |
|
280 |
if (twoSetsCalculator.hasCurrentPageAnyValuesInSecondSet()) { |
|
281 |
loadDataFromFeatureSet( |
|
282 |
values, |
|
283 |
// The cast will work as that size will be <= maxpagesize, |
|
284 |
// which is an int |
|
285 |
(int) twoSetsCalculator.getFirstSetHowMany(), getFeatureSet(), |
|
286 |
twoSetsCalculator.getSecondSetInitialIndex(), |
|
287 |
twoSetsCalculator.getSecondSetHowMany(), selection); |
|
288 |
} |
|
289 | 327 |
} |
290 | 328 |
|
291 | 329 |
private void loadCurrentPageDataNoSelection(final Feature[] values) |
292 |
throws DataException {
|
|
330 |
throws BaseException {
|
|
293 | 331 |
|
294 | 332 |
long firstPosition = getCalculator().getInitialIndex(); |
295 | 333 |
|
... | ... | |
299 | 337 |
firstPosition)); |
300 | 338 |
} |
301 | 339 |
|
302 |
loadDataFromFeatureSet(values, 0, getFeatureSet(), firstPosition, |
|
303 |
getCalculator().getCurrentPageSize(), null); |
|
340 |
FeatureSet featureSet = getFeatureSet(); |
|
341 |
try { |
|
342 |
loadDataFromFeatureSet(values, 0, featureSet, firstPosition, |
|
343 |
getCalculator().getCurrentPageSize(), null); |
|
344 |
} finally { |
|
345 |
featureSet.dispose(); |
|
346 |
} |
|
347 |
|
|
304 | 348 |
} |
305 | 349 |
|
306 | 350 |
private void loadDataFromFeatureSet(final Feature[] values, |
... | ... | |
338 | 382 |
} |
339 | 383 |
} |
340 | 384 |
|
341 |
private void loadFeatureSet() throws BaseException { |
|
342 |
if (featureSet != null) { |
|
343 |
featureSet.dispose(); |
|
344 |
} |
|
345 |
featureSet = getFeatureStore().getFeatureSet(getFeatureQuery()); |
|
346 |
setDynObjectSet(featureSet.getDynObjectSet(), getMaxPageSize()); |
|
347 |
} |
|
348 |
|
|
349 | 385 |
public void delete(Feature feature) throws BaseException { |
350 |
if (featureSet == null) { |
|
351 |
// FIXME change to RuntimeDalException |
|
352 |
throw new IllegalStateException(); |
|
353 |
} |
|
354 |
featureSet.delete(feature); |
|
386 |
featureStore.delete(feature); |
|
355 | 387 |
reloadCurrentPage(); |
356 | 388 |
} |
357 | 389 |
|
358 | 390 |
public void insert(EditableFeature feature) throws BaseException { |
359 |
if (featureSet == null) { |
|
360 |
// FIXME change to RuntimeDalException |
|
361 |
throw new IllegalStateException(); |
|
362 |
} |
|
363 |
featureSet.insert(feature); |
|
391 |
featureStore.insert(feature); |
|
364 | 392 |
reloadCurrentPage(); |
365 | 393 |
} |
366 | 394 |
|
367 | 395 |
public void update(EditableFeature feature) throws BaseException { |
368 |
if (featureSet == null) { |
|
369 |
// FIXME change to RuntimeDalException |
|
370 |
throw new IllegalStateException(); |
|
371 |
} |
|
372 |
featureSet.update(feature); |
|
396 |
featureStore.update(feature); |
|
373 | 397 |
reloadCurrentPage(); |
374 | 398 |
} |
375 | 399 |
|
376 | 400 |
public FeatureType getFeatureType() { |
377 |
return featureSet.getDefaultFeatureType(); |
|
401 |
FeatureSet featureSet = getFeatureSet(); |
|
402 |
try { |
|
403 |
return featureSet.getDefaultFeatureType(); |
|
404 |
} finally { |
|
405 |
featureSet.dispose(); |
|
406 |
} |
|
378 | 407 |
} |
379 | 408 |
|
380 | 409 |
protected void doDispose() throws BaseException { |
381 | 410 |
initialSelection.dispose(); |
382 |
featureSet.dispose(); |
|
383 | 411 |
} |
384 | 412 |
|
385 | 413 |
public DynObject[] getCurrentPageDynObjects() { |
branches/v2_0_0_prep/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/dal/feature/swing/table/FeatureTableModel.java | ||
---|---|---|
35 | 35 |
import org.gvsig.fmap.dal.feature.Feature; |
36 | 36 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
37 | 37 |
import org.gvsig.fmap.dal.feature.FeatureQuery; |
38 |
import org.gvsig.fmap.dal.feature.FeatureSet; |
|
39 | 38 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
40 | 39 |
import org.gvsig.fmap.dal.feature.FeatureStoreNotification; |
41 | 40 |
import org.gvsig.fmap.dal.feature.FeatureType; |
41 |
import org.gvsig.fmap.dal.feature.exception.ConcurrentDataModificationException; |
|
42 | 42 |
import org.gvsig.fmap.dal.feature.paging.FeaturePagingHelper; |
43 | 43 |
import org.gvsig.tools.exception.BaseException; |
44 |
import org.gvsig.tools.observer.ComplexNotification; |
|
45 |
import org.gvsig.tools.observer.ComplexObserver; |
|
44 | 46 |
import org.gvsig.tools.observer.Observable; |
45 |
import org.gvsig.tools.observer.Observer; |
|
47 |
import org.slf4j.Logger; |
|
48 |
import org.slf4j.LoggerFactory; |
|
46 | 49 |
|
47 | 50 |
/** |
48 | 51 |
* TableModel to access data of Features. |
... | ... | |
53 | 56 |
* |
54 | 57 |
* @author <a href="mailto:cordin@disid.com">C?sar Ordi?ana</a> |
55 | 58 |
*/ |
56 |
public class FeatureTableModel extends AbstractTableModel implements Observer { |
|
59 |
public class FeatureTableModel extends AbstractTableModel implements ComplexObserver {
|
|
57 | 60 |
|
61 |
|
|
62 |
private static final Logger LOG = LoggerFactory |
|
63 |
.getLogger(FeatureTableModel.class); |
|
64 |
|
|
58 | 65 |
private static final long serialVersionUID = -2488157521902851301L; |
59 | 66 |
|
60 | 67 |
private FeaturePagingHelper helper; |
... | ... | |
121 | 128 |
public int getRowCount() { |
122 | 129 |
// Return the total size of the collection |
123 | 130 |
// If the size is bigger than INTEGER.MAX_VALUE, return that instead |
124 |
long totalSize = getHelper().getTotalSize(); |
|
125 |
if (totalSize > Integer.MAX_VALUE) { |
|
126 |
return Integer.MAX_VALUE; |
|
127 |
} else { |
|
128 |
return (int) totalSize; |
|
129 |
} |
|
131 |
try { |
|
132 |
long totalSize = getHelper().getTotalSize(); |
|
133 |
if (totalSize > Integer.MAX_VALUE) { |
|
134 |
return Integer.MAX_VALUE; |
|
135 |
} else { |
|
136 |
return (int) totalSize; |
|
137 |
} |
|
138 |
} catch (ConcurrentDataModificationException e) { |
|
139 |
LOG.debug("Error while getting the total size of the set", e); |
|
140 |
return 0; |
|
141 |
} |
|
130 | 142 |
} |
131 | 143 |
|
132 | 144 |
public Object getValueAt(int rowIndex, int columnIndex) { |
133 | 145 |
// Get the Feature at row "rowIndex", and return the value of the |
134 | 146 |
// attribute at "columnIndex" |
135 | 147 |
Feature feature = getFeatureAt(rowIndex); |
136 |
return getFeatureValue(feature, columnIndex); |
|
148 |
return feature == null ? null : getFeatureValue(feature, columnIndex);
|
|
137 | 149 |
} |
138 | 150 |
|
139 | 151 |
/** |
... | ... | |
155 | 167 |
// Return the class of the FeatureAttributeDescriptor for the value |
156 | 168 |
FeatureAttributeDescriptor attributeDesc = |
157 | 169 |
internalGetFeatureDescriptorForColumn(columnIndex); |
170 |
if (attributeDesc == null) { |
|
171 |
return super.getColumnClass(columnIndex); |
|
172 |
} |
|
158 | 173 |
Class<?> clazz = attributeDesc.getObjectClass(); |
159 | 174 |
return (clazz == null ? super.getColumnClass(columnIndex) : clazz); |
160 | 175 |
} |
... | ... | |
244 | 259 |
fireTableChanged(new TableModelEvent(this, 0, getRowCount() - 1)); |
245 | 260 |
} |
246 | 261 |
|
247 |
public void update(Observable observable, Object notification) { |
|
248 |
if (observable.equals(getFeatureStore()) |
|
262 |
public void update(final Observable observable, final Object notification) { |
|
263 |
if (notification instanceof ComplexNotification) { |
|
264 |
// A lot of things might have happened in the store, so don't |
|
265 |
// bother looking into each notification. |
|
266 |
reloadAll(); |
|
267 |
} |
|
268 |
else if (observable.equals(getFeatureStore()) |
|
249 | 269 |
&& notification instanceof FeatureStoreNotification) { |
250 | 270 |
FeatureStoreNotification fsNotification = |
251 | 271 |
(FeatureStoreNotification) notification; |
... | ... | |
262 | 282 |
|
263 | 283 |
reloadIfFeatureUpdated(fsNotification.getFeature()); |
264 | 284 |
|
265 |
} else |
|
266 |
if (FeatureStoreNotification.AFTER_UPDATE_TYPE.equals(type)) { |
|
285 |
} else if (FeatureStoreNotification.AFTER_UPDATE_TYPE.equals(type)) { |
|
267 | 286 |
|
268 |
reloadIfTypeChanged(fsNotification.getFeatureType());
|
|
287 |
reloadIfTypeChanged(fsNotification.getFeatureType());
|
|
269 | 288 |
|
270 |
} else |
|
271 |
if (FeatureStoreNotification.TRANSFORM_CHANGE.equals(type) |
|
272 |
|| FeatureStoreNotification.AFTER_UNDO.equals(type) |
|
273 |
|| FeatureStoreNotification.AFTER_REFRESH.equals(type)) { |
|
274 |
|
|
275 |
reloadFeatureType(); |
|
289 |
} else if (FeatureStoreNotification.TRANSFORM_CHANGE.equals(type) |
|
290 |
|| FeatureStoreNotification.AFTER_UNDO.equals(type) |
|
291 |
|| FeatureStoreNotification.AFTER_REFRESH.equals(type) |
|
292 |
|| FeatureStoreNotification.AFTER_FINISHEDITING.equals(type) |
|
293 |
|| FeatureStoreNotification.AFTER_CANCELEDITING.equals(type)) { |
|
276 | 294 |
|
277 |
} else |
|
278 |
if (FeatureStoreNotification.AFTER_FINISHEDITING.equals(type) |
|
279 |
|| FeatureStoreNotification.AFTER_CANCELEDITING.equals(type)) { |
|
280 |
|
|
281 |
reloadFeatureType(); |
|
282 |
} |
|
295 |
reloadAll(); |
|
296 |
} |
|
283 | 297 |
|
284 |
}
|
|
298 |
}
|
|
285 | 299 |
} |
286 | 300 |
|
287 | 301 |
/** |
... | ... | |
307 | 321 |
* @param columnIndex |
308 | 322 |
* @return |
309 | 323 |
*/ |
310 |
protected FeatureAttributeDescriptor internalGetFeatureDescriptorForColumn( |
|
311 |
int columnIndex) { |
|
312 |
return getFeatureType().getAttributeDescriptor(columnIndex); |
|
313 |
} |
|
324 |
protected FeatureAttributeDescriptor internalGetFeatureDescriptorForColumn( |
|
325 |
int columnIndex) { |
|
326 |
FeatureType featureType = getFeatureType(); |
|
327 |
return featureType == null ? null : featureType |
|
328 |
.getAttributeDescriptor(columnIndex); |
|
329 |
} |
|
314 | 330 |
|
315 | 331 |
/** |
316 | 332 |
* Initialize the TableModel |
... | ... | |
354 | 370 |
} |
355 | 371 |
|
356 | 372 |
/** |
357 |
* Returns the FeatureSet used to get the data. |
|
358 |
* |
|
359 |
* @return the FeatureSet |
|
360 |
*/ |
|
361 |
protected FeatureSet getFeatureSet() { |
|
362 |
return getHelper().getFeatureSet(); |
|
363 |
} |
|
364 |
|
|
365 |
/** |
|
366 | 373 |
* Returns the FeatureQuery used to get the Features. |
367 | 374 |
* |
368 | 375 |
* @return the FeatureQuery |
... | ... | |
415 | 422 |
} |
416 | 423 |
} |
417 | 424 |
|
425 |
private void reloadAll() { |
|
426 |
reloadFeatureType(); |
|
427 |
} |
|
418 | 428 |
|
419 |
|
|
420 | 429 |
private void reloadFeatureType() { |
421 | 430 |
try { |
422 | 431 |
setFeatureType(getHelper().getFeatureStore().getFeatureType( |
Also available in: Unified diff