1 package com.quantum.wizards;
3 import java.sql.SQLException;
5 import com.quantum.adapters.DatabaseAdapter;
6 import com.quantum.model.Bookmark;
7 import com.quantum.model.Column;
8 import com.quantum.model.ConnectionException;
9 import com.quantum.model.Entity;
10 import com.quantum.model.NotConnectedException;
11 import com.quantum.sql.TableRow;
12 import com.quantum.view.ViewHelper;
13 import com.quantum.view.tableview.TableAdapter;
15 import org.eclipse.jface.wizard.WizardPage;
20 public abstract class BaseSQLPage extends WizardPage implements SQLPage {
22 protected TableRow row;
23 protected TableAdapter adapter;
25 public BaseSQLPage(String pageName) {
28 public boolean performFinish() {
30 Bookmark bookmark = this.adapter.getBookmark();
31 bookmark.addQuery(getQueryText());
32 ViewHelper.tryGetResults(getShell(), bookmark.getConnection(), getQueryText());
33 } catch (ConnectionException e) {
38 protected abstract String getQueryText();
39 protected void appendColumn(StringBuffer whereClause, Entity entity, String columnName, DatabaseAdapter adapter, String value) {
41 if (adapter != null && entity != null && getColumn(entity, columnName) != null) {
42 Column column = getColumn(entity, columnName);
43 whereClause.append(adapter.quote(value, column.getType(), column.getTypeName()));
45 whereClause.append(value);
52 * @throws NotConnectedException
53 * @throws SQLException
55 protected Column getColumn(Entity entity, String columnName) {
57 return entity == null ? null : entity.getColumn(columnName);
58 } catch (NotConnectedException e) {
60 } catch (SQLException e) {
64 public void init(TableRow row, TableAdapter adapter) {
66 this.adapter = adapter;