Revision 9524 branches/piloto3d/libraries/libFMap/src/com/iver/cit/gvsig/fmap/edition/EditableAdapter.java
EditableAdapter.java | ||
---|---|---|
40 | 40 |
|
41 | 41 |
/** |
42 | 42 |
* DOCUMENT ME! |
43 |
*
|
|
43 |
* |
|
44 | 44 |
* @author Vicente Caballero Navarro |
45 | 45 |
*/ |
46 | 46 |
public class EditableAdapter implements IEditableSource, IWriteable { |
... | ... | |
65 | 65 |
protected ArrayList listFields = new ArrayList(); |
66 | 66 |
|
67 | 67 |
protected ArrayList listInternalFields = new ArrayList(); |
68 |
|
|
68 |
|
|
69 | 69 |
protected boolean bFieldsHasBeenChanged = false; |
70 | 70 |
|
71 | 71 |
/** |
... | ... | |
77 | 77 |
* borran campos. Solo se van a?adiendo nuevos actualFields. |
78 | 78 |
*/ |
79 | 79 |
protected TreeMap actualFields; // la clave ser? el fieldId. |
80 |
|
|
80 |
|
|
81 | 81 |
protected ArrayList fastAccessFields = new ArrayList(); |
82 | 82 |
|
83 | 83 |
protected class MyFieldManager extends AbstractFieldManager { |
... | ... | |
135 | 135 |
|
136 | 136 |
protected int actualIndexFields; |
137 | 137 |
|
138 |
protected boolean isFullExtentDirty = false; |
|
139 |
|
|
138 | 140 |
/** |
139 | 141 |
* Crea un nuevo EditableAdapter. |
140 | 142 |
*/ |
... | ... | |
145 | 147 |
|
146 | 148 |
/** |
147 | 149 |
* DOCUMENT ME! |
148 |
*
|
|
150 |
* |
|
149 | 151 |
* @param ds |
150 | 152 |
* DOCUMENT ME! |
151 |
* @throws DriverException
|
|
153 |
* @throws DriverException |
|
152 | 154 |
*/ |
153 | 155 |
public void setOriginalDataSource(SelectableDataSource ds) throws DriverException { |
154 | 156 |
this.ods = ds; |
... | ... | |
158 | 160 |
setWriter(((IWriteable) drv).getWriter()); |
159 | 161 |
} |
160 | 162 |
|
161 |
|
|
163 |
|
|
162 | 164 |
} |
163 | 165 |
|
164 | 166 |
/** |
... | ... | |
197 | 199 |
InternalField clonedField = fld.cloneInternalField(); |
198 | 200 |
clonedFields.put(clonedField.getFieldId(), clonedField); |
199 | 201 |
} |
200 |
|
|
202 |
|
|
201 | 203 |
return clonedFields; |
202 | 204 |
} |
203 | 205 |
private void fieldsChanged() throws EditionException { |
... | ... | |
226 | 228 |
|
227 | 229 |
/** |
228 | 230 |
* DOCUMENT ME! |
229 |
*
|
|
231 |
* |
|
230 | 232 |
* @throws EditionException |
231 | 233 |
* DOCUMENT ME! |
232 | 234 |
*/ |
... | ... | |
242 | 244 |
* escribimos sobre la misma tabla) y luego se itera por los nuevos |
243 | 245 |
* registros llamando a process con el registro correcto. (A?adidos, |
244 | 246 |
* modificados). Para finalizar, se ejecuta PostProcess |
245 |
*
|
|
247 |
* |
|
246 | 248 |
* @param writer |
247 | 249 |
* IWriter que recibir? las llamadas. |
248 |
*
|
|
250 |
* |
|
249 | 251 |
* @throws EditionException |
250 | 252 |
* DOCUMENT ME! |
251 |
*
|
|
253 |
* |
|
252 | 254 |
*/ |
253 | 255 |
public void stopEdition(IWriter writer, int sourceType) |
254 | 256 |
throws EditionException { |
... | ... | |
260 | 262 |
|
261 | 263 |
public void saveEdits(IWriter writer, int sourceType) |
262 | 264 |
throws EditionException { |
263 |
|
|
265 |
|
|
264 | 266 |
// TODO: ARREGLAR ESTO PARA QUE CUANDO HA HABIDO CAMBIOS |
265 | 267 |
// EN LOS CAMPOS, PODAMOS CAMBIAR LO QUE TOQUE (A SER POSIBLE |
266 | 268 |
// SIN TENER QUE REESCRIBIR TODA LA TABLA CON POSTGIS) |
267 | 269 |
if (bFieldsHasBeenChanged) |
268 | 270 |
{ |
269 |
// Para cada campo de los originales, miramos si no est? en
|
|
271 |
// Para cada campo de los originales, miramos si no est? en |
|
270 | 272 |
// los actuales. Si no est?, le decimos al fieldManager |
271 | 273 |
// que lo borre. Si est?, pero le hemos cambiado el nombre |
272 | 274 |
// le pedimos al fieldManager que le cambie el nombre. |
273 | 275 |
// Luego recorremos los campos actuales para ver cuales |
274 | 276 |
// son nuevos, y los a?adimos. |
275 |
|
|
277 |
|
|
276 | 278 |
TreeMap ancientFields = (TreeMap) listInternalFields |
277 | 279 |
.get(0); |
278 | 280 |
Collection aux = ancientFields.values(); |
... | ... | |
287 | 289 |
if (f1.compareTo(f2) != 0) |
288 | 290 |
{ |
289 | 291 |
getFieldManager().renameField(f1, f2); |
290 |
}
|
|
292 |
} |
|
291 | 293 |
} |
292 | 294 |
else |
293 | 295 |
{ // No est?, hay que borrarlo |
... | ... | |
306 | 308 |
} |
307 | 309 |
// getFieldManager().alterTable(); // Se llama dentro del preprocess() |
308 | 310 |
} |
309 |
|
|
311 |
|
|
310 | 312 |
writer.preProcess(); |
311 | 313 |
|
312 | 314 |
try { |
... | ... | |
342 | 344 |
} |
343 | 345 |
|
344 | 346 |
int rowCount = getRowCount(); |
345 |
for (int i = 0; i < rowCount; i++) { |
|
346 |
IRowEdited rowEdited = getRow(i); |
|
347 |
if (writer.isWriteAll()) |
|
348 |
{ |
|
349 |
for (int i = 0; i < rowCount; i++) { |
|
350 |
IRowEdited rowEdited = getRow(i); |
|
351 |
|
|
352 |
if (rowEdited != null) { |
|
353 |
writer.process(rowEdited); |
|
354 |
} |
|
355 |
} |
|
356 |
} |
|
357 |
else |
|
358 |
{ |
|
359 |
// Escribimos solo aquellos registros que han cambiado |
|
360 |
for (int i = 0; i < rowCount; i++) { |
|
361 |
int calculatedIndex = getCalculatedIndex(i); |
|
362 |
Integer integer = new Integer(calculatedIndex); |
|
363 |
DefaultRowEdited edRow = null; |
|
364 |
// Si est? en el fichero de expansi?n hay que modificar |
|
365 |
if (relations.containsKey(integer)) { |
|
366 |
int num = ((Integer) relations.get(integer)).intValue(); |
|
347 | 367 |
|
348 |
if (rowEdited != null) { |
|
349 |
writer.process(rowEdited); |
|
368 |
// return expansionFile.getRow(num); |
|
369 |
// ExpansionFile ya entrega el registro formateado como debe |
|
370 |
IRowEdited rowFromExpansion = expansionFile.getRow(num); |
|
371 |
// ?Habr?a que hacer aqu? setID(index + "")? |
|
372 |
edRow = new DefaultRowEdited(rowFromExpansion.getLinkedRow() |
|
373 |
.cloneRow(), rowFromExpansion.getStatus(), i); |
|
374 |
writer.process(edRow); |
|
375 |
} |
|
350 | 376 |
} |
351 | 377 |
} |
352 | 378 |
writer.postProcess(); |
... | ... | |
362 | 388 |
ods.reload(); |
363 | 389 |
ds = null; |
364 | 390 |
clean(); |
365 |
|
|
391 |
|
|
366 | 392 |
} catch (DriverIOException e) { |
367 | 393 |
e.printStackTrace(); |
368 | 394 |
throw new EditionException(e); |
... | ... | |
378 | 404 |
|
379 | 405 |
/** |
380 | 406 |
* DOCUMENT ME! |
381 |
*
|
|
407 |
* |
|
382 | 408 |
* @throws IOException |
383 | 409 |
* DOCUMENT ME! |
384 | 410 |
*/ |
... | ... | |
397 | 423 |
|
398 | 424 |
/* |
399 | 425 |
* (non-Javadoc) |
400 |
*
|
|
426 |
* |
|
401 | 427 |
* @see com.iver.cit.gvsig.fmap.edition.IEditableSource#getRow(int) |
402 | 428 |
*/ |
403 | 429 |
public IRowEdited getRow(int index) throws DriverIOException, IOException { |
... | ... | |
433 | 459 |
.cloneRow(), rowFromExpansion.getStatus(), index); |
434 | 460 |
return edRow; |
435 | 461 |
} |
436 |
|
|
437 |
|
|
438 | 462 |
|
463 |
|
|
464 |
|
|
439 | 465 |
} |
440 | 466 |
|
441 | 467 |
/** |
442 | 468 |
* DOCUMENT ME! |
443 |
*
|
|
469 |
* |
|
444 | 470 |
* @return DOCUMENT ME! |
445 |
*
|
|
471 |
* |
|
446 | 472 |
* @throws DriverIOException |
447 | 473 |
* DOCUMENT ME! |
448 | 474 |
* @throws IOException |
... | ... | |
460 | 486 |
|
461 | 487 |
/* |
462 | 488 |
* (non-Javadoc) |
463 |
*
|
|
489 |
* |
|
464 | 490 |
* @see com.iver.cit.gvsig.fmap.edition.IEditableSource#addRow(com.iver.cit.gvsig.fmap.core.IRow, |
465 | 491 |
* java.lang.String) |
466 | 492 |
*/ |
... | ... | |
489 | 515 |
|
490 | 516 |
/** |
491 | 517 |
* DOCUMENT ME! |
492 |
*
|
|
518 |
* |
|
493 | 519 |
* @throws DriverIOException |
494 | 520 |
* DOCUMENT ME! |
495 | 521 |
* @throws IOException |
... | ... | |
504 | 530 |
|
505 | 531 |
/** |
506 | 532 |
* DOCUMENT ME! |
507 |
*
|
|
533 |
* |
|
508 | 534 |
* @throws DriverIOException |
509 | 535 |
* DOCUMENT ME! |
510 | 536 |
* @throws IOException |
... | ... | |
519 | 545 |
|
520 | 546 |
/* |
521 | 547 |
* (non-Javadoc) |
522 |
*
|
|
548 |
* |
|
523 | 549 |
* @see com.iver.cit.gvsig.fmap.edition.IEditableSource#removeRow(int) |
524 | 550 |
*/ |
525 | 551 |
public void removeRow(int index, String descrip, int sourceType) |
... | ... | |
540 | 566 |
|
541 | 567 |
/* |
542 | 568 |
* (non-Javadoc) |
543 |
*
|
|
569 |
* |
|
544 | 570 |
* @see com.iver.cit.gvsig.fmap.edition.IEditableSource#modifyRow(int, |
545 | 571 |
* com.iver.cit.gvsig.fmap.core.IRow) |
546 | 572 |
*/ |
... | ... | |
585 | 611 |
|
586 | 612 |
/** |
587 | 613 |
* DOCUMENT ME! |
588 |
*
|
|
614 |
* |
|
589 | 615 |
* @throws IOException |
590 | 616 |
* DOCUMENT ME! |
591 | 617 |
* @throws DriverIOException |
... | ... | |
604 | 630 |
* fuera una modificaci?n de una geometr?a que estuviese en el fichero de |
605 | 631 |
* expansi?n antes de ser modificada y se pone el puntero de escritura del |
606 | 632 |
* expansion file a justo despues de la penultima geometr?a |
607 |
*
|
|
633 |
* |
|
608 | 634 |
* @param geometryIndex |
609 | 635 |
* ?ndice de la geometr?a que se quiere deshacer su modificaci?n |
610 | 636 |
* @param previousExpansionFileIndex |
... | ... | |
612 | 638 |
* vale -1 quiere decir que es una modificaci?n de una geometr?a |
613 | 639 |
* original y por tanto no hay que actualizar el mapa de indices |
614 | 640 |
* sino eliminar su entrada. |
615 |
*
|
|
641 |
* |
|
616 | 642 |
* @throws IOException |
617 | 643 |
* @throws DriverIOException |
618 | 644 |
*/ |
... | ... | |
654 | 680 |
* se marca como eliminada (haya sido modificada o no). Si es una geometr?a |
655 | 681 |
* a?adida posteriormente se invalida en el fichero de expansi?n, para que |
656 | 682 |
* una futura compactaci?n termine con ella. |
657 |
*
|
|
683 |
* |
|
658 | 684 |
* @param index |
659 | 685 |
* ?ndice de la geometr?a. |
660 |
*
|
|
686 |
* |
|
661 | 687 |
* @throws DriverIOException |
662 | 688 |
* @throws IOException |
663 | 689 |
*/ |
... | ... | |
671 | 697 |
System.err.println("Elimina una Row en la posici?n: " + index); |
672 | 698 |
// TODO: Con tablas no es necesario devolver la anterior feature. Por |
673 | 699 |
// ahora. |
700 |
isFullExtentDirty = true; |
|
674 | 701 |
fireAfterRemoveRow(index, sourceType); |
675 | 702 |
return null; |
676 | 703 |
} |
... | ... | |
682 | 709 |
* fichero de expansi?n (por ser nueva o original pero modificada) se invoca |
683 | 710 |
* el m?todo modifyGeometry y se actualiza el ?ndice de la geometria en el |
684 | 711 |
* fichero. |
685 |
*
|
|
712 |
* |
|
686 | 713 |
* @param index |
687 | 714 |
* DOCUMENT ME! |
688 | 715 |
* @param feat |
689 | 716 |
* DOCUMENT ME! |
690 |
*
|
|
717 |
* |
|
691 | 718 |
* @return DOCUMENT ME! |
692 |
*
|
|
719 |
* |
|
693 | 720 |
* @throws IOException |
694 | 721 |
* @throws DriverIOException |
695 | 722 |
*/ |
... | ... | |
725 | 752 |
*/ |
726 | 753 |
relations.put(integer, new Integer(num)); |
727 | 754 |
} |
755 |
isFullExtentDirty = true; |
|
728 | 756 |
fireAfterModifyRow(index, sourceType); |
729 | 757 |
return pos; |
730 | 758 |
} |
... | ... | |
732 | 760 |
/** |
733 | 761 |
* A?ade una geometria al fichero de expansi?n y guarda la correspondencia |
734 | 762 |
* en la tabla relations. |
735 |
*
|
|
763 |
* |
|
736 | 764 |
* @param feat |
737 | 765 |
* geometr?a a guardar. |
738 |
*
|
|
766 |
* |
|
739 | 767 |
* @return calculatedIndex |
740 |
*
|
|
768 |
* |
|
741 | 769 |
* @throws DriverIOException |
742 | 770 |
* @throws IOException |
743 | 771 |
*/ |
... | ... | |
762 | 790 |
relations.put(new Integer(calculatedIndex), new Integer(pos)); |
763 | 791 |
numAdd++; |
764 | 792 |
System.err.println("A?ade una Row en la posici?n: " + calculatedIndex); |
765 |
fireAfterRowAdded(calculatedIndex, sourceType); |
|
793 |
isFullExtentDirty = true; |
|
794 |
fireAfterRowAdded(feat,calculatedIndex, sourceType); |
|
766 | 795 |
return calculatedIndex; |
767 | 796 |
} |
768 | 797 |
|
769 | 798 |
/** |
770 | 799 |
* Se desmarca como invalidada en el fichero de expansion o como eliminada |
771 | 800 |
* en el fichero original |
772 |
*
|
|
801 |
* |
|
773 | 802 |
* @param index |
774 | 803 |
* DOCUMENT ME! |
775 |
*
|
|
804 |
* |
|
776 | 805 |
* @throws IOException |
777 | 806 |
* @throws DriverIOException |
778 | 807 |
*/ |
... | ... | |
782 | 811 |
if (cancel) |
783 | 812 |
return; |
784 | 813 |
delRows.set(index, false); |
785 |
fireAfterRowAdded(index, sourceType); |
|
814 |
fireAfterRowAdded(null,index, sourceType);
|
|
786 | 815 |
} |
787 | 816 |
|
788 | 817 |
/** |
789 | 818 |
* Se elimina del final del fichero de expansi?n poniendo el puntero de |
790 | 819 |
* escritura apuntando al final de la pen?ltima geometr?a. Deber? quitar la |
791 | 820 |
* relaci?n del mapa de relaciones |
792 |
*
|
|
821 |
* |
|
793 | 822 |
* @param index |
794 | 823 |
* ?ndice de la geometr?a que se a?adi? |
795 |
*
|
|
824 |
* |
|
796 | 825 |
* @throws DriverIOException |
797 | 826 |
* @throws IOException |
798 | 827 |
*/ |
... | ... | |
809 | 838 |
|
810 | 839 |
/* |
811 | 840 |
* (non-Javadoc) |
812 |
*
|
|
841 |
* |
|
813 | 842 |
* @see com.iver.cit.gvsig.fmap.layers.VectorialAdapter#getRecordset() |
814 | 843 |
*/ |
815 | 844 |
public SelectableDataSource getRecordset() throws DriverLoadException { |
... | ... | |
819 | 848 |
.addDataSource((ObjectDriver) editingDriver); |
820 | 849 |
|
821 | 850 |
try { |
822 |
|
|
851 |
|
|
823 | 852 |
ds = new SelectableDataSource(LayerFactory |
824 | 853 |
.getDataSourceFactory().createRandomDataSource( |
825 | 854 |
name, DataSourceFactory.MANUAL_OPENING)); |
... | ... | |
842 | 871 |
|
843 | 872 |
/** |
844 | 873 |
* DOCUMENT ME! |
845 |
*
|
|
874 |
* |
|
846 | 875 |
* @return |
847 | 876 |
*/ |
848 | 877 |
public FBitSet getSelection() { |
... | ... | |
865 | 894 |
|
866 | 895 |
/** |
867 | 896 |
* DOCUMENT ME! |
868 |
*
|
|
897 |
* |
|
869 | 898 |
* @return DOCUMENT ME! |
870 | 899 |
*/ |
871 | 900 |
public boolean isEditing() { |
... | ... | |
898 | 927 |
|
899 | 928 |
/** |
900 | 929 |
* DOCUMENT ME! |
901 |
*
|
|
930 |
* |
|
902 | 931 |
* @param rowIndex |
903 | 932 |
* DOCUMENT ME! |
904 |
*
|
|
933 |
* |
|
905 | 934 |
* @return DOCUMENT ME! |
906 | 935 |
*/ |
907 | 936 |
public int getCalculatedIndex(long rowIndex) { |
... | ... | |
930 | 959 |
|
931 | 960 |
/** |
932 | 961 |
* DOCUMENT ME! |
933 |
*
|
|
962 |
* |
|
934 | 963 |
* @author Vicente Caballero Navarro |
935 | 964 |
*/ |
936 | 965 |
private class myObjectDriver implements ObjectDriver { |
937 | 966 |
/* |
938 | 967 |
* (non-Javadoc) |
939 |
*
|
|
968 |
* |
|
940 | 969 |
* @see com.hardcode.gdbms.engine.data.driver.ObjectDriver#getPrimaryKeys() |
941 | 970 |
*/ |
942 | 971 |
public int[] getPrimaryKeys() throws DriverException { |
... | ... | |
951 | 980 |
|
952 | 981 |
/* |
953 | 982 |
* (non-Javadoc) |
954 |
*
|
|
983 |
* |
|
955 | 984 |
* @see com.hardcode.gdbms.engine.data.driver.ObjectDriver#write(com.hardcode.gdbms.engine.data.edition.DataWare) |
956 | 985 |
*/ |
957 | 986 |
public void write(DataWare dataWare) throws DriverException { |
... | ... | |
962 | 991 |
|
963 | 992 |
/* |
964 | 993 |
* (non-Javadoc) |
965 |
*
|
|
994 |
* |
|
966 | 995 |
* @see com.hardcode.gdbms.engine.data.driver.GDBMSDriver#setDataSourceFactory(com.hardcode.gdbms.engine.data.DataSourceFactory) |
967 | 996 |
*/ |
968 | 997 |
public void setDataSourceFactory(DataSourceFactory dsf) { |
... | ... | |
971 | 1000 |
|
972 | 1001 |
/* |
973 | 1002 |
* (non-Javadoc) |
974 |
*
|
|
1003 |
* |
|
975 | 1004 |
* @see com.hardcode.driverManager.Driver#getName() |
976 | 1005 |
*/ |
977 | 1006 |
public String getName() { |
... | ... | |
980 | 1009 |
|
981 | 1010 |
/* |
982 | 1011 |
* (non-Javadoc) |
983 |
*
|
|
1012 |
* |
|
984 | 1013 |
* @see com.hardcode.gdbms.engine.data.driver.ReadAccess#getFieldValue(long, |
985 | 1014 |
* int) |
986 | 1015 |
*/ |
... | ... | |
1033 | 1062 |
|
1034 | 1063 |
/* |
1035 | 1064 |
* (non-Javadoc) |
1036 |
*
|
|
1065 |
* |
|
1037 | 1066 |
* @see com.hardcode.gdbms.engine.data.driver.ReadAccess#getFieldCount() |
1038 | 1067 |
*/ |
1039 | 1068 |
public int getFieldCount() throws DriverException { |
... | ... | |
1042 | 1071 |
|
1043 | 1072 |
/* |
1044 | 1073 |
* (non-Javadoc) |
1045 |
*
|
|
1074 |
* |
|
1046 | 1075 |
* @see com.hardcode.gdbms.engine.data.driver.ReadAccess#getFieldName(int) |
1047 | 1076 |
*/ |
1048 | 1077 |
public String getFieldName(int fieldId) throws DriverException { |
... | ... | |
1052 | 1081 |
// if (i == fieldId) |
1053 | 1082 |
// return fld.getFieldDesc().getFieldAlias(); |
1054 | 1083 |
// i++; |
1055 |
//
|
|
1084 |
// |
|
1056 | 1085 |
// } |
1057 | 1086 |
// throw new DriverException("FieldId " + fieldId + " not found "); |
1058 | 1087 |
FieldDescription aux = (FieldDescription) fastAccessFields.get(fieldId); |
... | ... | |
1063 | 1092 |
|
1064 | 1093 |
/* |
1065 | 1094 |
* (non-Javadoc) |
1066 |
*
|
|
1095 |
* |
|
1067 | 1096 |
* @see com.hardcode.gdbms.engine.data.driver.ReadAccess#getRowCount() |
1068 | 1097 |
*/ |
1069 | 1098 |
public long getRowCount() { |
... | ... | |
1081 | 1110 |
|
1082 | 1111 |
/* |
1083 | 1112 |
* (non-Javadoc) |
1084 |
*
|
|
1113 |
* |
|
1085 | 1114 |
* @see com.hardcode.gdbms.engine.data.driver.ReadAccess#getFieldType(int) |
1086 | 1115 |
*/ |
1087 | 1116 |
public int getFieldType(int fieldId) throws DriverException { |
... | ... | |
1091 | 1120 |
// if (i == fieldId) |
1092 | 1121 |
// return fld.getFieldDesc().getFieldType(); |
1093 | 1122 |
// i++; |
1094 |
//
|
|
1123 |
// |
|
1095 | 1124 |
// } |
1096 | 1125 |
FieldDescription aux = (FieldDescription) fastAccessFields.get(fieldId); |
1097 | 1126 |
return aux.getFieldType(); |
1098 |
|
|
1127 |
|
|
1099 | 1128 |
// return ods.getFieldType(i); |
1100 | 1129 |
} |
1101 | 1130 |
|
1102 | 1131 |
public int getFieldWidth(int fieldId) throws DriverException { |
1103 | 1132 |
// int i=0; |
1104 |
// for (Iterator iter = actualFields.values().iterator(); iter.hasNext();) {
|
|
1133 |
// for (Iterator iter = actualFields.values().iterator(); iter.hasNext();) { |
|
1105 | 1134 |
// InternalField fld = (InternalField) iter.next(); |
1106 | 1135 |
//// if (fld.getFieldIndex() == i) |
1107 | 1136 |
//// return fld.getFieldDesc().getFieldLength(); |
1108 | 1137 |
// if (i == fieldId) |
1109 | 1138 |
// return fld.getFieldDesc().getFieldLength(); |
1110 | 1139 |
// i++; |
1111 |
//
|
|
1140 |
// |
|
1112 | 1141 |
// } |
1113 | 1142 |
// |
1114 | 1143 |
// return ods.getFieldWidth(i); |
... | ... | |
1119 | 1148 |
|
1120 | 1149 |
public void reload() throws IOException, DriverException { |
1121 | 1150 |
ods.reload(); |
1122 |
|
|
1151 |
|
|
1123 | 1152 |
} |
1124 | 1153 |
} |
1125 | 1154 |
|
... | ... | |
1152 | 1181 |
return false; |
1153 | 1182 |
} |
1154 | 1183 |
|
1155 |
protected void fireAfterRowAdded(int calculatedIndex, int sourceType) { |
|
1184 |
protected void fireAfterRowAdded(IRow feat,int calculatedIndex, int sourceType) {
|
|
1156 | 1185 |
AfterRowEditEvent event = new AfterRowEditEvent(this, calculatedIndex, |
1157 | 1186 |
EditionEvent.CHANGE_TYPE_ADD, sourceType); |
1158 | 1187 |
for (int i = 0; i < editionListeners.size(); i++) { |
1159 | 1188 |
IEditionListener listener = (IEditionListener) editionListeners |
1160 | 1189 |
.get(i); |
1161 |
listener.afterRowEditEvent(null, event);
|
|
1190 |
listener.afterRowEditEvent(feat, event);
|
|
1162 | 1191 |
} |
1163 | 1192 |
} |
1164 | 1193 |
|
... | ... | |
1191 | 1220 |
listener.afterFieldEditEvent(event); |
1192 | 1221 |
} |
1193 | 1222 |
} |
1194 |
|
|
1195 |
|
|
1223 |
|
|
1224 |
|
|
1196 | 1225 |
protected boolean fireBeforeRowAdded(int sourceType) |
1197 | 1226 |
throws DriverIOException, IOException { |
1198 | 1227 |
Cancel cancel = new Cancel(); |
... | ... | |
1238 | 1267 |
return false; |
1239 | 1268 |
} |
1240 | 1269 |
|
1241 |
|
|
1270 |
|
|
1242 | 1271 |
protected boolean fireBeforeModifyRow(IRow feat, int index, int sourceType) { |
1243 | 1272 |
Cancel cancel = new Cancel(); |
1244 | 1273 |
BeforeRowEditEvent event = new BeforeRowEditEvent(this, index, |
... | ... | |
1355 | 1384 |
// listInternalFields, pero casi seguro que lo correcto ser?a hacer un |
1356 | 1385 |
// reload completo. |
1357 | 1386 |
initalizeFields(ods); |
1358 |
|
|
1387 |
|
|
1359 | 1388 |
// listInternalFields.clear(); |
1360 | 1389 |
// listInternalFields.add(actualFields); |
1361 | 1390 |
} |
1362 | 1391 |
|
1363 | 1392 |
/* |
1364 | 1393 |
* (non-Javadoc) |
1365 |
*
|
|
1394 |
* |
|
1366 | 1395 |
* @see com.iver.cit.gvsig.fmap.edition.IEditableSource#getFieldManager() |
1367 | 1396 |
*/ |
1368 | 1397 |
public IFieldManager getFieldManager() { |
... | ... | |
1381 | 1410 |
/** |
1382 | 1411 |
* Tiene en cuenta los campos actuales para formatear una row con ellos. Le |
1383 | 1412 |
* pasamos los campos que hab?a en el momento en que se cre? esa row. |
1384 |
*
|
|
1413 |
* |
|
1385 | 1414 |
* @param edRow |
1386 | 1415 |
* @param indexInternalFields |
1387 | 1416 |
* @return |
1388 | 1417 |
*/ |
1389 | 1418 |
public IRowEdited createExternalRow(IRowEdited edRow, |
1390 | 1419 |
int indexInternalFields) { |
1391 |
|
|
1420 |
|
|
1392 | 1421 |
// para acelerar |
1393 | 1422 |
if (bFieldsHasBeenChanged == false) |
1394 | 1423 |
return edRow; |
1395 |
|
|
1424 |
|
|
1396 | 1425 |
Value[] att = edRow.getAttributes(); |
1397 | 1426 |
TreeMap ancientFields = (TreeMap) listInternalFields |
1398 | 1427 |
.get(indexInternalFields); |
... | ... | |
1403 | 1432 |
Value val = null; |
1404 | 1433 |
while (it.hasNext()) { |
1405 | 1434 |
// Para cada campo de los actuales, miramos si ya estaba cuando |
1406 |
// el registro estaba guardado.
|
|
1435 |
// el registro estaba guardado. |
|
1407 | 1436 |
// Si estaba, cogemos el valor de ese campo en el registro |
1408 | 1437 |
// guardado. Si no estaba, ha sido a?adido despu?s y ponemos |
1409 | 1438 |
// su valor por defecto. |
... | ... | |
1452 | 1481 |
if (fld.getFieldDesc().getFieldAlias().compareToIgnoreCase(fieldName) == 0) |
1453 | 1482 |
return fld; |
1454 | 1483 |
} |
1455 |
|
|
1484 |
|
|
1456 | 1485 |
return null; |
1457 | 1486 |
} |
1458 | 1487 |
|
... | ... | |
1484 | 1513 |
doRenameField(fld, newName); |
1485 | 1514 |
|
1486 | 1515 |
} |
1487 |
|
|
1516 |
|
|
1488 | 1517 |
public void undoRenameField(InternalField field, String antName) throws EditionException { |
1489 | 1518 |
field.getFieldDesc().setFieldAlias(antName); |
1490 | 1519 |
fieldsChanged(); |
... | ... | |
1523 | 1552 |
actualFields.remove(field.getFieldId()); |
1524 | 1553 |
fieldsChanged(); |
1525 | 1554 |
fireAfterFieldRemoved(field.getFieldDesc()); |
1526 |
|
|
1555 |
|
|
1527 | 1556 |
} |
1528 | 1557 |
|
1529 | 1558 |
public int doAddField(InternalField field) throws EditionException { |
... | ... | |
1540 | 1569 |
// return field.getFieldIndex(); |
1541 | 1570 |
return field.getFieldId().intValue(); |
1542 | 1571 |
} |
1543 |
|
|
1572 |
|
|
1544 | 1573 |
public Driver getOriginalDriver() |
1545 | 1574 |
{ |
1546 | 1575 |
return ods.getDriver(); |
1547 | 1576 |
} |
1548 |
|
|
1577 |
|
|
1549 | 1578 |
/** |
1550 | 1579 |
* Use it to be sure the recordset will have the right fields. It forces a new SelectableDataSource |
1551 | 1580 |
* to be created next time it is needed |
... | ... | |
1558 | 1587 |
return (FieldDescription[]) fastAccessFields.toArray(new FieldDescription[0]); |
1559 | 1588 |
} |
1560 | 1589 |
|
1561 |
|
|
1590 |
|
|
1562 | 1591 |
// private InternalField getInternalFieldByIndex(int fieldId) |
1563 | 1592 |
// { |
1564 | 1593 |
// for (Iterator iter = actualFields.values().iterator(); iter.hasNext();) { |
... | ... | |
1568 | 1597 |
// } |
1569 | 1598 |
// return null; |
1570 | 1599 |
// } |
1571 |
|
|
1600 |
|
|
1572 | 1601 |
} |
Also available in: Unified diff