Revision 6335
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/edition/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 |
} |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/edition/IEditionListener.java | ||
---|---|---|
1 | 1 |
package com.iver.cit.gvsig.fmap.edition; |
2 | 2 |
|
3 | 3 |
import com.iver.cit.gvsig.fmap.core.IRow; |
4 |
import com.iver.cit.gvsig.fmap.drivers.FieldDescription; |
|
4 | 5 |
|
5 | 6 |
public interface IEditionListener { |
6 | 7 |
|
... | ... | |
9 | 10 |
void beforeRowEditEvent(IRow feat,BeforeRowEditEvent e); |
10 | 11 |
|
11 | 12 |
void afterRowEditEvent(AfterRowEditEvent e); |
13 |
|
|
14 |
void beforeFieldEditEvent(BeforeFieldEditEvent e); |
|
15 |
void afterFieldEditEvent(AfterFieldEditEvent e); |
|
12 | 16 |
|
13 | 17 |
} |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/edition/EditionEvent.java | ||
---|---|---|
5 | 5 |
public static int STOP_EDITION = 1; |
6 | 6 |
public static int CANCEL_EDITION = 2; |
7 | 7 |
public static int ROW_EDITION = 3; |
8 |
public static int FIELD_EDITION = 4; |
|
8 | 9 |
|
9 | 10 |
public static int CHANGE_TYPE_ADD = 10; |
10 | 11 |
public static int CHANGE_TYPE_MODIFY = 11; |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/edition/AfterFieldEditEvent.java | ||
---|---|---|
1 |
package com.iver.cit.gvsig.fmap.edition; |
|
2 |
|
|
3 |
import com.iver.cit.gvsig.fmap.drivers.FieldDescription; |
|
4 |
|
|
5 |
public class AfterFieldEditEvent extends EditionEvent { |
|
6 |
|
|
7 |
FieldDescription fieldChanged; |
|
8 |
int changeType; |
|
9 |
public AfterFieldEditEvent(IEditableSource source, FieldDescription field, int changeType) |
|
10 |
{ |
|
11 |
super(source, EditionEvent.FIELD_EDITION, EditionEvent.ALPHANUMERIC); |
|
12 |
this.fieldChanged = field; |
|
13 |
this.changeType = changeType; |
|
14 |
} |
|
15 |
/** |
|
16 |
* @return Returns the changeType. |
|
17 |
*/ |
|
18 |
public int getChangeType() { |
|
19 |
return changeType; |
|
20 |
} |
|
21 |
/** |
|
22 |
* @return Returns the changed field. |
|
23 |
*/ |
|
24 |
public FieldDescription getFieldChanged() { |
|
25 |
return fieldChanged; |
|
26 |
} |
|
27 |
|
|
28 |
} |
|
0 | 29 |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/edition/BeforeFieldEditEvent.java | ||
---|---|---|
1 |
package com.iver.cit.gvsig.fmap.edition; |
|
2 |
|
|
3 |
import com.iver.cit.gvsig.fmap.drivers.FieldDescription; |
|
4 |
import com.iver.utiles.swing.threads.Cancellable; |
|
5 |
|
|
6 |
public class BeforeFieldEditEvent extends EditionEvent { |
|
7 |
|
|
8 |
FieldDescription newField; |
|
9 |
int changeType; |
|
10 |
Cancellable cancel; |
|
11 |
public BeforeFieldEditEvent(IEditableSource source, FieldDescription field, int changeType, Cancellable cancel) |
|
12 |
{ |
|
13 |
super(source, EditionEvent.FIELD_EDITION, EditionEvent.ALPHANUMERIC); |
|
14 |
this.newField = field; |
|
15 |
this.changeType = changeType; |
|
16 |
this.cancel = cancel; |
|
17 |
} |
|
18 |
/** |
|
19 |
* @return Returns the cancel. |
|
20 |
*/ |
|
21 |
public Cancellable getCancel() { |
|
22 |
return cancel; |
|
23 |
} |
|
24 |
/** |
|
25 |
* @return Returns the changeType. |
|
26 |
*/ |
|
27 |
public int getChangeType() { |
|
28 |
return changeType; |
|
29 |
} |
|
30 |
/** |
|
31 |
* @return Returns the new field. |
|
32 |
*/ |
|
33 |
public FieldDescription getNewField() { |
|
34 |
return newField; |
|
35 |
} |
|
36 |
|
|
37 |
} |
|
0 | 38 |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/layers/SelectableDataSource.java | ||
---|---|---|
98 | 98 |
} |
99 | 99 |
|
100 | 100 |
/** |
101 |
* Maps real fields or "external" fields. We don't want to see virtual fields. |
|
101 | 102 |
* @throws DriverException |
102 | 103 |
*/ |
103 | 104 |
public void mapExternalFields() throws DriverException { |
Also available in: Unified diff