added 2 new Preferencepages
authorkhartlage <khartlage>
Wed, 5 Mar 2003 20:52:54 +0000 (20:52 +0000)
committerkhartlage <khartlage>
Wed, 5 Mar 2003 20:52:54 +0000 (20:52 +0000)
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/preferences/PHPSQLConnectionPreferencePage.java [new file with mode: 0644]
archive/net.sourceforge.phpeclipse.sql/src/net/sourceforge/phpdt/sql/preferences/PHPSQLTemplatesPreferencePage.java [new file with mode: 0644]
archive/net.sourceforge.phpeclipse.sql/src/net/sourceforge/phpdt/sql/wizards/BookmarkWizard.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

index 797cd75..240a879 100644 (file)
    <extension
          point="org.eclipse.ui.preferencePages">
       <page
-            name="PHPEclipse SQL Editor"
-            category="PHPSQL"
+            name="PHP SQL"
             class="net.sourceforge.phpdt.sql.preferences.PreferencesPage"
             id="net.sourceforge.phpdt.sql.preferences.PreferencesPage">
       </page>
+      <page
+            name="Connecting"
+            category="net.sourceforge.phpdt.sql.preferences.PreferencesPage"
+            class="net.sourceforge.phpdt.sql.preferences.PHPSQLConnectionPreferencePage"
+            id="net.sourceforge.phpdt.sql.preferences.PHPSQLConnectionPreferencePage">        
+      </page>
+      <page
+            name="Templates"
+            category="net.sourceforge.phpdt.sql.preferences.PreferencesPage"
+            class="net.sourceforge.phpdt.sql.preferences.PHPSQLTemplatesPreferencePage"
+            id="net.sourceforge.phpdt.sql.preferences.PHPSQLTemplatesPreferencePage">        
+      </page>
    </extension>
 <!-- Menu for Bookmark View -->
    <extension
index ea9b4c2..a08b9e0 100644 (file)
@@ -26,8 +26,10 @@ import net.sourceforge.phpdt.sql.view.bookmark.BookmarkContentProvider;
 /**
  * @author 
  */
-public class PHPEclipseSQLPlugin extends AbstractUIPlugin implements IConstants {
-  
+public class PHPEclipseSQLPlugin
+  extends AbstractUIPlugin
+  implements IConstants {
+
   private static final String BUNDLE_NAME =
     "net.sourceforge.phpdt.sql.PHPEclipseSQLResources";
   private static final ResourceBundle RESOURCE_BUNDLE =
@@ -99,15 +101,60 @@ public class PHPEclipseSQLPlugin extends AbstractUIPlugin implements IConstants
       "phpeclipse.sql.background.color",
       BACKGROUND);
     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);
