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>
<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"
<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>
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)
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)
*/
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
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;
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;
} 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()));
}
}
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);
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);
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);
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() {
* 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();
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);
Color defaultColor = manager.getColor(SQLColorConstants.DEFAULT);
backgroundColorEditor =
new ColorFieldEditor(
- "quantum.background.color",
+ "phpeclipse.sql.background.color",
"Background Color",
comp);
textColorEditor =
new ColorFieldEditor(
- "quantum.text.color",
+ "phpeclipse.sql.text.color",
"Default Text Color",
comp);
keywordColorEditor =
new ColorFieldEditor(
- "quantum.keyword.color",
+ "phpeclipse.sql.keyword.color",
"Keyword Text Color",
comp);
commentColorEditor =
new ColorFieldEditor(
- "quantum.comment.color",
+ "phpeclipse.sql.comment.color",
"Comment Text Color",
comp);
stringColorEditor =
new ColorFieldEditor(
- "quantum.string.color",
+ "phpeclipse.sql.string.color",
"String Text Color",
comp);
numericColorEditor =
new ColorFieldEditor(
- "quantum.numeric.color",
+ "phpeclipse.sql.numeric.color",
"Numeric Text Color",
comp);
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;
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;
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();
};
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);
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
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);
+ }
}