X-Git-Url: http://git.phpeclipse.com diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/BaseSQLPage.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/BaseSQLPage.java new file mode 100644 index 0000000..459a949 --- /dev/null +++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/BaseSQLPage.java @@ -0,0 +1,49 @@ +package com.quantum.wizards; + +import com.quantum.adapters.DatabaseAdapter; +import com.quantum.model.Bookmark; +import com.quantum.model.Column; +import com.quantum.model.ConnectionException; +import com.quantum.model.Entity; +import com.quantum.sql.TableRow; +import com.quantum.view.ViewHelper; +import com.quantum.view.tableview.TableAdapter; + +import org.eclipse.jface.wizard.WizardPage; + +/** + * @author BC + */ +public abstract class BaseSQLPage extends WizardPage implements SQLPage { + + protected TableRow row; + protected TableAdapter adapter; + + public BaseSQLPage(String pageName) { + super(pageName); + } + public boolean performFinish() { + try { + Bookmark bookmark = this.adapter.getBookmark(); + bookmark.addQuery(getQueryText()); + ViewHelper.tryGetResults(getShell(), bookmark.getConnection(), getQueryText()); + } catch (ConnectionException e) { + e.printStackTrace(); + } + return true; + } + protected abstract String getQueryText(); + protected void appendColumn(StringBuffer whereClause, Entity entity, String columnName, DatabaseAdapter adapter, String value) { + + if (adapter != null && entity != null && entity.getColumn(columnName) != null) { + Column column = entity.getColumn(columnName); + whereClause.append(adapter.quote(value, column.getType(), column.getTypeName())); + } else { + whereClause.append(value); + } + } + public void init(TableRow row, TableAdapter adapter) { + this.row = row; + this.adapter = adapter; + } +}