1 package net.sourceforge.phpdt.sql.actions;
3 import java.sql.Connection;
5 import org.eclipse.jface.action.Action;
6 import org.eclipse.jface.action.IAction;
7 import org.eclipse.jface.viewers.ISelection;
8 import org.eclipse.ui.IViewActionDelegate;
9 import org.eclipse.ui.IViewPart;
10 import org.eclipse.ui.IWorkbenchPart;
12 import net.sourceforge.phpdt.sql.Messages;
13 import net.sourceforge.phpdt.sql.view.BookmarkView;
14 import net.sourceforge.phpdt.sql.view.bookmark.BookmarkNode;
16 public class ConnectAction extends Action implements IViewActionDelegate {
17 private BookmarkView view;
19 * Constructor for Action1.
21 public ConnectAction() {
26 * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart)
28 public void setActivePart(IAction action, IWorkbenchPart targetPart) {
32 * @see IActionDelegate#run(IAction)
34 public void run(IAction action) {
39 * @see IActionDelegate#selectionChanged(IAction, ISelection)
41 public void selectionChanged(IAction action, ISelection selection) {
45 * @see org.eclipse.ui.IViewActionDelegate#init(IViewPart)
47 public void init(IViewPart view) {
48 this.view = (BookmarkView) view;
52 * @see org.eclipse.jface.action.IAction#run()
55 BookmarkNode current = view.getCurrentBookmark();
56 view.setStatus(Messages.getString("ConnectAction.ConnectingTo") + current.getName() + "..."); //$NON-NLS-2$ //$NON-NLS-1$
57 Connection con = current.getConnection();
59 view.refreshBookmarkData();
60 view.expandCurrent(current);
62 view.setStatus(Messages.getString("ConnectAction.ErrorConnecting") + current.getName()); //$NON-NLS-1$