fixed ID bug
[phpeclipse.git] / archive / net.sourceforge.phpeclipse.quantum.sql / src / com / quantum / actions / DeleteColumnAction.java
1 package com.quantum.actions;
2
3 import java.util.Iterator;
4
5 import com.quantum.Messages;
6 import com.quantum.view.bookmark.ColumnNode;
7 import com.quantum.view.subset.SubsetView;
8
9 import org.eclipse.jface.action.Action;
10 import org.eclipse.jface.action.IAction;
11 import org.eclipse.jface.dialogs.MessageDialog;
12 import org.eclipse.jface.viewers.ISelection;
13 import org.eclipse.jface.viewers.StructuredSelection;
14 import org.eclipse.ui.IViewActionDelegate;
15 import org.eclipse.ui.IViewPart;
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 ColumnNode) {
49                                 ColumnNode column = (ColumnNode) 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 }