Skip to content

Commit

Permalink
FIX SQLPower#19 Cannot delete Index
Browse files Browse the repository at this point in the history
  • Loading branch information
mathieu-lavigne committed Sep 8, 2017
1 parent 7403975 commit 665fe45
Showing 1 changed file with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

import javax.swing.JOptionPane;
import javax.swing.KeyStroke;
import javax.swing.tree.TreePath;

import org.apache.log4j.Logger;

Expand Down Expand Up @@ -86,7 +87,9 @@ public void actionPerformed(ActionEvent evt) {
logger.debug("delete action detected!"); //$NON-NLS-1$
logger.debug("ACTION COMMAND: " + evt.getActionCommand()); //$NON-NLS-1$

if (getPlaypen().getSelectedItems().size() < 1) {
final TreePath[] selectionPaths = getSession().getDBTree().getSelectionPaths();
final int selectionPathsSize = selectionPaths != null ? selectionPaths.length : 0;
if (getPlaypen().getSelectedItems().size() + selectionPathsSize < 1) {
JOptionPane.showMessageDialog(getPlaypen(), Messages.getString("DeleteSelectedAction.noItemsToDelete")); //$NON-NLS-1$
return;
}
Expand Down Expand Up @@ -218,6 +221,18 @@ List<SPObject> retrieveDeletableItems() {
}
}

// Invisible elements in the PlayPen but selected in the TreeView
TreePath[] selectionPaths = getSession().getDBTree().getSelectionPaths();
if (selectionPaths != null) {
for (final TreePath tp : selectionPaths) {
final Object c = tp.getLastPathComponent();
if (c instanceof SQLIndex && !deleteItems.contains(c)) {
final SQLIndex index = (SQLIndex) c;
deleteItems.add(index);
}
}
}

Set<SQLTable> tablesWithSelectedColumns = new HashSet<SQLTable>();

for (ListIterator<SPObject> it = deleteItems.listIterator(); it.hasNext(); ) {
Expand Down

0 comments on commit 665fe45

Please # to comment.