Author: [email protected]
Date: Mon Dec 15 15:28:19 2008
New Revision: 2883
Modified:
trunk/src/ca/sqlpower/architect/swingui/action/AbstractTableTargetedAction.java
trunk/src/ca/sqlpower/architect/swingui/action/InsertColumnAction.java
Log:
Fixed a bug regarding column creation when a column is selected. Apparently
There was code that handles column creation when a column is selected but
was never used.This is because selecting the column also selects its parent
table on the tree and there was a check that if there was more then one
selected paths in the tree, it would show a dialog instead of allowing it
to be handled.
Also added a message in a NPE if it ever occurs.
Modified:
trunk/src/ca/sqlpower/architect/swingui/action/AbstractTableTargetedAction.java
==============================================================================
---
trunk/src/ca/sqlpower/architect/swingui/action/AbstractTableTargetedAction.java
(original)
+++
trunk/src/ca/sqlpower/architect/swingui/action/AbstractTableTargetedAction.java
Mon Dec 15 15:28:19 2008
@@ -25,7 +25,9 @@
import javax.swing.tree.TreePath;
import ca.sqlpower.architect.ArchitectException;
+import ca.sqlpower.architect.SQLColumn;
import ca.sqlpower.architect.SQLObject;
+import ca.sqlpower.architect.SQLTable;
import ca.sqlpower.architect.swingui.ASUtils;
import ca.sqlpower.architect.swingui.ArchitectSwingConstants;
import ca.sqlpower.architect.swingui.ArchitectSwingSession;
@@ -73,12 +75,17 @@
}
} else if
(evt.getActionCommand().equals(ArchitectSwingConstants.ACTION_COMMAND_SRC_DBTREE))
{
TreePath [] selections = dbt.getSelectionPaths();
- if (selections == null || selections.length != 1) {
- JOptionPane.showMessageDialog(dbt,
Messages.getString("AbstractTableTargetedAction.instructions"));
//$NON-NLS-1$
- } else {
- TreePath tp = selections[0];
+ // This statement ensures that there is only one item
selected
+ // except for the special case of SQLColumns, in which its
+ // parent gets selected. Then, we need to use the column.
+ if (selections != null && (selections.length == 1 ||
+ (selections.length == 2 &&
selections[0].getLastPathComponent() instanceof SQLTable
+ &&
selections[1].getLastPathComponent() instanceof SQLColumn))) {
+ TreePath tp = selections[selections.length - 1];
SQLObject so = (SQLObject) tp.getLastPathComponent();
processSQLObject(so);
+ } else {
+ JOptionPane.showMessageDialog(dbt,
Messages.getString("AbstractTableTargetedAction.instructions"));
//$NON-NLS-1$
}
} else {
JOptionPane.showMessageDialog(
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
Mon Dec 15 15:28:19 2008
@@ -65,7 +65,7 @@
}
}
if (st == null) {
- throw new NullPointerException();
+ throw new NullPointerException("The SQLObject must be a
instance of SQLTable or SQLColumn");
} else {
st.addColumn(idx, new SQLColumn());
}