Added the PHP wizards again
authorkhartlage <khartlage>
Thu, 18 Dec 2003 20:40:13 +0000 (20:40 +0000)
committerkhartlage <khartlage>
Thu, 18 Dec 2003 20:40:13 +0000 (20:40 +0000)
12 files changed:
archive/net.sourceforge.phpeclipse.sql/.classpath
archive/net.sourceforge.phpeclipse.sql/src/net/sourceforge/phpdt/sql/PHPEclipseSQLPlugin.java
archive/net.sourceforge.phpeclipse.sql/src/net/sourceforge/phpdt/sql/PHPEclipseSQLResources.properties
archive/net.sourceforge.phpeclipse.sql/src/net/sourceforge/phpdt/sql/view/TableView.java
archive/net.sourceforge.phpeclipse.sql/src/net/sourceforge/phpdt/sql/wizards/DeleteRowPage.java
archive/net.sourceforge.phpeclipse.sql/src/net/sourceforge/phpdt/sql/wizards/InsertRowPage.java
archive/net.sourceforge.phpeclipse.sql/src/net/sourceforge/phpdt/sql/wizards/PHPDeleteRowPage.java
archive/net.sourceforge.phpeclipse.sql/src/net/sourceforge/phpdt/sql/wizards/PHPInsertRowPage.java
archive/net.sourceforge.phpeclipse.sql/src/net/sourceforge/phpdt/sql/wizards/PHPSelectRowPage.java
archive/net.sourceforge.phpeclipse.sql/src/net/sourceforge/phpdt/sql/wizards/PHPUpdateRowPage.java
archive/net.sourceforge.phpeclipse.sql/src/net/sourceforge/phpdt/sql/wizards/SQLPage.java
archive/net.sourceforge.phpeclipse.sql/src/net/sourceforge/phpdt/sql/wizards/UpdateRowPage.java

index d8f18b1..33c942c 100644 (file)
@@ -28,6 +28,5 @@
     <classpathentry kind="var"
         path="ECLIPSE_HOME/plugins/org.eclipse.ui.editors_2.1.0/editors.jar" sourcepath="ORG_ECLIPSE_PLATFORM_SOURCE_SRC/org.eclipse.ui.editors_2.1.0/editorssrc.zip"/>
     <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
-    <classpathentry kind="lib" path="D:/bin/eclipse/Plugins/org.eclipse.jdt.junit_2.1.1/junitsupport.jar"/>
     <classpathentry kind="output" path="bin"/>
 </classpath>
