Added constants from David Foerster to phpsyntax.xml file
[phpeclipse.git] / archive / net.sourceforge.phpeclipse.quantum.sql / src / com / quantum / wizards / BaseSQLPage.java
1 package com.quantum.wizards;
2
3 import com.quantum.adapters.DatabaseAdapter;
4 import com.quantum.model.Bookmark;
5 import com.quantum.model.Column;
6 import com.quantum.model.ConnectionException;
7 import com.quantum.model.Entity;
8 import com.quantum.sql.TableRow;
9 import com.quantum.view.ViewHelper;
10 import com.quantum.view.tableview.TableAdapter;
11
12 import org.eclipse.jface.wizard.WizardPage;
13
14 /**
15  * @author BC
16  */
17 public abstract class BaseSQLPage extends WizardPage implements SQLPage {
18
19     protected TableRow row;
20     protected TableAdapter adapter;
21
22     public BaseSQLPage(String pageName) {
23         super(pageName);
24     }
25     public boolean performFinish() {
26         try {
27             Bookmark bookmark = this.adapter.getBookmark();
28             bookmark.addQuery(getQueryText());
29             ViewHelper.tryGetResults(getShell(), bookmark.getConnection(), getQueryText());
30         } catch (ConnectionException e) {
31             e.printStackTrace();
32         }
33         return true;
34     }
35     protected abstract String getQueryText();
36     protected void appendColumn(StringBuffer whereClause, Entity entity, String columnName, DatabaseAdapter adapter, String value) {
37             
38         if (adapter != null && entity != null && entity.getColumn(columnName) != null) {
39             Column column = entity.getColumn(columnName);
40                 whereClause.append(adapter.quote(value, column.getType(), column.getTypeName()));
41         } else {
42                 whereClause.append(value);
43         }
44     }
45     public void init(TableRow row, TableAdapter adapter) {
46         this.row = row;
47         this.adapter = adapter;
48     }
49 }