SQL Plugin copied from Quantum plugin and refactored for PHPEclipse
[phpeclipse.git] / archive / net.sourceforge.phpeclipse.sql / src / net / sourceforge / phpdt / sql / actions / DeleteBookmarkAction.java
diff --git a/archive/net.sourceforge.phpeclipse.sql/src/net/sourceforge/phpdt/sql/actions/DeleteBookmarkAction.java b/archive/net.sourceforge.phpeclipse.sql/src/net/sourceforge/phpdt/sql/actions/DeleteBookmarkAction.java
new file mode 100644 (file)
index 0000000..26bc204
--- /dev/null
@@ -0,0 +1,57 @@
+package net.sourceforge.phpdt.sql.actions;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ui.IViewActionDelegate;
+import org.eclipse.ui.IViewPart;
+
+import net.sourceforge.phpdt.sql.view.BookmarkView;
+import net.sourceforge.phpdt.sql.view.bookmark.BookmarkNode;
+
+/**
+ * @author root
+ *
+ * To change this generated comment edit the template variable "typecomment":
+ * Window>Preferences>Java>Templates.
+ * To enable and disable the creation of type comments go to
+ * Window>Preferences>Java>Code Generation.
+ */
+public class DeleteBookmarkAction extends Action implements IViewActionDelegate  {
+    BookmarkView view;
+       /**
+        * @see org.eclipse.ui.IViewActionDelegate#init(IViewPart)
+        */
+       public void init(IViewPart view) {
+               this.view = (BookmarkView) view;
+       }
+
+       /**
+        * @see org.eclipse.ui.IActionDelegate#run(IAction)
+        */
+       public void run(IAction action) {
+               run();
+       }
+       
+       public void run() {
+               Object selection = view.getCurrent();
+               if (selection instanceof BookmarkNode) {
+                       BookmarkNode node = (BookmarkNode) selection;
+                       if (node != null) {
+                               String name = node.getName();
+                               boolean flag = MessageDialog.openConfirm(view.getSite().getShell(), Messages.getString("bookmarkview.deleteBookmark"), Messages.getString("bookmarkview.confirm") + name); //$NON-NLS-1$ //$NON-NLS-2$
+                               if (flag) {
+                                       view.deleteCurrent();
+                               }
+                       }
+               }
+       }
+
+       /**
+        * @see org.eclipse.ui.IActionDelegate#selectionChanged(IAction, ISelection)
+        */
+       public void selectionChanged(IAction action, ISelection selection) {
+       }
+
+}