index 7d3cbec..9fbd506 100644 (file)
@@ -62,10 +62,10 @@ implements IConstants {
         */
        protected void readStateFrom(File target) {
                String fileName = target.getName();
-               if (!fileName.endsWith("ext")) { //$NON-NLS-1$
-                       // It's the 2.0 format for preferences
-                       BookmarkContentProvider.getInstance().load(target);
-               } else {
+//             if (!fileName.endsWith("ext")) { //$NON-NLS-1$
+//                     // It's the 2.0 format for preferences
+//                     BookmarkContentProvider.getInstance().load(target);
+//             } else {
                        //It's the 2.1 format for preferences and subsets
                        XmlDocument doc = new XmlDocument();
                        FileInputStream source = null;
@@ -94,7 +94,7 @@ implements IConstants {
                        Element root = doc.getDocumentElement();
                        BookmarkContentProvider.getInstance().importXML(root);
                        SubsetContentProvider.getInstance().importXML(root);
-               }
+//             }
        }
 
        public void startup() throws CoreException {
index a347ea8..118d824 100644 (file)
@@ -32,6 +32,10 @@ tableview.refresh = Refresh Table
 tableview.copy = Copy Table Selection To Clipboard
 tableview.selectAll = Select All Table Rows
 tableview.close = Close Table
+tableview.phpselect = PHP Select...
+tableview.phpupdate = PHP Update...
+tableview.phpinsert = PHP Insert...
+tableview.phpdelete = PHP Delete...
 tableview.update = Update...
 tableview.insert = Insert...
 tableview.delete = Delete...
index d0048a5..eb24275 100644 (file)
@@ -1,5 +1,23 @@
 package net.sourceforge.phpdt.sql.view;
 
+import net.sourceforge.phpdt.sql.Messages;
+import net.sourceforge.phpdt.sql.PHPEclipseSQLPlugin;
+import net.sourceforge.phpdt.sql.actions.CloseTableAction;
+import net.sourceforge.phpdt.sql.actions.RefreshTableAction;
+import net.sourceforge.phpdt.sql.sql.SQLResults;
+import net.sourceforge.phpdt.sql.sql.TableRow;
+import net.sourceforge.phpdt.sql.view.bookmark.BookmarkNode;
+import net.sourceforge.phpdt.sql.view.tableview.TableAdapter;
+import net.sourceforge.phpdt.sql.wizards.DeleteRowPage;
+import net.sourceforge.phpdt.sql.wizards.InsertRowPage;
+import net.sourceforge.phpdt.sql.wizards.PHPDeleteRowPage;
+import net.sourceforge.phpdt.sql.wizards.PHPInsertRowPage;
+import net.sourceforge.phpdt.sql.wizards.PHPSelectRowPage;
+import net.sourceforge.phpdt.sql.wizards.PHPUpdateRowPage;
+import net.sourceforge.phpdt.sql.wizards.SQLRowWizard;
+import net.sourceforge.phpdt.sql.wizards.SortFilterPage;
+import net.sourceforge.phpdt.sql.wizards.UpdateRowPage;
+
 import org.eclipse.jface.action.Action;
 import org.eclipse.jface.action.IMenuListener;
 import org.eclipse.jface.action.IMenuManager;
@@ -28,403 +46,417 @@ import org.eclipse.ui.ISelectionListener;
 import org.eclipse.ui.IWorkbenchPart;
 import org.eclipse.ui.part.ViewPart;
 
-import net.sourceforge.phpdt.sql.Messages;
-import net.sourceforge.phpdt.sql.PHPEclipseSQLPlugin;
-import net.sourceforge.phpdt.sql.actions.CloseTableAction;
-import net.sourceforge.phpdt.sql.actions.RefreshTableAction;
-import net.sourceforge.phpdt.sql.sql.SQLResults;
-import net.sourceforge.phpdt.sql.sql.TableRow;
-import net.sourceforge.phpdt.sql.view.bookmark.BookmarkNode;
-import net.sourceforge.phpdt.sql.view.tableview.TableAdapter;
-import net.sourceforge.phpdt.sql.wizards.DeleteRowPage;
-import net.sourceforge.phpdt.sql.wizards.InsertRowPage;
-import net.sourceforge.phpdt.sql.wizards.SQLRowWizard;
-import net.sourceforge.phpdt.sql.wizards.SortFilterPage;
-import net.sourceforge.phpdt.sql.wizards.UpdateRowPage;
-
 public class TableView extends ViewPart implements ISelectionListener {
-       private Clipboard clip;
-       private RefreshTableAction refreshTableAction;
-       private CloseTableAction closeTableAction;
-       private static TableView instance = null;
-       private TabFolder tabs;
-       private Composite parent;
-       public TableView() {
-               super();
-       }
-       public void setFocus() {
-       }
-       public static TableView getInstance() {
-               return instance;
-       }
-       public void closeCurrent() {
-               TabItem item = tabs.getItem(tabs.getSelectionIndex());
-               item.dispose();
-       }
-       public void refreshCurrent() {
-               TabItem item = tabs.getItem(tabs.getSelectionIndex());
-               TableAdapter adapter = (TableAdapter) item.getData();
-               BookmarkView bookmarkView = BookmarkView.getInstance();
-               BookmarkNode bookmark = bookmarkView.getCurrentBookmark();
-               String table = adapter.getTable();
-               if (table == null) {
-                       loadTable(bookmark, item, null, null, true, true);
-               } else {
-                       loadTable(bookmark, item, null, null, true, true);
-               }
-       }
-       public void loadQuery(BookmarkNode bookmark, SQLResults results) {
-               loadTable(bookmark, null, null, results, true, false);
-       }
-       public void loadTable(BookmarkNode bookmark, String table) {
-               loadTable(bookmark, null, table, null, false, true);
-       }
-       public void loadTable(BookmarkNode bookmark, TabItem tabItem, String entity, SQLResults results, boolean query, boolean reload) {
-               TableAdapter adapter;
-               if (tabItem == null) {
-                       tabItem = new TabItem(tabs, SWT.NONE);
-                       if (query) {
-                               adapter = TableAdapter.createFromQuery(bookmark, results);
-                       } else {
-                               adapter = TableAdapter.createFromTable(bookmark, entity);
-                       }
-                       tabItem.setData(adapter);
-               } else {
-                       adapter = (TableAdapter) tabItem.getData();
-               }
+  private Clipboard clip;
+  private RefreshTableAction refreshTableAction;
+  private CloseTableAction closeTableAction;
+  private static TableView instance = null;
+  private TabFolder tabs;
+  private Composite parent;
+  public TableView() {
+    super();
+  }
+  public void setFocus() {
+  }
+  public static TableView getInstance() {
+    return instance;
+  }
+  public void closeCurrent() {
+    TabItem item = tabs.getItem(tabs.getSelectionIndex());
+    item.dispose();
+  }
+  public void refreshCurrent() {
+    TabItem item = tabs.getItem(tabs.getSelectionIndex());
+    TableAdapter adapter = (TableAdapter) item.getData();
+    BookmarkView bookmarkView = BookmarkView.getInstance();
+    BookmarkNode bookmark = bookmarkView.getCurrentBookmark();
+    String table = adapter.getTable();
+    if (table == null) {
+      loadTable(bookmark, item, null, null, true, true);
+    } else {
+      loadTable(bookmark, item, null, null, true, true);
+    }
+  }
+  public void loadQuery(BookmarkNode bookmark, SQLResults results) {
+    loadTable(bookmark, null, null, results, true, false);
+  }
+  public void loadTable(BookmarkNode bookmark, String table) {
+    loadTable(bookmark, null, table, null, false, true);
+  }
+  public void loadTable(BookmarkNode bookmark, TabItem tabItem, String entity, SQLResults results, boolean query, boolean reload) {
+    TableAdapter adapter;
+    if (tabItem == null) {
+      tabItem = new TabItem(tabs, SWT.NONE);
+      if (query) {
+        adapter = TableAdapter.createFromQuery(bookmark, results);
+      } else {
+        adapter = TableAdapter.createFromTable(bookmark, entity);
+      }
+      tabItem.setData(adapter);
+    } else {
+      adapter = (TableAdapter) tabItem.getData();
+    }
+
+    final TableAdapter ta = adapter;
+
+    Composite main = new Composite(tabs, SWT.NONE);
+    GridLayout layout = new GridLayout(1, false);
+    layout.horizontalSpacing = 0;
+    layout.verticalSpacing = 0;
+    main.setLayout(layout);
+
+    // load up main
+    ToolBar toolbar = new ToolBar(main, SWT.HORIZONTAL);
+    final Table table = new Table(main, SWT.FULL_SELECTION | SWT.MULTI);
+    final Label label = new Label(main, SWT.NULL);
+
+    final Action copyAction = new Action() {
+      public void run() {
+        TableItem items[] = table.getSelection();
+        StringBuffer text = new StringBuffer();
+        for (int i = 0; i < items.length; i++) {
+          int columns = table.getColumnCount();
+          for (int col = 0; col < columns; col++) {
+            text.append(items[i].getText(col));
+            text.append('\t');
+          }
+          text.append('\n');
+        }
+        clip.setContents(new Object[] { text.toString()}, new Transfer[] { TextTransfer.getInstance()});
+      }
+    };
+    final Action selectAllAction = new Action() {
+      public void run() {
+        table.selectAll();
+      }
+    };
+
+    // load toobar
+    ToolItem toolItem = new ToolItem(toolbar, SWT.PUSH);
+    toolItem.setImage(PHPEclipseSQLPlugin.getImage("refresh.gif")); //$NON-NLS-1$
+    toolItem.setToolTipText(Messages.getString("tableview.refresh")); //$NON-NLS-1$
+    toolItem.addSelectionListener(new SelectionListener() {
+      public void widgetDefaultSelected(SelectionEvent e) {
+      }
+      public void widgetSelected(SelectionEvent e) {
+        refreshTableAction.run();
+      }
+    });
+    toolItem = new ToolItem(toolbar, SWT.PUSH);
+    toolItem.setImage(PHPEclipseSQLPlugin.getImage("copy.gif")); //$NON-NLS-1$
+    toolItem.setToolTipText(Messages.getString("tableview.copy")); //$NON-NLS-1$
+    toolItem.addSelectionListener(new SelectionListener() {
+      public void widgetDefaultSelected(SelectionEvent e) {
+      }
+      public void widgetSelected(SelectionEvent e) {
+        copyAction.run();
+      }
+    });
+    toolItem = new ToolItem(toolbar, SWT.PUSH);
+    toolItem.setImage(PHPEclipseSQLPlugin.getImage("table.gif")); //$NON-NLS-1$
+    toolItem.setToolTipText(Messages.getString("tableview.selectAll")); //$NON-NLS-1$
+    toolItem.addSelectionListener(new SelectionListener() {
+      public void widgetDefaultSelected(SelectionEvent e) {
+      }
+      public void widgetSelected(SelectionEvent e) {
+        selectAllAction.run();
+      }
+    });
+
+    ToolItem filter = new ToolItem(toolbar, SWT.PUSH);
+    filter.setImage(PHPEclipseSQLPlugin.getImage("filter.gif")); //$NON-NLS-1$
+    filter.setToolTipText(Messages.getString("tableview.filterSort")); //$NON-NLS-1$
+
+    toolItem = new ToolItem(toolbar, SWT.SEPARATOR);
 
-               final TableAdapter ta = adapter;
-               
-               Composite main = new Composite(tabs, SWT.NONE);
-               GridLayout layout = new GridLayout(1, false);
-               layout.horizontalSpacing = 0;
-               layout.verticalSpacing = 0;
-               main.setLayout(layout);
+    final ToolItem fullMode = new ToolItem(toolbar, SWT.PUSH | SWT.CHECK);
 
-               // load up main
-               ToolBar toolbar = new ToolBar(main, SWT.HORIZONTAL);
-               final Table table = new Table(main, SWT.FULL_SELECTION | SWT.MULTI);
-               final Label label = new Label(main, SWT.NULL);
+    final ToolItem previous = new ToolItem(toolbar, SWT.PUSH);
+    final ToolItem next = new ToolItem(toolbar, SWT.PUSH);
 
-               final Action copyAction = new Action() {
-                       public void run() {
-                               TableItem items[] = table.getSelection();
-                               StringBuffer text = new StringBuffer();
-                               for (int i = 0; i < items.length; i++) {
-                                       int columns = table.getColumnCount();
-                                       for (int col = 0; col < columns; col++) {
-                                               text.append(items[i].getText(col));
-                                               text.append('\t');
-                                       }
-                                       text.append('\n');
-                               }
-                               clip.setContents(
-                                       new Object[] { text.toString()},
-                                       new Transfer[] { TextTransfer.getInstance()});
-                       }
-               };
-               final Action selectAllAction = new Action() {
-                       public void run() {
-                               table.selectAll();
-                       }
-               };
+    fullMode.setImage(PHPEclipseSQLPlugin.getImage("fulldata.gif")); //$NON-NLS-1$
+    fullMode.setToolTipText(Messages.getString("tableview.showAll")); //$NON-NLS-1$
+    fullMode.setSelection(false);
+    fullMode.addSelectionListener(new SelectionListener() {
+      public void widgetDefaultSelected(SelectionEvent e) {
+      }
+      public void widgetSelected(SelectionEvent e) {
+        if (ta.getPageSize() == Integer.MAX_VALUE) {
+          ta.resetMode();
+        } else {
+          ta.fullMode();
+        }
+        ta.loadData();
+        table.removeAll();
+        for (int i = table.getColumnCount() - 1; i >= 0; i--) {
+          table.getColumn(i).dispose();
+        }
+        ta.loadTable(table);
+        label.setText(ta.getStatusString());
+        previous.setEnabled(ta.hasPreviousPage());
+        next.setEnabled(ta.hasNextPage());
+      }
+    });
+    previous.setImage(PHPEclipseSQLPlugin.getImage("previous.gif")); //$NON-NLS-1$
+    previous.setToolTipText("Previous"); //$NON-NLS-1$
+    previous.addSelectionListener(new SelectionListener() {
+      public void widgetDefaultSelected(SelectionEvent e) {
+      }
+      public void widgetSelected(SelectionEvent e) {
+        ta.previousPage();
+        ta.loadData();
+        table.removeAll();
+        for (int i = table.getColumnCount() - 1; i >= 0; i--) {
+          table.getColumn(i).dispose();
+        }
+        ta.loadTable(table);
+        label.setText(ta.getStatusString());
+        previous.setEnabled(ta.hasPreviousPage());
+        next.setEnabled(ta.hasNextPage());
+      }
+    });
+    next.setImage(PHPEclipseSQLPlugin.getImage("next.gif")); //$NON-NLS-1$
+    next.setToolTipText("Next"); //$NON-NLS-1$
+    next.addSelectionListener(new SelectionListener() {
+      public void widgetDefaultSelected(SelectionEvent e) {
+      }
+      public void widgetSelected(SelectionEvent e) {
+        ta.nextPage();
+        ta.loadData();
+        table.removeAll();
+        for (int i = table.getColumnCount() - 1; i >= 0; i--) {
+          table.getColumn(i).dispose();
+        }
+        ta.loadTable(table);
+        label.setText(ta.getStatusString());
+        previous.setEnabled(ta.hasPreviousPage());
+        next.setEnabled(ta.hasNextPage());
+      }
+    });
 
-               // load toobar
-               ToolItem toolItem = new ToolItem(toolbar, SWT.PUSH);
-               toolItem.setImage(PHPEclipseSQLPlugin.getImage("refresh.gif")); //$NON-NLS-1$
-               toolItem.setToolTipText(Messages.getString("tableview.refresh")); //$NON-NLS-1$
-               toolItem.addSelectionListener(new SelectionListener() {
-                       public void widgetDefaultSelected(SelectionEvent e) {
-                       }
-                       public void widgetSelected(SelectionEvent e) {
-                               refreshTableAction.run();
-                       }
-               });
-               toolItem = new ToolItem(toolbar, SWT.PUSH);
-               toolItem.setImage(PHPEclipseSQLPlugin.getImage("copy.gif")); //$NON-NLS-1$
-               toolItem.setToolTipText(Messages.getString("tableview.copy")); //$NON-NLS-1$
-               toolItem.addSelectionListener(new SelectionListener() {
-                       public void widgetDefaultSelected(SelectionEvent e) {
-                       }
-                       public void widgetSelected(SelectionEvent e) {
-                               copyAction.run();
-                       }
-               });
-               toolItem = new ToolItem(toolbar, SWT.PUSH);
-               toolItem.setImage(PHPEclipseSQLPlugin.getImage("table.gif")); //$NON-NLS-1$
-               toolItem.setToolTipText(Messages.getString("tableview.selectAll")); //$NON-NLS-1$
-               toolItem.addSelectionListener(new SelectionListener() {
-                       public void widgetDefaultSelected(SelectionEvent e) {
-                       }
-                       public void widgetSelected(SelectionEvent e) {
-                               selectAllAction.run();
-                       }
-               });
+    toolItem = new ToolItem(toolbar, SWT.SEPARATOR);
 
-               ToolItem filter = new ToolItem(toolbar, SWT.PUSH);
-               filter.setImage(PHPEclipseSQLPlugin.getImage("filter.gif")); //$NON-NLS-1$
-               filter.setToolTipText(Messages.getString("tableview.filterSort")); //$NON-NLS-1$
+    toolItem = new ToolItem(toolbar, SWT.PUSH);
+    toolItem.setImage(PHPEclipseSQLPlugin.getImage("close.gif")); //$NON-NLS-1$
+    toolItem.setToolTipText(Messages.getString("tableview.close")); //$NON-NLS-1$
+    toolItem.addSelectionListener(new SelectionListener() {
+      public void widgetDefaultSelected(SelectionEvent e) {
+      }
+      public void widgetSelected(SelectionEvent e) {
+        closeTableAction.run();
+      }
+    });
 
-               toolItem = new ToolItem(toolbar, SWT.SEPARATOR);
+    // load table
+    if (reload) {
+      adapter.resetOffset();
+      adapter.loadData();
+    }
+    adapter.loadTable(table);
+    String tableName = adapter.getTable();
+    if (tableName != null) {
+      tabItem.setText(tableName);
+    } else {
+      tabItem.setText(adapter.getQuery());
+    }
 
-               final ToolItem fullMode = new ToolItem(toolbar, SWT.PUSH | SWT.CHECK);
+    previous.setEnabled(adapter.hasPreviousPage());
+    next.setEnabled(adapter.hasNextPage());
+    label.setText(ta.getStatusString());
 
-               final ToolItem previous = new ToolItem(toolbar, SWT.PUSH);
-               final ToolItem next = new ToolItem(toolbar, SWT.PUSH);
+    GridData gridData = new GridData();
+    gridData.horizontalAlignment = GridData.FILL;
+    gridData.verticalAlignment = GridData.FILL;
+    gridData.grabExcessHorizontalSpace = true;
+    gridData.grabExcessVerticalSpace = true;
+    table.setLayoutData(gridData);
 
-               fullMode.setImage(PHPEclipseSQLPlugin.getImage("fulldata.gif")); //$NON-NLS-1$
-               fullMode.setToolTipText(Messages.getString("tableview.showAll")); //$NON-NLS-1$
-               fullMode.setSelection(false);
-               fullMode.addSelectionListener(new SelectionListener() {
-                       public void widgetDefaultSelected(SelectionEvent e) {
-                       }
-                       public void widgetSelected(SelectionEvent e) {
-                               if (ta.getPageSize() == Integer.MAX_VALUE) {
-                                       ta.resetMode();
-                               } else {
-                                       ta.fullMode();
-                               }
-                               ta.loadData();
-                               table.removeAll();
-                               for (int i = table.getColumnCount() - 1; i >= 0; i--) {
-                                       table.getColumn(i).dispose();
-                               }
-                               ta.loadTable(table);
-                               label.setText(ta.getStatusString());
-                               previous.setEnabled(ta.hasPreviousPage());
-                               next.setEnabled(ta.hasNextPage());
-                       }
-               });
-               previous.setImage(PHPEclipseSQLPlugin.getImage("previous.gif")); //$NON-NLS-1$
-               previous.setToolTipText("Previous"); //$NON-NLS-1$
-               previous.addSelectionListener(new SelectionListener() {
-                       public void widgetDefaultSelected(SelectionEvent e) {
-                       }
-                       public void widgetSelected(SelectionEvent e) {
-                               ta.previousPage();
-                               ta.loadData();
-                               table.removeAll();
-                               for (int i = table.getColumnCount() - 1; i >= 0; i--) {
-                                       table.getColumn(i).dispose();
-                               }
-                               ta.loadTable(table);
-                               label.setText(ta.getStatusString());
-                               previous.setEnabled(ta.hasPreviousPage());
-                               next.setEnabled(ta.hasNextPage());
-                       }
-               });
-               next.setImage(PHPEclipseSQLPlugin.getImage("next.gif")); //$NON-NLS-1$
-               next.setToolTipText("Next"); //$NON-NLS-1$
-               next.addSelectionListener(new SelectionListener() {
-                       public void widgetDefaultSelected(SelectionEvent e) {
-                       }
-                       public void widgetSelected(SelectionEvent e) {
-                               ta.nextPage();
-                               ta.loadData();
-                               table.removeAll();
-                               for (int i = table.getColumnCount() - 1; i >= 0; i--) {
-                                       table.getColumn(i).dispose();
-                               }
-                               ta.loadTable(table);
-                               label.setText(ta.getStatusString());
-                               previous.setEnabled(ta.hasPreviousPage());
-                               next.setEnabled(ta.hasNextPage());
-                       }
-               });
+    gridData = new GridData();
+    gridData.horizontalAlignment = GridData.FILL;
+    label.setLayoutData(gridData);
 
-               toolItem = new ToolItem(toolbar, SWT.SEPARATOR);
+    // create empty table row
+    TableColumn[] columns = table.getColumns();
+    String columnNames[] = new String[columns.length];
+    for (int i = 0; i < columns.length; i++) {
+      columnNames[i] = columns[i].getText();
+    }
+    String data[] = new String[columnNames.length];
+    for (int i = 0; i < columns.length; i++) {
+      data[i] = ""; //$NON-NLS-1$
+    }
 
-               toolItem = new ToolItem(toolbar, SWT.PUSH);
-               toolItem.setImage(PHPEclipseSQLPlugin.getImage("close.gif")); //$NON-NLS-1$
-               toolItem.setToolTipText(Messages.getString("tableview.close")); //$NON-NLS-1$
-               toolItem.addSelectionListener(new SelectionListener() {
-                                                                                 public void widgetDefaultSelected(SelectionEvent e) {
-                                                                                 }
-                                                                                 public void widgetSelected(SelectionEvent e) {
-                                                                                         closeTableAction.run();
-                                                                                 }
-                                                                         });
+    final TableRow emptyRow = new TableRow(ta.getBookmark(), ta.getTable(), columnNames, data);
 
-               // load table
-               if (reload) {
-                       adapter.resetOffset();
-                       adapter.loadData();
-               }
-               adapter.loadTable(table);
-               String tableName = adapter.getTable();
-               if (tableName != null) {
-                       tabItem.setText(tableName);
-               } else {
-                       tabItem.setText(adapter.getQuery());
-               }
+    filter.addSelectionListener(new SelectionListener() {
+      public void widgetDefaultSelected(SelectionEvent e) {
+      }
+      public void widgetSelected(SelectionEvent e) {
+        SortFilterPage page = new SortFilterPage(""); //$NON-NLS-1$
+        SQLRowWizard wizard = new SQLRowWizard();
+        wizard.init(Messages.getString("TableView.FilterAndSort"), page, emptyRow, ta); //$NON-NLS-1$
+        WizardDialog dialog = new WizardDialog(getSite().getShell(), wizard);
+        dialog.open();
+      }
+    });
 
-               previous.setEnabled(adapter.hasPreviousPage());
-               next.setEnabled(adapter.hasNextPage());
-               label.setText(ta.getStatusString());
-               
-               GridData gridData = new GridData();
-               gridData.horizontalAlignment = GridData.FILL;
-               gridData.verticalAlignment = GridData.FILL;
-               gridData.grabExcessHorizontalSpace = true;
-               gridData.grabExcessVerticalSpace = true;
-               table.setLayoutData(gridData);
+    final Action defaultEncodingAction = new Action() {
+      public void run() {
+        ta.setEncoding(TableAdapter.DEFAULT);
+      }
+    };
+    defaultEncodingAction.setText(Messages.getString("tableview.defaultEncoding")); //$NON-NLS-1$
+    final Action UTF8EncodingAction = new Action() {
+      public void run() {
+        ta.setEncoding(TableAdapter.UTF_8);
+      }
+    };
+    UTF8EncodingAction.setText(Messages.getString("tableview.UTF8Encoding")); //$NON-NLS-1$
+    final Action UTF16EncodingAction = new Action() {
+      public void run() {
+        ta.setEncoding(TableAdapter.UTF_16);
+      }
+    };
+    UTF16EncodingAction.setText(Messages.getString("tableview.UTF16Encoding")); //$NON-NLS-1$
 
-               gridData = new GridData();
-               gridData.horizontalAlignment = GridData.FILL;
-               label.setLayoutData(gridData);
+    IMenuListener menuListener = new IMenuListener() {
+      public void menuAboutToShow(IMenuManager mgr) {
+        if (ta.getTable() != null) {
+          TableItem[] selection = table.getSelection();
+          TableColumn[] columns = table.getColumns();
+          String columnNames[] = new String[columns.length];
+          for (int i = 0; i < columns.length; i++) {
+            columnNames[i] = columns[i].getText();
+          }
+          String data[] = new String[columnNames.length];
+          if (selection != null && selection.length > 0) {
+            TableItem sel = selection[0];
+            for (int i = 0; i < columns.length; i++) {
+              data[i] = sel.getText(i);
+            }
+          } else {
+            for (int i = 0; i < columns.length; i++) {
+              data[i] = ""; //$NON-NLS-1$
+            }
+          }
+          final TableRow row = new TableRow(ta.getBookmark(), ta.getTable(), columnNames, data);
+          Action phpSelectAction = new Action() {
+            public void run() {
+                                                       PHPSelectRowPage page = new PHPSelectRowPage(""); //$NON-NLS-1$
+              SQLRowWizard wizard = new SQLRowWizard();
+              wizard.init(Messages.getString("TableView.UpdateRow"), page, row, ta); //$NON-NLS-1$
+              WizardDialog dialog = new WizardDialog(getSite().getShell(), wizard);
+              dialog.open();
+            }
+          };
+          phpSelectAction.setText(Messages.getString("tableview.phpselect")); //$NON-NLS-1$
 
-               // create empty table row
-               TableColumn[] columns = table.getColumns();
-               String columnNames[] = new String[columns.length];
-               for (int i = 0; i < columns.length; i++) {
-                       columnNames[i] = columns[i].getText();
-               }
-               String data[] = new String[columnNames.length];
-               for (int i = 0; i < columns.length; i++) {
-                       data[i] = ""; //$NON-NLS-1$
-               }
-               
-               final TableRow emptyRow =
-                       new TableRow(ta.getBookmark(), ta.getTable(), columnNames, data);
-               
-               filter.addSelectionListener(new SelectionListener() {
-                       public void widgetDefaultSelected(SelectionEvent e) {
-                       }
-                       public void widgetSelected(SelectionEvent e) {
-                                       SortFilterPage page = new SortFilterPage(""); //$NON-NLS-1$
-                                       SQLRowWizard wizard = new SQLRowWizard();
-                                       wizard.init(Messages.getString("TableView.FilterAndSort"), page, emptyRow, ta); //$NON-NLS-1$
-                                       WizardDialog dialog =
-                                               new WizardDialog(
-                                                       getSite().getShell(),
-                                                       wizard);
-                                       dialog.open();
-                       }
-               });
+          Action phpUpdateAction = new Action() {
+            public void run() {
+                                                       PHPUpdateRowPage page = new PHPUpdateRowPage(""); //$NON-NLS-1$
+              SQLRowWizard wizard = new SQLRowWizard();
+              wizard.init(Messages.getString("TableView.UpdateRow"), page, row, ta); //$NON-NLS-1$
+              WizardDialog dialog = new WizardDialog(getSite().getShell(), wizard);
+              dialog.open();
+            }
+          };
+          phpUpdateAction.setText(Messages.getString("tableview.phpupdate")); //$NON-NLS-1$
+          Action phpInsertAction = new Action() {
+            public void run() {
+              PHPInsertRowPage page = new PHPInsertRowPage(""); //$NON-NLS-1$
+              SQLRowWizard wizard = new SQLRowWizard();
+              wizard.init(Messages.getString("TableView.InsertRow"), page, row, ta); //$NON-NLS-1$
+              WizardDialog dialog = new WizardDialog(getSite().getShell(), wizard);
+              dialog.open();
+            }
+          };
+          phpInsertAction.setText(Messages.getString("tableview.phpinsert")); //$NON-NLS-1$
+          Action phpDeleteAction = new Action() {
+            public void run() {
+              PHPDeleteRowPage page = new PHPDeleteRowPage(""); //$NON-NLS-1$
+              SQLRowWizard wizard = new SQLRowWizard();
+              wizard.init(Messages.getString("TableView.DeleteRow"), page, row, ta); //$NON-NLS-1$
+              WizardDialog dialog = new WizardDialog(getSite().getShell(), wizard);
+              dialog.open();
+            }
+          };
+          phpDeleteAction.setText(Messages.getString("tableview.phpdelete")); //$NON-NLS-1$
 
+          Action updateAction = new Action() {
+            public void run() {
+              UpdateRowPage page = new UpdateRowPage(""); //$NON-NLS-1$
+              SQLRowWizard wizard = new SQLRowWizard();
+              wizard.init(Messages.getString("TableView.UpdateRow"), page, row, ta); //$NON-NLS-1$
+              WizardDialog dialog = new WizardDialog(getSite().getShell(), wizard);
+              dialog.open();
+            }
+          };
+          updateAction.setText(Messages.getString("tableview.update")); //$NON-NLS-1$
+          Action insertAction = new Action() {
+            public void run() {
+              InsertRowPage page = new InsertRowPage(""); //$NON-NLS-1$
+              SQLRowWizard wizard = new SQLRowWizard();
+              wizard.init(Messages.getString("TableView.InsertRow"), page, row, ta); //$NON-NLS-1$
+              WizardDialog dialog = new WizardDialog(getSite().getShell(), wizard);
+              dialog.open();
+            }
+          };
+          insertAction.setText(Messages.getString("tableview.insert")); //$NON-NLS-1$
+          Action deleteAction = new Action() {
+            public void run() {
+              DeleteRowPage page = new DeleteRowPage(""); //$NON-NLS-1$
+              SQLRowWizard wizard = new SQLRowWizard();
+              wizard.init(Messages.getString("TableView.DeleteRow"), page, row, ta); //$NON-NLS-1$
+              WizardDialog dialog = new WizardDialog(getSite().getShell(), wizard);
+              dialog.open();
+            }
+          };
+          deleteAction.setText(Messages.getString("tableview.delete")); //$NON-NLS-1$
+          mgr.add(phpSelectAction);
+          mgr.add(phpInsertAction);
+          mgr.add(phpUpdateAction);
+          mgr.add(phpDeleteAction);
 
-               final Action defaultEncodingAction = new Action() {
-                       public void run() {
-                               ta.setEncoding(TableAdapter.DEFAULT);
-                       }
-               };
-               defaultEncodingAction.setText(Messages.getString("tableview.defaultEncoding")); //$NON-NLS-1$
-               final Action UTF8EncodingAction = new Action() {
-                       public void run() {
-                               ta.setEncoding(TableAdapter.UTF_8);
-                       }
-               };
-               UTF8EncodingAction.setText(Messages.getString("tableview.UTF8Encoding")); //$NON-NLS-1$
-               final Action UTF16EncodingAction = new Action() {
-                       public void run() {
-                               ta.setEncoding(TableAdapter.UTF_16);
-                       }
-               };
-               UTF16EncodingAction.setText(Messages.getString("tableview.UTF16Encoding")); //$NON-NLS-1$
+          mgr.add(insertAction);
+          mgr.add(updateAction);
+          mgr.add(deleteAction);
+        }
+        mgr.add(defaultEncodingAction);
+        mgr.add(UTF8EncodingAction);
+        mgr.add(UTF16EncodingAction);
+      }
+    };
 
-               IMenuListener menuListener = new IMenuListener() {
-                       public void menuAboutToShow(IMenuManager mgr) {
-                               if (ta.getTable() != null) {
-                                       TableItem[] selection = table.getSelection();
-                                       TableColumn[] columns = table.getColumns();
-                                       String columnNames[] = new String[columns.length];
-                                       for (int i = 0; i < columns.length; i++) {
-                                               columnNames[i] = columns[i].getText();
-                                       }
-                                       String data[] = new String[columnNames.length];
-                                       if (selection != null && selection.length > 0) {
-                                               TableItem sel = selection[0];
-                                               for (int i = 0; i < columns.length; i++) {
-                                                       data[i] = sel.getText(i);
-                                               }
-                                       } else {
-                                               for (int i = 0; i < columns.length; i++) {
-                                                       data[i] = ""; //$NON-NLS-1$
-                                               }
-                                       }
-                                       final TableRow row =
-                                               new TableRow(ta.getBookmark(), ta.getTable(), columnNames, data);
-                                               Action updateAction = new Action() {
-                                                       public void run() {
-                                                               UpdateRowPage page = new UpdateRowPage(""); //$NON-NLS-1$
-                                                               SQLRowWizard wizard = new SQLRowWizard();
-                                                               wizard.init(Messages.getString("TableView.UpdateRow"), page, row, ta); //$NON-NLS-1$
-                                                               WizardDialog dialog =
-                                                                       new WizardDialog(
-                                                                               getSite().getShell(),
-                                                                               wizard);
-                                                               dialog.open();
-                                                       }
-                                               };
-                                               updateAction.setText(Messages.getString("tableview.update")); //$NON-NLS-1$
-                                               Action insertAction = new Action() {
-                                                       public void run() {
-                                                               InsertRowPage page = new InsertRowPage(""); //$NON-NLS-1$
-                                                               SQLRowWizard wizard = new SQLRowWizard();
-                                                               wizard.init(Messages.getString("TableView.InsertRow"), page, row, ta); //$NON-NLS-1$
-                                                               WizardDialog dialog =
-                                                                       new WizardDialog(
-                                                                               getSite().getShell(),
-                                                                               wizard);
-                                                               dialog.open();
-                                                       }
-                                               };
-                                               insertAction.setText(Messages.getString("tableview.insert")); //$NON-NLS-1$
-                                               Action deleteAction = new Action() {
-                                                       public void run() {
-                                                               DeleteRowPage page = new DeleteRowPage(""); //$NON-NLS-1$
-                                                               SQLRowWizard wizard = new SQLRowWizard();
-                                                               wizard.init(Messages.getString("TableView.DeleteRow"), page, row, ta); //$NON-NLS-1$
-                                                               WizardDialog dialog =
-                                                                       new WizardDialog(
-                                                                               getSite().getShell(),
-                                                                               wizard);
-                                                               dialog.open();
-                                                       }
-                                               };
-                                               deleteAction.setText(Messages.getString("tableview.delete")); //$NON-NLS-1$
-                                               mgr.add(insertAction);
-                                               mgr.add(updateAction);
-                                               mgr.add(deleteAction);
-                                       }
-                                       mgr.add(defaultEncodingAction);
-                                       mgr.add(UTF8EncodingAction);
-                                       mgr.add(UTF16EncodingAction);
-                               }
-               };
+    // final setup
+    MenuManager manager = new MenuManager();
+    manager.setRemoveAllWhenShown(true);
+    Menu fTextContextMenu = manager.createContextMenu(table);
+    table.setMenu(fTextContextMenu);
+    table.setLinesVisible(true);
+    manager.addMenuListener(menuListener);
 
-               // final setup
-               MenuManager manager = new MenuManager();
-               manager.setRemoveAllWhenShown(true);
-               Menu fTextContextMenu = manager.createContextMenu(table);
-               table.setMenu(fTextContextMenu);
-               table.setLinesVisible(true);
-               manager.addMenuListener(menuListener);
-               
-               tabItem.setControl(main);
-               tabs.setSelection(tabs.indexOf(tabItem));
-       }
+    tabItem.setControl(main);
+    tabs.setSelection(tabs.indexOf(tabItem));
+  }
 
-       public void createPartControl(Composite parent) {
-               instance = this;
-               this.parent = parent;
-               initActions();
-               clip = new Clipboard(getSite().getShell().getDisplay());
-               tabs = new TabFolder(parent, SWT.NONE);
-       }
-       public void initActions() {
-               refreshTableAction = new RefreshTableAction();
-               refreshTableAction.setText(Messages.getString("tableview.refresh")); //$NON-NLS-1$
-               refreshTableAction.setImageDescriptor(
-                       PHPEclipseSQLPlugin.getImageDescriptor("refresh.gif")); //$NON-NLS-1$
-               refreshTableAction.init(this);
-               closeTableAction = new CloseTableAction();
-               closeTableAction.setText(Messages.getString("tableview.close")); //$NON-NLS-1$
-               closeTableAction.setImageDescriptor(
-                       PHPEclipseSQLPlugin.getImageDescriptor("close.gif")); //$NON-NLS-1$
-               closeTableAction.init(this);
-       }
+  public void createPartControl(Composite parent) {
+    instance = this;
+    this.parent = parent;
+    initActions();
+    clip = new Clipboard(getSite().getShell().getDisplay());
+    tabs = new TabFolder(parent, SWT.NONE);
+  }
+  public void initActions() {
+    refreshTableAction = new RefreshTableAction();
+    refreshTableAction.setText(Messages.getString("tableview.refresh")); //$NON-NLS-1$
+    refreshTableAction.setImageDescriptor(PHPEclipseSQLPlugin.getImageDescriptor("refresh.gif")); //$NON-NLS-1$
+    refreshTableAction.init(this);
+    closeTableAction = new CloseTableAction();
+    closeTableAction.setText(Messages.getString("tableview.close")); //$NON-NLS-1$
+    closeTableAction.setImageDescriptor(PHPEclipseSQLPlugin.getImageDescriptor("close.gif")); //$NON-NLS-1$
+    closeTableAction.init(this);
+  }
 
-       public void selectionChanged(IWorkbenchPart part, ISelection selection) {
-       }
+  public void selectionChanged(IWorkbenchPart part, ISelection selection) {
+  }
 }
\ No newline at end of file
index 9265126..3908460 100644 (file)
@@ -25,139 +25,152 @@ import net.sourceforge.phpdt.sql.view.bookmark.TreeNode;
 import net.sourceforge.phpdt.sql.view.tableview.TableAdapter;
 
 public class DeleteRowPage extends WizardPage implements SQLPage {
-       TableRow row;
-       String[] columnNames;
-       Text[] values;
-       Button[] whereValues;
-       Text query;
-
-       public DeleteRowPage(String pageName) {
-               super(pageName);
-       }
-       
-       public void init(TableRow row, TableAdapter adapter) {
-               this.row = row;
-       }
-
-       public void createControl(Composite parent) {
-               System.out.println("page create control"); //$NON-NLS-1$
-               Composite container = new Composite(parent, SWT.NULL);
-               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$
-               }
-               BookmarkNode bookmark = row.getBookmarkNode();
-               TreeNode node = bookmark.find(row.getTable());
-               ObjectMetaData metadata = null;
-               if (node != null) metadata = node.getMetaData(); 
-               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()];
-               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++) {
-                       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]);
-
-                       values[i].addModifyListener(new ModifyListener() {
-                               public void modifyText(ModifyEvent e) {
-                                       updateQuery();
-                               }                               
-                       });
-                       
-                       whereValues[i] = new Button(container, SWT.CHECK);
-                       whereValues[i].setText(Messages.getString("DeleteRowPage.WhereClause")); //$NON-NLS-1$
-                       // we check if it's a primary key to select it in the WHERE clause
-                       if (metadata != null && metadata.getPrimaryKeyOrder(columnNames[i]) > 0)
-                               whereValues[i].setSelection(true);
-                       else
-                               whereValues[i].setSelection(false);
-                       whereValues[i].addSelectionListener(new SelectionListener() {
-                               public void widgetDefaultSelected(SelectionEvent e) {
-                               }
-                               public void widgetSelected(SelectionEvent e) {
-                                       updateQuery();
-                               }
-                       });
-               }
-               query = new Text(container, SWT.MULTI | SWT.READ_ONLY | SWT.WRAP);
-               GridData gridData = new GridData();
-               gridData.horizontalSpan = layout.numColumns;
-               gridData.verticalSpan = 3;
-               gridData.horizontalAlignment = GridData.FILL;
-               gridData.verticalAlignment = GridData.FILL;
-               gridData.grabExcessHorizontalSpace = true;
-               gridData.grabExcessVerticalSpace = true;
-               query.setLayoutData(gridData);
-
-               setControl(container);
-        updateQuery();
-       
-               setPageComplete(true);
-       }
-       public void updateQuery() {
-               System.out.println(Messages.getString("DeleteRowPage.UpdatingQuery")); //$NON-NLS-1$
-               StringBuffer whereClause = new StringBuffer();
-               BookmarkNode bookmark = row.getBookmarkNode();
-               TreeNode node = bookmark.find(row.getTable());
-               ObjectMetaData metadata = null;
-               if (node != null) metadata = node.getMetaData(); 
-               DatabaseAdapter adapter = AdapterFactory.getInstance().getAdapter(bookmark.getType());
-               
-               int numSelected = 0;
-               for (int i = 0; i < columnNames.length; i++) {
-                       if (whereValues[i].getSelection()) {
-                               if (numSelected > 0) whereClause.append(" AND "); //$NON-NLS-1$
-                               numSelected++;
-                               whereClause.append("("); //$NON-NLS-1$
-                               whereClause.append(columnNames[i]);
-                               whereClause.append(" = "); //$NON-NLS-1$
-                               if (adapter != null && metadata != null)
-                                       whereClause.append(adapter.quote(values[i].getText(), metadata.getColumnType(columnNames[i])));
-                               else
-                                       whereClause.append(values[i].getText());
-                                                               
-                               whereClause.append(")"); //$NON-NLS-1$
-                       }
-               }
-               String query = "DELETE FROM " + row.getTable(); //$NON-NLS-1$
-               if (numSelected > 0) {
-                       query += " WHERE " + whereClause.toString(); //$NON-NLS-1$
-               }
-               if (numSelected > 0) {
-                       setMessage(""); //$NON-NLS-1$
-               } else {
-                       setMessage(Messages.getString("DeleteRowPage.WarningNoWhere")); //$NON-NLS-1$
-               }
-               this.query.setText(query);
-       }
-       
-       
-       public boolean performFinish() {
-          MultiSQLServer server = MultiSQLServer.getInstance();
-          BookmarkView bookmarkView = BookmarkView.getInstance(); 
-          BookmarkNode bookmark = bookmarkView.getCurrentBookmark();
-          server.execute(bookmark.getConnection(), query.getText());
-          return true;
-       }
+  TableRow row;
+  String[] columnNames;
+  Text[] values;
+  Button[] whereValues;
+  Text query;
+
+  public DeleteRowPage(String pageName) {
+    super(pageName);
+  }
+
+  public void init(TableRow row, TableAdapter adapter) {
+    this.row = row;
+  }
+
+  public void createControl(Composite parent) {
+    if (DEBUG) {
+      System.out.println("page create control"); //$NON-NLS-1$
+    }
+    Composite container = new Composite(parent, SWT.NULL);
+    GridLayout layout = new GridLayout();
+    container.setLayout(layout);
+    layout.numColumns = 3;
+
+    if (DEBUG) {
+      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$
+      }
+    }
+    BookmarkNode bookmark = row.getBookmarkNode();
+    TreeNode node = bookmark.find(row.getTable());
+    ObjectMetaData metadata = null;
+    if (node != null)
+      metadata = node.getMetaData();
+    columnNames = row.getColumnNames();
+    String[] data = row.getTableData();
+
+    if (DEBUG) {
+      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()];
+    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++) {
+      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]);
+
+      values[i].addModifyListener(new ModifyListener() {
+        public void modifyText(ModifyEvent e) {
+          updateQuery();
+        }
+      });
+
+      whereValues[i] = new Button(container, SWT.CHECK);
+      whereValues[i].setText(Messages.getString("DeleteRowPage.WhereClause")); //$NON-NLS-1$
+      // we check if it's a primary key to select it in the WHERE clause
+      if (metadata != null && metadata.getPrimaryKeyOrder(columnNames[i]) > 0)
+        whereValues[i].setSelection(true);
+      else
+        whereValues[i].setSelection(false);
+      whereValues[i].addSelectionListener(new SelectionListener() {
+        public void widgetDefaultSelected(SelectionEvent e) {
+        }
+        public void widgetSelected(SelectionEvent e) {
+          updateQuery();
+        }
+      });
+    }
+    query = new Text(container, SWT.MULTI | SWT.READ_ONLY | SWT.WRAP);
+    GridData gridData = new GridData();
+    gridData.horizontalSpan = layout.numColumns;
+    gridData.verticalSpan = 3;
+    gridData.horizontalAlignment = GridData.FILL;
+    gridData.verticalAlignment = GridData.FILL;
+    gridData.grabExcessHorizontalSpace = true;
+    gridData.grabExcessVerticalSpace = true;
+    query.setLayoutData(gridData);
+
+    setControl(container);
+    updateQuery();
+
+    setPageComplete(true);
+  }
+  public void updateQuery() {
+    if (DEBUG) {
+      System.out.println(Messages.getString("DeleteRowPage.UpdatingQuery")); //$NON-NLS-1$
+    }
+
+    StringBuffer whereClause = new StringBuffer();
+    BookmarkNode bookmark = row.getBookmarkNode();
+    TreeNode node = bookmark.find(row.getTable());
+    ObjectMetaData metadata = null;
+    if (node != null)
+      metadata = node.getMetaData();
+    DatabaseAdapter adapter = AdapterFactory.getInstance().getAdapter(bookmark.getType());
+
+    int numSelected = 0;
+    for (int i = 0; i < columnNames.length; i++) {
+      if (whereValues[i].getSelection()) {
+        if (numSelected > 0)
+          whereClause.append(" AND "); //$NON-NLS-1$
+        numSelected++;
+        whereClause.append("("); //$NON-NLS-1$
+        whereClause.append(columnNames[i]);
+        whereClause.append(" = "); //$NON-NLS-1$
+        if (adapter != null && metadata != null)
+          whereClause.append(adapter.quote(values[i].getText(), metadata.getColumnType(columnNames[i])));
+        else
+          whereClause.append(values[i].getText());
+
+        whereClause.append(")"); //$NON-NLS-1$
+      }
+    }
+    String query = "DELETE FROM " + row.getTable(); //$NON-NLS-1$
+    if (numSelected > 0) {
+      query += " WHERE " + whereClause.toString(); //$NON-NLS-1$
+    }
+    if (numSelected > 0) {
+      setMessage(""); //$NON-NLS-1$
+    } else {
+      setMessage(Messages.getString("DeleteRowPage.WarningNoWhere")); //$NON-NLS-1$
+    }
+    this.query.setText(query);
+  }
+
+  public boolean performFinish() {
+    MultiSQLServer server = MultiSQLServer.getInstance();
+    BookmarkView bookmarkView = BookmarkView.getInstance();
+    BookmarkNode bookmark = bookmarkView.getCurrentBookmark();
+    server.execute(bookmark.getConnection(), query.getText());
+    return true;
+  }
 }
