Revision 42814
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.file/org.gvsig.fmap.dal.file.shp/src/main/java/org/gvsig/fmap/dal/store/shp/SHPStoreProvider.java | ||
---|---|---|
140 | 140 |
|
141 | 141 |
resource.frozen(); |
142 | 142 |
resource.addMultiResourceConsumer(this); |
143 |
super.initResource(resource, storeServices); |
|
143 | 144 |
} |
144 | 145 |
|
145 | 146 |
; |
... | ... | |
274 | 275 |
} |
275 | 276 |
|
276 | 277 |
public String getProviderName() { |
277 |
return NAME;
|
|
278 |
return NAME; |
|
278 | 279 |
} |
279 | 280 |
|
280 | 281 |
public boolean allowWrite() { |
281 |
return this.shpFile.isEditable(); |
|
282 |
return this.shpFile.isEditable() && |
|
283 |
super.allowWrite() && |
|
284 |
!this.getShpParameters().getLoadCorruptGeometriesAsNull() && |
|
285 |
!this.getShpParameters().getAllowInconsistenciesInGeometryType() && |
|
286 |
!this.getShpParameters().getFixLinearRings(); |
|
282 | 287 |
} |
283 | 288 |
|
284 | 289 |
/** |
... | ... | |
350 | 355 |
} |
351 | 356 |
|
352 | 357 |
} |
353 |
|
|
358 |
|
|
354 | 359 |
public class ReadGeometryException extends ReadException { |
355 | 360 |
|
356 |
private final static String MESSAGE_FORMAT = "There was errors loading a geometry from '%(store)'.\nCheck 'Load corrupt geometries as null' in the shape's properties of the add layer dialog to skip corrupt geometries."; |
|
361 |
private final static String MESSAGE_FORMAT = "There was errors loading a geometry from '%(store)'.\nCheck 'Load corrupt geometries as null' in the shape's properties of the add layer dialog to skip corrupt geometries. The layer will become read only.";
|
|
357 | 362 |
private final static String MESSAGE_KEY = "_ReadGeometryException"; |
358 | 363 |
private static final long serialVersionUID = 2626155328734197112L; |
359 | 364 |
|
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.file/org.gvsig.fmap.dal.file.shp/src/main/resources/org/gvsig/fmap/dal/store/shp/SHPParameters.xml | ||
---|---|---|
55 | 55 |
<description>The shx file associated to this shape file |
56 | 56 |
</description> |
57 | 57 |
</field> |
58 |
|
|
58 |
|
|
59 | 59 |
<field order="200" name="useNullGeometry" label="Use NullGeometry instead of null" type="boolean" group="Advanced" hidden="true" mandatory="false" defaultValue="false"> |
60 | 60 |
<description>If set, use NullGeometry object instead a null value</description> |
61 | 61 |
</field> |
62 | 62 |
<field order="210" name="allowInconsistenciesInGeometryType" label="Allow inconsistencies in geometry type" type="boolean" mandatory="false" group="Advanced" defaultValue="false"> |
63 |
<description>If set, attempts to load the geometry but does not match the type of shape file.</description> |
|
63 |
<description>If set, attempts to load the geometry but does not match the type of shape file. The layer will be read only.</description>
|
|
64 | 64 |
</field> |
65 | 65 |
<field order="220" name="loadCorruptGeometriesAsNull" label="Load corrupt geometries as null" type="boolean" mandatory="false" group="Advanced" defaultValue="false"> |
66 |
<description>If set, load geometries that have inconsistencies as null and not fails.</description> |
|
66 |
<description>If set, load geometries that have inconsistencies as null and not fails. The layer will be read only.</description>
|
|
67 | 67 |
</field> |
68 | 68 |
<field order="230" name="fixLinearRings" label="Fix LinearRings" type="boolean" mandatory="false" group="Advanced" defaultValue="false"> |
69 |
<description>If set, fix LinearRings to minimum four vertices duplicating last vertex.</description> |
|
69 |
<description>If set, fix LinearRings to minimum four vertices duplicating last vertex. The layer will be read only.</description>
|
|
70 | 70 |
</field> |
71 | 71 |
</fields> |
72 | 72 |
</class> |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.file/org.gvsig.fmap.dal.file.dbf/src/main/java/org/gvsig/fmap/dal/store/dbf/DBFStoreParameters.java | ||
---|---|---|
45 | 45 |
OpenDataStoreParameters, FilesystemStoreParameters { |
46 | 46 |
|
47 | 47 |
private static final Logger logger = LoggerFactory.getLogger(DBFStoreParameters.class); |
48 |
|
|
48 |
|
|
49 | 49 |
public static final String PARAMETERS_DEFINITION_NAME = "DBFStoreParameters"; |
50 | 50 |
|
51 | 51 |
public static final String DBFFILE_PARAMTER_NAME = "dbfFile"; |
... | ... | |
53 | 53 |
public static final String HANDLE_DATES_AS_STRINGS = "handleDatesAsStrings"; |
54 | 54 |
public static final String DATE_FORMAT = "dateFormat"; |
55 | 55 |
public static final String LOCALE = "locale"; |
56 |
public static final String ALLOW_DUPLICATED_FIELD_NAMES = "allowDuplicatedFieldNames"; |
|
56 | 57 |
|
57 | 58 |
private DelegatedDynObject parameters; |
58 | 59 |
|
... | ... | |
123 | 124 |
} |
124 | 125 |
return s.trim(); |
125 | 126 |
} |
126 |
|
|
127 |
|
|
127 | 128 |
public Charset getEncoding() { |
128 | 129 |
String name = getEncodingName(); |
129 | 130 |
if( StringUtils.isBlank(name) ) { |
... | ... | |
134 | 135 |
|
135 | 136 |
public void setEncoding(String encoding) { |
136 | 137 |
this.setEncoding(Charset.forName(encoding)); |
137 |
}
|
|
138 |
}
|
|
138 | 139 |
|
139 |
public boolean handleDatesAsStrings() { |
|
140 |
Boolean x = (Boolean) getDynValue(HANDLE_DATES_AS_STRINGS); |
|
141 |
return BooleanUtils.isTrue(x); |
|
142 |
} |
|
143 |
|
|
144 |
public void setEncoding(Charset charset) { |
|
145 |
this.setDynValue(ENCODING_PARAMTER_NAME, charset.name()); |
|
140 |
public boolean handleDatesAsStrings() { |
|
141 |
Boolean x = (Boolean) getDynValue(HANDLE_DATES_AS_STRINGS); |
|
142 |
return BooleanUtils.isTrue(x); |
|
143 |
} |
|
144 |
|
|
145 |
public boolean allowDuplicatedFieldNames() { |
|
146 |
Boolean x = (Boolean) getDynValue(ALLOW_DUPLICATED_FIELD_NAMES); |
|
147 |
return BooleanUtils.isTrue(x); |
|
148 |
} |
|
149 |
|
|
150 |
public void setEncoding(Charset charset) { |
|
151 |
this.setDynValue(ENCODING_PARAMTER_NAME, charset.name()); |
|
146 | 152 |
} |
147 | 153 |
|
148 | 154 |
protected DelegatedDynObject getDelegatedDynObject() { |
149 | 155 |
return parameters; |
150 | 156 |
} |
151 |
|
|
157 |
|
|
152 | 158 |
public Locale getLocale() { |
153 | 159 |
try { |
154 | 160 |
String s = (String) this.getDynValue(LOCALE); |
... | ... | |
195 | 201 |
} |
196 | 202 |
} |
197 | 203 |
} |
198 |
|
|
204 |
|
|
199 | 205 |
private static class InvalidDateFormatException extends ValidateDataParametersException { |
200 |
|
|
206 |
|
|
201 | 207 |
public InvalidDateFormatException(String sfmt, Throwable cause) { |
202 | 208 |
super( |
203 | 209 |
"Date format specified '%(dataformat)' is not valid.", |
... | ... | |
206 | 212 |
0 |
207 | 213 |
); |
208 | 214 |
setValue("dataformat",sfmt); |
209 |
|
|
215 |
|
|
210 | 216 |
} |
211 | 217 |
} |
212 |
|
|
218 |
|
|
213 | 219 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.file/org.gvsig.fmap.dal.file.dbf/src/main/java/org/gvsig/fmap/dal/store/dbf/utils/DbaseFileHeader.java | ||
---|---|---|
86 | 86 |
private DbaseFieldDescriptor[] myFieldDescriptions; |
87 | 87 |
|
88 | 88 |
private byte myLanguageID; |
89 |
|
|
89 |
|
|
90 | 90 |
private List<String> encodingSupportedByString = null; |
91 | 91 |
|
92 | 92 |
/** |
... | ... | |
94 | 94 |
*/ |
95 | 95 |
public DbaseFileHeader() { |
96 | 96 |
super(); |
97 |
|
|
97 |
|
|
98 | 98 |
encodingSupportedByString = new ArrayList<String>(); |
99 | 99 |
SortedMap<String, Charset> m = Charset.availableCharsets(); |
100 | 100 |
Set<String> k = m.keySet(); |
... | ... | |
398 | 398 |
* @throws UnsupportedEncodingException |
399 | 399 |
|
400 | 400 |
*/ |
401 |
public void readHeader(BigByteBuffer2 in, String charsName) |
|
401 |
public void readHeader(BigByteBuffer2 in, String charsName, boolean allowDuplicatedFieldNames)
|
|
402 | 402 |
throws UnsupportedVersionException, UnsupportedEncodingException { |
403 | 403 |
// type of file. |
404 | 404 |
myFileType = in.get(); |
... | ... | |
453 | 453 |
myFieldDescriptions = new DbaseFieldDescriptor[myNumFields]; |
454 | 454 |
int fieldOffset = 0; |
455 | 455 |
|
456 |
List fieldNames = new ArrayList<String>(); |
|
457 |
|
|
456 | 458 |
for (int i = 0; i < myNumFields; i++) { |
457 | 459 |
myFieldDescriptions[i] = new DbaseFieldDescriptor(); |
458 | 460 |
|
459 | 461 |
// read the field name |
460 | 462 |
byte[] buffer = new byte[11]; |
461 | 463 |
in.get(buffer); |
464 |
String fieldName; |
|
462 | 465 |
if (charsName != null) { |
463 |
myFieldDescriptions[i].myFieldName = new String(buffer,
|
|
466 |
fieldName = new String(buffer,
|
|
464 | 467 |
charsName); |
465 | 468 |
} else { |
466 |
myFieldDescriptions[i].myFieldName = new String(buffer);
|
|
469 |
fieldName = new String(buffer);
|
|
467 | 470 |
} |
471 |
|
|
472 |
if(allowDuplicatedFieldNames){ |
|
473 |
fieldName = getUniqueFieldName(fieldName, fieldNames); |
|
474 |
} |
|
475 |
fieldNames.add(fieldName); |
|
476 |
|
|
477 |
myFieldDescriptions[i].myFieldName = fieldName; |
|
478 |
|
|
468 | 479 |
myFieldDescriptions[i].myFieldName_trim = myFieldDescriptions[i].myFieldName |
469 | 480 |
.trim(); |
470 | 481 |
|
... | ... | |
494 | 505 |
// Fin NUEVO |
495 | 506 |
// read the reserved bytes. |
496 | 507 |
in.position(in.position() + 14); |
508 |
|
|
497 | 509 |
} |
498 | 510 |
|
499 | 511 |
// Last byte is a marker for the end of the field definitions. |
... | ... | |
775 | 787 |
return "ISO-8859-1"; |
776 | 788 |
} |
777 | 789 |
} |
778 |
|
|
790 |
|
|
779 | 791 |
public String mappingEncoding(String dbfEnconding) { |
780 | 792 |
if(encodingSupportedByString.contains(dbfEnconding)) |
781 | 793 |
return dbfEnconding; |
... | ... | |
783 | 795 |
return "UTF-8"; |
784 | 796 |
} |
785 | 797 |
|
798 |
private String getUniqueFieldName(String fieldName, List fieldNames) { |
|
799 |
|
|
800 |
int index = 0; |
|
801 |
String tempFieldName = fieldName; |
|
802 |
while(fieldNames.contains(tempFieldName) && index<1000){ |
|
803 |
index++; |
|
804 |
String sufix = String.valueOf(index); |
|
805 |
tempFieldName = tempFieldName.substring(0, DbaseFile.MAX_FIELD_NAME_LENGTH-sufix.length())+sufix; |
|
806 |
} |
|
807 |
if(index>=1000){ |
|
808 |
throw new RuntimeException("Can't fix duplicated name for field '"+fieldName+"'."); |
|
809 |
} |
|
810 |
return tempFieldName; |
|
811 |
} |
|
786 | 812 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.file/org.gvsig.fmap.dal.file.dbf/src/main/java/org/gvsig/fmap/dal/store/dbf/utils/DbaseFile.java | ||
---|---|---|
40 | 40 |
import org.gvsig.fmap.dal.exception.UnsupportedEncodingException; |
41 | 41 |
import org.gvsig.fmap.dal.exception.UnsupportedVersionException; |
42 | 42 |
import org.gvsig.fmap.dal.exception.WriteException; |
43 |
import org.gvsig.fmap.dal.feature.EditableFeatureType; |
|
43 | 44 |
import org.gvsig.utils.bigfile.BigByteBuffer2; |
45 |
|
|
46 |
import org.exolab.castor.util.List; |
|
44 | 47 |
import org.slf4j.Logger; |
45 | 48 |
import org.slf4j.LoggerFactory; |
46 | 49 |
|
... | ... | |
52 | 55 |
public class DbaseFile { |
53 | 56 |
|
54 | 57 |
private static final Logger logger = LoggerFactory.getLogger(DbaseFile.class); |
55 |
|
|
58 |
|
|
56 | 59 |
public static final int MAX_FIELD_NAME_LENGTH = 10; |
57 |
|
|
60 |
|
|
58 | 61 |
// Header information for the DBase File |
59 | 62 |
private DbaseFileHeader myHeader; |
60 | 63 |
|
... | ... | |
89 | 92 |
|
90 | 93 |
private boolean isOpen = false; |
91 | 94 |
|
95 |
private boolean allowDuplicatedFieldNames; |
|
92 | 96 |
|
97 |
|
|
93 | 98 |
/** Utility for formatting Dbase fields. */ |
94 | 99 |
public static class FieldFormatter { |
95 | 100 |
private StringBuffer buffer = new StringBuffer(255); |
... | ... | |
196 | 201 |
} |
197 | 202 |
} |
198 | 203 |
|
199 |
public DbaseFile(File afile){
|
|
200 |
this(afile, null);
|
|
201 |
}
|
|
204 |
public DbaseFile(File afile) {
|
|
205 |
this(afile, null);
|
|
206 |
}
|
|
202 | 207 |
|
203 |
public DbaseFile(File afile, Charset chars) { |
|
204 |
this.file = afile; |
|
205 |
this.chars = chars; |
|
206 |
} |
|
208 |
public DbaseFile(File afile, Charset chars) { |
|
209 |
this(afile, null, false); |
|
210 |
} |
|
207 | 211 |
|
212 |
public DbaseFile(File afile, Charset chars, boolean allowDuplicatedFieldNames) { |
|
213 |
this.file = afile; |
|
214 |
this.chars = chars; |
|
215 |
this.allowDuplicatedFieldNames = allowDuplicatedFieldNames; |
|
216 |
} |
|
217 |
|
|
208 | 218 |
public byte getCodePage() { |
209 | 219 |
return myHeader.getLanguageID(); |
210 | 220 |
} |
... | ... | |
438 | 448 |
// create the header to contain the header information. |
439 | 449 |
myHeader = new DbaseFileHeader(); |
440 | 450 |
if (chars == null) { |
441 |
myHeader.readHeader(buffer, null); |
|
451 |
myHeader.readHeader(buffer, null, allowDuplicatedFieldNames);
|
|
442 | 452 |
} else { |
443 |
myHeader.readHeader(buffer, chars.name()); |
|
453 |
myHeader.readHeader(buffer, chars.name(), allowDuplicatedFieldNames);
|
|
444 | 454 |
} |
445 | 455 |
charsOriginal = Charset.forName(myHeader.mappingEncoding(myHeader.getCharsetName())); |
446 | 456 |
if (chars == null) { |
... | ... | |
545 | 555 |
this.chars = chars; |
546 | 556 |
} |
547 | 557 |
|
558 |
public boolean isWritable(){ |
|
559 |
return this.file.canWrite(); |
|
560 |
} |
|
561 |
|
|
548 | 562 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.file/org.gvsig.fmap.dal.file.dbf/src/main/java/org/gvsig/fmap/dal/store/dbf/DBFStoreProvider.java | ||
---|---|---|
26 | 26 |
import java.io.IOException; |
27 | 27 |
import java.nio.charset.Charset; |
28 | 28 |
import java.text.DateFormat; |
29 |
import java.text.MessageFormat; |
|
29 | 30 |
import java.text.ParseException; |
30 | 31 |
import java.text.SimpleDateFormat; |
31 | 32 |
import java.util.ArrayList; |
... | ... | |
36 | 37 |
|
37 | 38 |
import org.apache.commons.io.FileUtils; |
38 | 39 |
import org.apache.commons.lang3.StringUtils; |
40 |
|
|
39 | 41 |
import org.gvsig.fmap.dal.DALLocator; |
40 | 42 |
import org.gvsig.fmap.dal.DataManager; |
41 | 43 |
import org.gvsig.fmap.dal.DataServerExplorer; |
... | ... | |
87 | 89 |
import org.gvsig.tools.dynobject.DynObject; |
88 | 90 |
import org.gvsig.tools.dynobject.exception.DynFieldNotFoundException; |
89 | 91 |
import org.gvsig.tools.exception.BaseException; |
92 |
|
|
90 | 93 |
import org.slf4j.Logger; |
91 | 94 |
import org.slf4j.LoggerFactory; |
92 | 95 |
|
... | ... | |
114 | 117 |
|
115 | 118 |
private boolean loTengoEnUso; |
116 | 119 |
|
120 |
private boolean allowDuplicatedFieldNames; |
|
121 |
|
|
117 | 122 |
protected static void registerMetadataDefinition() throws MetadataException { |
118 | 123 |
MetadataManager manager = MetadataLocator.getMetadataManager(); |
119 | 124 |
if (manager.getDefinition(METADATA_DEFINITION_NAME) == null) { |
... | ... | |
155 | 160 |
initResource(params, storeServices); |
156 | 161 |
|
157 | 162 |
Charset charset = params.getEncoding(); |
158 |
this.dbfFile = new DbaseFile(theFile, charset); |
|
163 |
allowDuplicatedFieldNames = params.allowDuplicatedFieldNames(); |
|
164 |
this.dbfFile = new DbaseFile(theFile, charset, allowDuplicatedFieldNames); |
|
159 | 165 |
|
160 | 166 |
writer = new DBFFeatureWriter(this.getProviderName()); |
161 | 167 |
|
... | ... | |
188 | 194 |
dbfResource.addConsumer(this); |
189 | 195 |
} |
190 | 196 |
|
197 |
protected void initResource(ResourceProvider resource, |
|
198 |
DataStoreProviderServices storeServices){ |
|
199 |
dbfResource = resource; |
|
200 |
dbfResource.addConsumer(this); |
|
201 |
} |
|
202 |
|
|
191 | 203 |
public String getProviderName() { |
192 | 204 |
return NAME; |
193 | 205 |
} |
... | ... | |
375 | 387 |
} |
376 | 388 |
} |
377 | 389 |
|
390 |
public class DuplicatedFieldNameException extends ReadException { |
|
391 |
|
|
392 |
/** |
|
393 |
* |
|
394 |
*/ |
|
395 |
private static final long serialVersionUID = -1671651605329756160L; |
|
396 |
private final static String MESSAGE_FORMAT = "Duplicated field name '%(fieldName)'.\nCheck 'Allow duplicated field names' in layer properties in add layer dialog. The layer will become read only."; |
|
397 |
private final static String MESSAGE_KEY = "_DuplicatedFieldNameException"; |
|
398 |
|
|
399 |
public DuplicatedFieldNameException(String fieldName) { |
|
400 |
super(MESSAGE_FORMAT, null, MESSAGE_KEY, serialVersionUID); |
|
401 |
setValue("fieldName", fieldName); |
|
402 |
} |
|
403 |
} |
|
404 |
|
|
405 |
// |
|
406 |
// private String getUniqueFieldName(String fieldName, EditableFeatureType fType) { |
|
407 |
// |
|
408 |
// int index = 1; |
|
409 |
// String tempFieldName = fieldName; |
|
410 |
// while(fType.get(tempFieldName)!=null && index<1000){ |
|
411 |
// index++; |
|
412 |
// String sufix = String.valueOf(index); |
|
413 |
// tempFieldName = tempFieldName.substring(0, DbaseFile.MAX_FIELD_NAME_LENGTH-sufix.length())+sufix; |
|
414 |
// } |
|
415 |
// if(index>=1000){ |
|
416 |
// throw new RuntimeException("Can't fix duplicated name for field '"+fieldName+"'."); |
|
417 |
// } |
|
418 |
// return tempFieldName; |
|
419 |
// } |
|
420 |
|
|
378 | 421 |
protected EditableFeatureType getTheFeatureType() |
379 | 422 |
throws InitializeException, OpenException { |
380 | 423 |
try { |
... | ... | |
397 | 440 |
char fieldType = dbfFile.getFieldType(i); |
398 | 441 |
EditableFeatureAttributeDescriptor attr; |
399 | 442 |
|
443 |
String fieldName = dbfFile.getFieldName(i); |
|
444 |
if(fType.get(fieldName)!=null){ |
|
445 |
throw new DuplicatedFieldNameException(fieldName); |
|
446 |
} |
|
447 |
|
|
400 | 448 |
if (fieldType == 'L') { |
401 |
attr = fType.add(dbfFile.getFieldName(i), DataTypes.BOOLEAN);
|
|
449 |
attr = fType.add(fieldName, DataTypes.BOOLEAN);
|
|
402 | 450 |
attr.setDefaultValue(new Boolean(false)); |
403 | 451 |
attr.setAllowNull(false); |
404 | 452 |
|
405 | 453 |
} else if ((fieldType == 'F') || (fieldType == 'N')) { |
406 | 454 |
precision = dbfFile.getFieldDecimalLength(i); |
407 | 455 |
if (precision > 0) { |
408 |
attr = fType.add(dbfFile.getFieldName(i),
|
|
456 |
attr = fType.add(fieldName,
|
|
409 | 457 |
DataTypes.DOUBLE, |
410 | 458 |
dbfFile.getFieldLength(i)); |
411 | 459 |
attr.setPrecision(precision); |
... | ... | |
417 | 465 |
if (length > 9) { |
418 | 466 |
type = DataTypes.LONG; |
419 | 467 |
} |
420 |
attr = fType.add(dbfFile.getFieldName(i),
|
|
468 |
attr = fType.add(fieldName,
|
|
421 | 469 |
type, |
422 | 470 |
length); |
423 | 471 |
attr.setDefaultValue(new Integer(0)); |
... | ... | |
425 | 473 |
attr.setAllowNull(false); |
426 | 474 |
|
427 | 475 |
} else if (fieldType == 'C' || getDBFParameters().handleDatesAsStrings()) { |
428 |
attr = fType.add(dbfFile.getFieldName(i), DataTypes.STRING);
|
|
476 |
attr = fType.add(fieldName, DataTypes.STRING);
|
|
429 | 477 |
attr.setSize(dbfFile.getFieldLength(i)); |
430 | 478 |
attr.setDefaultValue(""); |
431 | 479 |
attr.setAllowNull(false); |
432 | 480 |
|
433 | 481 |
} else if (fieldType == 'D') { |
434 |
attr = fType.add(dbfFile.getFieldName(i), DataTypes.DATE);
|
|
482 |
attr = fType.add(fieldName, DataTypes.DATE);
|
|
435 | 483 |
attr.setDefaultValue(new Date(0)); // def value 1-1-1970 |
436 | 484 |
attr.setAllowNull(true); |
437 | 485 |
String sfmt = getDBFParameters().getDateFormat(); |
... | ... | |
446 | 494 |
} else { |
447 | 495 |
throw new InitializeException(getProviderName(), |
448 | 496 |
new UnknownDataTypeException( |
449 |
dbfFile.getFieldName(i), ""
|
|
497 |
fieldName, ""
|
|
450 | 498 |
+ fieldType, getProviderName())); |
451 | 499 |
} |
452 | 500 |
} |
... | ... | |
455 | 503 |
// rules.add(new DBFRowValidator()); |
456 | 504 |
return fType; |
457 | 505 |
} |
506 |
|
|
458 | 507 |
} |
459 | 508 |
); |
460 | 509 |
} |
... | ... | |
693 | 742 |
} |
694 | 743 |
|
695 | 744 |
public boolean allowWrite() { |
696 |
File file; |
|
697 |
try { |
|
698 |
file = ((File) this.dbfResource.get()); |
|
699 |
} catch (AccessResourceException e) { |
|
745 |
if(allowDuplicatedFieldNames){ |
|
700 | 746 |
return false; |
701 | 747 |
} |
702 |
return file.canWrite();
|
|
748 |
return this.dbfFile.isWritable();
|
|
703 | 749 |
} |
704 | 750 |
|
705 | 751 |
public void refresh() throws OpenException { |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.file/org.gvsig.fmap.dal.file.dbf/src/main/resources/org/gvsig/fmap/dal/store/dbf/DBFParameters.xml | ||
---|---|---|
54 | 54 |
<value label="UTF-16LE">UTF-16LE</value> |
55 | 55 |
</availableValues> |
56 | 56 |
</field> |
57 |
|
|
58 |
|
|
57 |
|
|
58 |
|
|
59 | 59 |
<field order="10" name="locale" type="string" mandatory="true" defaultValue="DEFAULT" group="Advanced"> |
60 | 60 |
<description>Locale used to parse dates (BCP47 language tag representing the locale)</description> |
61 | 61 |
<availableValues> |
... | ... | |
72 | 72 |
<value label="Spain">es</value> |
73 | 73 |
<value label="Uk">en-GB</value> |
74 | 74 |
<value label="Us">en-US</value> |
75 |
</availableValues>
|
|
76 |
</field>
|
|
75 |
</availableValues> |
|
76 |
</field> |
|
77 | 77 |
<field order="30" name="dateFormat" label="Date format" type="string" mandatory="false" defaultValue="" group="Advanced"> |
78 | 78 |
<description>Date format used to parse fields of type date.</description> |
79 |
</field>
|
|
79 |
</field> |
|
80 | 80 |
<field order="100" name="handleDatesAsStrings" label="Handle dates as strings" type="boolean" mandatory="false" defaultValue="false" group="Advanced"> |
81 | 81 |
<description>If set handle fields of date types as strings.</description> |
82 | 82 |
</field> |
83 |
<field order="105" name="allowDuplicatedFieldNames" label="Allow duplicated field names" type="boolean" mandatory="false" defaultValue="false" group="Advanced"> |
|
84 |
<description>If set allow duplicated field names. The layer will be read only.</description> |
|
85 |
</field> |
|
83 | 86 |
</fields> |
84 | 87 |
</class> |
85 | 88 |
|
... | ... | |
90 | 93 |
<class namespace="dal" name="NewProviderParameters"/> |
91 | 94 |
</extends> |
92 | 95 |
<fields> |
93 |
<field order="20" name="codePage" type="Integer" mandatory="false" group="Advanced">
|
|
96 |
<field order="20" name="codePage" type="Integer" mandatory="false" group="Advanced"> |
|
94 | 97 |
<description>Code page used in this file</description> |
95 | 98 |
<availableValues> |
96 | 99 |
<value label="DOS USA">0x01</value> |
... | ... | |
112 | 115 |
<value label="Russian Windows">0xC9</value> |
113 | 116 |
<value label="Turkish Windows">0xCA</value> |
114 | 117 |
<value label="Greek Windows">0xCB</value> |
115 |
</availableValues>
|
|
118 |
</availableValues> |
|
116 | 119 |
</field> |
117 | 120 |
</fields> |
118 | 121 |
</class> |
119 | 122 |
|
120 | 123 |
</classes> |
121 |
</definitions> |
|
124 |
</definitions> |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/gui/WizardPanel.java | ||
---|---|---|
23 | 23 |
package org.gvsig.app.gui; |
24 | 24 |
|
25 | 25 |
import java.awt.Window; |
26 |
|
|
26 | 27 |
import javax.swing.JOptionPane; |
27 |
|
|
28 | 28 |
import javax.swing.JPanel; |
29 | 29 |
|
30 | 30 |
import org.cresques.cts.IProjection; |
31 |
|
|
31 | 32 |
import org.gvsig.app.ApplicationLocator; |
32 | 33 |
import org.gvsig.app.ApplicationManager; |
33 | 34 |
import org.gvsig.app.gui.wizards.WizardListener; |
34 | 35 |
import org.gvsig.app.gui.wizards.WizardListenerSupport; |
35 | 36 |
import org.gvsig.app.prepareAction.PrepareContextView_v1; |
37 |
import org.gvsig.app.project.documents.view.toc.actions.LayerErrorsPanel; |
|
36 | 38 |
import org.gvsig.fmap.dal.DALLocator; |
37 | 39 |
import org.gvsig.fmap.dal.DataManager; |
38 | 40 |
import org.gvsig.fmap.dal.DataStore; |
... | ... | |
49 | 51 |
import org.gvsig.tools.dispose.DisposeUtils; |
50 | 52 |
import org.gvsig.tools.i18n.I18nManager; |
51 | 53 |
import org.gvsig.tools.identitymanagement.UnauthorizedException; |
54 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
|
55 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager; |
|
56 |
|
|
52 | 57 |
import org.slf4j.Logger; |
53 | 58 |
import org.slf4j.LoggerFactory; |
54 | 59 |
|
... | ... | |
266 | 271 |
logger.warn("Unauthorized access to layer '" + layerName + "'.", e); |
267 | 272 |
|
268 | 273 |
} catch (Exception e) { |
274 |
LayerErrorsPanel panel = new LayerErrorsPanel(layerName, e); |
|
269 | 275 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
270 |
ApplicationManager application = ApplicationLocator.getManager(); |
|
271 |
application.messageDialog( |
|
272 |
i18nManager.getTranslation("_Cant_load_the_layer") + " (" + layerName + ")", |
|
273 |
i18nManager.getTranslation("_Probems_loading_the_layer"), |
|
274 |
JOptionPane.WARNING_MESSAGE |
|
276 |
ToolsSwingLocator.getWindowManager().showWindow( |
|
277 |
panel, |
|
278 |
i18nManager.getTranslation("_Problems_loading_the_layer"), |
|
279 |
WindowManager.MODE.WINDOW |
|
275 | 280 |
); |
276 | 281 |
logger.warn("Can't load layer '" + layerName + "'.", e); |
277 | 282 |
|
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/project/documents/view/toc/actions/LayerErrorsPanel.java | ||
---|---|---|
3 | 3 |
import java.awt.Dimension; |
4 | 4 |
import java.awt.event.ActionEvent; |
5 | 5 |
import java.awt.event.ActionListener; |
6 |
import java.util.ArrayList; |
|
6 | 7 |
import java.util.List; |
8 |
|
|
7 | 9 |
import org.apache.commons.lang3.exception.ExceptionUtils; |
10 |
|
|
8 | 11 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
9 | 12 |
import org.gvsig.fmap.mapcontext.layers.operations.SingleLayer; |
10 | 13 |
import org.gvsig.fmap.mapcontrol.swing.dynobject.DynObjectEditor; |
11 | 14 |
import org.gvsig.tools.ToolsLocator; |
12 | 15 |
import org.gvsig.tools.i18n.I18nManager; |
16 |
|
|
13 | 17 |
import org.slf4j.Logger; |
14 | 18 |
import org.slf4j.LoggerFactory; |
15 | 19 |
|
... | ... | |
24 | 28 |
this.setLayer(layer); |
25 | 29 |
} |
26 | 30 |
|
31 |
public LayerErrorsPanel(String name, Exception ex) { |
|
32 |
this.initComponents(); |
|
33 |
this.setName(name); |
|
34 |
this.setError(ex); |
|
35 |
} |
|
36 |
|
|
27 | 37 |
private void initComponents() { |
28 | 38 |
this.translate(); |
29 | 39 |
this.txtMessage.setContentType("text/html"); |
... | ... | |
44 | 54 |
this.setPreferredSize(new Dimension(550, 400)); |
45 | 55 |
} |
46 | 56 |
|
57 |
public void setName(String name){ |
|
58 |
this.txtLayerName.setText(name); |
|
59 |
} |
|
60 |
|
|
61 |
public void setError(Exception e){ |
|
62 |
List<Exception> exs = new ArrayList<Exception>(); |
|
63 |
exs.add(e); |
|
64 |
this.txtMessage.setText(this.getMessageAsHTML(exs)); |
|
65 |
this.btnViewParameters.setEnabled(false); |
|
66 |
} |
|
67 |
|
|
47 | 68 |
public void setLayer(FLayer layer) { |
48 | 69 |
this.layer = layer; |
49 |
this.txtLayerName.setText(layer.getName());
|
|
70 |
setName(layer.getName());
|
|
50 | 71 |
this.txtMessage.setText(this.getMessageAsHTML(layer.getErrors())); |
51 | 72 |
this.btnViewParameters.setEnabled(this.layer instanceof SingleLayer); |
52 | 73 |
} |
... | ... | |
92 | 113 |
editor.editObject(true); |
93 | 114 |
} catch (Throwable th) { |
94 | 115 |
logger.warn("Can't show standard properties dialog for this parameters.",th); |
95 |
}
|
|
116 |
} |
|
96 | 117 |
} |
97 | 118 |
|
98 | 119 |
} |
Also available in: Unified diff