Revision 47436 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/DefaultEditableFeatureType.java
DefaultEditableFeatureType.java | ||
---|---|---|
35 | 35 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
36 | 36 |
import org.gvsig.fmap.dal.feature.FeatureType; |
37 | 37 |
import org.gvsig.fmap.dal.feature.exception.FeatureTypeIntegrityException; |
38 |
import static org.gvsig.fmap.dal.feature.impl.DefaultFeatureAttributeDescriptor.NOTIFICATION_FIXED_CHANGED; |
|
38 | 39 |
import org.gvsig.fmap.dal.impl.DefaultDataManager; |
39 | 40 |
import org.gvsig.json.Json; |
40 | 41 |
import org.gvsig.json.JsonManager; |
... | ... | |
42 | 43 |
import org.gvsig.json.SupportToJson; |
43 | 44 |
import org.gvsig.tools.ToolsLocator; |
44 | 45 |
import org.gvsig.tools.evaluator.Evaluator; |
46 |
import org.gvsig.tools.observer.Notification; |
|
47 |
import org.gvsig.tools.observer.Observable; |
|
48 |
import org.gvsig.tools.observer.Observer; |
|
45 | 49 |
|
46 | 50 |
@SuppressWarnings("UseSpecificCatch") |
47 | 51 |
public class DefaultEditableFeatureType extends DefaultFeatureType implements |
48 |
EditableFeatureType { |
|
52 |
EditableFeatureType, Observer {
|
|
49 | 53 |
|
50 | 54 |
/** |
51 | 55 |
* |
... | ... | |
134 | 138 |
editableAttr = new DefaultEditableFeatureAttributeDescriptor( |
135 | 139 |
attr); |
136 | 140 |
} |
141 |
editableAttr.addObserver(this); |
|
137 | 142 |
super.add(editableAttr); |
138 | 143 |
} |
139 | 144 |
this.pk = null; |
... | ... | |
151 | 156 |
if (!editableAttr.isComputed()) { |
152 | 157 |
this.hasStrongChanges = true; |
153 | 158 |
} |
159 |
editableAttr.addObserver(this); |
|
154 | 160 |
this.fixAll(); |
155 | 161 |
return editableAttr; |
156 | 162 |
} |
... | ... | |
183 | 189 |
@Override |
184 | 190 |
public void removeAll() { |
185 | 191 |
while (!super.isEmpty()) { |
192 |
FeatureAttributeDescriptor attr = this.get(0); |
|
193 |
if(attr instanceof Observable){ |
|
194 |
((Observable) attr).deleteObserver(this); |
|
195 |
} |
|
186 | 196 |
super.remove(0); |
187 | 197 |
} |
188 | 198 |
this.fixAll(); |
... | ... | |
211 | 221 |
this.hasStrongChanges = this.hasStrongChanges || strongChanges; |
212 | 222 |
super.add(attr); |
213 | 223 |
this.pk = null; |
224 |
attr.addObserver(this); |
|
225 |
this.fixed = false; |
|
214 | 226 |
return attr; |
215 | 227 |
} |
216 | 228 |
|
... | ... | |
273 | 285 |
} |
274 | 286 |
super.remove(attr); |
275 | 287 |
this.pk = null; |
288 |
if(attr instanceof Observable){ |
|
289 |
((Observable) attr).deleteObserver(this); |
|
290 |
} |
|
276 | 291 |
this.fixAll(); |
277 | 292 |
return attr; |
278 | 293 |
} |
... | ... | |
295 | 310 |
|
296 | 311 |
@Override |
297 | 312 |
protected void fixAll() { |
313 |
if(this.fixed){ |
|
314 |
return; |
|
315 |
} |
|
298 | 316 |
super.fixAll(); |
299 | 317 |
for (FeatureAttributeDescriptor attr : this) { |
300 | 318 |
if (attr instanceof DefaultEditableFeatureAttributeDescriptor) { |
... | ... | |
305 | 323 |
} |
306 | 324 |
} |
307 | 325 |
} |
326 |
this.fixed = true; |
|
308 | 327 |
} |
309 | 328 |
|
310 | 329 |
public void checkIntegrity() throws DataListException { |
... | ... | |
335 | 354 |
throw new IllegalStateException("Default geometry attribute not set."); |
336 | 355 |
} |
337 | 356 |
descr.setGeometryType(type, subType); |
357 |
this.fixed = false; |
|
338 | 358 |
} |
339 | 359 |
|
340 | 360 |
@Override |
... | ... | |
350 | 370 |
} |
351 | 371 |
this.defaultGeometryAttributeName = name; |
352 | 372 |
this.defaultGeometryAttributeIndex = attr.getIndex(); |
373 |
this.fixed = false; |
|
353 | 374 |
} |
354 | 375 |
|
355 | 376 |
@Override |
... | ... | |
385 | 406 |
@Override |
386 | 407 |
public void setHasOID(boolean hasOID) { |
387 | 408 |
this.hasOID = hasOID; |
409 |
this.fixed = false; |
|
388 | 410 |
} |
389 | 411 |
|
390 | 412 |
@Override |
... | ... | |
405 | 427 |
@Override |
406 | 428 |
public void setCheckFeaturesAtFinishEditing(boolean check) { |
407 | 429 |
this.checkFeaturesAtFinishEditing = check; |
430 |
this.fixed = false; |
|
408 | 431 |
} |
409 | 432 |
|
410 | 433 |
@Override |
411 | 434 |
public void setCheckFeaturesAtInsert(boolean check) { |
412 | 435 |
this.checkFeaturesAtInsert = check; |
436 |
this.fixed = false; |
|
413 | 437 |
} |
414 | 438 |
|
415 | 439 |
protected class EditableDelegatedIterator extends DelegatedIterator { |
... | ... | |
431 | 455 |
|
432 | 456 |
protected void setAllowAutomaticValues(boolean value) { |
433 | 457 |
this.allowAtomaticValues = value; |
458 |
this.fixed = false; |
|
434 | 459 |
} |
435 | 460 |
|
436 | 461 |
@Override |
... | ... | |
444 | 469 |
this.hasStrongChanges = false; |
445 | 470 |
this.source = (DefaultFeatureType) other; |
446 | 471 |
} |
472 |
this.fixed = false; |
|
447 | 473 |
} |
448 | 474 |
|
449 | 475 |
public void copyFrom(JsonObject json) { |
450 | 476 |
// TODO: falta por implementar copyFrom(json) |
477 |
this.fixed = false; |
|
451 | 478 |
} |
452 | 479 |
|
453 | 480 |
@Override |
... | ... | |
470 | 497 |
default: |
471 | 498 |
throw new IllegalArgumentException("Name attribute '" + name + "' not valid."); |
472 | 499 |
} |
500 |
this.fixed = false; |
|
473 | 501 |
} |
474 | 502 |
|
475 | 503 |
private static class TheJsonSerializer implements JsonManager.JsonSerializer { |
... | ... | |
499 | 527 |
public static void selfRegister() { |
500 | 528 |
Json.registerSerializer(new TheJsonSerializer()); |
501 | 529 |
} |
530 |
|
|
531 |
@Override |
|
532 |
public void update(Observable observable, Object notification) { |
|
533 |
if (notification instanceof Notification && observable instanceof DefaultFeatureAttributeDescriptor){ |
|
534 |
DefaultFeatureAttributeDescriptor attr = (DefaultFeatureAttributeDescriptor) observable; |
|
535 |
Notification n = (Notification) notification; |
|
536 |
if(n.isOfType(NOTIFICATION_FIXED_CHANGED)){ |
|
537 |
if(!attr.isFixed()) { |
|
538 |
this.fixed = false; |
|
539 |
} |
|
540 |
} |
|
541 |
} |
|
542 |
} |
|
543 |
|
|
544 |
|
|
502 | 545 |
} |
Also available in: Unified diff