\ No newline at end of file
index fde6b50..5f8f6c2 100644 (file)
@@ -22,101 +22,116 @@ import net.sourceforge.phpdt.sql.view.bookmark.TreeNode;
 import net.sourceforge.phpdt.sql.view.tableview.TableAdapter;
 
 public class InsertRowPage extends WizardPage implements SQLPage {
-       TableRow row;
-       String[] columnNames;
-       Text[] values;
-       Label query;
-       public InsertRowPage(String pageName) {
-               super(pageName);
-       }
+  TableRow row;
+  String[] columnNames;
+  Text[] values;
+  Label query;
+  public InsertRowPage(String pageName) {
+    super(pageName);
+  }
 
-       public void init(TableRow row, TableAdapter adapter) {
-               this.row = row;
-       }
+  public void init(TableRow row, TableAdapter adapter) {
+    this.row = row;
+  }
 
-       public void createControl(Composite parent) {
-               System.out.println("page create control"); //$NON-NLS-1$
-               Composite container = new Composite(parent, SWT.NULL);
-               GridLayout layout = new GridLayout();
-               container.setLayout(layout);
-               layout.numColumns = 2;
+  public void createControl(Composite parent) {
+    if (DEBUG) {
+      System.out.println("page create control"); //$NON-NLS-1$
+    }
 
-               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()];
-               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++) {
-                       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);
+    Composite container = new Composite(parent, SWT.NULL);
+    GridLayout layout = new GridLayout();
+    container.setLayout(layout);
+    layout.numColumns = 2;
 
-                       //values[i].setText(data[i]);
-                       values[i].addModifyListener(new ModifyListener() {
-                               public void modifyText(ModifyEvent e) {
-                                       updateQuery();
-                               }                               
-                       });
-               }
-               query = new Label(container, SWT.WRAP);
-               GridData gridData = new GridData();
-               gridData.horizontalSpan = layout.numColumns;
-               gridData.horizontalAlignment = GridData.FILL;
-               gridData.verticalAlignment = GridData.FILL;
-               gridData.grabExcessHorizontalSpace = true;
-               gridData.grabExcessVerticalSpace = true;
-               query.setLayoutData(gridData);
+    if (DEBUG) {
+      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$
+      }
+    }
 