+    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);
+
+    getPreferenceStore().setDefault(
+      "phpeclipse.sql.select.template",
+      "$results = mysql_query(\"SELECT {0} FROM {1} WHERE {2} \");");
+
+    getPreferenceStore().setDefault(
+      "phpeclipse.sql.insert.template",
+      "$results = mysql_query(\"INSERT INTO {0} ({1}) VALUES {2} \");");
+
+    getPreferenceStore().setDefault(
+      "phpeclipse.sql.update.template",
+      "$results = mysql_query(\"UPDATE {0} SET {1} WHERE {2} \");");
+
+    getPreferenceStore().setDefault(
+      "phpeclipse.sql.delete.template",
+      "$results = mysql_query(\"DELETE FROM {0} WHERE {1} \");");
+
+    getPreferenceStore().setDefault("phpeclipse.sql.username.connect", "root");
+
+    getPreferenceStore().setDefault(
+      "phpeclipse.sql.connect.connect",
+      "jdbc:mysql://localhost/test");
+
+    getPreferenceStore().setDefault(
+      "phpeclipse.sql.driver.connect",
+      "com.mysql.jdbc.Driver");
+
+    getPreferenceStore().setDefault("phpeclipse.sql.type.connect", "MySQL");
+
+    getPreferenceStore().setDefault(
+      "phpeclipse.sql.filename.connect",
+      "C:\\apache\\mysql\\lib\\mysql-connector-java-2.0.14-bin.jar");
+
     PreferenceConverter.setDefault(
       getPreferenceStore(),
       "phpeclipse.sql.font",
@@ -140,23 +187,21 @@ class PHPSQLSaveParticipant implements ISaveParticipant, IConstants {
   public void saving(ISaveContext context) throws CoreException {
     switch (context.getKind()) {
       case ISaveContext.FULL_SAVE :
-        PHPEclipseSQLPlugin sqlPluginInstance = PHPEclipseSQLPlugin.getDefault();
+        PHPEclipseSQLPlugin sqlPluginInstance =
+          PHPEclipseSQLPlugin.getDefault();
         // save the plug in state 
         if (BookmarkContentProvider.getInstance().hasChanged()) {
           int saveNumber = context.getSaveNumber();
           String saveFileName = "save " + Integer.toString(saveNumber);
           File f =
-            sqlPluginInstance
-              .getStateLocation()
-              .append(saveFileName)
-              .toFile();
+            sqlPluginInstance.getStateLocation().append(saveFileName).toFile();
           // if we fail to write, an exception is thrown and we do not update the path 
           sqlPluginInstance.writeImportantState(f);
           context.map(new Path("save"), new Path(saveFileName));
           context.needSaveNumber();
         } else {
           if (DEBUG) {
-          System.out.println("Not saving unchanged bookmarks");
+            System.out.println("Not saving unchanged bookmarks");
           }
         }
         break;
diff --git a/archive/net.sourceforge.phpeclipse.sql/src/net/sourceforge/phpdt/sql/preferences/PHPSQLConnectionPreferencePage.java b/archive/net.sourceforge.phpeclipse.sql/src/net/sourceforge/phpdt/sql/preferences/PHPSQLConnectionPreferencePage.java
new file mode 100644 (file)
index 0000000..421a853
--- /dev/null
@@ -0,0 +1,109 @@
+package net.sourceforge.phpdt.sql.preferences;
+
+import net.sourceforge.phpdt.sql.PHPEclipseSQLPlugin;
+
+import org.eclipse.jface.preference.FileFieldEditor;
+import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.jface.preference.StringFieldEditor;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+
+public class PHPSQLConnectionPreferencePage
+  extends PreferencePage
+  implements IWorkbenchPreferencePage {
+
+  StringFieldEditor fUserNameSFE;
+  StringFieldEditor fConnectSFE;
+  StringFieldEditor fDriverSFE;
+  StringFieldEditor fTypeSFE;
+  StringFieldEditor fDriverFileFFE;
+
+  public PHPSQLConnectionPreferencePage() {
+    super();
+    setPreferenceStore(PHPEclipseSQLPlugin.getDefault().getPreferenceStore());
+  }
+  public void init(IWorkbench workbench) {
+    setPreferenceStore(PHPEclipseSQLPlugin.getDefault().getPreferenceStore());
+  }
+  protected void performDefaults() {
+    fUserNameSFE.loadDefault();
+    fConnectSFE.loadDefault();
+    fDriverSFE.loadDefault();
+    fTypeSFE.loadDefault();
+    fDriverFileFFE.loadDefault();
+    super.performDefaults();
+  }
+
+  public boolean performOk() {
+    fUserNameSFE.store();
+    fConnectSFE.store();
+    fDriverSFE.store();
+    fTypeSFE.store();
+    fDriverFileFFE.store();
+    return super.performOk();
+  }
+
+  protected Control createContents(Composite parent) {
+    initializeDialogUnits(parent);
+    //  final IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore();
+    Composite composite = new Composite(parent, SWT.LEFT);
+    GridLayout layout = new GridLayout();
+    composite.setLayout(layout);
+    composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+    //   layout.numColumns = 1;
+
+    fUserNameSFE =
+      new StringFieldEditor(
+        "phpeclipse.sql.username.connect",
+        "Default User name:",
+        composite);
+    fUserNameSFE.setPreferencePage(this);
+    fUserNameSFE.setPreferenceStore(getPreferenceStore());
+    fUserNameSFE.load();
+
+    fConnectSFE =
+      new StringFieldEditor(
+        "phpeclipse.sql.connect.connect",
+        "Connect:",
+        composite);
+    fConnectSFE.setPreferencePage(this);
+    fConnectSFE.setPreferenceStore(getPreferenceStore());
+    fConnectSFE.load();
+
+    fDriverSFE =
+      new StringFieldEditor(
+        "phpeclipse.sql.driver.connect",
+        "Driver:",
+        composite);
+    fDriverSFE.setPreferencePage(this);
+    fDriverSFE.setPreferenceStore(getPreferenceStore());
+    fDriverSFE.load();
+
+    fTypeSFE =
+      new StringFieldEditor("phpeclipse.sql.type.connect", "Type:", composite);
+    fTypeSFE.setPreferencePage(this);
+    fTypeSFE.setPreferenceStore(getPreferenceStore());
+    fTypeSFE.load();
+
+    //    fDriverFileFFE =
+    //      new FileFieldEditor(
+    //        "phpeclipse.sql.filename.connect",
+    //        "Driver filename:",
+    //        composite);
+    fDriverFileFFE =
+      new StringFieldEditor(
+        "phpeclipse.sql.filename.connect",
+        "Driver filename:",
+        composite);
+    fDriverFileFFE.setPreferencePage(this);
+    fDriverFileFFE.setPreferenceStore(getPreferenceStore());
+    fDriverFileFFE.load();
+
+    return composite;
+  }
+}
diff --git a/archive/net.sourceforge.phpeclipse.sql/src/net/sourceforge/phpdt/sql/preferences/PHPSQLTemplatesPreferencePage.java b/archive/net.sourceforge.phpeclipse.sql/src/net/sourceforge/phpdt/sql/preferences/PHPSQLTemplatesPreferencePage.java
new file mode 100644 (file)
index 0000000..6ff4e9a
--- /dev/null
@@ -0,0 +1,94 @@
+package net.sourceforge.phpdt.sql.preferences;
+
+import net.sourceforge.phpdt.sql.PHPEclipseSQLPlugin;
+
+import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.jface.preference.StringFieldEditor;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+
+public class PHPSQLTemplatesPreferencePage
+  extends PreferencePage
+  implements IWorkbenchPreferencePage {
+
+  StringFieldEditor fPHPSelectSFE;
+  StringFieldEditor fPHPInsertSFE;
+  StringFieldEditor fPHPUpdateSFE;
+  StringFieldEditor fPHPDeleteSFE;
+
+  public PHPSQLTemplatesPreferencePage() {
+    super();
+    setPreferenceStore(PHPEclipseSQLPlugin.getDefault().getPreferenceStore());
+    //  setDescription("PHP SQL templates"); //$NON-NLS-1$
+  }
+  
+  public void init(IWorkbench workbench) {
+    setPreferenceStore(PHPEclipseSQLPlugin.getDefault().getPreferenceStore());
+  }
+  
+  protected void performDefaults() {
+    fPHPSelectSFE.loadDefault();
+    fPHPInsertSFE.loadDefault();
+    fPHPUpdateSFE.loadDefault();
+    fPHPDeleteSFE.loadDefault();
+    super.performDefaults();
+  }
+
+  public boolean performOk() {
+    fPHPSelectSFE.store();
+    fPHPInsertSFE.store();
+    fPHPUpdateSFE.store();
+    fPHPDeleteSFE.store();
+    return super.performOk();
+  }
+
+  protected Control createContents(Composite parent) {
+    initializeDialogUnits(parent);
+    //  final IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore();
+    Composite composite = new Composite(parent, SWT.LEFT);
+    composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+    composite.setLayout(new GridLayout());
+
+    fPHPSelectSFE =
+      new StringFieldEditor(
+        "phpeclipse.sql.select.template",
+        "SELECT template:",
+        composite);
+    fPHPSelectSFE.setPreferencePage(this);
+    fPHPSelectSFE.setPreferenceStore(getPreferenceStore());
+    fPHPSelectSFE.load();
+
+    fPHPInsertSFE =
+      new StringFieldEditor(
+        "phpeclipse.sql.insert.template",
+        "INSERT template:",
+        composite);
+    fPHPInsertSFE.setPreferencePage(this);
+    fPHPInsertSFE.setPreferenceStore(getPreferenceStore());
+    fPHPInsertSFE.load();
+
+    fPHPUpdateSFE =
+      new StringFieldEditor(
+        "phpeclipse.sql.update.template",
+        "UPDATE template:",
+        composite);
+    fPHPUpdateSFE.setPreferencePage(this);
+    fPHPUpdateSFE.setPreferenceStore(getPreferenceStore());
+    fPHPUpdateSFE.load();
+
+    fPHPDeleteSFE =
+      new StringFieldEditor(
+        "phpeclipse.sql.delete.template",
+        "DELETE template:",
+        composite);
+    fPHPDeleteSFE.setPreferencePage(this);
+    fPHPDeleteSFE.setPreferenceStore(getPreferenceStore());
+    fPHPDeleteSFE.load();
+    return composite;
+  }
+}
index 71d1112..9bdf6db 100644 (file)
@@ -1,11 +1,13 @@
 package net.sourceforge.phpdt.sql.wizards;
 
 import net.sourceforge.phpdt.sql.IConstants;
+import net.sourceforge.phpdt.sql.PHPEclipseSQLPlugin;
 import net.sourceforge.phpdt.sql.adapters.AdapterFactory;
 import net.sourceforge.phpdt.sql.adapters.DriverInfo;
 import net.sourceforge.phpdt.sql.view.BookmarkView;
 import net.sourceforge.phpdt.sql.view.bookmark.BookmarkNode;
 
+import org.eclipse.jface.preference.IPreferenceStore;
 import org.eclipse.jface.wizard.Wizard;
 import org.eclipse.jface.wizard.WizardPage;
 import org.eclipse.swt.SWT;
@@ -32,6 +34,7 @@ public class BookmarkWizard extends Wizard implements IConstants {
     this.current = selection;
     setWindowTitle("New Bookmark");
   }
+
   public void init() {
     if (DEBUG) {
       System.out.println("Initing workbench");
@@ -39,6 +42,7 @@ public class BookmarkWizard extends Wizard implements IConstants {
     current = null;
     setWindowTitle("New Bookmark");
   }
+
   public boolean performFinish() {
     if (DEBUG) {
       System.out.println("perform finish workbench");
@@ -46,6 +50,7 @@ public class BookmarkWizard extends Wizard implements IConstants {
     mainPage.performFinish();
     return true;
   }
+
   public void addPages() {
     if (DEBUG) {
       System.out.println("adding pages");
@@ -230,6 +235,23 @@ class BookmarkPage extends WizardPage implements IConstants {
       type.select(selectedIndex);
       driverFile.setText(initialData.getDriverFile());
       updateDriverList();
+    } else {
+
+      IPreferenceStore fStore =
+        PHPEclipseSQLPlugin.getDefault().getPreferenceStore();
+      username.setText(fStore.getString("phpeclipse.sql.username.connect"));
+      connect.setText(fStore.getString("phpeclipse.sql.connect.connect"));
+      driver.setText(fStore.getString("phpeclipse.sql.driver.connect"));
+      String typeData = fStore.getString("phpeclipse.sql.type.connect");
+      int selectedIndex = 0;
+      for (int i = 0; i < drivers.length; i++) {
+        if (typeData.equals(drivers[i].getDisplayName())) {
+          selectedIndex = i;
+        }
+      }
+      type.select(selectedIndex);
+      driverFile.setText(fStore.getString("phpeclipse.sql.filename.connect"));
+      //   updateDriverList();
     }
     setControl(container);
 
index fb50a4a..a0b3869 100644 (file)
@@ -1,9 +1,13 @@
 package net.sourceforge.phpdt.sql.wizards;
 
+import java.text.MessageFormat;
+
+import net.sourceforge.phpdt.sql.PHPEclipseSQLPlugin;
 import net.sourceforge.phpdt.sql.sql.TableRow;
 import net.sourceforge.phpdt.sql.view.PHPSourceConsole;
 import net.sourceforge.phpdt.sql.view.tableview.TableAdapter;
 
+import org.eclipse.jface.preference.IPreferenceStore;
 import org.eclipse.jface.wizard.WizardPage;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.ModifyEvent;
@@ -23,6 +27,7 @@ public class PHPDeleteRowPage extends WizardPage implements SQLPage {
   Text[] values;
   Button[] whereValues;
   Label query;
+  IPreferenceStore fStore;
 
   public PHPDeleteRowPage(String pageName) {
     super(pageName);
@@ -36,6 +41,7 @@ public class PHPDeleteRowPage extends WizardPage implements SQLPage {
     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);
@@ -139,12 +145,19 @@ public class PHPDeleteRowPage extends WizardPage implements SQLPage {
     //      whereClause.deleteCharAt(whereClause.length() - 1);
     //      whereClause.deleteCharAt(whereClause.length() - 1);
     //    }
-    String query = "$results = mysql_query(\"DELETE FROM " + row.getTable();
-    if (numSelected > 0) {
-      query += " WHERE " + whereClause.toString() + "\");";
-    } else {
-      query += "\");";
-    }
+    
+    
+    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("");
index 4f7f044..74aac22 100644 (file)
@@ -1,9 +1,13 @@
 package net.sourceforge.phpdt.sql.wizards;
 
+import java.text.MessageFormat;
+
+import net.sourceforge.phpdt.sql.PHPEclipseSQLPlugin;
 import net.sourceforge.phpdt.sql.sql.TableRow;
 import net.sourceforge.phpdt.sql.view.PHPSourceConsole;
 import net.sourceforge.phpdt.sql.view.tableview.TableAdapter;
 
+import org.eclipse.jface.preference.IPreferenceStore;
 import org.eclipse.jface.wizard.WizardPage;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.ModifyEvent;
@@ -19,6 +23,8 @@ public class PHPInsertRowPage extends WizardPage implements SQLPage {
   String[] columnNames;
   Text[] values;
   Label query;
+  private IPreferenceStore fStore;
+  
   public PHPInsertRowPage(String pageName) {
     super(pageName);
   }
@@ -31,6 +37,7 @@ public class PHPInsertRowPage extends WizardPage implements SQLPage {
     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);
@@ -115,10 +122,15 @@ public class PHPInsertRowPage extends WizardPage implements SQLPage {
 //      valuesClause.deleteCharAt(valuesClause.length() - 1);
 //      valuesClause.deleteCharAt(valuesClause.length() - 1);
 //    }
-    String query = "$results = mysql_query(\"INSERT INTO " + row.getTable() + " (";
-    query += fieldClause.toString() + ") ";
-    query += " VALUES (" + valuesClause.toString();
-    query += ")\");";
+    String[] arguments = { row.getTable(), fieldClause.toString(), valuesClause.toString() };
+    MessageFormat form = new MessageFormat(fStore.getString("phpeclipse.sql.insert.template"));
+
+    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() {
index 26cae8a..4bfa368 100644 (file)
@@ -1,9 +1,13 @@
 package net.sourceforge.phpdt.sql.wizards;
 
+import java.text.MessageFormat;
+
+import net.sourceforge.phpdt.sql.PHPEclipseSQLPlugin;
 import net.sourceforge.phpdt.sql.sql.TableRow;
 import net.sourceforge.phpdt.sql.view.PHPSourceConsole;
 import net.sourceforge.phpdt.sql.view.tableview.TableAdapter;
 
+import org.eclipse.jface.preference.IPreferenceStore;
 import org.eclipse.jface.wizard.WizardPage;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.ModifyEvent;
@@ -25,6 +29,7 @@ public class PHPSelectRowPage extends WizardPage implements SQLPage {
   Button[] primaryKeys;
   Button[] setValues;
   Label query;
+  IPreferenceStore fStore;
 
   public PHPSelectRowPage(String pageName) {
     super(pageName);
@@ -39,6 +44,8 @@ public class PHPSelectRowPage extends WizardPage implements SQLPage {
       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;
@@ -174,9 +181,14 @@ public class PHPSelectRowPage extends WizardPage implements SQLPage {
       setClause.deleteCharAt(setClause.length() - 1);
       setClause.deleteCharAt(setClause.length() - 1);
     }
-    String query = "$results = mysql_query(\"SELECT " + setClause.toString();
-    query += " FROM " + row.getTable();
-    query += " WHERE " + whereClause.toString() + "\");";
+    
+    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);
   }
 
index 3f62d19..fdb15ec 100644 (file)
@@ -1,9 +1,13 @@
 package net.sourceforge.phpdt.sql.wizards;
 
+import java.text.MessageFormat;
+
+import net.sourceforge.phpdt.sql.PHPEclipseSQLPlugin;
 import net.sourceforge.phpdt.sql.sql.TableRow;
 import net.sourceforge.phpdt.sql.view.PHPSourceConsole;
 import net.sourceforge.phpdt.sql.view.tableview.TableAdapter;
 
+import org.eclipse.jface.preference.IPreferenceStore;
 import org.eclipse.jface.wizard.WizardPage;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.ModifyEvent;
@@ -25,6 +29,8 @@ public class PHPUpdateRowPage extends WizardPage implements SQLPage {
   Button[] primaryKeys;
   Button[] setValues;
   Label query;
+  IPreferenceStore fStore;
+  
   public PHPUpdateRowPage(String pageName) {
     super(pageName);
   }
@@ -37,6 +43,7 @@ public class PHPUpdateRowPage extends WizardPage implements SQLPage {
     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);
@@ -164,9 +171,14 @@ public class PHPUpdateRowPage extends WizardPage implements SQLPage {
       setClause.deleteCharAt(setClause.length() - 1);
       setClause.deleteCharAt(setClause.length() - 1);
     }
-    String query = "$results = mysql_query(\"UPDATE " + row.getTable();
-    query += " SET " + setClause.toString();
-    query += " WHERE " + whereClause.toString() + "\");";
+    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() {