1 package com.quantum.actions;
3 import java.util.Iterator;
6 import com.quantum.Messages;
7 import com.quantum.QuantumPlugin;
8 import com.quantum.model.BookmarkCollection;
9 import com.quantum.view.bookmark.BookmarkNode;
11 import org.eclipse.jface.action.IAction;
12 import org.eclipse.jface.dialogs.MessageDialog;
13 import org.eclipse.jface.viewers.IStructuredSelection;
14 import org.eclipse.ui.IViewPart;
15 import org.eclipse.ui.actions.SelectionListenerAction;
21 public class DeleteBookmarkAction extends SelectionListenerAction {
23 private IViewPart view;
25 public DeleteBookmarkAction(IViewPart view) {
26 super(Messages.getString(DeleteBookmarkAction.class.getName() + ".text"));
27 setImageDescriptor(QuantumPlugin.getImageDescriptor("delete.gif"));
32 * @see org.eclipse.ui.IActionDelegate#run(IAction)
34 public void run(IAction action) {
39 List bookmarkNodes = getSelectedNonResources();
40 boolean flag = MessageDialog.openConfirm(view.getSite().getShell(), Messages.getString("bookmarkview.deleteBookmark"), Messages.getString("bookmarkview.confirm")); //$NON-NLS-1$ //$NON-NLS-2$
42 for (Iterator i = bookmarkNodes.iterator(); flag && i.hasNext();) {
43 BookmarkNode bookmarkNode = (BookmarkNode) i.next();
44 if (bookmarkNode != null) {
45 BookmarkCollection.getInstance().removeBookmark(bookmarkNode.getBookmark());
50 public boolean updateSelection(IStructuredSelection selection) {
51 boolean enabled = super.updateSelection(selection);
52 for (Iterator i = selection.iterator(); enabled && i.hasNext(); ) {
53 enabled &= (i.next() instanceof BookmarkNode);