-               setControl(container);
-        updateQuery();
-       
-               setPageComplete(true);
-       }
-       public void updateQuery() {
-               System.out.println("Updating query"); //$NON-NLS-1$
-               StringBuffer valuesClause = new StringBuffer();
-               BookmarkNode bookmark = row.getBookmarkNode();
-               TreeNode node = bookmark.find(row.getTable());
-               ObjectMetaData metadata = null;
-               if (node != null) metadata = node.getMetaData(); 
-               DatabaseAdapter adapter = AdapterFactory.getInstance().getAdapter(bookmark.getType());
-               
-               int numValues = 0;
-               for (int i = 0; i < columnNames.length; i++) {
-                       String value = values[i].getText();
-                       if (numValues > 0) valuesClause.append(", "); //$NON-NLS-1$
-                       if (adapter != null && metadata != null && value != "") //$NON-NLS-1$
-                               valuesClause.append(adapter.quote(value, metadata.getColumnType(columnNames[i])));
-                       else
-                               valuesClause.append(value);     
-                       numValues++;
-               }
-               String query = "INSERT INTO " + row.getTable(); //$NON-NLS-1$
-               query += " VALUES (" + valuesClause; //$NON-NLS-1$
-               query += " )"; //$NON-NLS-1$
-               this.query.setText(query);
-       }
-       public boolean performFinish() {
-          MultiSQLServer server = MultiSQLServer.getInstance();
-          BookmarkView bookmarkView = BookmarkView.getInstance(); 
-          BookmarkNode bookmark = bookmarkView.getCurrentBookmark();
-          server.execute(bookmark.getConnection(), query.getText());
-          return true;
-       }
+    columnNames = row.getColumnNames();
+    String[] data = row.getTableData();
+
+    if (DEBUG) {
+      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()];
+    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++) {
+      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]);
+      values[i].addModifyListener(new ModifyListener() {
+        public void modifyText(ModifyEvent e) {
+          updateQuery();
+        }
+      });
+    }
+    query = new Label(container, SWT.WRAP);
+    GridData gridData = new GridData();
+    gridData.horizontalSpan = layout.numColumns;
+    gridData.horizontalAlignment = GridData.FILL;
+    gridData.verticalAlignment = GridData.FILL;
+    gridData.grabExcessHorizontalSpace = true;
+    gridData.grabExcessVerticalSpace = true;
+    query.setLayoutData(gridData);
+
+    setControl(container);
+    updateQuery();
+
+    setPageComplete(true);
+  }
+  public void updateQuery() {
+    if (DEBUG) {
+      System.out.println("Updating query"); //$NON-NLS-1$
+    }
+
+    StringBuffer valuesClause = new StringBuffer();
+    BookmarkNode bookmark = row.getBookmarkNode();
+    TreeNode node = bookmark.find(row.getTable());
+    ObjectMetaData metadata = null;
+    if (node != null)
+      metadata = node.getMetaData();
+    DatabaseAdapter adapter = AdapterFactory.getInstance().getAdapter(bookmark.getType());
+
+    int numValues = 0;
+    for (int i = 0; i < columnNames.length; i++) {
+      String value = values[i].getText();
+      if (numValues > 0)
+        valuesClause.append(", "); //$NON-NLS-1$
+      if (adapter != null && metadata != null && value != "") //$NON-NLS-1$
+        valuesClause.append(adapter.quote(value, metadata.getColumnType(columnNames[i])));
+      else
+        valuesClause.append(value);
+      numValues++;
+    }
+    String query = "INSERT INTO " + row.getTable(); //$NON-NLS-1$
+    query += " VALUES (" + valuesClause; //$NON-NLS-1$
+    query += " )"; //$NON-NLS-1$
+    this.query.setText(query);
+  }
+  public boolean performFinish() {
+    MultiSQLServer server = MultiSQLServer.getInstance();
+    BookmarkView bookmarkView = BookmarkView.getInstance();
+    BookmarkNode bookmark = bookmarkView.getCurrentBookmark();
+    server.execute(bookmark.getConnection(), query.getText());
+    return true;
+  }
 }
