1 package com.quantum.actions;
3 import java.util.Iterator;
5 import com.quantum.Messages;
6 import com.quantum.view.subset.ObjectNode;
7 import com.quantum.view.subset.SubsetNode;
8 import com.quantum.view.subset.SubsetView;
10 import org.eclipse.jface.action.Action;
11 import org.eclipse.jface.action.IAction;
12 import org.eclipse.jface.dialogs.MessageDialog;
13 import org.eclipse.jface.viewers.ISelection;
14 import org.eclipse.jface.viewers.StructuredSelection;
15 import org.eclipse.ui.IViewActionDelegate;
16 import org.eclipse.ui.IViewPart;
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) {