Revision: 3786
Author: [email protected]
Date: Fri Jul 23 13:50:23 2010
Log: Corrected the tests that failed due to upstream types being mandatory. The tests now fail more gracefully instead of causing the tests to time out.
Also improved the error dialog's look.
http://code.google.com/p/power-architect/source/detail?r=3786

Modified:
 /trunk/regress/ca/sqlpower/architect/swingui/TestColumnEditPanel.java
 /trunk/src/main/java/ca/sqlpower/architect/swingui/ColumnEditPanel.java
 /trunk/src/main/resources/ca/sqlpower/architect/swingui/messages.properties

=======================================
--- /trunk/regress/ca/sqlpower/architect/swingui/TestColumnEditPanel.java Mon May 31 12:13:44 2010 +++ /trunk/regress/ca/sqlpower/architect/swingui/TestColumnEditPanel.java Fri Jul 23 13:50:23 2010
@@ -160,9 +160,12 @@
        }

/** Tests for real problem (columns in pk were getting moved to bottom of PK after editing) */
-       public void testPKColumnMoveRegression() throws Exception{
+       public void testPKColumnMoveRegression() throws Exception{
+           UserDefinedSQLType stubType = session.getSQLTypes().get(0);
                SQLColumn c1 = new SQLColumn(table,"PKColumn 1",1,2,3);
                SQLColumn c2 = new SQLColumn(table,"PKColumn 2",1,2,3);
+               c1.getUserDefinedSQLType().setUpstreamType(stubType);
+               c2.getUserDefinedSQLType().setUpstreamType(stubType);
                table.addColumn(c1);
                table.addColumn(c2);
                table.addToPK(c1);
@@ -173,7 +176,8 @@

int previousIdx = table.getColumnIndex(table.getColumnByName("PKColumn 1"));
         ColumnEditPanel editPanel = new ColumnEditPanel(c1, session);
-               editPanel.applyChanges();
+               boolean changesApplied = editPanel.applyChanges();
+               assertTrue(changesApplied);
assertEquals(previousIdx, table.getColumnIndex(table.getColumnByName("PKColumn 1")));
        }

@@ -186,13 +190,16 @@
public void testColumnStaysSelectedWhenMovedToPK() throws SQLObjectException, IOException { TestingArchitectSwingSessionContext context = new TestingArchitectSwingSessionContext();
         ArchitectSwingSession session = context.createSession();
+        UserDefinedSQLType stubType = session.getSQLTypes().get(0);
         PlayPen pp = new PlayPen(session);
         TablePane tp = new TablePane(table, pp.getContentPane());
         tp.setSelected(true,SelectionEvent.SINGLE_SELECT);
         tp.selectItem(table.getColumnIndex(col3));
+        col3.getUserDefinedSQLType().setUpstreamType(stubType);
         ColumnEditPanel ce = new ColumnEditPanel(col3, session);
         ce.getColInPK().setSelected(true);
-        ce.applyChanges();
+        boolean changesApplied = ce.applyChanges();
+        assertTrue(changesApplied);
assertEquals(table.getColumnIndex(col3), tp.getSelectedItemIndex());
     }

=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/swingui/ColumnEditPanel.java Fri Jul 23 11:28:13 2010 +++ /trunk/src/main/java/ca/sqlpower/architect/swingui/ColumnEditPanel.java Fri Jul 23 13:50:23 2010
@@ -79,9 +79,9 @@
 import ca.sqlpower.sqlobject.SQLObjectException;
 import ca.sqlpower.sqlobject.SQLObjectUtils;
 import ca.sqlpower.sqlobject.SQLTypePhysicalPropertiesProvider;
-import ca.sqlpower.sqlobject.SQLTypePhysicalPropertiesProvider.PropertyType;
 import ca.sqlpower.sqlobject.UserDefinedSQLType;
 import ca.sqlpower.sqlobject.UserDefinedSQLTypeSnapshot;
+import ca.sqlpower.sqlobject.SQLTypePhysicalPropertiesProvider.PropertyType;
 import ca.sqlpower.swingui.ChangeListeningDataEntryPanel;
 import ca.sqlpower.swingui.DataEntryPanelChangeUtil;
 import ca.sqlpower.swingui.SPSUtils;
@@ -963,7 +963,15 @@
         SQLPowerUtils.unlistenToHierarchy(session.getRootObject(), this);
         List<String> errors = updateModel();
         if (!errors.isEmpty()) {
-            JOptionPane.showMessageDialog(panel, errors.toString());
+            StringBuffer buffer = new StringBuffer();
+            buffer.append("<html>");
+            for (String error : errors) {
+                buffer.append(error);
+                buffer.append("<br>");
+            }
+            buffer.append("</html>");
+            JOptionPane.showMessageDialog(panel, buffer.toString(),
+ Messages.getString("ColumnEditPanel.errorTitle"), JOptionPane.WARNING_MESSAGE);
             return false;
         } else {
             return true;
=======================================
--- /trunk/src/main/resources/ca/sqlpower/architect/swingui/messages.properties Fri Jul 23 11:28:13 2010 +++ /trunk/src/main/resources/ca/sqlpower/architect/swingui/messages.properties Fri Jul 23 13:50:23 2010
@@ -78,6 +78,7 @@
 ColumnEditPanel.columnNameRequired=Column name is required
 ColumnEditPanel.compoundEditName=Modify Column Properties
 ColumnEditPanel.defaultValue=Default Value
+ColumnEditPanel.errorTitle=Error changing properties
 ColumnEditPanel.inPrimaryKey=In Primary Key
 ColumnEditPanel.physicalName=Physical Name
 ColumnEditPanel.logicalName=Logical Name

Reply via email to