misc changes/refactorings
authorkhartlage <khartlage>
Tue, 4 Mar 2003 19:09:46 +0000 (19:09 +0000)
committerkhartlage <khartlage>
Tue, 4 Mar 2003 19:09:46 +0000 (19:09 +0000)
12 files changed:
archive/net.sourceforge.phpeclipse.sql/plugin.xml
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/actions/ViewTableDetailsAction.java
archive/net.sourceforge.phpeclipse.sql/src/net/sourceforge/phpdt/sql/editors/SQLConfiguration.java
archive/net.sourceforge.phpeclipse.sql/src/net/sourceforge/phpdt/sql/editors/SQLEditor.java
archive/net.sourceforge.phpeclipse.sql/src/net/sourceforge/phpdt/sql/preferences/PreferencesPage.java
archive/net.sourceforge.phpeclipse.sql/src/net/sourceforge/phpdt/sql/view/TableView.java
archive/net.sourceforge.phpeclipse.sql/src/net/sourceforge/phpdt/sql/wizards/PHPDeleteRowPage.java [new file with mode: 0644]
archive/net.sourceforge.phpeclipse.sql/src/net/sourceforge/phpdt/sql/wizards/PHPInsertRowPage.java [new file with mode: 0644]
archive/net.sourceforge.phpeclipse.sql/src/net/sourceforge/phpdt/sql/wizards/PHPUpdateRowPage.java [new file with mode: 0644]
archive/net.sourceforge.phpeclipse.sql/src/net/sourceforge/phpdt/sql/wizards/SQLRowWizard.java

index 1970cc5..23bdeca 100644 (file)
@@ -23,7 +23,7 @@
          point="org.eclipse.ui.perspectives">
       <perspective
             name="%perspective.name"
-            icon="icons/quantum-ng.gif"
+            icon="icons/phpsql.gif"
             class="net.sourceforge.phpdt.sql.perspective.DBPerspective"
             id="net.sourceforge.phpdt.sql.dbperspective">
       </perspective>
@@ -84,7 +84,7 @@
    <extension
          point="org.eclipse.ui.editors">
       <editor
-            name="Quantum SQL Editor"
+            name="PHPEclipse SQL Editor"
             icon="icons/script.gif"
             extensions="sql,ddl"
             contributorClass="org.eclipse.ui.texteditor.BasicTextEditorActionContributor"
@@ -96,8 +96,8 @@
    <extension
          point="org.eclipse.ui.preferencePages">
       <page
-            name="Quantum SQL Editor"
-            category="QuantumDB"
+            name="PHPEclipse SQL Editor"
+            category="PHPSQL"
             class="net.sourceforge.phpdt.sql.preferences.PreferencesPage"
             id="net.sourceforge.phpdt.sql.preferences">
       </page>