\ No newline at end of file
index fd0ebb7..de7ec86 100644 (file)
@@ -22,149 +22,152 @@ import net.sourceforge.phpdt.sql.view.PHPSourceConsole;
 import net.sourceforge.phpdt.sql.view.tableview.TableAdapter;
 
 public class PHPDeleteRowPage extends WizardPage implements SQLPage {
-       TableRow row;
-       String[] columnNames;
-       Text[] values;
-       Button[] whereValues;
-       Label query;
-       IPreferenceStore fStore;
-
-       public PHPDeleteRowPage(String pageName) {
-               super(pageName);
-       }
-
-       public void init(TableRow row, TableAdapter adapter) {
-               this.row = row;
-       }
-
-       public void createControl(Composite parent) {
-               System.out.println("page create control");
-               fStore = PHPEclipseSQLPlugin.getDefault().getPreferenceStore();
-               Composite container = new Composite(parent, SWT.NULL);
-               GridLayout layout = new GridLayout();
-               container.setLayout(layout);
-               int layoutColumns = 3;
-               layout.numColumns = layoutColumns;
-
-               if (row == null) {
-                       System.out.println("Row is null");
-               }
-               if (row.getColumnNames() == null) {
-                       System.out.println("Columns are null");
-               }
-               if (row.getTableData() == null) {
-                       System.out.println("Data is null");
-               }
-
-               columnNames = row.getColumnNames();
-               String[] data = row.getTableData();
-               for (int i = 0; i < row.getColumnCount(); i++) {
-                       System.out.println("data = " + i + "=" + data[i]);
-                       System.out.println("column = " + i + "=" + columnNames[i]);
-               }
-               values = new Text[row.getColumnCount()];
-               whereValues = new Button[row.getColumnCount()];
-               Label temp = new Label(container, SWT.NULL);
-               temp.setText("Column Name");
-               temp = new Label(container, SWT.NULL);
-               temp.setText("Value");
-               temp = new Label(container, SWT.NULL);
-               temp.setText("Include in?");
-               for (int i = 0; i < row.getColumnCount(); 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);
-
-                       if (data[i] == null || data[i].equals("")) {
-                               values[i].setText('$' + columnNames[i]);
-                       } else {
-                               values[i].setText(data[i]);
-                       }
-
-                       values[i].addModifyListener(new ModifyListener() {
-                               public void modifyText(ModifyEvent e) {
-                                       updateQuery();
-                               }
-                       });
-
-                       whereValues[i] = new Button(container, SWT.CHECK);
-                       whereValues[i].setText("Where clause");
-                       whereValues[i].addSelectionListener(new SelectionListener() {
-                               public void widgetDefaultSelected(SelectionEvent e) {
-                               }
-                               public void widgetSelected(SelectionEvent e) {
-                                       updateQuery();
-                               }
-                       });
-               }
-               query = new Label(container, SWT.WRAP);
-               GridData gridData = new GridData();
-               gridData.horizontalSpan = layoutColumns;
-               gridData.horizontalAlignment = GridData.FILL;
-               gridData.verticalAlignment = GridData.FILL;
-               gridData.grabExcessHorizontalSpace = true;
-               gridData.grabExcessVerticalSpace = true;
-               query.setLayoutData(gridData);
-
-               setControl(container);
-               updateQuery();
-
-               setPageComplete(true);
-       }
-       public void updateQuery() {
-               System.out.println("Updating delete query");
-               StringBuffer whereClause = new StringBuffer();
-               int numSelected = 0;
-               boolean first = false;
-               for (int i = 0; i < columnNames.length; i++) {
-                       if (whereValues[i].getSelection()) {
-                               numSelected++;
-                               if (first) {
-                                       whereClause.append(", ");
-                               }
-
-                               whereClause.append(columnNames[i]);
-                               whereClause.append(" = ");
-                               whereClause.append("'" + values[i].getText() + "'");
-
-                               first = true;
-                       }
-               }
-               //    if (whereClause.length() > 1) {
-               //      whereClause.deleteCharAt(whereClause.length() - 1);
-               //      whereClause.deleteCharAt(whereClause.length() - 1);
-               //    }
-
-               String[] arguments = { row.getTable(), whereClause.toString()};
-               MessageFormat form =
-                       new MessageFormat(
-                               fStore.getString("phpeclipse.sql.delete.template"));
-
-               String query = form.format(arguments);
-
-               //        String query = "$results = mysql_query(\"DELETE FROM " + row.getTable();
-               //        if (numSelected > 0) {
-               //              query += " WHERE " + whereClause.toString() + "\");";
-               //        } else {
-               //              query += "\");";
-               //        }
-
-               if (numSelected > 0) {
-                       setMessage("");
-               } else {
-                       setMessage("Warning: no \"where clause\" columns selected, all rows will be deleted");
-               }
-
-               this.getControl().pack();
-               this.query.setText(query);
-       }
-       public boolean performFinish() {
-               PHPSourceConsole console = PHPSourceConsole.getInstance();
-               console.clear();
-               console.print(query.getText());
-               return true;
-       }
+  TableRow row;
+  String[] columnNames;
+  Text[] values;
+  Button[] whereValues;
+  Label query;
+  IPreferenceStore fStore;
+
+  public PHPDeleteRowPage(String pageName) {
+    super(pageName);
+  }
+
+  public void init(TableRow row, TableAdapter adapter) {
+    this.row = row;
+  }
+
+  public void createControl(Composite parent) {
+    System.out.println("page create control");
+    fStore = PHPEclipseSQLPlugin.getDefault().getPreferenceStore();
+    Composite container = new Composite(parent, SWT.NULL);
+    GridLayout layout = new GridLayout();
+    container.setLayout(layout);
+    int layoutColumns = 3;
+    layout.numColumns = layoutColumns;
+
+    if (DEBUG) {
+      if (row == null) {
+        System.out.println("Row is null");
+      }
+      if (row.getColumnNames() == null) {
+        System.out.println("Columns are null");
+      }
+      if (row.getTableData() == null) {
+        System.out.println("Data is null");
+      }
+    }
+    columnNames = row.getColumnNames();
+    String[] data = row.getTableData();
+    if (DEBUG) {
+      for (int i = 0; i < row.getColumnCount(); i++) {
+        System.out.println("data = " + i + "=" + data[i]);
+        System.out.println("column = " + i + "=" + columnNames[i]);
+      }
+    }
+    values = new Text[row.getColumnCount()];
+    whereValues = new Button[row.getColumnCount()];
+    Label temp = new Label(container, SWT.NULL);
+    temp.setText("Column Name");
+    temp = new Label(container, SWT.NULL);
+    temp.setText("Value");
+    temp = new Label(container, SWT.NULL);
+    temp.setText("Include in?");
+    for (int i = 0; i < row.getColumnCount(); 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);
+
+      if (data[i] == null || data[i].equals("")) {
+        values[i].setText('$' + columnNames[i]);
+      } else {
+        values[i].setText(data[i]);
+      }
+
+      values[i].addModifyListener(new ModifyListener() {
+        public void modifyText(ModifyEvent e) {
+          updateQuery();
+        }
+      });
+
+      whereValues[i] = new Button(container, SWT.CHECK);
+      whereValues[i].setText("Where clause");
+      whereValues[i].addSelectionListener(new SelectionListener() {
+        public void widgetDefaultSelected(SelectionEvent e) {
+        }
+        public void widgetSelected(SelectionEvent e) {
+          updateQuery();
+        }
+      });
+    }
+    query = new Label(container, SWT.WRAP);
+    GridData gridData = new GridData();
+    gridData.horizontalSpan = layoutColumns;
+    gridData.horizontalAlignment = GridData.FILL;
+    gridData.verticalAlignment = GridData.FILL;
+    gridData.grabExcessHorizontalSpace = true;
+    gridData.grabExcessVerticalSpace = true;
+    query.setLayoutData(gridData);
+
+    setControl(container);
+    updateQuery();
+
+    setPageComplete(true);
+  }
+  public void updateQuery() {
+    if (DEBUG) {
+      System.out.println("Updating delete query");
+    }
+    StringBuffer whereClause = new StringBuffer();
+    int numSelected = 0;
+    boolean first = false;
+    for (int i = 0; i < columnNames.length; i++) {
+      if (whereValues[i].getSelection()) {
+        numSelected++;
+        if (first) {
+          whereClause.append(", ");
+        }
+
+        whereClause.append(columnNames[i]);
+        whereClause.append(" = ");
+        whereClause.append("'" + values[i].getText() + "'");
+
+        first = true;
+      }
+    }
+    //    if (whereClause.length() > 1) {
+    //      whereClause.deleteCharAt(whereClause.length() - 1);
+    //      whereClause.deleteCharAt(whereClause.length() - 1);
+    //    }
+
+    String[] arguments = { row.getTable(), whereClause.toString()};
+    MessageFormat form = new MessageFormat(fStore.getString("phpeclipse.sql.delete.template"));
+
+    String query = form.format(arguments);
+
+    //   String query = "$results = mysql_query(\"DELETE FROM " + row.getTable();
+    //   if (numSelected > 0) {
+    //         query += " WHERE " + whereClause.toString() + "\");";
+    //   } else {
+    //         query += "\");";
+    //   }
+
+    if (numSelected > 0) {
+      setMessage("");
+    } else {
+      setMessage("Warning: no \"where clause\" columns selected, all rows will be deleted");
+    }
+
+    this.getControl().pack();
+    this.query.setText(query);
+  }
+  public boolean performFinish() {
+    PHPSourceConsole console = PHPSourceConsole.getInstance();
+    console.clear();
+    console.print(query.getText());
+    return true;
+  }
 }
\ No newline at end of file
index 47e479f..0e31aa6 100644 (file)
@@ -19,119 +19,125 @@ import net.sourceforge.phpdt.sql.view.PHPSourceConsole;
 import net.sourceforge.phpdt.sql.view.tableview.TableAdapter;
 
 public class PHPInsertRowPage extends WizardPage implements SQLPage {
-       TableRow row;
-       String[] columnNames;
-       Text[] values;
-       Label query;
-       private IPreferenceStore fStore;
+  TableRow row;
+  String[] columnNames;
+  Text[] values;
+  Label query;
+  private IPreferenceStore fStore;
 
-       public PHPInsertRowPage(String pageName) {
-               super(pageName);
-       }
+  public PHPInsertRowPage(String pageName) {
+    super(pageName);
+  }
 
-       public void init(TableRow row, TableAdapter adapter) {
-               this.row = row;
-       }
+  public void init(TableRow row, TableAdapter adapter) {
+    this.row = row;
+  }
 
-       public void createControl(Composite parent) {
-               System.out.println("page create control");
-               fStore = PHPEclipseSQLPlugin.getDefault().getPreferenceStore();
-               Composite container = new Composite(parent, SWT.NULL);
-               GridLayout layout = new GridLayout();
-               container.setLayout(layout);
-               int layoutColumns = 2;
-               layout.numColumns = layoutColumns;
+  public void createControl(Composite parent) {
+    if (DEBUG) {
+      System.out.println("page create control");
+    }
+    fStore = PHPEclipseSQLPlugin.getDefault().getPreferenceStore();
+    Composite container = new Composite(parent, SWT.NULL);
+    GridLayout layout = new GridLayout();
+    container.setLayout(layout);
+    int layoutColumns = 2;
+    layout.numColumns = layoutColumns;
 
-               if (row == null) {
-                       System.out.println("Row is null");
-               }
-               if (row.getColumnNames() == null) {
-                       System.out.println("Columns are null");
-               }
-               if (row.getTableData() == null) {
-                       System.out.println("Data is null");
-               }
-               columnNames = row.getColumnNames();
-               String[] data = row.getTableData();
-               for (int i = 0; i < row.getColumnCount(); i++) {
-                       System.out.println("data = " + i + "=" + data[i]);
-                       System.out.println("column = " + i + "=" + columnNames[i]);
-               }
-               values = new Text[row.getColumnCount()];
-               Label temp = new Label(container, SWT.NULL);
-               temp.setText("Column Name");
-               temp = new Label(container, SWT.NULL);
-               temp.setText("Value");
-               for (int i = 0; i < row.getColumnCount(); 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);
+    if (DEBUG) {
+      if (row == null) {
+        System.out.println("Row is null");
+      }
+      if (row.getColumnNames() == null) {
+        System.out.println("Columns are null");
+      }
+      if (row.getTableData() == null) {
+        System.out.println("Data is null");
+      }
+    }
 
-                       //values[i].setText(data[i]);
-                       values[i].addModifyListener(new ModifyListener() {
-                               public void modifyText(ModifyEvent e) {
-                                       updateQuery();
-                               }
-                       });
-               }
-               query = new Label(container, SWT.WRAP);
-               GridData gridData = new GridData();
-               gridData.horizontalSpan = layoutColumns;
-               gridData.horizontalAlignment = GridData.FILL;
-               gridData.verticalAlignment = GridData.FILL;
-               gridData.grabExcessHorizontalSpace = true;
-               gridData.grabExcessVerticalSpace = true;
-               query.setLayoutData(gridData);
+    columnNames = row.getColumnNames();
+    String[] data = row.getTableData();
+    if (DEBUG) {
+      for (int i = 0; i < row.getColumnCount(); i++) {
+        System.out.println("data = " + i + "=" + data[i]);
+        System.out.println("column = " + i + "=" + columnNames[i]);
+      }
+    }
+    values = new Text[row.getColumnCount()];
+    Label temp = new Label(container, SWT.NULL);
+    temp.setText("Column Name");
+    temp = new Label(container, SWT.NULL);
+    temp.setText("Value");
+    for (int i = 0; i < row.getColumnCount(); 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);
 
-               setControl(container);
-               updateQuery();
+      //values[i].setText(data[i]);
+      values[i].addModifyListener(new ModifyListener() {
+        public void modifyText(ModifyEvent e) {
+          updateQuery();
+        }
+      });
+    }
+    query = new Label(container, SWT.WRAP);
+    GridData gridData = new GridData();
+    gridData.horizontalSpan = layoutColumns;
+    gridData.horizontalAlignment = GridData.FILL;
+    gridData.verticalAlignment = GridData.FILL;
+    gridData.grabExcessHorizontalSpace = true;
+    gridData.grabExcessVerticalSpace = true;
+    query.setLayoutData(gridData);
 
-               setPageComplete(true);
-       }
-       public void updateQuery() {
-               System.out.println("Updating insert query");
-               StringBuffer fieldClause = new StringBuffer();
+    setControl(container);
+    updateQuery();
 
-               StringBuffer valuesClause = new StringBuffer();
-               String text;
-               boolean first = false;
-               for (int i = 0; i < columnNames.length; i++) {
-                       text = values[i].getText();
-                       if (!text.equals("")) {
-                               if (first) {
-                                       valuesClause.append(", ");
-                                       fieldClause.append(", ");
-                               }
-                               valuesClause.append("'" + values[i].getText() + "'");
-                               fieldClause.append(columnNames[i]);
-                               first = true;
-                       }
-               }
-               //    if (valuesClause.length() > 1) {
-               //      valuesClause.deleteCharAt(valuesClause.length() - 1);
-               //      valuesClause.deleteCharAt(valuesClause.length() - 1);
-               //    }
-               String[] arguments =
-                       { row.getTable(), fieldClause.toString(), valuesClause.toString()};
-               MessageFormat form =
-                       new MessageFormat(
-                               fStore.getString("phpeclipse.sql.insert.template"));
+    setPageComplete(true);
+  }
+  public void updateQuery() {
+    if (DEBUG) {
+      System.out.println("Updating insert query");
+    }
+    StringBuffer fieldClause = new StringBuffer();
 
-               String query = form.format(arguments);
+    StringBuffer valuesClause = new StringBuffer();
+    String text;
+    boolean first = false;
+    for (int i = 0; i < columnNames.length; i++) {
+      text = values[i].getText();
+      if (!text.equals("")) {
+        if (first) {
+          valuesClause.append(", ");
+          fieldClause.append(", ");
+        }
+        valuesClause.append("'" + values[i].getText() + "'");
+        fieldClause.append(columnNames[i]);
+        first = true;
+      }
+    }
+    //    if (valuesClause.length() > 1) {
+    //      valuesClause.deleteCharAt(valuesClause.length() - 1);
+    //      valuesClause.deleteCharAt(valuesClause.length() - 1);
+    //    }
+    String[] arguments = { row.getTable(), fieldClause.toString(), valuesClause.toString()};
+    MessageFormat form = new MessageFormat(fStore.getString("phpeclipse.sql.insert.template"));
 
-               //    String query = "$results = mysql_query(\"INSERT INTO " + row.getTable() + " (";
-               //    query += fieldClause.toString() + ") ";
-               //    query += " VALUES (" + valuesClause.toString();
-               //    query += ")\");";
-               this.query.setText(query);
-       }
-       public boolean performFinish() {
-               PHPSourceConsole console = PHPSourceConsole.getInstance();
-               console.clear();
-               console.print(query.getText());
-               return true;
-       }
+    String query = form.format(arguments);
+
+    //    String query = "$results = mysql_query(\"INSERT INTO " + row.getTable() + " (";
+    //    query += fieldClause.toString() + ") ";
+    //    query += " VALUES (" + valuesClause.toString();
+    //    query += ")\");";
+    this.query.setText(query);
+  }
+  public boolean performFinish() {
+    PHPSourceConsole console = PHPSourceConsole.getInstance();
+    console.clear();
+    console.print(query.getText());
+    return true;
+  }
 }
