1 package com.quantum.util.connection;
3 import java.sql.Connection;
5 import com.quantum.Messages;
6 import com.quantum.model.Bookmark;
7 import com.quantum.model.ConnectionException;
8 import com.quantum.model.NotConnectedException;
9 import com.quantum.ui.dialog.ExceptionDisplayDialog;
10 import com.quantum.ui.dialog.PasswordDialog;
12 import org.eclipse.swt.widgets.Shell;
15 * <p>This utility gets a connection from a bookmark, and handles any UI-specific
16 * interactions such as providing messages to the user and/or prompting for a
21 public class ConnectionUtil {
23 public Connection getConnection(Bookmark bookmark, Shell shell) {
24 Connection connection = null;
26 connection = bookmark.getConnection();
27 } catch (NotConnectedException e) {
28 connection = connect(bookmark, shell);
33 public Connection connect(Bookmark bookmark, Shell shell) {
34 Connection connection = null;
36 connection = bookmark.connect(PasswordDialog.createPasswordFinder(shell));
37 } catch (ConnectionException e) {
38 ExceptionDisplayDialog.openError(shell,
39 Messages.getString(getClass().getName() + ".title"),
40 Messages.getString(getClass().getName() + ".message") +
41 " (Bookmark:"+bookmark.getName()+")", e);