Revision 44504 trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.swing/org.gvsig.fmap.dal.swing.impl/src/main/java/org/gvsig/fmap/dal/swing/impl/featuretype/DefaultFeatureTypePanel.java
DefaultFeatureTypePanel.java | ||
---|---|---|
41 | 41 |
{ |
42 | 42 |
|
43 | 43 |
private static final Logger LOGGER = LoggerFactory.getLogger(DefaultFeatureTypePanel.class); |
44 |
private FeatureType originalFeatureType; |
|
44 |
private FeatureType originalFeatureType = null;
|
|
45 | 45 |
|
46 | 46 |
private class FeatureTypeTableModel extends AbstractTableModel { |
47 | 47 |
|
... | ... | |
241 | 241 |
|
242 | 242 |
private boolean doFormFieldFetch() { |
243 | 243 |
int row = this.tblFields.getSelectedRow(); |
244 |
if( row<0 ) {
|
|
244 |
if (row < 0) {
|
|
245 | 245 |
return true; |
246 | 246 |
} |
247 | 247 |
FeatureAttributeDescriptor descriptor = this.featureType.getAttributeDescriptor(row); |
248 | 248 |
int previousType = descriptor.getType(); |
249 |
if( descriptor instanceof EditableFeatureAttributeDescriptor ) {
|
|
250 |
if( this.descriptorPanel.fetch((EditableFeatureAttributeDescriptor) descriptor)==null ) {
|
|
249 |
if (descriptor instanceof EditableFeatureAttributeDescriptor) {
|
|
250 |
if (this.descriptorPanel.fetch((EditableFeatureAttributeDescriptor) descriptor) == null) {
|
|
251 | 251 |
return false; |
252 | 252 |
} |
253 | 253 |
this.tableModel.fireUpdateEvent(); |
254 |
} |
|
255 |
|
|
256 |
FeatureAttributeDescriptor oldDescriptor = this.originalFeatureType.getAttributeDescriptor(descriptor.getName()); |
|
257 |
if (oldDescriptor !=null && |
|
258 |
oldDescriptor.getDataType()!=descriptor.getDataType() && |
|
259 |
previousType != descriptor.getType()) { |
|
260 |
ThreadSafeDialogsManager dialogs = ToolsSwingLocator.getThreadSafeDialogsManager(); |
|
254 |
} |
|
255 |
FeatureAttributeDescriptor oldDescriptor = null; |
|
256 |
if (this.originalFeatureType != null) { |
|
257 |
oldDescriptor = this.originalFeatureType.getAttributeDescriptor(descriptor.getName()); |
|
258 |
} |
|
259 |
if (oldDescriptor != null |
|
260 |
&& oldDescriptor.getDataType() != descriptor.getDataType() |
|
261 |
&& previousType != descriptor.getType()) { |
|
262 |
ThreadSafeDialogsManager dialogs = ToolsSwingLocator.getThreadSafeDialogsManager(); |
|
261 | 263 |
I18nManager i18manager = ToolsLocator.getI18nManager(); |
262 | 264 |
StringBuilder message = new StringBuilder(); |
263 |
|
|
265 |
|
|
264 | 266 |
String[] messageArgs = new String[]{oldDescriptor.getName()}; |
265 | 267 |
message.append(i18manager.getTranslation("_Already_existed_a_field_named_XfieldnameX_but_with_different_data_type", messageArgs)); |
266 | 268 |
message.append(".\n"); |
267 | 269 |
message.append(i18manager.getTranslation("_Values_of_data_will_try_to_coerce_to_this_type")); |
268 |
dialogs.messageDialog( |
|
269 |
message.toString(), |
|
270 |
null, |
|
271 |
i18manager.getTranslation("_Values_will_change"), |
|
272 |
JOptionPane.INFORMATION_MESSAGE, |
|
273 |
"feature-type-manager-field-already-exist-in-previous-schema"); |
|
274 |
} |
|
275 |
|
|
276 |
|
|
270 |
dialogs.messageDialog( |
|
271 |
message.toString(), |
|
272 |
null, |
|
273 |
i18manager.getTranslation("_Values_will_change"), |
|
274 |
JOptionPane.INFORMATION_MESSAGE, |
|
275 |
"feature-type-manager-field-already-exist-in-previous-schema"); |
|
276 |
} |
|
277 |
|
|
277 | 278 |
return true; |
278 | 279 |
} |
279 | 280 |
|
... | ... | |
402 | 403 |
|
403 | 404 |
@Override |
404 | 405 |
public void put(FeatureType type) { |
405 |
FeatureType ftypeToCompare = type.getOriginalFeatureType(); |
|
406 |
if (ftypeToCompare==null) { |
|
407 |
ftypeToCompare = type; |
|
408 |
} |
|
409 |
this.originalFeatureType = ftypeToCompare.getCopy(); |
|
410 | 406 |
this.featureType = type; |
411 |
if( type == null ) { |
|
407 |
this.originalFeatureType = null; |
|
408 |
if (type == null) { |
|
412 | 409 |
this.store = null; |
413 | 410 |
} else { |
411 |
FeatureType ftypeToCompare = type.getOriginalFeatureType(); |
|
412 |
if (ftypeToCompare == null) { |
|
413 |
ftypeToCompare = type; |
|
414 |
} |
|
415 |
this.originalFeatureType = ftypeToCompare.getCopy(); |
|
414 | 416 |
// Nos quedamos una referencia para evitar que se destruya, ya que |
415 | 417 |
// el featureType se guarda solo una WeakReference. |
416 |
this.store = type.getStore();
|
|
418 |
this.store = type.getStore(); |
|
417 | 419 |
this.txtLabel.setText( |
418 |
StringUtils.defaultIfBlank(((DynStruct_v2)type).getLabel(), "")
|
|
420 |
StringUtils.defaultIfBlank(((DynStruct_v2) type).getLabel(), "")
|
|
419 | 421 |
); |
420 | 422 |
this.txtDescription.setText( |
421 |
StringUtils.defaultIfBlank(((DynStruct_v2)type).getDescription(), "")
|
|
423 |
StringUtils.defaultIfBlank(((DynStruct_v2) type).getDescription(), "")
|
|
422 | 424 |
); |
423 |
this.tagsController.set(((DynStruct_v2)type).getTags()); |
|
425 |
this.tagsController.set(((DynStruct_v2) type).getTags());
|
|
424 | 426 |
} |
425 | 427 |
if( !(type instanceof EditableFeatureType) ) { |
426 | 428 |
this.setEditable(false); |
Also available in: Unified diff