Add predefined Velocity and CSS templates if wiki builder is assigned to a project
[phpeclipse.git] / archive / net.sourceforge.phpeclipse.quantum.sql / src / com / quantum / actions / DeleteBookmarkAction.java
1 package com.quantum.actions;
2
3 import java.util.Iterator;
4 import java.util.List;
5
6 import com.quantum.ImageStore;
7 import com.quantum.Messages;
8 import com.quantum.model.BookmarkCollection;
9 import com.quantum.view.bookmark.BookmarkNode;
10
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;
16
17 /**
18  * @author root
19  *
20  */
21 public class DeleteBookmarkAction extends SelectionListenerAction {
22     
23     private IViewPart view;
24     
25         public DeleteBookmarkAction(IViewPart view) {
26         super(Messages.getString(DeleteBookmarkAction.class.getName() + ".text"));
27         setImageDescriptor(ImageStore.getImageDescriptor(ImageStore.DELETE));
28                 this.view = 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                 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$
41
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());
46             }
47         }
48         }
49
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);
54         }
55         
56         return enabled;
57         }
58
59 }