Author: [EMAIL PROTECTED]
Date: Wed Dec 3 15:47:11 2008
New Revision: 2862
Modified:
trunk/src/ca/sqlpower/architect/swingui/DBTree.java
trunk/src/ca/sqlpower/architect/swingui/action/DeleteSelectedAction.java
Log:
Fixed a bug mentioned on the forum. SQLIndexes could be deleted, but the
delete option was still greyed out on the right click menu. The playpen is
also updated correctly when a delete occurs.
Modified: trunk/src/ca/sqlpower/architect/swingui/DBTree.java
==============================================================================
--- trunk/src/ca/sqlpower/architect/swingui/DBTree.java (original)
+++ trunk/src/ca/sqlpower/architect/swingui/DBTree.java Wed Dec 3 15:47:11
2008
@@ -450,8 +450,7 @@
if (p.getLastPathComponent() instanceof SQLTable ||
p.getLastPathComponent() instanceof SQLColumn ||
p.getLastPathComponent() instanceof
SQLRelationship ||
- (p.getLastPathComponent() instanceof SQLIndex &&
- !((SQLIndex)
p.getLastPathComponent()).isPrimaryKeyIndex())) {
+ p.getLastPathComponent() instanceof SQLIndex) {
mi.setEnabled(true);
} else {
mi.setEnabled(false);
Modified:
trunk/src/ca/sqlpower/architect/swingui/action/DeleteSelectedAction.java
==============================================================================
---
trunk/src/ca/sqlpower/architect/swingui/action/DeleteSelectedAction.java
(original)
+++
trunk/src/ca/sqlpower/architect/swingui/action/DeleteSelectedAction.java
Wed Dec 3 15:47:11 2008
@@ -42,6 +42,7 @@
import ca.sqlpower.architect.SQLObject;
import ca.sqlpower.architect.SQLRelationship;
import ca.sqlpower.architect.SQLTable;
+import ca.sqlpower.architect.SQLIndex.Column;
import ca.sqlpower.architect.swingui.ArchitectSwingConstants;
import ca.sqlpower.architect.swingui.ArchitectSwingSession;
import ca.sqlpower.architect.swingui.DBTree;
@@ -132,7 +133,21 @@
for (SQLObject o : deleteItems) {
try {
- o.getParent().removeChild(o);
+ if (o instanceof SQLIndex) {
+ SQLIndex index = (SQLIndex) o;
+ SQLTable table = index.getParentTable();
+ o.getParent().removeChild(o);
+ List<SQLColumn> cols = new ArrayList<SQLColumn>();
+ for (Column col : index.getChildren()) {
+ cols.add(col.getColumn());
+ }
+ for (SQLColumn col : cols) {
+ col.setPrimaryKeySeq(null);
+ table.addColumn(col);
+ }
+ } else {
+ o.getParent().removeChild(o);
+ }
} catch (LockedColumnException ex) {
int decision = JOptionPane.showConfirmDialog(playpen,
Messages.getString("DeleteSelectedAction.couldNotDeleteColumnContinueConfirmation",
o.getName(), ex.getLockingRelationship().toString()), //$NON-NLS-1$
@@ -141,7 +156,9 @@
if (decision == JOptionPane.NO_OPTION) {
return;
}
- }
+ } catch (ArchitectException e) {
+ throw new RuntimeException(e);
+ }
}
} finally {