Revision: 3562
Author: [email protected]
Date: Thu May 27 14:27:01 2010
Log: Fixed the ColumnEditPanel so that it enforces the PropertyType of precision and scale. If the property type is constant, the property cannot be changed by the user, except through the data type editor or domain editor.
http://code.google.com/p/power-architect/source/detail?r=3562

Modified:
 /trunk/src/main/java/ca/sqlpower/architect/swingui/ColumnEditPanel.java

=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/swingui/ColumnEditPanel.java Wed May 26 09:32:14 2010 +++ /trunk/src/main/java/ca/sqlpower/architect/swingui/ColumnEditPanel.java Thu May 27 14:27:01 2010
@@ -836,19 +836,23 @@
column.getUserDefinedSQLType().setUpstreamType(upstreamType);

                     // Set scale
-                    if (typeOverrideMap.get(colScale).isSelected()) {
+                    if (column.getScaleType() == PropertyType.CONSTANT
+ || typeOverrideMap.get(colScale).isSelected()) { column.setScale(((Integer) colScale.getValue()).intValue());
                     } else {
                         column.getUserDefinedSQLType().setScale(
- SQLTypePhysicalPropertiesProvider.GENERIC_PLATFORM, null); + SQLTypePhysicalPropertiesProvider.GENERIC_PLATFORM,
+                                null);
                     }

                     // Set precision
-                    if (typeOverrideMap.get(colPrec).isSelected()) {
+                    if (column.getPrecisionType() == PropertyType.CONSTANT
+                            || typeOverrideMap.get(colPrec).isSelected()) {
column.setPrecision(((Integer) colPrec.getValue()).intValue());
                     } else {
                         column.getUserDefinedSQLType().setPrecision(
- SQLTypePhysicalPropertiesProvider.GENERIC_PLATFORM, null); + SQLTypePhysicalPropertiesProvider.GENERIC_PLATFORM,
+                                null);
                     }

                     // Set nullability
@@ -1167,10 +1171,12 @@
             return;
         }

- if (sqlType.getScaleType(SQLTypePhysicalPropertiesProvider.GENERIC_PLATFORM) == PropertyType.NOT_APPLICABLE) { + if (sqlType.getScaleType(SQLTypePhysicalPropertiesProvider.GENERIC_PLATFORM)
+                != PropertyType.VARIABLE) {
             typeOverrideMap.get(colScale).setSelected(false);
             typeOverrideMap.get(colScale).setEnabled(false);
- } else if (sqlType.getDefaultPhysicalProperties().getScale() == null || !overrideIfNotNull) { + } else if (sqlType.getDefaultPhysicalProperties().getScale() == null
+                || !overrideIfNotNull) {
             typeOverrideMap.get(colScale).setSelected(false);
             typeOverrideMap.get(colScale).setEnabled(true);
         } else {
@@ -1180,10 +1186,12 @@
colScale.setValue(sqlType.getScale(SQLTypePhysicalPropertiesProvider.GENERIC_PLATFORM));


- if (sqlType.getPrecisionType(SQLTypePhysicalPropertiesProvider.GENERIC_PLATFORM) == PropertyType.NOT_APPLICABLE) { + if (sqlType.getPrecisionType(SQLTypePhysicalPropertiesProvider.GENERIC_PLATFORM)
+                != PropertyType.VARIABLE) {
             typeOverrideMap.get(colPrec).setSelected(false);
             typeOverrideMap.get(colPrec).setEnabled(false);
- } else if (sqlType.getDefaultPhysicalProperties().getPrecision() == null || !overrideIfNotNull) { + } else if (sqlType.getDefaultPhysicalProperties().getPrecision() == null
+                || !overrideIfNotNull) {
             typeOverrideMap.get(colPrec).setSelected(false);
             typeOverrideMap.get(colPrec).setEnabled(true);
         } else {

Reply via email to