Revision 6335 trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/edition/EditableAdapter.java
EditableAdapter.java | ||
---|---|---|
1066 | 1066 |
} |
1067 | 1067 |
} |
1068 | 1068 |
|
1069 |
protected void fireAfterFieldAdded(FieldDescription field) { |
|
1070 |
AfterFieldEditEvent event = new AfterFieldEditEvent(this,field, |
|
1071 |
EditionEvent.CHANGE_TYPE_ADD); |
|
1072 |
for (int i = 0; i < editionListeners.size(); i++) { |
|
1073 |
IEditionListener listener = (IEditionListener) editionListeners |
|
1074 |
.get(i); |
|
1075 |
listener.afterFieldEditEvent(event); |
|
1076 |
} |
|
1077 |
} |
|
1078 |
|
|
1079 |
protected void fireAfterFieldRemoved(FieldDescription field) { |
|
1080 |
AfterFieldEditEvent event = new AfterFieldEditEvent(this,field, |
|
1081 |
EditionEvent.CHANGE_TYPE_DELETE); |
|
1082 |
for (int i = 0; i < editionListeners.size(); i++) { |
|
1083 |
IEditionListener listener = (IEditionListener) editionListeners |
|
1084 |
.get(i); |
|
1085 |
listener.afterFieldEditEvent(event); |
|
1086 |
} |
|
1087 |
} |
|
1088 |
|
|
1069 | 1089 |
protected boolean fireBeforeRowAdded(int sourceType) |
1070 | 1090 |
throws DriverIOException, IOException { |
1071 | 1091 |
Cancel cancel = new Cancel(); |
... | ... | |
1081 | 1101 |
return false; |
1082 | 1102 |
} |
1083 | 1103 |
|
1104 |
protected boolean fireBeforeFieldAdded(FieldDescription field) |
|
1105 |
throws EditionException { |
|
1106 |
Cancel cancel = new Cancel(); |
|
1107 |
BeforeFieldEditEvent event = new BeforeFieldEditEvent(this, field, |
|
1108 |
EditionEvent.CHANGE_TYPE_ADD, cancel); |
|
1109 |
for (int i = 0; i < editionListeners.size(); i++) { |
|
1110 |
IEditionListener listener = (IEditionListener) editionListeners |
|
1111 |
.get(i); |
|
1112 |
listener.beforeFieldEditEvent(event); |
|
1113 |
if (cancel.isCanceled()) |
|
1114 |
return true; |
|
1115 |
} |
|
1116 |
return false; |
|
1117 |
} |
|
1118 |
|
|
1119 |
protected boolean fireBeforeRemoveField(FieldDescription field) |
|
1120 |
throws EditionException { |
|
1121 |
Cancel cancel = new Cancel(); |
|
1122 |
BeforeFieldEditEvent event = new BeforeFieldEditEvent(this, field, |
|
1123 |
EditionEvent.CHANGE_TYPE_DELETE, cancel); |
|
1124 |
for (int i = 0; i < editionListeners.size(); i++) { |
|
1125 |
IEditionListener listener = (IEditionListener) editionListeners |
|
1126 |
.get(i); |
|
1127 |
listener.beforeFieldEditEvent(event); |
|
1128 |
if (cancel.isCanceled()) |
|
1129 |
return true; |
|
1130 |
} |
|
1131 |
return false; |
|
1132 |
} |
|
1133 |
|
|
1134 |
|
|
1084 | 1135 |
protected boolean fireBeforeModifyRow(IRow feat, int index, int sourceType) { |
1085 | 1136 |
Cancel cancel = new Cancel(); |
1086 | 1137 |
BeforeRowEditEvent event = new BeforeRowEditEvent(this, index, |
... | ... | |
1283 | 1334 |
} |
1284 | 1335 |
|
1285 | 1336 |
public void doRemoveField(InternalField field) throws EditionException { |
1337 |
boolean cancel = fireBeforeRemoveField(field.getFieldDesc()); |
|
1338 |
if (cancel) return; |
|
1286 | 1339 |
field.setDeleted(true); |
1287 | 1340 |
actualFields.remove(field.getFieldId()); |
1288 | 1341 |
fieldsChanged(); |
1342 |
fireAfterFieldRemoved(field.getFieldDesc()); |
|
1289 | 1343 |
} |
1290 | 1344 |
|
1291 | 1345 |
public void renameField(String antName, String newName) throws EditionException { |
... | ... | |
1325 | 1379 |
} |
1326 | 1380 |
|
1327 | 1381 |
public void undoAddField(InternalField field) throws EditionException { |
1382 |
boolean cancel = fireBeforeRemoveField(field.getFieldDesc()); |
|
1383 |
if (cancel) |
|
1384 |
return; |
|
1385 |
|
|
1328 | 1386 |
field.setDeleted(true); |
1329 | 1387 |
|
1330 | 1388 |
actualFields.remove(field.getFieldId()); |
1331 | 1389 |
fieldsChanged(); |
1390 |
fireAfterFieldRemoved(field.getFieldDesc()); |
|
1332 | 1391 |
|
1333 | 1392 |
} |
1334 | 1393 |
|
1335 |
public void doAddField(InternalField field) throws EditionException { |
|
1394 |
public int doAddField(InternalField field) throws EditionException { |
|
1395 |
boolean cancel; |
|
1396 |
cancel = fireBeforeFieldAdded(field.getFieldDesc()); |
|
1397 |
if (cancel) |
|
1398 |
return -1; |
|
1399 |
|
|
1336 | 1400 |
field.setDeleted(false); |
1337 | 1401 |
field.setFieldIndex(actualFields.size()); |
1338 | 1402 |
actualFields.put(field.getFieldId(), field); |
1339 | 1403 |
fieldsChanged(); |
1340 |
|
|
1404 |
fireAfterFieldAdded(field.getFieldDesc()); |
|
1405 |
return field.getFieldIndex(); |
|
1341 | 1406 |
} |
1342 | 1407 |
|
1343 | 1408 |
} |
Also available in: Unified diff