Revision 43725 trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.impl/src/main/java/org/gvsig/fmap/dal/feature/impl/DefaultFeatureReferenceSelection.java
DefaultFeatureReferenceSelection.java | ||
---|---|---|
476 | 476 |
|
477 | 477 |
// *** Persistence *** |
478 | 478 |
|
479 |
@Override |
|
479 | 480 |
public void saveToState(PersistentState state) throws PersistenceException { |
480 | 481 |
state.set("store", featureStore); |
481 | 482 |
state.set("reversed", this.getData().isReversed()); |
... | ... | |
483 | 484 |
state.set("selected", this.getData().getSelected().iterator()); |
484 | 485 |
} |
485 | 486 |
|
487 |
@Override |
|
486 | 488 |
public void loadFromState(PersistentState state) |
487 | 489 |
throws PersistenceException { |
488 |
featureStore = (FeatureStore)state.get("store"); |
|
489 |
helper = new DefaultFeatureSelectionHelper((DefaultFeatureStore)featureStore); |
|
490 |
this.getData().setReversed(state.getBoolean("reversed")); |
|
491 |
this.getData().setTotalSize(state.getLong("totalSize")); |
|
492 |
Iterator it = state.getIterator("selected"); |
|
493 |
while (it.hasNext()) { |
|
494 |
DefaultFeatureReference ref = (DefaultFeatureReference) it.next(); |
|
495 |
this.getData().add(ref); |
|
496 |
} |
|
497 |
|
|
498 |
/* |
|
499 |
* If we do not do this, feature store will not listen |
|
500 |
* to changes in selection after instantiating a |
|
501 |
* persisted selection. For non-persisted instances, |
|
502 |
* this line corresponds to the line found in method: |
|
503 |
* getFeatureSelection() in DefaultFeatureStore. |
|
504 |
* This is not dangerous because "addObserver" only adds |
|
505 |
* if they were not already added, so future invocations |
|
506 |
* with same instances will have no effect. |
|
507 |
*/ |
|
508 |
this.addObserver((DefaultFeatureStore)featureStore); |
|
490 |
SelectionData data = new SelectionData(); // Do not use this.getData() |
|
491 |
featureStore = (FeatureStore)state.get("store"); |
|
492 |
helper = new DefaultFeatureSelectionHelper((DefaultFeatureStore)featureStore); |
|
493 |
data.setReversed(state.getBoolean("reversed")); |
|
494 |
data.setTotalSize(state.getLong("totalSize")); |
|
495 |
Iterator it = state.getIterator("selected"); |
|
496 |
while (it.hasNext()) { |
|
497 |
DefaultFeatureReference ref = (DefaultFeatureReference) it.next(); |
|
498 |
data.add(ref); |
|
499 |
} |
|
500 |
|
|
501 |
/* |
|
502 |
* If we do not do this, feature store will not listen |
|
503 |
* to changes in selection after instantiating a |
|
504 |
* persisted selection. For non-persisted instances, |
|
505 |
* this line corresponds to the line found in method: |
|
506 |
* getFeatureSelection() in DefaultFeatureStore. |
|
507 |
* This is not dangerous because "addObserver" only adds |
|
508 |
* if they were not already added, so future invocations |
|
509 |
* with same instances will have no effect. |
|
510 |
*/ |
|
511 |
this.addObserver((DefaultFeatureStore)featureStore); |
|
509 | 512 |
} |
510 | 513 |
|
511 | 514 |
public static void registerPersistent() { |
Also available in: Unified diff