\ No newline at end of file
index e31fe2f..d5081d1 100644 (file)
@@ -22,176 +22,180 @@ import net.sourceforge.phpdt.sql.view.PHPSourceConsole;
 import net.sourceforge.phpdt.sql.view.tableview.TableAdapter;
 
 public class PHPSelectRowPage extends WizardPage implements SQLPage {
-       TableRow row;
-       String[] columnNames;
-       Text[] whereValues;
-       // Text[] newValues;
-       Button[] primaryKeys;
-       Button[] setValues;
-       Label query;
-       IPreferenceStore fStore;
-
-       public PHPSelectRowPage(String pageName) {
-               super(pageName);
-       }
-
-       public void init(TableRow row, TableAdapter adapter) {
-               this.row = row;
-       }
-
-       public void createControl(Composite parent) {
-               System.out.println("page create control");
-               Composite container = new Composite(parent, SWT.NULL);
-               fStore = PHPEclipseSQLPlugin.getDefault().getPreferenceStore();
-
-               GridLayout layout = new GridLayout();
-               container.setLayout(layout);
-               int layoutColumns = 4;
-               layout.numColumns = layoutColumns;
-
-               if (row == null) {
-                       System.out.println("Row is null");
-               }
-               if (row.getColumnNames() == null) {
-                       System.out.println("Columns are null");
-               }
-               if (row.getTableData() == null) {
-                       System.out.println("Data is null");
-               }
-               columnNames = row.getColumnNames();
-               String[] data = row.getTableData();
-
-               for (int i = 0; i < row.getColumnCount(); i++) {
-                       System.out.println("data = " + i + "=" + data[i]);
-                       System.out.println("column = " + i + "=" + columnNames[i]);
-               }
-
-               whereValues = new Text[row.getColumnCount()];
-               //  newValues = new Text[row.getColumnCount()];
-               primaryKeys = new Button[row.getColumnCount()];
-               setValues = new Button[row.getColumnCount()];
-               Label temp = new Label(container, SWT.NULL);
-               temp.setText("Column Name");
-               temp = new Label(container, SWT.NULL);
-               temp.setText("Value");
-               temp = new Label(container, SWT.NULL);
-               temp.setText("Where");
-               //    temp = new Label(container, SWT.NULL);
-               //    temp.setText("New Value");
-               temp = new Label(container, SWT.NULL);
-               temp.setText("Select");
-               for (int i = 0; i < row.getColumnCount(); i++) {
-                       Label label = new Label(container, SWT.NULL);
-                       label.setText(columnNames[i]);
-                       whereValues[i] = new Text(container, SWT.BORDER | SWT.SINGLE);
-                       if (data[i] == null || data[i].equals("")) {
-                               whereValues[i].setText('$' + columnNames[i]);
-                       } else {
-                               whereValues[i].setText(data[i]);
-                       }
-
-                       whereValues[i].addModifyListener(new ModifyListener() {
-                               public void modifyText(ModifyEvent e) {
-                                       updateQuery();
-                               }
-                       });
-
-                       primaryKeys[i] = new Button(container, SWT.CHECK);
-                       //primaryKeys[i].setText("Where Clause");
-                       primaryKeys[i].addSelectionListener(new SelectionListener() {
-                               public void widgetDefaultSelected(SelectionEvent e) {
-                               }
-                               public void widgetSelected(SelectionEvent e) {
-                                       updateQuery();
-                               }
-                       });
-                       //   newValues[i] = new Text(container, SWT.BORDER | SWT.SINGLE);
-                       //   newValues[i].setText(data[i]);
-                       //   newValues[i].addModifyListener(new ModifyListener() {
-                       //    public void modifyText(ModifyEvent e) {
-                       //       updateQuery();
-                       //    }
-                       //  });
-                       setValues[i] = new Button(container, SWT.CHECK);
-                       //setValues[i].setText("Select Value");
-                       setValues[i].addSelectionListener(new SelectionListener() {
-                               public void widgetDefaultSelected(SelectionEvent e) {
-                               }
-                               public void widgetSelected(SelectionEvent e) {
-                                       updateQuery();
-                               }
-                       });
-               }
-               query = new Label(container, SWT.WRAP);
-               GridData gridData = new GridData();
-               gridData.horizontalSpan = layoutColumns;
-               gridData.horizontalAlignment = GridData.FILL;
-               gridData.verticalAlignment = GridData.FILL;
-               gridData.grabExcessHorizontalSpace = true;
-               gridData.grabExcessVerticalSpace = true;
-               query.setLayoutData(gridData);
-
-               setControl(container);
-               updateQuery();
-
-               setPageComplete(true);
-       }
-
-       public void updateQuery() {
-               System.out.println("PHP SELECT");
-               StringBuffer setClause = new StringBuffer();
-               StringBuffer whereClause = new StringBuffer();
-               String temp;
-               boolean firstClause = false;
-               for (int i = 0; i < columnNames.length; i++) {
-                       if (primaryKeys[i].getSelection()) {
-                               if (firstClause) {
-                                       whereClause.append(" AND ");
-                               }
-                               firstClause = true;
-                               whereClause.append(columnNames[i]);
-                               whereClause.append(" = ");
-                               temp = whereValues[i].getText();
-                               //        if (temp.charAt(0) == '$') {
-                               //          whereClause.append(temp);
-                               //        } else {
-                               whereClause.append("'" + temp + "'");
-                               //        }
-
-                       }
-                       if (setValues[i].getSelection()) {
-                               setClause.append(columnNames[i]);
-                               //   setClause.append(" = ");
-                               //   setClause.append(newValues[i].getText());
-                               setClause.append(", ");
-                       }
-               }
-               //    if (whereClause.length() > 1) {
-               //      whereClause.deleteCharAt(whereClause.length() - 1);
-               //      whereClause.deleteCharAt(whereClause.length() - 1);
-               //    }
-               if (setClause.length() > 1) {
-                       setClause.deleteCharAt(setClause.length() - 1);
-                       setClause.deleteCharAt(setClause.length() - 1);
-               }
-
-               String[] arguments =
-                       { setClause.toString(), row.getTable(), whereClause.toString()};
-               MessageFormat form =
-                       new MessageFormat(
-                               fStore.getString("phpeclipse.sql.select.template"));
-
-               String query = form.format(arguments);
-               //    String query = "$results = mysql_query(\"SELECT " + setClause.toString();
-               //    query += " FROM " + row.getTable();
-               //    query += " WHERE " + whereClause.toString() + "\");";
-               this.query.setText(query);
-       }
-
-       public boolean performFinish() {
-               PHPSourceConsole console = PHPSourceConsole.getInstance();
-               console.clear();
-               console.print(query.getText());
-               return true;
-       }
+  TableRow row;
+  String[] columnNames;
+  Text[] whereValues;
+  // Text[] newValues;
+  Button[] primaryKeys;
+  Button[] setValues;
+  Label query;
+  IPreferenceStore fStore;
+
+  public PHPSelectRowPage(String pageName) {
+    super(pageName);
+  }
+
+  public void init(TableRow row, TableAdapter adapter) {
+    this.row = row;
+  }
+
+  public void createControl(Composite parent) {
+    if (DEBUG) {
+      System.out.println("page create control");
+    }
+    Composite container = new Composite(parent, SWT.NULL);
+    fStore = PHPEclipseSQLPlugin.getDefault().getPreferenceStore();
+
+    GridLayout layout = new GridLayout();
+    container.setLayout(layout);
+    int layoutColumns = 4;
+    layout.numColumns = layoutColumns;
+
+    if (DEBUG) {
+      if (row == null) {
+        System.out.println("Row is null");
+      }
+      if (row.getColumnNames() == null) {
+        System.out.println("Columns are null");
+      }
+      if (row.getTableData() == null) {
+        System.out.println("Data is null");
+      }
+    }
+
+    columnNames = row.getColumnNames();
+    String[] data = row.getTableData();
+
+    for (int i = 0; i < row.getColumnCount(); i++) {
+      System.out.println("data = " + i + "=" + data[i]);
+      System.out.println("column = " + i + "=" + columnNames[i]);
+    }
+
+    whereValues = new Text[row.getColumnCount()];
+    //  newValues = new Text[row.getColumnCount()];
+    primaryKeys = new Button[row.getColumnCount()];
+    setValues = new Button[row.getColumnCount()];
+    Label temp = new Label(container, SWT.NULL);
+    temp.setText("Column Name");
+    temp = new Label(container, SWT.NULL);
+    temp.setText("Value");
+    temp = new Label(container, SWT.NULL);
+    temp.setText("Where");
+    //    temp = new Label(container, SWT.NULL);
+    //    temp.setText("New Value");
+    temp = new Label(container, SWT.NULL);
+    temp.setText("Select");
+    for (int i = 0; i < row.getColumnCount(); i++) {
+      Label label = new Label(container, SWT.NULL);
+      label.setText(columnNames[i]);
+      whereValues[i] = new Text(container, SWT.BORDER | SWT.SINGLE);
+      if (data[i] == null || data[i].equals("")) {
+        whereValues[i].setText('$' + columnNames[i]);
+      } else {
+        whereValues[i].setText(data[i]);
+      }
+
+      whereValues[i].addModifyListener(new ModifyListener() {
+        public void modifyText(ModifyEvent e) {
+          updateQuery();
+        }
+      });
+
+      primaryKeys[i] = new Button(container, SWT.CHECK);
+      //primaryKeys[i].setText("Where Clause");
+      primaryKeys[i].addSelectionListener(new SelectionListener() {
+        public void widgetDefaultSelected(SelectionEvent e) {
+        }
+        public void widgetSelected(SelectionEvent e) {
+          updateQuery();
+        }
+      });
+      //   newValues[i] = new Text(container, SWT.BORDER | SWT.SINGLE);
+      //   newValues[i].setText(data[i]);
+      //   newValues[i].addModifyListener(new ModifyListener() {
+      //    public void modifyText(ModifyEvent e) {
+      //       updateQuery();
+      //    }
+      //  });
+      setValues[i] = new Button(container, SWT.CHECK);
+      //setValues[i].setText("Select Value");
+      setValues[i].addSelectionListener(new SelectionListener() {
+        public void widgetDefaultSelected(SelectionEvent e) {
+        }
+        public void widgetSelected(SelectionEvent e) {
+          updateQuery();
+        }
+      });
+    }
+    query = new Label(container, SWT.WRAP);
+    GridData gridData = new GridData();
+    gridData.horizontalSpan = layoutColumns;
+    gridData.horizontalAlignment = GridData.FILL;
+    gridData.verticalAlignment = GridData.FILL;
+    gridData.grabExcessHorizontalSpace = true;
+    gridData.grabExcessVerticalSpace = true;
+    query.setLayoutData(gridData);
+
+    setControl(container);
+    updateQuery();
+
+    setPageComplete(true);
+  }
+
+  public void updateQuery() {
+    if (DEBUG) {
+      System.out.println("PHP SELECT");
+    }
+    StringBuffer setClause = new StringBuffer();
+    StringBuffer whereClause = new StringBuffer();
+    String temp;
+    boolean firstClause = false;
+    for (int i = 0; i < columnNames.length; i++) {
+      if (primaryKeys[i].getSelection()) {
+        if (firstClause) {
+          whereClause.append(" AND ");
+        }
+        firstClause = true;
+        whereClause.append(columnNames[i]);
+        whereClause.append(" = ");
+        temp = whereValues[i].getText();
+        //        if (temp.charAt(0) == '$') {
+        //          whereClause.append(temp);
+        //        } else {
+        whereClause.append("'" + temp + "'");
+        //        }
+
+      }
+      if (setValues[i].getSelection()) {
+        setClause.append(columnNames[i]);
+        //   setClause.append(" = ");
+        //   setClause.append(newValues[i].getText());
+        setClause.append(", ");
+      }
+    }
+    //    if (whereClause.length() > 1) {
+    //      whereClause.deleteCharAt(whereClause.length() - 1);
+    //      whereClause.deleteCharAt(whereClause.length() - 1);
+    //    }
+    if (setClause.length() > 1) {
+      setClause.deleteCharAt(setClause.length() - 1);
+      setClause.deleteCharAt(setClause.length() - 1);
+    }
+
+    String[] arguments = { setClause.toString(), row.getTable(), whereClause.toString()};
+    MessageFormat form = new MessageFormat(fStore.getString("phpeclipse.sql.select.template"));
+
+    String query = form.format(arguments);
+    //    String query = "$results = mysql_query(\"SELECT " + setClause.toString();
+    //    query += " FROM " + row.getTable();
+    //    query += " WHERE " + whereClause.toString() + "\");";
+    this.query.setText(query);
+  }
+
+  public boolean performFinish() {
+    PHPSourceConsole console = PHPSourceConsole.getInstance();
+    console.clear();
+    console.print(query.getText());
+    return true;
+  }
 }
