1 package com.quantum.ui.dialog;
3 import java.sql.SQLException;
5 import com.quantum.Messages;
6 import com.quantum.model.Bookmark;
8 import org.eclipse.jface.dialogs.IDialogConstants;
9 import org.eclipse.jface.dialogs.MessageDialog;
10 import org.eclipse.swt.SWT;
11 import org.eclipse.swt.layout.GridData;
12 import org.eclipse.swt.layout.GridLayout;
13 import org.eclipse.swt.widgets.Composite;
14 import org.eclipse.swt.widgets.Control;
15 import org.eclipse.swt.widgets.Label;
16 import org.eclipse.swt.widgets.Shell;
22 public class SQLExceptionDialog extends MessageDialog {
24 private final SQLException sqlException;
31 private SQLExceptionDialog(Shell parentShell, String dialogTitle,
32 SQLException sqlException) {
33 super(parentShell, dialogTitle, null, sqlException.getLocalizedMessage(), ERROR,
34 new String[]{IDialogConstants.OK_LABEL}, 0);
35 this.sqlException = sqlException;
38 protected Control createCustomArea(Composite parent) {
39 Composite composite = new Composite(parent, SWT.NONE);
40 composite.setLayout(new GridLayout(2, false));
41 composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
43 Label label = new Label(composite, SWT.NONE);
44 label.setText(Messages.getString(SQLExceptionDialog.class, "sqlState"));
45 label = new Label(composite, SWT.NONE);
46 label.setText(this.sqlException.getSQLState() == null
47 ? "" : this.sqlException.getSQLState());
49 label = new Label(composite, SWT.NONE);
50 label.setText(Messages.getString(SQLExceptionDialog.class, "errorCode"));
51 label = new Label(composite, SWT.NONE);
52 label.setText(String.valueOf(this.sqlException.getErrorCode()));
56 public static void openException(Shell shell, Bookmark bookmark, SQLException sqlException) {
57 SQLExceptionDialog dialog = new SQLExceptionDialog(shell,
59 ? Messages.getString(SQLExceptionDialog.class, "title")
61 SQLExceptionDialog.class, "titleWithBookmark",
62 new Object[] { bookmark.getDisplayName() }),