package net.sourceforge.phpdt.sql.actions; import java.sql.Connection; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IAction; import org.eclipse.jface.viewers.ISelection; import org.eclipse.ui.IViewActionDelegate; import org.eclipse.ui.IViewPart; import org.eclipse.ui.IWorkbenchPart; import net.sourceforge.phpdt.sql.Messages; import net.sourceforge.phpdt.sql.view.BookmarkView; import net.sourceforge.phpdt.sql.view.bookmark.BookmarkNode; public class ConnectAction extends Action implements IViewActionDelegate { private BookmarkView view; /** * Constructor for Action1. */ public ConnectAction() { super(); } /** * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart) */ public void setActivePart(IAction action, IWorkbenchPart targetPart) { } /** * @see IActionDelegate#run(IAction) */ public void run(IAction action) { run(); } /** * @see IActionDelegate#selectionChanged(IAction, ISelection) */ public void selectionChanged(IAction action, ISelection selection) { } /** * @see org.eclipse.ui.IViewActionDelegate#init(IViewPart) */ public void init(IViewPart view) { this.view = (BookmarkView) view; } /** * @see org.eclipse.jface.action.IAction#run() */ public void run() { BookmarkNode current = view.getCurrentBookmark(); view.setStatus(Messages.getString("ConnectAction.ConnectingTo") + current.getName() + "..."); //$NON-NLS-2$ //$NON-NLS-1$ Connection con = current.getConnection(); if (con != null) { view.refreshBookmarkData(); view.expandCurrent(current); } else { view.setStatus(Messages.getString("ConnectAction.ErrorConnecting") + current.getName()); //$NON-NLS-1$ } } }