\ No newline at end of file
index 9ebab2b..951d4f6 100644 (file)
@@ -22,164 +22,173 @@ import net.sourceforge.phpdt.sql.view.PHPSourceConsole;
 import net.sourceforge.phpdt.sql.view.tableview.TableAdapter;
 
 public class PHPUpdateRowPage extends WizardPage implements SQLPage {
-       TableRow row;
-       String[] columnNames;
-       Text[] oldValues;
-       Text[] newValues;
-       Button[] primaryKeys;
-       Button[] setValues;
-       Label query;
-       IPreferenceStore fStore;
-
-       public PHPUpdateRowPage(String pageName) {
-               super(pageName);
-       }
-
-       public void init(TableRow row, TableAdapter adapter) {
-               this.row = row;
-       }
-
-       public void createControl(Composite parent) {
-               System.out.println("page create control");
-               fStore = PHPEclipseSQLPlugin.getDefault().getPreferenceStore();
-               Composite container = new Composite(parent, SWT.NULL);
-               GridLayout layout = new GridLayout();
-               container.setLayout(layout);
-               int layoutColumns = 5;
-               layout.numColumns = layoutColumns;
-
-               if (row == null) {
-                       System.out.println("Row is null");
-               }
-               if (row.getColumnNames() == null) {
-                       System.out.println("Columns are null");
-               }
-               if (row.getTableData() == null) {
-                       System.out.println("Data is null");
-               }
-
-               columnNames = row.getColumnNames();
-               String[] data = row.getTableData();
-               for (int i = 0; i < row.getColumnCount(); i++) {
-                       System.out.println("data = " + i + "=" + data[i]);
-                       System.out.println("column = " + i + "=" + columnNames[i]);
-               }
-               oldValues = new Text[row.getColumnCount()];
-               newValues = new Text[row.getColumnCount()];
-               primaryKeys = new Button[row.getColumnCount()];
-               setValues = new Button[row.getColumnCount()];
-               Label temp = new Label(container, SWT.NULL);
-               temp.setText("Column Name");
-               temp = new Label(container, SWT.NULL);
-               temp.setText("Where Value");
-               temp = new Label(container, SWT.NULL);
-               temp.setText("Where");
-               temp = new Label(container, SWT.NULL);
-               temp.setText("Set Value");
-               temp = new Label(container, SWT.NULL);
-               temp.setText("Set");
-               for (int i = 0; i < row.getColumnCount(); i++) {
-                       Label label = new Label(container, SWT.NULL);
-                       label.setText(columnNames[i]);
-                       oldValues[i] = new Text(container, SWT.BORDER | SWT.SINGLE);
-                       if (data[i] == null || data[i].equals("")) {
-                               oldValues[i].setText('$' + columnNames[i]);
-                       } else {
-                               oldValues[i].setText(data[i]);
-                       }
-                       oldValues[i].addModifyListener(new ModifyListener() {
-                               public void modifyText(ModifyEvent e) {
-                                       updateQuery();
-                               }
-                       });
-                       primaryKeys[i] = new Button(container, SWT.CHECK);
-                       //   primaryKeys[i].setText("Where");
-                       primaryKeys[i].addSelectionListener(new SelectionListener() {
-                               public void widgetDefaultSelected(SelectionEvent e) {
-                               }
-                               public void widgetSelected(SelectionEvent e) {
-                                       updateQuery();
-                               }
-                       });
-                       newValues[i] = new Text(container, SWT.BORDER | SWT.SINGLE);
-
-                       if (data[i] == null || data[i].equals("")) {
-                               newValues[i].setText('$' + columnNames[i]);
-                       } else {
-                               newValues[i].setText(data[i]);
-                       }
-                       newValues[i].addModifyListener(new ModifyListener() {
-                               public void modifyText(ModifyEvent e) {
-                                       updateQuery();
-                               }
-                       });
-                       setValues[i] = new Button(container, SWT.CHECK);
-                       //  setValues[i].setText("Set Value");
-                       setValues[i].addSelectionListener(new SelectionListener() {
-                               public void widgetDefaultSelected(SelectionEvent e) {
-                               }
-                               public void widgetSelected(SelectionEvent e) {
-                                       updateQuery();
-                               }
-                       });
-               }
-               query = new Label(container, SWT.WRAP);
-               GridData gridData = new GridData();
-               gridData.horizontalSpan = layoutColumns;
-               gridData.horizontalAlignment = GridData.FILL;
-               gridData.verticalAlignment = GridData.FILL;
-               gridData.grabExcessHorizontalSpace = true;
-               gridData.grabExcessVerticalSpace = true;
-               query.setLayoutData(gridData);
-
-               setControl(container);
-               updateQuery();
-
-               setPageComplete(true);
-       }
-       public void updateQuery() {
-               System.out.println("Updating update query");
-               StringBuffer setClause = new StringBuffer();
-               StringBuffer whereClause = new StringBuffer();
-               for (int i = 0; i < columnNames.length; i++) {
-                       if (primaryKeys[i].getSelection()) {
-                               whereClause.append(columnNames[i]);
-                               whereClause.append(" = ");
-                               whereClause.append("'" + oldValues[i].getText() + "'");
-                               whereClause.append(", ");
-                       }
-                       if (setValues[i].getSelection()) {
-                               setClause.append(columnNames[i]);
-                               setClause.append(" = ");
-                               setClause.append("'" + newValues[i].getText() + "'");
-                               setClause.append(", ");
-                       }
-               }
-               if (whereClause.length() > 1) {
-                       whereClause.deleteCharAt(whereClause.length() - 1);
-                       whereClause.deleteCharAt(whereClause.length() - 1);
-               }
-               if (setClause.length() > 1) {
-                       setClause.deleteCharAt(setClause.length() - 1);
-                       setClause.deleteCharAt(setClause.length() - 1);
-               }
-               String[] arguments =
-                       { setClause.toString(), row.getTable(), whereClause.toString()};
-               MessageFormat form =
-                       new MessageFormat(
-                               fStore.getString("phpeclipse.sql.update.template"));
-
-               String query = form.format(arguments);
-               //
-               //    String query = "$results = mysql_query(\"UPDATE " + row.getTable();
-               //    query += " SET " + setClause.toString();
-               //    query += " WHERE " + whereClause.toString() + "\");";
-               this.query.setText(query);
-       }
-       public boolean performFinish() {
-               PHPSourceConsole console = PHPSourceConsole.getInstance();
-               console.clear();
-               console.print(query.getText());
-               return true;
-       }
+  TableRow row;
+  String[] columnNames;
+  Text[] oldValues;
+  Text[] newValues;
+  Button[] primaryKeys;
+  Button[] setValues;
+  Label query;
+  IPreferenceStore fStore;
+
+  public PHPUpdateRowPage(String pageName) {
+    super(pageName);
+  }
+
+  public void init(TableRow row, TableAdapter adapter) {
+    this.row = row;
+  }
+
+  public void createControl(Composite parent) {
+    if (DEBUG) {
+      System.out.println("page create control");
+    }
+    fStore = PHPEclipseSQLPlugin.getDefault().getPreferenceStore();
+    Composite container = new Composite(parent, SWT.NULL);
+    GridLayout layout = new GridLayout();
+    container.setLayout(layout);
+    int layoutColumns = 5;
+    layout.numColumns = layoutColumns;
+
+    if (DEBUG) {
+      if (row == null) {
+        System.out.println("Row is null");
+      }
+      if (row.getColumnNames() == null) {
+        System.out.println("Columns are null");
+      }
+      if (row.getTableData() == null) {
+        System.out.println("Data is null");
+      }
+    }
+
+    columnNames = row.getColumnNames();
+    String[] data = row.getTableData();
+
+    if (DEBUG) {
+      for (int i = 0; i < row.getColumnCount(); i++) {
+        System.out.println("data = " + i + "=" + data[i]);
+        System.out.println("column = " + i + "=" + columnNames[i]);
+      }
+    }
+
+    oldValues = new Text[row.getColumnCount()];
+    newValues = new Text[row.getColumnCount()];
+    primaryKeys = new Button[row.getColumnCount()];
+    setValues = new Button[row.getColumnCount()];
+    Label temp = new Label(container, SWT.NULL);
+    temp.setText("Column Name");
+    temp = new Label(container, SWT.NULL);
+    temp.setText("Where Value");
+    temp = new Label(container, SWT.NULL);
+    temp.setText("Where");
+    temp = new Label(container, SWT.NULL);
+    temp.setText("Set Value");
+    temp = new Label(container, SWT.NULL);
+    temp.setText("Set");
+    for (int i = 0; i < row.getColumnCount(); i++) {
+      Label label = new Label(container, SWT.NULL);
+      label.setText(columnNames[i]);
+      oldValues[i] = new Text(container, SWT.BORDER | SWT.SINGLE);
+      if (data[i] == null || data[i].equals("")) {
+        oldValues[i].setText('$' + columnNames[i]);
+      } else {
+        oldValues[i].setText(data[i]);
+      }
+      oldValues[i].addModifyListener(new ModifyListener() {
+        public void modifyText(ModifyEvent e) {
+          updateQuery();
+        }
+      });
+      primaryKeys[i] = new Button(container, SWT.CHECK);
+      //   primaryKeys[i].setText("Where");
+      primaryKeys[i].addSelectionListener(new SelectionListener() {
+        public void widgetDefaultSelected(SelectionEvent e) {
+        }
+        public void widgetSelected(SelectionEvent e) {
+          updateQuery();
+        }
+      });
+      newValues[i] = new Text(container, SWT.BORDER | SWT.SINGLE);
+
+      if (data[i] == null || data[i].equals("")) {
+        newValues[i].setText('$' + columnNames[i]);
+      } else {
+        newValues[i].setText(data[i]);
+      }
+      newValues[i].addModifyListener(new ModifyListener() {
+        public void modifyText(ModifyEvent e) {
+          updateQuery();
+        }
+      });
+      setValues[i] = new Button(container, SWT.CHECK);
+      //  setValues[i].setText("Set Value");
+      setValues[i].addSelectionListener(new SelectionListener() {
+        public void widgetDefaultSelected(SelectionEvent e) {
+        }
+        public void widgetSelected(SelectionEvent e) {
+          updateQuery();
+        }
+      });
+    }
+    query = new Label(container, SWT.WRAP);
+    GridData gridData = new GridData();
+    gridData.horizontalSpan = layoutColumns;
+    gridData.horizontalAlignment = GridData.FILL;
+    gridData.verticalAlignment = GridData.FILL;
+    gridData.grabExcessHorizontalSpace = true;
+    gridData.grabExcessVerticalSpace = true;
+    query.setLayoutData(gridData);
+
+    setControl(container);
+    updateQuery();
+
+    setPageComplete(true);
+  }
+  
+  public void updateQuery() {
+    if (DEBUG) {
+      System.out.println("Updating update query");
+    }
+
+    StringBuffer setClause = new StringBuffer();
+    StringBuffer whereClause = new StringBuffer();
+    for (int i = 0; i < columnNames.length; i++) {
+      if (primaryKeys[i].getSelection()) {
+        whereClause.append(columnNames[i]);
+        whereClause.append(" = ");
+        whereClause.append("'" + oldValues[i].getText() + "'");
+        whereClause.append(", ");
+      }
+      if (setValues[i].getSelection()) {
+        setClause.append(columnNames[i]);
+        setClause.append(" = ");
+        setClause.append("'" + newValues[i].getText() + "'");
+        setClause.append(", ");
+      }
+    }
+    if (whereClause.length() > 1) {
+      whereClause.deleteCharAt(whereClause.length() - 1);
+      whereClause.deleteCharAt(whereClause.length() - 1);
+    }
+    if (setClause.length() > 1) {
+      setClause.deleteCharAt(setClause.length() - 1);
+      setClause.deleteCharAt(setClause.length() - 1);
+    }
+    String[] arguments = { row.getTable(), setClause.toString(), whereClause.toString()};
+    MessageFormat form = new MessageFormat(fStore.getString("phpeclipse.sql.update.template"));
+
+    String query = form.format(arguments);
+    //
+    //    String query = "$results = mysql_query(\"UPDATE " + row.getTable();
+    //    query += " SET " + setClause.toString();
+    //    query += " WHERE " + whereClause.toString() + "\");";
+    this.query.setText(query);
+  }
+  public boolean performFinish() {
+    PHPSourceConsole console = PHPSourceConsole.getInstance();
+    console.clear();
+    console.print(query.getText());
+    return true;
+  }
 }
