unified title and description handling in wizards
[phpeclipse.git] / archive / net.sourceforge.phpeclipse.sql / src / net / sourceforge / phpdt / sql / actions / DeleteColumnAction.java
1 package net.sourceforge.phpdt.sql.actions;
2
3 import java.util.Iterator;
4
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;
12
13 import net.sourceforge.phpdt.sql.Messages;
14 import net.sourceforge.phpdt.sql.view.SubsetView;
15 import net.sourceforge.phpdt.sql.view.bookmark.ColumnMetaData;
16
17 /**
18  * Deletes the selected columns from the Subset items (Tables)
19  * @author root
20  *
21  */
22 public class DeleteColumnAction extends Action implements IViewActionDelegate  {
23         SubsetView view;
24         /**
25          * @see org.eclipse.ui.IViewActionDelegate#init(IViewPart)
26          */
27         public void init(IViewPart view) {
28                 this.view = (SubsetView) view;
29         }
30
31         /**
32          * @see org.eclipse.ui.IActionDelegate#run(IAction)
33          */
34         public void run(IAction action) {
35                 run();
36         }
37         
38         public void run() {
39                 StructuredSelection selection = view.getSelection();
40                 Iterator iter = selection.iterator();
41                 if (! MessageDialog.openConfirm(view.getSite().getShell(), 
42                                                 Messages.getString("DeleteColumnAction.DeleteColumns"),  //$NON-NLS-1$
43                                                 Messages.getString("DeleteColumnAction.ConfirmDeleteColumns") )) //$NON-NLS-1$
44                         return;
45                 
46                 while (iter.hasNext()) {
47                         Object current = iter.next();
48                         if (current instanceof ColumnMetaData) {
49                                 ColumnMetaData column = (ColumnMetaData) current;
50                                 if (column != null) {
51                                                 view.deleteColumn(column);
52                                 }
53                         }
54                 }
55         }
56
57         /**
58          * @see org.eclipse.ui.IActionDelegate#selectionChanged(IAction, ISelection)
59          */
60         public void selectionChanged(IAction action, ISelection selection) {
61         }
62
63 }