index c5bd07a..8449c6f 100644 (file)
@@ -50,7 +50,7 @@ public class PHPEclipseSQLPlugin extends AbstractUIPlugin implements IConstants
 
   public void startup() throws CoreException {
     super.startup();
-    ISaveParticipant saveParticipant = new QuantumSaveParticipant();
+    ISaveParticipant saveParticipant = new PHPSQLSaveParticipant();
     ISavedState lastState =
       ResourcesPlugin.getWorkspace().addSaveParticipant(this, saveParticipant);
     if (lastState == null)
@@ -96,26 +96,26 @@ public class PHPEclipseSQLPlugin extends AbstractUIPlugin implements IConstants
     IPreferenceStore store = getPreferenceStore();
     PreferenceConverter.setDefault(
       store,
-      "quantum.background.color",
+      "phpeclipse.sql.background.color",
       BACKGROUND);
-    PreferenceConverter.setDefault(store, "quantum.text.color", DEFAULT);
-    PreferenceConverter.setDefault(store, "quantum.keyword.color", KEYWORD);
-    PreferenceConverter.setDefault(store, "quantum.comment.color", COMMENT);
-    PreferenceConverter.setDefault(store, "quantum.string.color", STRING);
-    PreferenceConverter.setDefault(store, "quantum.numeric.color", NUMERIC);
-    getPreferenceStore().setDefault("quantum.text.bold", false);
-    getPreferenceStore().setDefault("quantum.keyword.bold", true);
-    getPreferenceStore().setDefault("quantum.string.bold", false);
-    getPreferenceStore().setDefault("quantum.comment.bold", false);
-    getPreferenceStore().setDefault("quantum.numeric.bold", false);
+    PreferenceConverter.setDefault(store, "phpeclipse.sql.text.color", DEFAULT);
+    PreferenceConverter.setDefault(store, "phpeclipse.sql.keyword.color", KEYWORD);
+    PreferenceConverter.setDefault(store, "phpeclipse.sql.comment.color", COMMENT);
+    PreferenceConverter.setDefault(store, "phpeclipse.sql.string.color", STRING);
+    PreferenceConverter.setDefault(store, "phpeclipse.sql.numeric.color", NUMERIC);
+    getPreferenceStore().setDefault("phpeclipse.sql.text.bold", false);
+    getPreferenceStore().setDefault("phpeclipse.sql.keyword.bold", true);
+    getPreferenceStore().setDefault("phpeclipse.sql.string.bold", false);
+    getPreferenceStore().setDefault("phpeclipse.sql.comment.bold", false);
+    getPreferenceStore().setDefault("phpeclipse.sql.numeric.bold", false);
     PreferenceConverter.setDefault(
       getPreferenceStore(),
-      "quantum.font",
+      "phpeclipse.sql.font",
       (FontData) null);
   }
 
 }