\ No newline at end of file
index bf53558..173ed5d 100644 (file)
@@ -6,6 +6,7 @@ import net.sourceforge.phpdt.sql.sql.TableRow;
 import net.sourceforge.phpdt.sql.view.tableview.TableAdapter;
 
 public interface SQLPage extends IWizardPage {
+       public final static boolean DEBUG = false;
        public void init(TableRow row, TableAdapter adapter);
        public boolean performFinish();
 }
index d9391ec..bebd311 100644 (file)
@@ -25,163 +25,181 @@ import net.sourceforge.phpdt.sql.view.bookmark.TreeNode;
 import net.sourceforge.phpdt.sql.view.tableview.TableAdapter;
 
 public class UpdateRowPage extends WizardPage implements SQLPage {
-       TableRow row;
-       String[] columnNames;
-       Text[] oldValues;
-       Text[] newValues;
-       Button[] primaryKeys;
-       Button[] setValues;
-       Label query;
-       public UpdateRowPage(String pageName) {
-               super(pageName);
-       }
-
-       public void init(TableRow row, TableAdapter adapter) {
-               this.row = row;
-       }
-       
-       public void createControl(Composite parent) {
-               System.out.println("page create control"); //$NON-NLS-1$
-               Composite container = new Composite(parent, SWT.NULL);
-               GridLayout layout = new GridLayout();
-               container.setLayout(layout);
-               BookmarkNode bookmark = row.getBookmarkNode();
-               TreeNode node = bookmark.find(row.getTable());
-               ObjectMetaData metadata = null;
-               if (node != null) metadata = node.getMetaData(); 
-               
-               int layoutColumns = 5;
-               layout.numColumns = layoutColumns;
-
-               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$
-               }
-               oldValues = new Text[row.getColumnCount()];
-               newValues = new Text[row.getColumnCount()];
-               primaryKeys = new Button[row.getColumnCount()];
-               setValues = new Button[row.getColumnCount()];
-               Label temp = new Label(container, SWT.NULL);
-               temp.setText(Messages.getString("UpdateRowPage.ColumnName")); //$NON-NLS-1$
-               temp = new Label(container, SWT.NULL);
-               temp.setText(Messages.getString("UpdateRowPage.OldValue")); //$NON-NLS-1$
-               temp = new Label(container, SWT.NULL);
-               temp.setText(""); //$NON-NLS-1$
-               temp = new Label(container, SWT.NULL);
-               temp.setText(Messages.getString("UpdateRowPage.NewValue")); //$NON-NLS-1$
-               temp = new Label(container, SWT.NULL);
-               temp.setText(Messages.getString("UpdateRowPage._13")); //$NON-NLS-1$
-               for (int i = 0; i < row.getColumnCount(); i++) {
-                       Label label = new Label(container, SWT.NULL);
-                       label.setText(columnNames[i]);
-                       oldValues[i] = new Text(container, SWT.BORDER | SWT.SINGLE);
-                       oldValues[i].setText(data[i]);
-                       oldValues[i].addModifyListener(new ModifyListener() {
-                               public void modifyText(ModifyEvent e) {
-                                       updateQuery();
-                               }                               
-                       });
-                       primaryKeys[i] = new Button(container, SWT.CHECK);
-                       primaryKeys[i].setText("Where"); //$NON-NLS-1$
-                       if (metadata != null && metadata.getPrimaryKeyOrder(columnNames[i]) > 0) primaryKeys[i].setSelection(true);
-                       primaryKeys[i].addSelectionListener(new SelectionListener() {
-                               public void widgetDefaultSelected(SelectionEvent e) {
-                               }
-                               public void widgetSelected(SelectionEvent e) {
-                                       updateQuery();
-                               }
-                       });
-                       newValues[i] = new Text(container, SWT.BORDER | SWT.SINGLE);
-                       newValues[i].setText(data[i]);
-                       newValues[i].addModifyListener(new ModifyListener() {
-                               public void modifyText(ModifyEvent e) {
-                                       updateQuery();
-                               }                               
-                       });
-                       setValues[i] = new Button(container, SWT.CHECK);
-                       setValues[i].setText(Messages.getString("UpdateRowPage.SetValue")); //$NON-NLS-1$
-                       setValues[i].addSelectionListener(new SelectionListener() {
-                               public void widgetDefaultSelected(SelectionEvent e) {
-                               }
-                               public void widgetSelected(SelectionEvent e) {
-                                       updateQuery();
-                               }
-                       });
-               }
-               query = new Label(container, SWT.WRAP);
-               GridData gridData = new GridData();
-               gridData.horizontalSpan = layoutColumns;
-               gridData.horizontalAlignment = GridData.FILL;
-               gridData.verticalAlignment = GridData.FILL;
-               gridData.grabExcessHorizontalSpace = true;
-               gridData.grabExcessVerticalSpace = true;
-               query.setLayoutData(gridData);
-
-               setControl(container);
-        updateQuery();
-       
-               setPageComplete(true);
-       }
-       public void updateQuery() {
-               System.out.println("Updating query"); //$NON-NLS-1$
-               StringBuffer setClause = new StringBuffer();
-               StringBuffer whereClause = new StringBuffer();
-               BookmarkNode bookmark = row.getBookmarkNode();
-               TreeNode node = bookmark.find(row.getTable());
-               ObjectMetaData metadata = null;
-               if (node != null) metadata = node.getMetaData(); 
-               DatabaseAdapter adapter = AdapterFactory.getInstance().getAdapter(bookmark.getType());
-               
-               int numValuesSet = 0;
-               int numValuesWhere = 0;
-               for (int i = 0; i < columnNames.length; i++) {
-                       if (primaryKeys[i].getSelection()) {
-                               String value = oldValues[i].getText();
-                               if (numValuesWhere > 0) whereClause.append(" AND "); //$NON-NLS-1$
-                               whereClause.append("("); //$NON-NLS-1$
-                               whereClause.append(columnNames[i]);
-                               whereClause.append(" = "); //$NON-NLS-1$
-                               if (adapter != null && metadata != null && value != "") //$NON-NLS-1$
-                                       whereClause.append(adapter.quote(value, metadata.getColumnType(columnNames[i])));
-                               else
-                                       whereClause.append(value);
-                               whereClause.append(")"); //$NON-NLS-1$
-                               numValuesWhere++;
-                       } 
-                       if (setValues[i].getSelection()) {
-                               String value = newValues[i].getText();
-                               if (numValuesSet > 0) setClause.append(", "); //$NON-NLS-1$
-                               setClause.append(columnNames[i]);
-                               setClause.append(" = "); //$NON-NLS-1$
-                               if (adapter != null && metadata != null && value != "") //$NON-NLS-1$
-                                       setClause.append(adapter.quote(value, metadata.getColumnType(columnNames[i])));
-                               else
-                                       setClause.append(value);
-                               numValuesSet++;
-                               
-                       }
-               }
-                       String query = "UPDATE " + row.getTable(); //$NON-NLS-1$
-               query += " SET " + setClause.toString(); //$NON-NLS-1$
-               query += " WHERE " + whereClause.toString(); //$NON-NLS-1$
-               this.query.setText(query);
-       }
-       public boolean performFinish() {
-          MultiSQLServer server = MultiSQLServer.getInstance();
-          BookmarkView bookmarkView = BookmarkView.getInstance(); 
-          BookmarkNode bookmark = bookmarkView.getCurrentBookmark();
-          server.execute(bookmark.getConnection(), query.getText());
-          return true;
-       }
+  TableRow row;
+  String[] columnNames;
+  Text[] oldValues;
+  Text[] newValues;
+  Button[] primaryKeys;
+  Button[] setValues;
+  Label query;
+  public UpdateRowPage(String pageName) {
+    super(pageName);
+  }
+
+  public void init(TableRow row, TableAdapter adapter) {
+    this.row = row;
+  }
+
+  public void createControl(Composite parent) {
+    if (DEBUG) {
+      System.out.println("page create control"); //$NON-NLS-1$
+    }
+
+    Composite container = new Composite(parent, SWT.NULL);
+    GridLayout layout = new GridLayout();
+    container.setLayout(layout);
+    BookmarkNode bookmark = row.getBookmarkNode();
+    TreeNode node = bookmark.find(row.getTable());
+    ObjectMetaData metadata = null;
+    if (node != null)
+      metadata = node.getMetaData();
+
+    int layoutColumns = 5;
+    layout.numColumns = layoutColumns;
+
+    if (DEBUG) {
+      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();
+
+    if (DEBUG) {
+      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$
+      }
+    }
+
+    oldValues = new Text[row.getColumnCount()];
+    newValues = new Text[row.getColumnCount()];
+    primaryKeys = new Button[row.getColumnCount()];
+    setValues = new Button[row.getColumnCount()];
+    Label temp = new Label(container, SWT.NULL);
+    temp.setText(Messages.getString("UpdateRowPage.ColumnName")); //$NON-NLS-1$
+    temp = new Label(container, SWT.NULL);
+    temp.setText(Messages.getString("UpdateRowPage.OldValue")); //$NON-NLS-1$
+    temp = new Label(container, SWT.NULL);
+    temp.setText(""); //$NON-NLS-1$
+    temp = new Label(container, SWT.NULL);
+    temp.setText(Messages.getString("UpdateRowPage.NewValue")); //$NON-NLS-1$
+    temp = new Label(container, SWT.NULL);
+    temp.setText(Messages.getString("UpdateRowPage._13")); //$NON-NLS-1$
+    for (int i = 0; i < row.getColumnCount(); i++) {
+      Label label = new Label(container, SWT.NULL);
+      label.setText(columnNames[i]);
+      oldValues[i] = new Text(container, SWT.BORDER | SWT.SINGLE);
+      oldValues[i].setText(data[i]);
+      oldValues[i].addModifyListener(new ModifyListener() {
+        public void modifyText(ModifyEvent e) {
+          updateQuery();
+        }
+      });
+      primaryKeys[i] = new Button(container, SWT.CHECK);
+      primaryKeys[i].setText("Where"); //$NON-NLS-1$
+      if (metadata != null && metadata.getPrimaryKeyOrder(columnNames[i]) > 0)
+        primaryKeys[i].setSelection(true);
+      primaryKeys[i].addSelectionListener(new SelectionListener() {
+        public void widgetDefaultSelected(SelectionEvent e) {
+        }
+        public void widgetSelected(SelectionEvent e) {
+          updateQuery();
+        }
+      });
+      newValues[i] = new Text(container, SWT.BORDER | SWT.SINGLE);
+      newValues[i].setText(data[i]);
+      newValues[i].addModifyListener(new ModifyListener() {
+        public void modifyText(ModifyEvent e) {
+          updateQuery();
+        }
+      });
+      setValues[i] = new Button(container, SWT.CHECK);
+      setValues[i].setText(Messages.getString("UpdateRowPage.SetValue")); //$NON-NLS-1$
+      setValues[i].addSelectionListener(new SelectionListener() {
+        public void widgetDefaultSelected(SelectionEvent e) {
+        }
+        public void widgetSelected(SelectionEvent e) {
+          updateQuery();
+        }
+      });
+    }
+    query = new Label(container, SWT.WRAP);
+    GridData gridData = new GridData();
+    gridData.horizontalSpan = layoutColumns;
+    gridData.horizontalAlignment = GridData.FILL;
+    gridData.verticalAlignment = GridData.FILL;
+    gridData.grabExcessHorizontalSpace = true;
+    gridData.grabExcessVerticalSpace = true;
+    query.setLayoutData(gridData);
+
+    setControl(container);
+    updateQuery();
+
+    setPageComplete(true);
+  }
+  public void updateQuery() {
+    if (DEBUG) {
+      System.out.println("Updating query"); //$NON-NLS-1$
+    }
+
+    StringBuffer setClause = new StringBuffer();
+    StringBuffer whereClause = new StringBuffer();
+    BookmarkNode bookmark = row.getBookmarkNode();
+    TreeNode node = bookmark.find(row.getTable());
+    ObjectMetaData metadata = null;
+    if (node != null)
+      metadata = node.getMetaData();
+    DatabaseAdapter adapter = AdapterFactory.getInstance().getAdapter(bookmark.getType());
+
+    int numValuesSet = 0;
+    int numValuesWhere = 0;
+    for (int i = 0; i < columnNames.length; i++) {
+      if (primaryKeys[i].getSelection()) {
+        String value = oldValues[i].getText();
+        if (numValuesWhere > 0)
+          whereClause.append(" AND "); //$NON-NLS-1$
+        whereClause.append("("); //$NON-NLS-1$
+        whereClause.append(columnNames[i]);
+        whereClause.append(" = "); //$NON-NLS-1$
+        if (adapter != null && metadata != null && value != "") //$NON-NLS-1$
+          whereClause.append(adapter.quote(value, metadata.getColumnType(columnNames[i])));
+        else
+          whereClause.append(value);
+        whereClause.append(")"); //$NON-NLS-1$
+        numValuesWhere++;
+      }
+      if (setValues[i].getSelection()) {
+        String value = newValues[i].getText();
+        if (numValuesSet > 0)
+          setClause.append(", "); //$NON-NLS-1$
+        setClause.append(columnNames[i]);
+        setClause.append(" = "); //$NON-NLS-1$
+        if (adapter != null && metadata != null && value != "") //$NON-NLS-1$
+          setClause.append(adapter.quote(value, metadata.getColumnType(columnNames[i])));
+        else
+          setClause.append(value);
+        numValuesSet++;
+
+      }
+    }
+    String query = "UPDATE " + row.getTable(); //$NON-NLS-1$
+    query += " SET " + setClause.toString(); //$NON-NLS-1$
+    query += " WHERE " + whereClause.toString(); //$NON-NLS-1$
+    this.query.setText(query);
+  }
+  public boolean performFinish() {
+    MultiSQLServer server = MultiSQLServer.getInstance();
+    BookmarkView bookmarkView = BookmarkView.getInstance();
+    BookmarkNode bookmark = bookmarkView.getCurrentBookmark();
+    server.execute(bookmark.getConnection(), query.getText());
+    return true;
+  }
 }
\ No newline at end of file