bug 1037094, to much indentation for first comment in a function parameters and defau...
[phpeclipse.git] / net.sourceforge.phpeclipse.wizards / src / net / sourceforge / phpeclipse / wizards / actions / metadata / BaseSQLPage.java
1 package net.sourceforge.phpeclipse.wizards.actions.metadata;
2
3 import java.sql.SQLException;
4
5 import org.eclipse.jface.wizard.WizardPage;
6
7 import com.quantum.adapters.DatabaseAdapter;
8 import com.quantum.model.Column;
9 import com.quantum.model.Entity;
10 import com.quantum.model.NotConnectedException;
11 import com.quantum.util.connection.ConnectionUtil;
12
13 /**
14  * @author BC Holmes
15  */
16 public abstract class BaseSQLPage extends WizardPage implements SQLPage {
17
18     protected Row row;
19     protected Column[] columns;
20 //      protected SQLResultSetResults results;
21         private ConnectionUtil connectionUtil = new ConnectionUtil();
22
23     public BaseSQLPage(String pageName) {
24         super(pageName);
25     }
26     public boolean performFinish() {
27 //              Bookmark bookmark = (Bookmark) this.results.getConnectable();
28 //              try {
29 //                      bookmark.addQuery(getQueryText());
30 //                      SQLResults sqlResults = MultiSQLServer.getInstance().execute(bookmark, 
31 //                                      this.connectionUtil.getConnection(bookmark, getShell()), getQueryText());
32 //                      return sqlResults == null ? false : true;
33 //              } catch (SQLException e) {
34 //                      SQLExceptionDialog.openException(getShell(), bookmark, e);
35 //                      return false;
36 //              }
37       return false;
38         }
39     
40     protected abstract String getQueryText();
41     protected void appendColumn(StringBuffer whereClause, Entity entity, String columnName, DatabaseAdapter adapter, String value) {
42         
43         if (adapter != null && entity != null && getColumn(entity, columnName) != null) {
44             Column column = getColumn(entity, columnName);
45                 whereClause.append(adapter.quote(value, column.getType(), column.getTypeName()));
46         } else {
47                 whereClause.append(value);
48         }
49     }
50     /**
51          * @param entity
52          * @param columnName
53          * @return
54          * @throws NotConnectedException
55          * @throws SQLException
56          */
57         protected Column getColumn(Entity entity, String columnName)  {
58                 try {
59                         return entity == null ? null : entity.getColumn(columnName);
60                 } catch (NotConnectedException e) {
61                         return null;
62                 } catch (SQLException e) {
63                         return null;
64                 }
65         }
66         public void init(Row row, Column[] columns) {
67 //      this.results = results;
68                 this.row = row;
69                 this.columns = columns;
70     }
71 }