1 package net.sourceforge.phpdt.sql.actions;
3 import java.util.Iterator;
5 import org.eclipse.jface.action.Action;
6 import org.eclipse.jface.action.IAction;
7 import org.eclipse.jface.dialogs.MessageDialog;
8 import org.eclipse.jface.viewers.ISelection;
9 import org.eclipse.jface.viewers.StructuredSelection;
10 import org.eclipse.ui.IViewActionDelegate;
11 import org.eclipse.ui.IViewPart;
13 import net.sourceforge.phpdt.sql.Messages;
14 import net.sourceforge.phpdt.sql.view.SubsetView;
15 import net.sourceforge.phpdt.sql.view.bookmark.ObjectNode;
16 import net.sourceforge.phpdt.sql.view.bookmark.SubsetNode;
19 * Deletes an entire object (Table) from the SubsetView
23 public class DeleteObjectAction extends Action implements IViewActionDelegate {
26 * @see org.eclipse.ui.IViewActionDelegate#init(IViewPart)
28 public void init(IViewPart view) {
29 this.view = (SubsetView) view;
33 * @see org.eclipse.ui.IActionDelegate#run(IAction)
35 public void run(IAction action) {
40 Object selection = view.getCurrent();
41 if (selection instanceof SubsetNode) {
42 SubsetNode node = (SubsetNode) selection;
44 boolean flag = MessageDialog.openConfirm(view.getSite().getShell(),
45 Messages.getString("DeleteObjectAction.DeleteSubset"), //$NON-NLS-1$
46 Messages.getString("DeleteObjectAction.ConfirmDeleteSubset") + node.getName()); //$NON-NLS-1$
51 } else if (selection instanceof ObjectNode) {
52 StructuredSelection allSelected = view.getSelection();
53 Iterator iter = allSelected.iterator();
54 if (! MessageDialog.openConfirm(view.getSite().getShell(),
55 Messages.getString("DeleteObjectAction.DeleteItems"), //$NON-NLS-1$
56 Messages.getString("DeleteObjectAction.ConfirmDeleteItems") )) //$NON-NLS-1$
59 while (iter.hasNext()) {
60 Object current = iter.next();
61 if (current instanceof ObjectNode) {
62 ObjectNode node = (ObjectNode) current;
64 view.deleteObject(node);
72 * @see org.eclipse.ui.IActionDelegate#selectionChanged(IAction, ISelection)
74 public void selectionChanged(IAction action, ISelection selection) {