-class QuantumSaveParticipant implements ISaveParticipant, IConstants {
+class PHPSQLSaveParticipant implements ISaveParticipant, IConstants {
   /**
    * @see org.eclipse.core.resources.ISaveParticipant#doneSaving(ISaveContext)
    */
index 5953147..1959397 100644 (file)
@@ -26,6 +26,9 @@ tableview.update = Update...
 tableview.insert = Insert...
 tableview.delete = Delete...
 tableview.phpselect = PHP Select...
+tableview.phpupdate = PHP Update...
+tableview.phpinsert = PHP Insert...
+tableview.phpdelete = PHP Delete...
 tableview.filterSort = Sort or Filter Table...
 tableview.showAll = Toggle Show All Table Rows
 tableview.defaultEncoding = Set Default Encoding
index 2c8d5b5..778b332 100644 (file)
@@ -1,11 +1,5 @@
 package net.sourceforge.phpdt.sql.actions;
 
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.ui.IViewActionDelegate;
-import org.eclipse.ui.IViewPart;
-
 import net.sourceforge.phpdt.sql.sql.MultiSQLServer;
 import net.sourceforge.phpdt.sql.view.BookmarkView;
 import net.sourceforge.phpdt.sql.view.TableView;
@@ -13,6 +7,15 @@ import net.sourceforge.phpdt.sql.view.bookmark.TableNode;
 import net.sourceforge.phpdt.sql.view.bookmark.TreeNode;
 import net.sourceforge.phpdt.sql.view.bookmark.ViewNode;
 
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ui.IViewActionDelegate;
+import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+
 public class ViewTableDetailsAction extends Action implements IViewActionDelegate {
        BookmarkView view;
        
@@ -32,6 +35,12 @@ public class ViewTableDetailsAction extends Action implements IViewActionDelegat
                } else if (node instanceof ViewNode) {
                        query.append(((ViewNode) node).getName());
                }
+    try {
+      IWorkbenchPage page =
+        PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+      page.showView(TableView.TABLEVIEW_ID);
+    } catch (PartInitException e) {
+    }
                MultiSQLServer server = MultiSQLServer.getInstance();
                TableView.getInstance().loadQuery(server.execute(query.toString()));
        }
index 10a5a3c..97eae15 100644 (file)
@@ -42,18 +42,18 @@ public class SQLConfiguration extends SourceViewerConfiguration {
        }
        public void loadPrefs() {
                IPreferenceStore store = PHPEclipseSQLPlugin.getDefault().getPreferenceStore();
-               textBold = store.getBoolean("quantum.text.bold");
-               keywordBold = store.getBoolean("quantum.keyword.bold");
-               stringBold = store.getBoolean("quantum.string.bold");
-               commentBold = store.getBoolean("quantum.comment.bold");
-               numericBold = store.getBoolean("quantum.numeric.bold");
-               SQLColorConstants.BACKGROUND = PreferenceConverter.getColor(store, "quantum.background.color");
-               SQLColorConstants.DEFAULT = PreferenceConverter.getColor(store, "quantum.text.color");
-               SQLColorConstants.IDENTIFIER = PreferenceConverter.getColor(store, "quantum.text.color");
-               SQLColorConstants.KEYWORD = PreferenceConverter.getColor(store, "quantum.keyword.color");
-               SQLColorConstants.STRING = PreferenceConverter.getColor(store, "quantum.string.color");
-               SQLColorConstants.COMMENT = PreferenceConverter.getColor(store, "quantum.comment.color");
-               SQLColorConstants.NUMERIC = PreferenceConverter.getColor(store, "quantum.numeric.color");
+               textBold = store.getBoolean("phpeclipse.sql.text.bold");
+               keywordBold = store.getBoolean("phpeclipse.sql.keyword.bold");
+               stringBold = store.getBoolean("phpeclipse.sql.string.bold");
+               commentBold = store.getBoolean("phpeclipse.sql.comment.bold");
+               numericBold = store.getBoolean("phpeclipse.sql.numeric.bold");
+               SQLColorConstants.BACKGROUND = PreferenceConverter.getColor(store, "phpeclipse.sql.background.color");
+               SQLColorConstants.DEFAULT = PreferenceConverter.getColor(store, "phpeclipse.sql.text.color");
+               SQLColorConstants.IDENTIFIER = PreferenceConverter.getColor(store, "phpeclipse.sql.text.color");
+               SQLColorConstants.KEYWORD = PreferenceConverter.getColor(store, "phpeclipse.sql.keyword.color");
+               SQLColorConstants.STRING = PreferenceConverter.getColor(store, "phpeclipse.sql.string.color");
+               SQLColorConstants.COMMENT = PreferenceConverter.getColor(store, "phpeclipse.sql.comment.color");
+               SQLColorConstants.NUMERIC = PreferenceConverter.getColor(store, "phpeclipse.sql.numeric.color");
        }
        public void initializeColors() {
                setDamageRepairer(getAttr(SQLColorConstants.KEYWORD, keywordBold), SQLPartitionScanner.SQL_KEYWORD);
index a7bb715..636c0d1 100644 (file)
@@ -32,7 +32,7 @@ public class SQLEditor extends TextEditor {
                                config.initializeColors();
                                getSourceViewer().invalidateTextPresentation();
                                StyledText widget = getSourceViewer().getTextWidget();
-                               FontData font = PreferenceConverter.getFontData(getPreferenceStore(), "quantum.font");
+                               FontData font = PreferenceConverter.getFontData(getPreferenceStore(), "phpeclipse.sql.font");
                                widget.setFont(new Font(Display.getCurrent(), font));
                                Color background = colorManager.getColor(SQLColorConstants.BACKGROUND);
                                widget.setBackground(background);
@@ -51,7 +51,7 @@ public class SQLEditor extends TextEditor {
        public void createPartControl(Composite arg0) {
                super.createPartControl(arg0);
                StyledText widget = getSourceViewer().getTextWidget();
-               FontData font = PreferenceConverter.getFontData(getPreferenceStore(), "quantum.font");
+               FontData font = PreferenceConverter.getFontData(getPreferenceStore(), "phpeclipse.sql.font");
                widget.setFont(new Font(Display.getCurrent(), font));
                Color background = colorManager.getColor(SQLColorConstants.BACKGROUND);
                widget.setBackground(background);
index 55129f0..c265deb 100644 (file)
@@ -67,17 +67,17 @@ public class PreferencesPage extends PreferencePage
                RGB NUMERIC = new RGB(255, 0, 0);
                RGB DEFAULT = new RGB(0, 0, 0);
                PreferenceConverter.setDefault(store,
-                       "quantum.background.color", BACKGROUND);
+                       "phpeclipse.sql.background.color", BACKGROUND);
                PreferenceConverter.setDefault(store,
-                       "quantum.text.color", DEFAULT);
+                       "phpeclipse.sql.text.color", DEFAULT);
                PreferenceConverter.setDefault(store,
-                       "quantum.keyword.color", KEYWORD);
+                       "phpeclipse.sql.keyword.color", KEYWORD);
                PreferenceConverter.setDefault(store,
-                       "quantum.comment.color", COMMENT);
+                       "phpeclipse.sql.comment.color", COMMENT);
                PreferenceConverter.setDefault(store,
-                       "quantum.string.color", STRING);
+                       "phpeclipse.sql.string.color", STRING);
                PreferenceConverter.setDefault(store,
-                       "quantum.numeric.color", NUMERIC);
+                       "phpeclipse.sql.numeric.color", NUMERIC);
        }
 
        protected void performDefaults() {
@@ -100,12 +100,12 @@ public class PreferencesPage extends PreferencePage
         * Save the preferences to the preference store.
         */
        public boolean performOk() {
-               PreferenceConverter.setValue(getPreferenceStore(), "quantum.font", fontData);
-               getPreferenceStore().setValue("quantum.text.bold", textFlag);
-               getPreferenceStore().setValue("quantum.keyword.bold", keywordFlag);
-               getPreferenceStore().setValue("quantum.string.bold", stringFlag);
-               getPreferenceStore().setValue("quantum.comment.bold", commentFlag);
-               getPreferenceStore().setValue("quantum.numeric.bold", numericFlag);
+               PreferenceConverter.setValue(getPreferenceStore(), "phpeclipse.sql.font", fontData);
+               getPreferenceStore().setValue("phpeclipse.sql.text.bold", textFlag);
+               getPreferenceStore().setValue("phpeclipse.sql.keyword.bold", keywordFlag);
+               getPreferenceStore().setValue("phpeclipse.sql.string.bold", stringFlag);
+               getPreferenceStore().setValue("phpeclipse.sql.comment.bold", commentFlag);
+               getPreferenceStore().setValue("phpeclipse.sql.numeric.bold", numericFlag);
                backgroundColorEditor.store();
                textColorEditor.store();
                keywordColorEditor.store();
@@ -121,12 +121,12 @@ public class PreferencesPage extends PreferencePage
                innerLayout.numColumns = 4;
                main.setLayout(innerLayout);
 
-               fontData = PreferenceConverter.getFontData(getPreferenceStore(), "quantum.font");
-               textFlag = getPreferenceStore().getBoolean("quantum.text.bold");
-               keywordFlag = getPreferenceStore().getBoolean("quantum.keyword.bold");
-               stringFlag = getPreferenceStore().getBoolean("quantum.string.bold");
-               commentFlag = getPreferenceStore().getBoolean("quantum.comment.bold");
-               numericFlag = getPreferenceStore().getBoolean("quantum.numeric.bold");
+               fontData = PreferenceConverter.getFontData(getPreferenceStore(), "phpeclipse.sql.font");
+               textFlag = getPreferenceStore().getBoolean("phpeclipse.sql.text.bold");
+               keywordFlag = getPreferenceStore().getBoolean("phpeclipse.sql.keyword.bold");
+               stringFlag = getPreferenceStore().getBoolean("phpeclipse.sql.string.bold");
+               commentFlag = getPreferenceStore().getBoolean("phpeclipse.sql.comment.bold");
+               numericFlag = getPreferenceStore().getBoolean("phpeclipse.sql.numeric.bold");
                
                fontDialog = new FontDialog(workbench.getActiveWorkbenchWindow().getShell());
                Button fontButton = new Button(main, SWT.PUSH);
@@ -172,7 +172,7 @@ public class PreferencesPage extends PreferencePage
                Color defaultColor = manager.getColor(SQLColorConstants.DEFAULT);
                backgroundColorEditor =
                        new ColorFieldEditor(
-                               "quantum.background.color",
+                               "phpeclipse.sql.background.color",
                                "Background Color",
                                comp);                          
 
@@ -186,7 +186,7 @@ public class PreferencesPage extends PreferencePage
                
                textColorEditor =
                        new ColorFieldEditor(
-                               "quantum.text.color",
+                               "phpeclipse.sql.text.color",
                                "Default Text Color",
                                comp);                          
 
@@ -208,7 +208,7 @@ public class PreferencesPage extends PreferencePage
 
                keywordColorEditor =
                        new ColorFieldEditor(
-                               "quantum.keyword.color",
+                               "phpeclipse.sql.keyword.color",
                                "Keyword Text Color",
                                comp);
 
@@ -230,7 +230,7 @@ public class PreferencesPage extends PreferencePage
 
                commentColorEditor =
                        new ColorFieldEditor(
-                               "quantum.comment.color",
+                               "phpeclipse.sql.comment.color",
                                "Comment Text Color",
                                comp);
 
@@ -252,7 +252,7 @@ public class PreferencesPage extends PreferencePage
 
                stringColorEditor =
                        new ColorFieldEditor(
-                               "quantum.string.color",
+                               "phpeclipse.sql.string.color",
                                "String Text Color",
                                comp);
 
@@ -274,7 +274,7 @@ public class PreferencesPage extends PreferencePage
 
                numericColorEditor =
                        new ColorFieldEditor(
-                               "quantum.numeric.color",
+                               "phpeclipse.sql.numeric.color",
                                "Numeric Text Color",
                                comp);
 
index 97c351f..6f0123c 100644 (file)
@@ -1,6 +1,20 @@
 package net.sourceforge.phpdt.sql.view;
 
 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.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;
@@ -30,21 +44,9 @@ import org.eclipse.ui.ISelectionListener;
 import org.eclipse.ui.IWorkbenchPart;
 import org.eclipse.ui.part.ViewPart;
 
-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.tableview.TableAdapter;
-import net.sourceforge.phpdt.sql.wizards.DeleteRowPage;
-import net.sourceforge.phpdt.sql.wizards.InsertRowPage;
-import net.sourceforge.phpdt.sql.wizards.PHPSelectRowPage;
-import net.sourceforge.phpdt.sql.wizards.SQLRowWizard;
-import net.sourceforge.phpdt.sql.wizards.SortFilterPage;
-import net.sourceforge.phpdt.sql.wizards.UpdateRowPage;
-import net.sourceforge.phpdt.sql.wizards.PHPSelectRowPage;
-
 public class TableView extends ViewPart implements ISelectionListener {
-  public static String TABLEVIEW_ID = "net.sourceforge.phpdt.sql.view.tableview";
+  public static String TABLEVIEW_ID =
+    "net.sourceforge.phpdt.sql.view.tableview";
   private Clipboard clip;
   private RefreshTableAction refreshTableAction;
   private CloseTableAction closeTableAction;
@@ -380,7 +382,7 @@ public class TableView extends ViewPart implements ISelectionListener {
             public void run() {
               PHPSelectRowPage page = new PHPSelectRowPage("");
               SQLRowWizard wizard = new SQLRowWizard();
-              wizard.init("PHP Select Generation", page, row, ta);
+              wizard.init("PHP Select Generator", page, row, ta);
               WizardDialog dialog =
                 new WizardDialog(getSite().getShell(), wizard);
               dialog.open();
@@ -388,13 +390,51 @@ public class TableView extends ViewPart implements ISelectionListener {
           };
           phpSelectAction.setText(Messages.getString("tableview.phpselect")); //$NON-NLS-1$
 
+          Action phpUpdateAction = new Action() {
+            public void run() {
+              PHPUpdateRowPage page = new PHPUpdateRowPage("");
+              SQLRowWizard wizard = new SQLRowWizard();
+              wizard.init("PHP Update Generator", page, row, ta);
+              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("");
+              SQLRowWizard wizard = new SQLRowWizard();
+              wizard.init("PHP Insert Generator", page, row, ta);
+              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("");
+              SQLRowWizard wizard = new SQLRowWizard();
+              wizard.init("PHP Delete Generator", page, row, ta);
+              WizardDialog dialog =
+                new WizardDialog(getSite().getShell(), wizard);
+              dialog.open();
+            }
+          };
+          phpDeleteAction.setText(Messages.getString("tableview.phpdelete")); //$NON-NLS-1$
+
           mgr.add(phpSelectAction);
-          
+          mgr.add(phpUpdateAction);
+          mgr.add(phpInsertAction);
+          mgr.add(phpDeleteAction);
+
           mgr.add(insertAction);
           mgr.add(updateAction);
           mgr.add(deleteAction);
-          
-          
+
         }
         mgr.add(defaultEncodingAction);
         mgr.add(UTF8EncodingAction);
diff --git a/archive/net.sourceforge.phpeclipse.sql/src/net/sourceforge/phpdt/sql/wizards/PHPDeleteRowPage.java b/archive/net.sourceforge.phpeclipse.sql/src/net/sourceforge/phpdt/sql/wizards/PHPDeleteRowPage.java
new file mode 100644 (file)
index 0000000..0815049
--- /dev/null
@@ -0,0 +1,148 @@
+package net.sourceforge.phpdt.sql.wizards;
+
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+import net.sourceforge.phpdt.sql.sql.MultiSQLServer;
+import net.sourceforge.phpdt.sql.sql.TableRow;
+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;
+
+  public PHPDeleteRowPage(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);
+    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);
+      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 query");
+    }
+    StringBuffer whereClause = new StringBuffer();
+    int numSelected = 0;
+    for (int i = 0; i < columnNames.length; i++) {
+      if (whereValues[i].getSelection()) {
+        numSelected++;
+        whereClause.append(columnNames[i]);
+        whereClause.append(" = ");
+        whereClause.append(values[i].getText());
+        whereClause.append(", ");
+      }
+    }
+    if (whereClause.length() > 1) {
+      whereClause.deleteCharAt(whereClause.length() - 1);
+      whereClause.deleteCharAt(whereClause.length() - 1);
+    }
+    String query = "DELETE FROM " + row.getTable();
+    if (numSelected > 0) {
+      query += " WHERE " + whereClause.toString();
+    }
+    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() {
+    MultiSQLServer server = MultiSQLServer.getInstance();
+    server.execute(query.getText());
+    return true;
+  }
+}
\ No newline at end of file
diff --git a/archive/net.sourceforge.phpeclipse.sql/src/net/sourceforge/phpdt/sql/wizards/PHPInsertRowPage.java b/archive/net.sourceforge.phpeclipse.sql/src/net/sourceforge/phpdt/sql/wizards/PHPInsertRowPage.java
new file mode 100644 (file)
index 0000000..cfceda7
--- /dev/null
@@ -0,0 +1,116 @@
+package net.sourceforge.phpdt.sql.wizards;
+
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+import net.sourceforge.phpdt.sql.sql.MultiSQLServer;
+import net.sourceforge.phpdt.sql.sql.TableRow;
+import net.sourceforge.phpdt.sql.view.tableview.TableAdapter;
+
+public class PHPInsertRowPage extends WizardPage implements SQLPage {
+  TableRow row;
+  String[] columnNames;
+  Text[] values;
+  Label query;
+  public PHPInsertRowPage(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);
+    GridLayout layout = new GridLayout();
+    container.setLayout(layout);
+    int layoutColumns = 2;
+    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()];
+    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);
+
+      //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);
+
+    setControl(container);
+    updateQuery();
+
+    setPageComplete(true);
+  }
+  public void updateQuery() {
+    if (DEBUG) {
+      System.out.println("Updating query");
+    }
+    StringBuffer valuesClause = new StringBuffer();
+    for (int i = 0; i < columnNames.length; i++) {
+      valuesClause.append(values[i].getText());
+      valuesClause.append(", ");
+    }
+    if (valuesClause.length() > 1) {
+      valuesClause.deleteCharAt(valuesClause.length() - 1);
+      valuesClause.deleteCharAt(valuesClause.length() - 1);
+    }
+    String query = "INSERT INTO " + row.getTable();
+    query += " VALUES (" + valuesClause.toString();
+    query += " )";
+    this.query.setText(query);
+  }
+  public boolean performFinish() {
+    MultiSQLServer server = MultiSQLServer.getInstance();
+    server.execute(query.getText());
+    return true;
+  }
+}
\ No newline at end of file
diff --git a/archive/net.sourceforge.phpeclipse.sql/src/net/sourceforge/phpdt/sql/wizards/PHPUpdateRowPage.java b/archive/net.sourceforge.phpeclipse.sql/src/net/sourceforge/phpdt/sql/wizards/PHPUpdateRowPage.java
new file mode 100644 (file)
index 0000000..0c6690f
--- /dev/null
@@ -0,0 +1,168 @@
+package net.sourceforge.phpdt.sql.wizards;
+
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+import net.sourceforge.phpdt.sql.sql.MultiSQLServer;
+import net.sourceforge.phpdt.sql.sql.TableRow;
+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;
+  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");
+    }
+    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("Old Value");
+    temp = new Label(container, SWT.NULL);
+    temp.setText("");
+    temp = new Label(container, SWT.NULL);
+    temp.setText("New Value");
+    temp = new Label(container, SWT.NULL);
+    temp.setText("");
+    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("Primary Key");
+      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("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 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 query = "UPDATE " + row.getTable();
+    query += " SET " + setClause.toString();
+    query += " WHERE " + whereClause.toString();
+    this.query.setText(query);
+  }
+  public boolean performFinish() {
+    MultiSQLServer server = MultiSQLServer.getInstance();
+    server.execute(query.getText());
+    return true;
+  }
+}
\ No newline at end of file
index 0ab65b4..8162d3c 100644 (file)
@@ -1,28 +1,39 @@
 package net.sourceforge.phpdt.sql.wizards;
 
