|
From: <cro...@li...> - 2003-09-25 22:44:09
|
Module Name: CFJavaEditor
Committed By: avogl
Date: Thu Sep 25 22:43:57 UTC 2003
Modified Files:
CFJavaEditor/src/cfeditor: CAttribDialog.java
Log Message:
Fixed a bug in the parse logic for floating points.
Also improved handling of fixed attributes in
combination with type-changing.
--AV
Start of context diffs
Index: CFJavaEditor/src/cfeditor/CAttribDialog.java
diff -c CFJavaEditor/src/cfeditor/CAttribDialog.java:1.7 CFJavaEditor/src/cfeditor/CAttribDialog.java:1.8
*** CFJavaEditor/src/cfeditor/CAttribDialog.java:1.7 Sat May 3 11:23:07 2003
--- CFJavaEditor/src/cfeditor/CAttribDialog.java Thu Sep 25 15:43:56 2003
***************
*** 1199,1205 ****
double def_value = 0; // value from the default arch
// try to parse floating point
value = Double.parseDouble(((FloatAttrib)attr).input.getText().trim());
! def_value = Double.parseDouble(defarch.getAttributeString(attr.ref.getNameOld(), null).trim());
if (value != def_value)
new_ArchText = new_ArchText+attr.ref.getNameOld()+" "+value+"\n";
}
--- 1199,1207 ----
double def_value = 0; // value from the default arch
// try to parse floating point
value = Double.parseDouble(((FloatAttrib)attr).input.getText().trim());
! String defValueStr = defarch.getAttributeString(attr.ref.getNameOld(), null).trim();
! if (defValueStr.length() > 0)
! def_value = Double.parseDouble(defValueStr);
if (value != def_value)
new_ArchText = new_ArchText+attr.ref.getNameOld()+" "+value+"\n";
}
***************
*** 1312,1321 ****
// Also write all the 'fixed' attributes into the archtext
for (int i=0; type.getAttr().length > i; i++) {
! if (type.getAttr()[i].getDataType() == CFArchAttrib.T_FIXED &&
! defarch.getAttributeString(type.getAttr()[i].getNameOld(), null).length()==0)
new_ArchText = new_ArchText+type.getAttr()[i].getNameOld()+" "+
type.getAttr()[i].getNameNew()+"\n";
}
// before we modify the archtext, we look for errors and save them.
--- 1314,1332 ----
// Also write all the 'fixed' attributes into the archtext
for (int i=0; type.getAttr().length > i; i++) {
! if (type.getAttr()[i].getDataType() == CFArchAttrib.T_FIXED) {
! String defaultValue = defarch.getAttributeString(type.getAttr()[i].getNameOld(), null);
! if (defaultValue.length()==0 || (arch.getArchTypNr() != defarch.getArchTypNr() &&
! !defaultValue.equalsIgnoreCase(type.getAttr()[i].getNameNew()))) {
! // usually, fixed attributes are only applied when *not* defined in the defarch.
! // the reason behind this is: if the default arch violates our fixed attribute,
! // we assume the default arch is "right" and we are "wrong". The typedefs aren't that trustworthy.
! // BUT - if the arch has a changed type, the defarch has lost it's credibility.
! // So, in this special case, the fixed attribute applies always.
new_ArchText = new_ArchText+type.getAttr()[i].getNameOld()+" "+
type.getAttr()[i].getNameNew()+"\n";
+ }
+ }
}
// before we modify the archtext, we look for errors and save them.
|