Revision 12148 trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/edition/EditableAdapter.java
EditableAdapter.java | ||
---|---|---|
1 | 1 |
package com.iver.cit.gvsig.fmap.edition; |
2 | 2 |
|
3 | 3 |
import java.io.IOException; |
4 |
import java.rmi.server.UID; |
|
4 | 5 |
import java.util.ArrayList; |
5 | 6 |
import java.util.Collection; |
6 | 7 |
import java.util.HashMap; |
... | ... | |
647 | 648 |
} catch (ReadDriverException e) { |
648 | 649 |
throw new EditionCommandException(writer.getName(),e); |
649 | 650 |
} |
650 |
boolean cancel = fireBeforeModifyRow(edRow, geometryIndex, |
|
651 |
sourceType); |
|
651 |
boolean cancel=true; |
|
652 |
try { |
|
653 |
cancel = fireBeforeModifyRow(edRow, geometryIndex, |
|
654 |
sourceType); |
|
655 |
} catch (ReadDriverException e) { |
|
656 |
throw new EditionCommandException(writer.getName(),e); |
|
657 |
} |
|
652 | 658 |
if (cancel) |
653 | 659 |
return; |
654 | 660 |
// Se elimina de las relaciones y del fichero de expansi?n |
655 | 661 |
relations.remove(new Integer(geometryIndex)); |
656 | 662 |
expansionFile.deleteLastRow(); |
657 | 663 |
} else { |
658 |
boolean cancel; |
|
664 |
boolean cancel=true;
|
|
659 | 665 |
try { |
660 | 666 |
cancel = fireBeforeModifyRow(expansionFile |
661 | 667 |
.getRow(previousExpansionFileIndex), geometryIndex, |
662 | 668 |
sourceType); |
663 | 669 |
} catch (ExpansionFileReadException e) { |
664 | 670 |
throw new EditionCommandException(writer.getName(),e); |
671 |
} catch (ReadDriverException e) { |
|
672 |
throw new EditionCommandException(writer.getName(),e); |
|
665 | 673 |
} |
666 | 674 |
if (cancel) |
667 | 675 |
return; |
... | ... | |
769 | 777 |
* @throws IOException |
770 | 778 |
*/ |
771 | 779 |
public int doAddRow(IRow feat, int sourceType) throws ReadDriverException, ExpansionFileWriteException { |
772 |
boolean cancel = fireBeforeRowAdded(sourceType); |
|
780 |
boolean cancel = fireBeforeRowAdded(sourceType,feat.getID());
|
|
773 | 781 |
if (cancel) |
774 | 782 |
return -1; |
775 | 783 |
// A?ade la geometr?a |
... | ... | |
795 | 803 |
* DOCUMENT ME! |
796 | 804 |
*/ |
797 | 805 |
public void undoRemoveRow(int index, int sourceType) throws EditionCommandException { |
798 |
boolean cancel; |
|
806 |
delRows.set(index, false); |
|
807 |
String fid; |
|
799 | 808 |
try { |
800 |
cancel = fireBeforeRowAdded(sourceType); |
|
809 |
fid = getRow(index).getID(); |
|
810 |
|
|
811 |
boolean cancel = fireBeforeRowAdded(sourceType,fid); |
|
812 |
if (cancel){ |
|
813 |
delRows.set(index,true); |
|
814 |
return; |
|
815 |
} |
|
816 |
} catch (ExpansionFileReadException e) { |
|
817 |
throw new EditionCommandException(getOriginalDriver().getName(),e); |
|
801 | 818 |
} catch (ReadDriverException e) { |
802 |
throw new EditionCommandException(writer.getName(),e);
|
|
819 |
throw new EditionCommandException(getOriginalDriver().getName(),e);
|
|
803 | 820 |
} |
804 |
if (cancel) |
|
805 |
return; |
|
806 |
delRows.set(index, false); |
|
807 | 821 |
fireAfterRowAdded(null,index, sourceType); |
808 | 822 |
} |
809 | 823 |
|
... | ... | |
819 | 833 |
*/ |
820 | 834 |
public void undoAddRow(int calculatedIndex, int sourceType) |
821 | 835 |
throws EditionCommandException { |
822 |
boolean cancel = fireBeforeRemoveRow(calculatedIndex, sourceType); |
|
836 |
boolean cancel; |
|
837 |
try { |
|
838 |
cancel = fireBeforeRemoveRow(calculatedIndex, sourceType); |
|
839 |
} catch (ReadDriverException e) { |
|
840 |
throw new EditionCommandException(getOriginalDriver().getName(),e); |
|
841 |
} |
|
823 | 842 |
if (cancel) |
824 | 843 |
return; |
825 | 844 |
expansionFile.deleteLastRow(); |
... | ... | |
1160 | 1179 |
|
1161 | 1180 |
} |
1162 | 1181 |
|
1163 |
protected boolean fireBeforeRemoveRow(int index, int sourceType) { |
|
1182 |
protected boolean fireBeforeRemoveRow(int index, int sourceType) throws ReadDriverException {
|
|
1164 | 1183 |
Cancel cancel = new Cancel(); |
1165 |
BeforeRowEditEvent event = new BeforeRowEditEvent(this, index, |
|
1184 |
String fid=null; |
|
1185 |
try { |
|
1186 |
fid = getRow(index).getID(); |
|
1187 |
} catch (ExpansionFileReadException e) { |
|
1188 |
throw new ReadDriverException(getOriginalDriver().getName(),e); |
|
1189 |
} |
|
1190 |
BeforeRowEditEvent event = new BeforeRowEditEvent(this, fid, |
|
1166 | 1191 |
EditionEvent.CHANGE_TYPE_DELETE, cancel, sourceType); |
1167 | 1192 |
for (int i = 0; i < editionListeners.size(); i++) { |
1168 | 1193 |
IEditionListener listener = (IEditionListener) editionListeners |
... | ... | |
1232 | 1257 |
} |
1233 | 1258 |
|
1234 | 1259 |
|
1235 |
protected boolean fireBeforeRowAdded(int sourceType) throws ReadDriverException{ |
|
1260 |
protected boolean fireBeforeRowAdded(int sourceType,String newFID) throws ReadDriverException{
|
|
1236 | 1261 |
Cancel cancel = new Cancel(); |
1237 |
BeforeRowEditEvent event = new BeforeRowEditEvent(this, getNewIndex(),
|
|
1262 |
BeforeRowEditEvent event = new BeforeRowEditEvent(this, newFID,
|
|
1238 | 1263 |
EditionEvent.CHANGE_TYPE_ADD, cancel, sourceType); |
1239 | 1264 |
for (int i = 0; i < editionListeners.size(); i++) { |
1240 | 1265 |
IEditionListener listener = (IEditionListener) editionListeners |
... | ... | |
1275 | 1300 |
} |
1276 | 1301 |
|
1277 | 1302 |
|
1278 |
protected boolean fireBeforeModifyRow(IRow feat, int index, int sourceType) { |
|
1303 |
protected boolean fireBeforeModifyRow(IRow feat, int index, int sourceType) throws ReadDriverException {
|
|
1279 | 1304 |
Cancel cancel = new Cancel(); |
1280 |
BeforeRowEditEvent event = new BeforeRowEditEvent(this, index, |
|
1305 |
String fid=null; |
|
1306 |
try { |
|
1307 |
fid = getRow(index).getID(); |
|
1308 |
} catch (ExpansionFileReadException e) { |
|
1309 |
throw new ReadDriverException(getOriginalDriver().getName(),e); |
|
1310 |
} |
|
1311 |
BeforeRowEditEvent event = new BeforeRowEditEvent(this, fid, |
|
1281 | 1312 |
EditionEvent.CHANGE_TYPE_MODIFY, cancel, sourceType); |
1282 | 1313 |
for (int i = 0; i < editionListeners.size(); i++) { |
1283 | 1314 |
IEditionListener listener = (IEditionListener) editionListeners |
... | ... | |
1626 | 1657 |
public FieldDescription[] getFieldsDescription() { |
1627 | 1658 |
return (FieldDescription[]) fastAccessFields.toArray(new FieldDescription[0]); |
1628 | 1659 |
} |
1629 |
public int getNewIndex() throws ReadDriverException { |
|
1630 |
int index=(int)ods.getRowCount() + numAdd; |
|
1631 |
return index; |
|
1660 |
public String getNewFID() { |
|
1661 |
return "fid-" + (new UID()).toString(); |
|
1632 | 1662 |
} |
1633 | 1663 |
|
1634 | 1664 |
// private InternalField getInternalFieldByIndex(int fieldId) |
Also available in: Unified diff