synchronized from quantum plugin
[phpeclipse.git] / archive / net.sourceforge.phpeclipse.quantum.sql / src / com / quantum / actions / DeleteSubsetAction.java
1 package com.quantum.actions;
2
3 import com.quantum.Messages;
4 import com.quantum.view.subset.SubsetNode;
5 import com.quantum.view.subset.SubsetView;
6
7 import org.eclipse.jface.action.Action;
8 import org.eclipse.jface.action.IAction;
9 import org.eclipse.jface.dialogs.MessageDialog;
10 import org.eclipse.jface.viewers.ISelection;
11 import org.eclipse.ui.IViewActionDelegate;
12 import org.eclipse.ui.IViewPart;
13
14 /**
15  * @author root
16  *      Deletes a complete subset from the subset view
17  */
18 public class DeleteSubsetAction extends Action implements IViewActionDelegate  {
19         SubsetView view;
20         /**
21          * @see org.eclipse.ui.IViewActionDelegate#init(IViewPart)
22          */
23         public void init(IViewPart view) {
24                 this.view = (SubsetView) view;
25         }
26
27         /**
28          * @see org.eclipse.ui.IActionDelegate#run(IAction)
29          */
30         public void run(IAction action) {
31                 run();
32         }
33         
34         public void run() {
35                 Object selection = view.getCurrent();
36                 if (selection instanceof SubsetNode) {
37                         SubsetNode node = (SubsetNode) selection;
38                         if (node != null) {
39                                 boolean flag = MessageDialog.openConfirm(view.getSite().getShell(), 
40                                                                 Messages.getString("DeleteSubsetAction.DeleteSubset"),  //$NON-NLS-1$
41                                                                 Messages.getString("DeleteSubsetAction.ConfirmDeleteSubset") + node.getName()); //$NON-NLS-1$
42                                 if (flag) {
43                                         view.deleteCurrent();
44                                 }
45                         }
46                 }
47         }
48
49         /**
50          * @see org.eclipse.ui.IActionDelegate#selectionChanged(IAction, ISelection)
51          */
52         public void selectionChanged(IAction action, ISelection selection) {
53         }
54
55 }