1 package net.sourceforge.phpdt.sql.actions;
3 import org.eclipse.jface.action.Action;
4 import org.eclipse.jface.action.IAction;
5 import org.eclipse.jface.viewers.ISelection;
6 import org.eclipse.ui.IViewActionDelegate;
7 import org.eclipse.ui.IViewPart;
8 import org.eclipse.ui.IWorkbenchPart;
10 import net.sourceforge.phpdt.sql.sql.MultiSQLServer;
11 import net.sourceforge.phpdt.sql.sql.SQLHelper;
12 import net.sourceforge.phpdt.sql.view.BookmarkView;
13 import net.sourceforge.phpdt.sql.view.bookmark.BookmarkNode;
15 public class ConnectAction extends Action implements IViewActionDelegate {
16 private SQLHelper helper = new SQLHelper();
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()
56 BookmarkNode current = view.getCurrentBookmark();
57 view.setStatus("Connecting to " + current.getName() + "..."); //$NON-NLS-1$ //$NON-NLS-2$
58 boolean status = MultiSQLServer.getInstance().connect(current);
60 view.refreshBookmarkData();
61 view.expandCurrent(current);
63 view.setStatus("Error while connecting to " + current.getName()); //$NON-NLS-1$