Revision: 3557
Author: [email protected]
Date: Wed May 26 09:32:14 2010
Log: Fixed the bug where changing data types on columns in a server
workspace causes exceptions. Also, fixed the Data Type Manager so that
newly added data types have the precision and scale combo boxes, as well as
the constraint radio box selected always.
http://code.google.com/p/power-architect/source/detail?r=3557
Modified:
/trunk/src/main/java/ca/sqlpower/architect/swingui/ColumnEditPanel.java
=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/swingui/ColumnEditPanel.java
Fri May 14 11:58:04 2010
+++ /trunk/src/main/java/ca/sqlpower/architect/swingui/ColumnEditPanel.java
Wed May 26 09:32:14 2010
@@ -831,41 +831,34 @@
column.setPhysicalName(colPhysicalName.getText());
}
if (componentEnabledMap.get(colType).isSelected()) {
-
column.getUserDefinedSQLType().setUpstreamType((UserDefinedSQLType)
colType.getLastSelectedPathComponent());
- }
-
- if (componentEnabledMap.get(colType).isSelected()) {
+ // Set upstream type on column
+ UserDefinedSQLType upstreamType = (UserDefinedSQLType)
colType.getLastSelectedPathComponent();
+
column.getUserDefinedSQLType().setUpstreamType(upstreamType);
+
+ // Set scale
if (typeOverrideMap.get(colScale).isSelected()) {
column.setScale(((Integer)
colScale.getValue()).intValue());
} else {
column.getUserDefinedSQLType().setScale(
SQLTypePhysicalPropertiesProvider.GENERIC_PLATFORM, null);
}
- }
-
- if (componentEnabledMap.get(colType).isSelected()) {
+
+ // Set precision
if (typeOverrideMap.get(colPrec).isSelected()) {
column.setPrecision(((Integer)
colPrec.getValue()).intValue());
} else {
column.getUserDefinedSQLType().setPrecision(
SQLTypePhysicalPropertiesProvider.GENERIC_PLATFORM, null);
}
- }
-
- if (componentEnabledMap.get(colType).isSelected()) {
+
+ // Set nullability
if (typeOverrideMap.get(colNullable).isSelected()) {
column.setNullable(((YesNoEnum)
colNullable.getSelectedItem()).getValue() ? DatabaseMetaData.columnNullable
- : DatabaseMetaData.columnNoNulls);
+ : DatabaseMetaData.columnNoNulls);
} else {
column.getUserDefinedSQLType().setMyNullability(null);
}
- }
-
- if (componentEnabledMap.get(colRemarks).isSelected()) {
- column.setRemarks(colRemarks.getText());
- }
-
- if (componentEnabledMap.get(colType).isSelected()) {
+
if (typeOverrideMap.get(colDefaultValue).isSelected())
{
// avoid setting default value to empty string
if (!(column.getDefaultValue() == null &&
colDefaultValue.getText().equals(""))) { //$NON-NLS-1$
@@ -875,11 +868,9 @@
column.getUserDefinedSQLType().setDefaultValue(
SQLTypePhysicalPropertiesProvider.GENERIC_PLATFORM, null);
}
- }
-
- // Autoincrement has to go before the primary key or
- // this column will never allow nulls
- if (componentEnabledMap.get(colType).isSelected()) {
+
+ // Autoincrement has to go before the primary key or
+ // this column will never allow nulls
if (typeOverrideMap.get(colAutoInc).isSelected()) {
column.setAutoIncrement(((YesNoEnum)
colAutoInc.getSelectedItem()).getValue());
} else {
@@ -887,6 +878,10 @@
}
}
+ if (componentEnabledMap.get(colRemarks).isSelected()) {
+ column.setRemarks(colRemarks.getText());
+ }
+
if (componentEnabledMap.get(colInPK).isSelected()) {
if (colInPK.isSelected() && !column.isPrimaryKey()) {
column.getParent().addToPK(column);