new htmledit.gif and phpedit.gif (Mark Chakerian)
[phpeclipse.git] / archive / net.sourceforge.phpeclipse.quantum.sql / src / com / quantum / wizards / InsertRowPage.java
index cbf7ff1..ecaf832 100644 (file)
@@ -1,11 +1,5 @@
 package com.quantum.wizards;
 
-import com.quantum.Messages;
-import com.quantum.adapters.AdapterFactory;
-import com.quantum.adapters.DatabaseAdapter;
-import com.quantum.model.Bookmark;
-import com.quantum.model.Entity;
-
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.ModifyEvent;
 import org.eclipse.swt.events.ModifyListener;
@@ -15,6 +9,11 @@ import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Label;
 import org.eclipse.swt.widgets.Text;
 
+import com.quantum.Messages;
+import com.quantum.adapters.DatabaseAdapter;
+import com.quantum.model.Bookmark;
+import com.quantum.model.Entity;
+
 public class InsertRowPage extends BaseSQLPage implements SQLPage {
        String[] columnNames;
        Text[] values;
@@ -27,36 +26,22 @@ public class InsertRowPage extends BaseSQLPage implements SQLPage {
 
        public void createControl(Composite parent) {
                System.out.println("page create control"); //$NON-NLS-1$
-               Composite container = new Composite(parent, SWT.NULL);
+               Composite container = new Composite(parent, SWT.V_SCROLL);
                GridLayout layout = new GridLayout();
                container.setLayout(layout);
                layout.numColumns = 2;
 
-               if (row == null) {
-                       System.out.println("Row is null"); //$NON-NLS-1$
-               }
-               if (row.getColumnNames() == null) {
-                       System.out.println("Columns are null"); //$NON-NLS-1$
-               }
-               if (row.getTableData() == null) {
-                       System.out.println("Data is null"); //$NON-NLS-1$
-               }
-               columnNames = row.getColumnNames();
-               String[] data = row.getTableData();
-               for (int i = 0; i < row.getColumnCount(); i++) {
-                       System.out.println("data = " + i + "=" + data[i]); //$NON-NLS-1$ //$NON-NLS-2$
-                       System.out.println("column = " + i + "=" + columnNames[i]); //$NON-NLS-1$ //$NON-NLS-2$
-               }
-               values = new Text[row.getColumnCount()];
+               columnNames = this.results.getColumnNames();
+               values = new Text[columnNames.length];
                new Label(container, SWT.NULL).setText(Messages.getString("InsertRowPage.ColumnName")); //$NON-NLS-1$
                new Label(container, SWT.NULL).setText(Messages.getString("InsertRowPage.Value")); //$NON-NLS-1$
-               for (int i = 0; i < row.getColumnCount(); i++) {
+               for (int i = 0; i < columnNames.length; i++) {
                        Label label = new Label(container, SWT.NULL);
                        label.setText(columnNames[i]);
                        values[i] = new Text(container, SWT.BORDER | SWT.SINGLE);
-                       GridData fullHorizontal = new GridData();
-                       fullHorizontal.horizontalAlignment = GridData.FILL;
-                       values[i].setLayoutData(fullHorizontal);
+                       GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
+                       gridData.widthHint = 150;
+                       values[i].setLayoutData(gridData);
 
                        //values[i].setText(data[i]);
                        values[i].addModifyListener(new ModifyListener() {
@@ -83,9 +68,9 @@ public class InsertRowPage extends BaseSQLPage implements SQLPage {
                System.out.println("Updating query"); //$NON-NLS-1$
                StringBuffer valuesClause = new StringBuffer();
                StringBuffer namesClause = new StringBuffer();
-               Bookmark bookmark = row.getBookmark();
-               Entity entity = row.getEntity();
-               DatabaseAdapter adapter = AdapterFactory.getInstance().getAdapter(bookmark.getType());
+               Bookmark bookmark = this.results.getBookmark();
+               Entity entity = this.results.getEntity();
+               DatabaseAdapter adapter = bookmark.getAdapter();
                
                numColumns = 0;
                for (int i = 0; i < columnNames.length; i++) {
@@ -102,7 +87,7 @@ public class InsertRowPage extends BaseSQLPage implements SQLPage {
                        }
                }
                
-               String query = "INSERT INTO " + row.getTable(); //$NON-NLS-1$
+               String query = "INSERT INTO " + this.results.getEntity().getQuotedTableName(); //$NON-NLS-1$
                if (numColumns > 0) {
                        query += " (" + namesClause + ")";
                        query += " VALUES " + "(" + valuesClause; //$NON-NLS-1$
@@ -116,5 +101,4 @@ public class InsertRowPage extends BaseSQLPage implements SQLPage {
     protected String getQueryText() {
         return this.query.getText();
     }
-
 }
\ No newline at end of file