<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
/**
* @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 =
"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",
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;
--- /dev/null
+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;
+ }
+}
--- /dev/null
+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;
+ }
+}
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;
this.current = selection;
setWindowTitle("New Bookmark");
}
+
public void init() {
if (DEBUG) {
System.out.println("Initing workbench");
current = null;
setWindowTitle("New Bookmark");
}
+
public boolean performFinish() {
if (DEBUG) {
System.out.println("perform finish workbench");
mainPage.performFinish();
return true;
}
+
public void addPages() {
if (DEBUG) {
System.out.println("adding pages");
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);
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;
Text[] values;
Button[] whereValues;
Label query;
+ IPreferenceStore fStore;
public PHPDeleteRowPage(String pageName) {
super(pageName);
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);
// 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("");
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;
String[] columnNames;
Text[] values;
Label query;
+ private IPreferenceStore fStore;
+
public PHPInsertRowPage(String pageName) {
super(pageName);
}
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);
// 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() {
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;
Button[] primaryKeys;
Button[] setValues;
Label query;
+ IPreferenceStore fStore;
public PHPSelectRowPage(String pageName) {
super(pageName);
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;
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);
}
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;
Button[] primaryKeys;
Button[] setValues;
Label query;
+ IPreferenceStore fStore;
+
public PHPUpdateRowPage(String pageName) {
super(pageName);
}
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);
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() {