Quantum version 2.4.1
[phpeclipse.git] / archive / net.sourceforge.phpeclipse.quantum.sql / src / com / quantum / wizards / DeleteRowPage.java
index e259f76..10d1fda 100644 (file)
@@ -30,45 +30,32 @@ public class DeleteRowPage 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 = 3;
 
-               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$
-               }
-               Entity entity = row.getEntity();
-               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()];
-               whereValues = new Button[row.getColumnCount()];
+               Entity entity = this.results.getEntity();
+               columnNames = this.results.getColumnNames();
+
+               values = new Text[columnNames.length];
+               whereValues = new Button[columnNames.length];
                new Label(container, SWT.NULL).setText(Messages.getString("DeleteRowPage.ColumnName")); //$NON-NLS-1$
                new Label(container, SWT.NULL).setText(Messages.getString("DeleteRowPage.Value")); //$NON-NLS-1$
                new Label(container, SWT.NULL).setText(Messages.getString("DeleteRowPage.IncludeIn")); //$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);
-                       values[i].setText(data[i]);
-
+                       Object object = this.row == null ? null : this.row.get(i+1);
+                       values[i].setText(object == null ? "" : object.toString());
+                       GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
+                       gridData.widthHint = 150;
+                       values[i].setLayoutData(gridData);
                        values[i].addModifyListener(new ModifyListener() {
-                               public void modifyText(ModifyEvent e) {
+                               public void modifyText(ModifyEvent event) {
                                        updateQuery();
-                               }                               
+                               }
                        });
                        
                        whereValues[i] = new Button(container, SWT.CHECK);
@@ -102,8 +89,8 @@ public class DeleteRowPage extends BaseSQLPage implements SQLPage {
        public void updateQuery() {
                System.out.println(Messages.getString("DeleteRowPage.UpdatingQuery")); //$NON-NLS-1$
                StringBuffer whereClause = new StringBuffer();
-               Bookmark bookmark = row.getBookmark();
-               Entity entity = row.getEntity();
+               Bookmark bookmark = this.results.getBookmark();
+               Entity entity = this.results.getEntity();
                DatabaseAdapter adapter = bookmark.getAdapter();
                
                int numSelected = 0;
@@ -118,7 +105,7 @@ public class DeleteRowPage extends BaseSQLPage implements SQLPage {
                                whereClause.append(")"); //$NON-NLS-1$
                        }
                }
-               String query = "DELETE FROM " + row.getTable(); //$NON-NLS-1$
+               String query = "DELETE FROM " + this.results.getEntity().getQuotedTableName(); //$NON-NLS-1$
                if (numSelected > 0) {
                        query += " WHERE " + whereClause.toString(); //$NON-NLS-1$
                }