Revision 6259 trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/edition/EditableAdapter.java
EditableAdapter.java | ||
---|---|---|
162 | 162 |
field.setFieldIndex(i); |
163 | 163 |
actualFields.put(field.getFieldId(), field); |
164 | 164 |
} |
165 |
fieldsChanged(); |
|
165 |
try { |
|
166 |
fieldsChanged(); |
|
167 |
} catch (EditionException e) { |
|
168 |
e.printStackTrace(); |
|
169 |
throw new DriverException(e); |
|
170 |
} |
|
166 | 171 |
|
167 | 172 |
} |
168 | 173 |
|
169 |
private void fieldsChanged() { |
|
174 |
private void fieldsChanged() throws EditionException {
|
|
170 | 175 |
listInternalFields.add(actualFields); |
171 | 176 |
actualIndexFields = listInternalFields.size()-1; |
177 |
try { |
|
178 |
getRecordset().mapExternalFields(); |
|
179 |
} catch (DriverLoadException e) { |
|
180 |
e.printStackTrace(); |
|
181 |
throw new EditionException(e); |
|
182 |
} catch (DriverException e) { |
|
183 |
e.printStackTrace(); |
|
184 |
throw new EditionException(e); |
|
185 |
} |
|
172 | 186 |
} |
173 | 187 |
|
174 | 188 |
/** |
... | ... | |
872 | 886 |
public Value getFieldValue(long rowIndex, int fieldId) |
873 | 887 |
throws DriverException { |
874 | 888 |
// Si no est? en el fichero de expansi?n |
875 |
Integer integer = new Integer(getCalculatedIndex(rowIndex)); |
|
889 |
// Integer integer = new Integer(getCalculatedIndex(rowIndex));
|
|
876 | 890 |
|
891 |
|
|
877 | 892 |
try { |
878 |
if (!relations.containsKey(integer)) { |
|
879 |
return ods.getFieldValue(rowIndex, fieldId); |
|
880 |
} else { |
|
881 |
int num = ((Integer) relations.get(integer)).intValue(); |
|
882 |
DefaultRowEdited feat = (DefaultRowEdited) expansionFile |
|
883 |
.getRow(num); |
|
884 |
|
|
885 |
if (feat == null) { |
|
886 |
return null; |
|
887 |
} |
|
888 |
|
|
889 |
return feat.getAttribute(fieldId); |
|
890 |
} |
|
891 |
} catch (DriverException e) { |
|
893 |
IRow row = getRow((int)rowIndex); |
|
894 |
return row.getAttribute(fieldId); |
|
895 |
// if (!relations.containsKey(integer)) { |
|
896 |
// return ods.getFieldValue(rowIndex, fieldId); |
|
897 |
// } else { |
|
898 |
// int num = ((Integer) relations.get(integer)).intValue(); |
|
899 |
// DefaultRowEdited feat = (DefaultRowEdited) expansionFile |
|
900 |
// .getRow(num); |
|
901 |
// |
|
902 |
// if (feat == null) { |
|
903 |
// return null; |
|
904 |
// } |
|
905 |
// |
|
906 |
// return feat.getAttribute(fieldId); |
|
907 |
// } |
|
908 |
// } catch (DriverException e) { |
|
909 |
// e.printStackTrace(); |
|
910 |
// throw new DriverException(e); |
|
911 |
} catch (IOException e) { |
|
892 | 912 |
e.printStackTrace(); |
893 | 913 |
throw new DriverException(e); |
894 |
} catch (IOException e) { |
|
914 |
} catch (DriverIOException e) {
|
|
895 | 915 |
e.printStackTrace(); |
896 | 916 |
throw new DriverException(e); |
897 | 917 |
} |
... | ... | |
916 | 936 |
* @see com.hardcode.gdbms.engine.data.driver.ReadAccess#getFieldCount() |
917 | 937 |
*/ |
918 | 938 |
public int getFieldCount() throws DriverException { |
919 |
// TODO Por ahora, no dejamos que se a?adan campos |
|
920 |
return ods.getFieldCount(); |
|
939 |
return actualFields.size(); |
|
921 | 940 |
} |
922 | 941 |
|
923 | 942 |
/* |
... | ... | |
926 | 945 |
* @see com.hardcode.gdbms.engine.data.driver.ReadAccess#getFieldName(int) |
927 | 946 |
*/ |
928 | 947 |
public String getFieldName(int fieldId) throws DriverException { |
929 |
return ods.getFieldName(fieldId); |
|
948 |
|
|
949 |
for (Iterator iter = actualFields.values().iterator(); iter.hasNext();) { |
|
950 |
InternalField fld = (InternalField) iter.next(); |
|
951 |
if (fld.getFieldIndex() == fieldId) |
|
952 |
return fld.getFieldDesc().getFieldAlias(); |
|
953 |
|
|
954 |
} |
|
955 |
throw new DriverException("FieldId " + fieldId + " not found "); |
|
956 |
// return null; |
|
957 |
// return ods.getFieldName(fieldId); |
|
930 | 958 |
} |
931 | 959 |
|
932 | 960 |
/* |
... | ... | |
953 | 981 |
* @see com.hardcode.gdbms.engine.data.driver.ReadAccess#getFieldType(int) |
954 | 982 |
*/ |
955 | 983 |
public int getFieldType(int i) throws DriverException { |
984 |
for (Iterator iter = actualFields.values().iterator(); iter.hasNext();) { |
|
985 |
InternalField fld = (InternalField) iter.next(); |
|
986 |
if (fld.getFieldIndex() == i) |
|
987 |
return fld.getFieldDesc().getFieldType(); |
|
988 |
|
|
989 |
} |
|
990 |
|
|
956 | 991 |
return ods.getFieldType(i); |
957 | 992 |
} |
958 | 993 |
|
959 | 994 |
public int getFieldWidth(int i) throws DriverException { |
995 |
for (Iterator iter = actualFields.values().iterator(); iter.hasNext();) { |
|
996 |
InternalField fld = (InternalField) iter.next(); |
|
997 |
if (fld.getFieldIndex() == i) |
|
998 |
return fld.getFieldDesc().getFieldLength(); |
|
999 |
|
|
1000 |
} |
|
1001 |
|
|
960 | 1002 |
return ods.getFieldWidth(i); |
961 | 1003 |
} |
962 | 1004 |
} |
... | ... | |
1176 | 1218 |
public void removeField(String fieldName) throws EditionException { |
1177 | 1219 |
|
1178 | 1220 |
InternalField fld = findFieldByName(fieldName); |
1221 |
if (fld == null) |
|
1222 |
throw new EditionException("Field " + fieldName + " not found when removing field"); |
|
1179 | 1223 |
Command command = new RemoveFieldCommand(this, fld); |
1180 | 1224 |
if (complex) { |
1181 | 1225 |
commands.add(command); |
... | ... | |
1198 | 1242 |
return null; |
1199 | 1243 |
} |
1200 | 1244 |
|
1201 |
public void undoRemoveField(InternalField field) { |
|
1245 |
public void undoRemoveField(InternalField field) throws EditionException {
|
|
1202 | 1246 |
field.setDeleted(false); |
1203 | 1247 |
field.setFieldIndex(actualFields.size()); |
1204 | 1248 |
actualFields.put(field.getFieldId(), field); |
1205 | 1249 |
fieldsChanged(); |
1206 | 1250 |
} |
1207 | 1251 |
|
1208 |
public void doRemoveField(InternalField field) { |
|
1252 |
public void doRemoveField(InternalField field) throws EditionException {
|
|
1209 | 1253 |
field.setDeleted(true); |
1210 | 1254 |
actualFields.remove(field.getFieldId()); |
1211 | 1255 |
fieldsChanged(); |
... | ... | |
1247 | 1291 |
|
1248 | 1292 |
} |
1249 | 1293 |
|
1250 |
public void undoAddField(InternalField field) { |
|
1294 |
public void undoAddField(InternalField field) throws EditionException {
|
|
1251 | 1295 |
field.setDeleted(true); |
1252 | 1296 |
|
1253 | 1297 |
actualFields.remove(field.getFieldId()); |
... | ... | |
1255 | 1299 |
|
1256 | 1300 |
} |
1257 | 1301 |
|
1258 |
public void doAddField(InternalField field) { |
|
1302 |
public void doAddField(InternalField field) throws EditionException {
|
|
1259 | 1303 |
field.setDeleted(false); |
1260 | 1304 |
field.setFieldIndex(actualFields.size()); |
1261 | 1305 |
actualFields.put(field.getFieldId(), field); |
Also available in: Unified diff