-import org.eclipse.jface.wizard.Wizard;
-
+import net.sourceforge.phpdt.sql.IConstants;
 import net.sourceforge.phpdt.sql.sql.TableRow;
 import net.sourceforge.phpdt.sql.view.tableview.TableAdapter;
 
-public class SQLRowWizard extends Wizard {
-       SQLPage page;
-       TableRow row;
-       TableAdapter adapter;
-       public void init(String title, SQLPage page, TableRow row, TableAdapter adapter) {
-               System.out.println("Init SQL row wizard");
-               this.row = row;
-               this.adapter = adapter;
-               this.page = page;
-               setWindowTitle(title);
-       }
-       public boolean performFinish() {
-               System.out.println("Perform SQL row wizard finish");
-               return page.performFinish();
-       }
-       public void addPages() {
-               System.out.println("QL row wizard adding pages");
-               page.init(row, adapter);
-               addPage(page);
-       }
+import org.eclipse.jface.wizard.Wizard;
+
+public class SQLRowWizard extends Wizard implements IConstants {
+  SQLPage page;
+  TableRow row;
+  TableAdapter adapter;
+  public void init(
+    String title,
+    SQLPage page,
+    TableRow row,
+    TableAdapter adapter) {
+    if (DEBUG) {
+      System.out.println("Init SQL row wizard");
+    }
+    this.row = row;
+    this.adapter = adapter;
+    this.page = page;
+    setWindowTitle(title);
+  }
+  public boolean performFinish() {
+    if (DEBUG) {
+      System.out.println("Perform SQL row wizard finish");
+    }
+    return page.performFinish();
+  }
+  public void addPages() {
+    if (DEBUG) {
+      System.out.println("SQL row wizard adding pages");
+    }
+    page.init(row, adapter);
+    addPage(page);
+  }
 }