Author: mo.jeff
Date: Thu Apr 23 13:26:24 2009
New Revision: 3001

Modified:
   trunk/src/ca/sqlpower/architect/swingui/action/EditColumnAction.java
   trunk/src/ca/sqlpower/architect/swingui/action/InsertColumnAction.java

Log:
A new column will be selected once it is added to a table. Also, modified adding new column behaviour from the DBTree to be more in line with how it works in the PlayPen (canceling in the playpen would not create the column in the first place, whereas in the dbtree, it creates it and leaves it even if cancelling)

Modified: trunk/src/ca/sqlpower/architect/swingui/action/EditColumnAction.java
==============================================================================
--- trunk/src/ca/sqlpower/architect/swingui/action/EditColumnAction.java (original) +++ trunk/src/ca/sqlpower/architect/swingui/action/EditColumnAction.java Thu Apr 23 13:26:24 2009
@@ -132,6 +132,8 @@
tp.getModel().startCompoundEdit("adding a new column '" + columnEditPanel.getColPhysicalName().getText() + "'"); //$NON-NLS-1$ //$NON-NLS-2$
                                                            try {
                                                                
tp.getModel().addColumn(colIdx, column);
+                                                               tp.selectNone();
+                                                               
tp.selectItem(colIdx); // select new column
                                                            } catch 
(SQLObjectException e) {
ASUtils.showExceptionDialog(session, "Error Could not add column to table", e); //$NON-NLS-1$
                                                            }

Modified: trunk/src/ca/sqlpower/architect/swingui/action/InsertColumnAction.java
==============================================================================
--- trunk/src/ca/sqlpower/architect/swingui/action/InsertColumnAction.java (original) +++ trunk/src/ca/sqlpower/architect/swingui/action/InsertColumnAction.java Thu Apr 23 13:26:24 2009
@@ -59,9 +59,8 @@
                st = sc.getParentTable();
                idx = st.getColumnIndex(sc);
                if (idx == -1)  {
-                       // not found
- logger.debug("did not find column, inserting at start of table."); //$NON-NLS-1$
-                       idx = 0;
+ throw new IllegalStateException("Selected column '" + sc.getName() + + "' could not be found in parent table '" + st.getName() + "'");
                } else {
//This is so that the column is added after the selected the column
                    idx++;
@@ -69,11 +68,13 @@
         }
         if (st == null) {
throw new NullPointerException("The SQLObject must be a instance of SQLTable or SQLColumn");
-        } else {
-            st.addColumn(idx, new SQLColumn());
         }
+
+        // Expecting the playpen and dbtree selctions to be synchronized.
+        TablePane tp = (TablePane) playpen.getSelectedItems().get(0);
+
         EditColumnAction editColumnAction = new EditColumnAction(session);
-        editColumnAction.showDialog(st, idx);
+        editColumnAction.showDialog(st, idx, true, tp);

     }

Reply via email to