From: axelcl Date: Tue, 31 May 2005 19:20:27 +0000 (+0000) Subject: Very ugly start of a first wizard page. Needs a lot of cleanup! X-Git-Url: http://secure.phpeclipse.com Very ugly start of a first wizard page. Needs a lot of cleanup! --- diff --git a/net.sourceforge.phpeclipse.wizards/src/net/sourceforge/phpeclipse/wizards/actions/metadata/BaseSQLPage.java b/net.sourceforge.phpeclipse.wizards/src/net/sourceforge/phpeclipse/wizards/actions/metadata/BaseSQLPage.java new file mode 100644 index 0000000..201953e --- /dev/null +++ b/net.sourceforge.phpeclipse.wizards/src/net/sourceforge/phpeclipse/wizards/actions/metadata/BaseSQLPage.java @@ -0,0 +1,72 @@ +package net.sourceforge.phpeclipse.wizards.actions.metadata; + +import java.sql.SQLException; + +import org.eclipse.jface.wizard.WizardPage; + +import com.quantum.adapters.DatabaseAdapter; +import com.quantum.model.Column; +import com.quantum.model.Entity; +import com.quantum.sql.SQLResultSetResults; +import com.quantum.ui.dialog.ConnectionUtil; +import com.quantum.util.connection.NotConnectedException; + +/** + * @author BC Holmes + */ +public abstract class BaseSQLPage extends WizardPage implements SQLPage { + + protected Row row; + protected Column[] columns; +// protected SQLResultSetResults results; + private ConnectionUtil connectionUtil = new ConnectionUtil(); + + public BaseSQLPage(String pageName) { + super(pageName); + } + public boolean performFinish() { +// Bookmark bookmark = (Bookmark) this.results.getConnectable(); +// try { +// bookmark.addQuery(getQueryText()); +// SQLResults sqlResults = MultiSQLServer.getInstance().execute(bookmark, +// this.connectionUtil.getConnection(bookmark, getShell()), getQueryText()); +// return sqlResults == null ? false : true; +// } catch (SQLException e) { +// SQLExceptionDialog.openException(getShell(), bookmark, e); +// return false; +// } + return false; + } + + protected abstract String getQueryText(); + protected void appendColumn(StringBuffer whereClause, Entity entity, String columnName, DatabaseAdapter adapter, String value) { + + if (adapter != null && entity != null && getColumn(entity, columnName) != null) { + Column column = getColumn(entity, columnName); + whereClause.append(adapter.quote(value, column.getType(), column.getTypeName())); + } else { + whereClause.append(value); + } + } + /** + * @param entity + * @param columnName + * @return + * @throws NotConnectedException + * @throws SQLException + */ + protected Column getColumn(Entity entity, String columnName) { + try { + return entity == null ? null : entity.getColumn(columnName); + } catch (NotConnectedException e) { + return null; + } catch (SQLException e) { + return null; + } + } + public void init(Row row, Column[] columns) { +// this.results = results; + this.row = row; + this.columns = columns; + } +} diff --git a/net.sourceforge.phpeclipse.wizards/src/net/sourceforge/phpeclipse/wizards/actions/metadata/CommonWizardUI.java b/net.sourceforge.phpeclipse.wizards/src/net/sourceforge/phpeclipse/wizards/actions/metadata/CommonWizardUI.java new file mode 100644 index 0000000..9c5ef7b --- /dev/null +++ b/net.sourceforge.phpeclipse.wizards/src/net/sourceforge/phpeclipse/wizards/actions/metadata/CommonWizardUI.java @@ -0,0 +1,73 @@ +package net.sourceforge.phpeclipse.wizards.actions.metadata; + +import java.util.Arrays; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.TableColumn; + +/** + * @author Elvin E. Ebora + */ + +public class CommonWizardUI { + + /** + * constructor + */ + public CommonWizardUI() {} + + /** + * Creates a standard Table UI for wizard implementation + * @param composite + * @return Table + */ + protected Table createTablePage(Composite composite) { + int style = SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.HIDE_SELECTION; + Table table = new Table(composite, style); + table.setHeaderVisible(true); + table.setLinesVisible(true); + table.setLayoutData(new GridData(GridData.FILL_BOTH | GridData.VERTICAL_ALIGN_BEGINNING)); + return table; + } + + /** + * Creates a standard TableColumn UI for wizard implementation + * @param table + * @param colName + * @param style + * @param pos + * @param width + */ + protected void createTableColumn(Table table, String colName, int style, int pos, int width) { + TableColumn column = new TableColumn(table, style, pos); + column.setText(colName); + column.setWidth(width); + } + + /** + * Creates a standard GridData UI for wizard implementation + * @param horzSpan + * @param alignment + * @return GridData + */ + protected GridData createGridData(int horzSpan, int vertSpan, int alignment) { + GridData gridData = new GridData(); + gridData.horizontalSpan = horzSpan; + gridData.verticalSpan = vertSpan; + gridData.horizontalAlignment = alignment; + gridData.verticalAlignment = alignment; + return gridData; + } + + /** + * Returns a List implementation of an array of string input + * @param columnNames + * @return java.util.List + */ + protected java.util.List getColumnNamesAsList(String[] columnNames) { + return Arrays.asList(columnNames); + } +} \ No newline at end of file diff --git a/net.sourceforge.phpeclipse.wizards/src/net/sourceforge/phpeclipse/wizards/actions/metadata/Messages.java b/net.sourceforge.phpeclipse.wizards/src/net/sourceforge/phpeclipse/wizards/actions/metadata/Messages.java new file mode 100644 index 0000000..eff8f45 --- /dev/null +++ b/net.sourceforge.phpeclipse.wizards/src/net/sourceforge/phpeclipse/wizards/actions/metadata/Messages.java @@ -0,0 +1,41 @@ +package net.sourceforge.phpeclipse.wizards.actions.metadata; + +import java.text.MessageFormat; +import java.util.MissingResourceException; +import java.util.ResourceBundle; + +public class Messages { + + private static final String BUNDLE_NAME = "net.sourceforge.phpeclipse.wizards.actions.metadata.Messages"; //$NON-NLS-1$ + + private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME); + + private Messages() { + } + + public static String getString(Class resourceClass, String key) { + return getString( + createKey(resourceClass, key)); + } + + private static String createKey(Class resourceClass, String key) { + return resourceClass.getName() + (key.startsWith(".") ? key : "." + key); + } + + public static String getString(String key) { + try { + return RESOURCE_BUNDLE.getString(key); + } catch (MissingResourceException e) { + return '!' + key + '!'; + } + } + + public static String getString(Class resourceClass, String key, Object[] arguments) { + return getString(createKey(resourceClass, key), arguments); + } + + public static String getString(String key, Object[] arguments) { + String string = getString(key); + return MessageFormat.format(string, arguments); + } +} diff --git a/net.sourceforge.phpeclipse.wizards/src/net/sourceforge/phpeclipse/wizards/actions/metadata/Messages.properties b/net.sourceforge.phpeclipse.wizards/src/net/sourceforge/phpeclipse/wizards/actions/metadata/Messages.properties new file mode 100644 index 0000000..791cf0f --- /dev/null +++ b/net.sourceforge.phpeclipse.wizards/src/net/sourceforge/phpeclipse/wizards/actions/metadata/Messages.properties @@ -0,0 +1,23 @@ +TableView.UpdateRow=Update Row + +tableview.refresh = Refresh Table +tableview.copy = Copy Table Selection To Clipboard +tableview.selectAll = Select All Table Rows +tableview.close = Close Table +tableview.update = Update... +tableview.insert = Insert... +tableview.delete = Delete... +tableview.showAll = Toggle Show All Table Rows +tableview.defaultEncoding = Set Default Encoding +tableview.UTF8Encoding = Set UTF-8 +tableview.UTF16Encoding = Set UTF-16 +tableview.QuantumTableViewName=Quantum Table View +tableview.ViewNameFinalDecoration=) +tableview.BookmarkSeparator=: +tableview.ViewNameInitialDecoration=\ ( + +UpdateRowPage.ColumnName=Column Name +UpdateRowPage.OldValue=Old Value +UpdateRowPage.NewValue=New Value +UpdateRowPage._13= +UpdateRowPage.SetValue=Set Value diff --git a/net.sourceforge.phpeclipse.wizards/src/net/sourceforge/phpeclipse/wizards/actions/metadata/PHPMetadataWizard.java b/net.sourceforge.phpeclipse.wizards/src/net/sourceforge/phpeclipse/wizards/actions/metadata/PHPMetadataWizard.java index da589b3..dd9291f 100644 --- a/net.sourceforge.phpeclipse.wizards/src/net/sourceforge/phpeclipse/wizards/actions/metadata/PHPMetadataWizard.java +++ b/net.sourceforge.phpeclipse.wizards/src/net/sourceforge/phpeclipse/wizards/actions/metadata/PHPMetadataWizard.java @@ -1,7 +1,12 @@ package net.sourceforge.phpeclipse.wizards.actions.metadata; +import java.util.ArrayList; +import java.util.List; +import java.util.Vector; + import net.sourceforge.phpeclipse.wizards.xml.ModelUtil; +import org.eclipse.jface.wizard.WizardDialog; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -17,10 +22,9 @@ public class PHPMetadataWizard implements IMetadataExtension { * @see com.quantum.extensions.IDataExtension#run(org.w3c.dom.Document) */ public void run(Document doc) { -// System.out.println(doc); - - Element root = doc.getDocumentElement(); + // System.out.println(doc); + Element root = doc.getDocumentElement(); try { XMLToModelConverter c = new XMLToModelConverter(root); String name = ModelUtil.getTableName(root); @@ -28,13 +32,62 @@ public class PHPMetadataWizard implements IMetadataExtension { System.out.println(name); Column[] cols = c.getColumns(); for (int i = 0; i < cols.length; i++) { - System.out.print("Column-name: "+i+" "); + System.out.print("Column-name: " + i + " "); System.out.println(cols[i].getName()); } + UpdateRowPage page = new UpdateRowPage(""); //$NON-NLS-1$ + SQLRowWizard wizard = new SQLRowWizard(); + + List rowList = new ArrayList(); + for (int i = 1; i < cols.length; i++) { + Vector row = new Vector(); + row.addElement(cols[i].getName()); + row.addElement(cols[i].getTypeName()); + long precision = 0; + try { + precision = cols[i].getSize();// metaData.getPrecision(i); + } catch (Throwable t) { + // Do nothing. An exception can be generated by some very large row sizes, like BLOB in Oracle. + // Then getPrecision() will generate an exception. So we ignore it and go on. + } + // if (precision == 0) { + // precision = cols[i].getSize(); + // } + int scale = cols[i].getNumberOfFractionalDigits();// metaData.getScale(i); + + row.addElement(new Long(precision)); + row.addElement(new Integer(scale)); + + boolean nullable = cols[i].isNullable();// metaData.isNullable(i); + // if (nullable == ResultSetMetaData.columnNoNulls) { + // row.addElement("Not Null"); //$NON-NLS-1$ + // } else if (nullable == ResultSetMetaData.columnNullable) { + // row.addElement("Nullable"); //$NON-NLS-1$ + // } else if (nullable == ResultSetMetaData.columnNullableUnknown) { + // row.addElement("Nullable"); //$NON-NLS-1$ + // } else { + // row.addElement(""); //$NON-NLS-1$ + // } + if (nullable) { + row.addElement("Nullable"); //$NON-NLS-1$ + } else { + row.addElement(""); //$NON-NLS-1$ + } + // row.addElement(metaData.isAutoIncrement(i) ? Boolean.TRUE : Boolean.FALSE); + rowList.add(new Row(row)); + row.addElement(new Integer(cols[i].getType()));// metaData.getColumnType(i))); + } + + Row rrow = new Row(rowList); + wizard.init(Messages.getString("TableView.UpdateRow"), page, rrow, cols); //$NON-NLS-1$ + WizardDialog dialog = new WizardDialog(null, wizard); + dialog.open(); + } catch (Exception e) { e.printStackTrace(); } } -} \ No newline at end of file +} + diff --git a/net.sourceforge.phpeclipse.wizards/src/net/sourceforge/phpeclipse/wizards/actions/metadata/Row.java b/net.sourceforge.phpeclipse.wizards/src/net/sourceforge/phpeclipse/wizards/actions/metadata/Row.java new file mode 100644 index 0000000..fd55b5c --- /dev/null +++ b/net.sourceforge.phpeclipse.wizards/src/net/sourceforge/phpeclipse/wizards/actions/metadata/Row.java @@ -0,0 +1,35 @@ +package net.sourceforge.phpeclipse.wizards.actions.metadata; + +import java.util.Iterator; +import java.util.List; + +import com.quantum.sql.SQLResultSetResults; + +public class Row { + private final List elements; + + public Row(List elements) { + this.elements = elements; + } + + public Object get(int columnNumber) { + return (columnNumber > this.elements.size() || columnNumber <= 0) + ? null + : this.elements.get(columnNumber - 1); + } + + public String[] getAsStringArray() { + String[] resultArray = new String[this.elements.size()]; + int i = 0; + for (Iterator iter = this.elements.iterator(); iter.hasNext() ; ) { + String element = iter.next().toString(); + resultArray[i] = element; + i++; + } + return resultArray; + } + +// public SQLResultSetResults getResultSet() { +// return SQLResultSetResults.this; +// } +} diff --git a/net.sourceforge.phpeclipse.wizards/src/net/sourceforge/phpeclipse/wizards/actions/metadata/SQLPage.java b/net.sourceforge.phpeclipse.wizards/src/net/sourceforge/phpeclipse/wizards/actions/metadata/SQLPage.java new file mode 100644 index 0000000..fef2ee1 --- /dev/null +++ b/net.sourceforge.phpeclipse.wizards/src/net/sourceforge/phpeclipse/wizards/actions/metadata/SQLPage.java @@ -0,0 +1,11 @@ +package net.sourceforge.phpeclipse.wizards.actions.metadata; + +import com.quantum.model.Column; +import com.quantum.sql.SQLResultSetResults; + +import org.eclipse.jface.wizard.IWizardPage; + +public interface SQLPage extends IWizardPage { + public void init(Row row, Column[] columns); + public boolean performFinish(); +} diff --git a/net.sourceforge.phpeclipse.wizards/src/net/sourceforge/phpeclipse/wizards/actions/metadata/SQLRowWizard.java b/net.sourceforge.phpeclipse.wizards/src/net/sourceforge/phpeclipse/wizards/actions/metadata/SQLRowWizard.java new file mode 100644 index 0000000..d6ce86b --- /dev/null +++ b/net.sourceforge.phpeclipse.wizards/src/net/sourceforge/phpeclipse/wizards/actions/metadata/SQLRowWizard.java @@ -0,0 +1,29 @@ +package net.sourceforge.phpeclipse.wizards.actions.metadata; + +import org.eclipse.jface.wizard.Wizard; + +import com.quantum.model.Column; + +public class SQLRowWizard extends Wizard { + protected SQLPage page; + protected Row row; + protected Column[] columns; + + public void init(String title, SQLPage page, + Row row, Column[] cols) { + System.out.println("Init SQL row wizard"); //$NON-NLS-1$ + this.row = row; + this.columns = cols; + this.page = page; + setWindowTitle(title); + } + public boolean performFinish() { + System.out.println("Perform SQL row wizard finish"); //$NON-NLS-1$ + return page.performFinish(); + } + public void addPages() { + System.out.println("QL row wizard adding pages"); //$NON-NLS-1$ + page.init(this.row, this.columns); + addPage(page); + } +} diff --git a/net.sourceforge.phpeclipse.wizards/src/net/sourceforge/phpeclipse/wizards/actions/metadata/UpdateRowPage.java b/net.sourceforge.phpeclipse.wizards/src/net/sourceforge/phpeclipse/wizards/actions/metadata/UpdateRowPage.java new file mode 100644 index 0000000..97b9777 --- /dev/null +++ b/net.sourceforge.phpeclipse.wizards/src/net/sourceforge/phpeclipse/wizards/actions/metadata/UpdateRowPage.java @@ -0,0 +1,401 @@ +package net.sourceforge.phpeclipse.wizards.actions.metadata; + +import org.eclipse.jface.viewers.CellEditor; +import org.eclipse.jface.viewers.CheckboxCellEditor; +import org.eclipse.jface.viewers.ICellModifier; +import org.eclipse.jface.viewers.ILabelProviderListener; +import org.eclipse.jface.viewers.IStructuredContentProvider; +import org.eclipse.jface.viewers.ITableLabelProvider; +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.jface.viewers.TextCellEditor; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.TableItem; +import org.eclipse.swt.widgets.Text; + +import com.quantum.ImageStore; +import com.quantum.Messages; +import com.quantum.adapters.DatabaseAdapter; +import com.quantum.model.Bookmark; +import com.quantum.model.Column; +import com.quantum.model.Entity; +import com.quantum.util.StringMatrix; + +/** + * @author BC Holmes + * @author Elvin E. Ebora + */ +public class UpdateRowPage extends BaseSQLPage implements SQLPage { + + class UpdateRowTableValues { + private String sColNames = null; + + private String sOldValue = null; + + private boolean bPrimary = false; + + private String sNewValue = null; + + private boolean bSetValue = false; + + public UpdateRowTableValues() { + } + + /** + * @return Returns the bSetValue. + */ + public boolean isBSetValue() { + return bSetValue; + } + + /** + * @param setValue + * The bSetValue to set. + */ + public void setBSetValue(boolean setValue) { + bSetValue = setValue; + } + + /** + * @return Returns the bPrimary. + */ + public boolean isBPrimary() { + return bPrimary; + } + + /** + * @param where + * The bPrimary to set. + */ + public void setBPrimary(boolean where) { + bPrimary = where; + } + + /** + * @return Returns the sColNames. + */ + public String getSColNames() { + return sColNames; + } + + /** + * @param colNames + * The sColNames to set. + */ + public void setSColNames(String colNames) { + sColNames = colNames; + } + + /** + * @return Returns the sNewValue. + */ + public String getSNewValue() { + return sNewValue; + } + + /** + * @param newValue + * The sNewValue to set. + */ + public void setSNewValue(String newValue) { + sNewValue = newValue; + } + + /** + * @return Returns the sOldValue. + */ + public String getSOldValue() { + return sOldValue; + } + + /** + * @param oldValue + * The sOldValue to set. + */ + public void setSOldValue(String oldValue) { + sOldValue = oldValue; + } + } + + class LabelProviderImpl implements ITableLabelProvider { + public Image getColumnImage(Object element, int columnIndex) { + if (columnIndex == 2) { + return ((UpdateRowTableValues) element).isBPrimary() ? imgCheck : imgUncheck; + } else if (columnIndex == 4) { + return ((UpdateRowTableValues) element).isBSetValue() ? imgCheck : imgUncheck; + } else { + return null; + } + } + + public String getColumnText(Object element, int columnIndex) { + String sReturn = ""; + UpdateRowTableValues updateRow = (UpdateRowTableValues) element; + switch (columnIndex) { + case 0: // column names + sReturn = updateRow.getSColNames(); + break; + case 1: // old values + sReturn = updateRow.getSOldValue(); + break; + case 2: // set checkbox + break; + case 3: // new value + sReturn = updateRow.getSNewValue(); + break; + case 4: // set value checkbox + break; + default: + break; + } + return sReturn; + } + + public void addListener(ILabelProviderListener listener) { + } + + public void dispose() { + } + + public boolean isLabelProperty(Object element, String property) { + return false; + } + + public void removeListener(ILabelProviderListener listener) { + } + } + + class ContentProviderImpl implements IStructuredContentProvider { + public Object[] getElements(Object inputElement) { + return updateTable; + } + + public void dispose() { + } + + public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { + } + } + + class CellModifierImpl implements ICellModifier { + + public boolean canModify(Object element, String property) { + return true; + } + + public Object getValue(Object element, String property) { + System.out.println("getValue called"); + + // Find the index of the column + int colIndx = comUI.getColumnNamesAsList(colNames).indexOf(property); + System.out.println("colIndx : " + colIndx); + + Object rResult = null; + UpdateRowTableValues updateVal = (UpdateRowTableValues) element; + + switch (colIndx) { + case 0: // column names + rResult = updateVal.getSColNames(); + break; + case 1: // old values + rResult = updateVal.getSOldValue(); + break; + case 2: // set checkbox + rResult = new Boolean(updateVal.isBPrimary()); + break; + case 3: // new value + rResult = updateVal.getSNewValue(); + break; + case 4: // set value checkbox + rResult = new Boolean(updateVal.isBSetValue()); + break; + default: + break; + } + + return rResult; + } + + public void modify(Object element, String property, Object value) { + int colIndx = comUI.getColumnNamesAsList(colNames).indexOf(property); + + TableItem item = (TableItem) element; + UpdateRowTableValues updateVal = (UpdateRowTableValues) item.getData(); + + switch (colIndx) { + case 0: // column names + break; + case 1: // old values + break; + case 2: // set checkbox + updateVal.setBPrimary(((Boolean) value).booleanValue()); + break; + case 3: // new value + updateVal.setSNewValue(value.toString()); + break; + case 4: // set value checkbox + updateVal.setBSetValue(((Boolean) value).booleanValue()); + break; + default: + break; + } + + updateView(); + updateQuery(); + } + } + + String[] columnNames; + + String[] colNames; + + Text query; + + UpdateRowTableValues[] updateTable = null; + + CommonWizardUI comUI; + + TableViewer tableViewer = null; + + static Image imgCheck = null; + + static Image imgUncheck = null; + + static { + imgCheck = ImageStore.getImage(ImageStore.CHECKED); + imgUncheck = ImageStore.getImage(ImageStore.UNCHECKED); + } + + public UpdateRowPage(String pageName) { + super(pageName); + } + + public void createControl(Composite parent) { + System.out.println("page create control"); //$NON-NLS-1$ + Composite container = new Composite(parent, SWT.NULL); + container.setLayout(new GridLayout()); + container.setLayoutData(new GridData(GridData.FILL_BOTH | GridData.VERTICAL_ALIGN_BEGINNING)); + + // Entity entity = this.results.getEntity(); + + comUI = new CommonWizardUI(); + + // init values to be displayed on the table + + // columnNames = this.results.getColumnNames(); + int nLen = this.columns.length; + columnNames = new String[nLen]; + for (int i = 0; i < this.columns.length; i++) { + columnNames[i] = this.columns[i].getName(); + } + updateTable = new UpdateRowTableValues[nLen]; + + for (int nCtr = 0; nCtr < nLen; nCtr++) { + updateTable[nCtr] = new UpdateRowTableValues(); + updateTable[nCtr].setSColNames(columnNames[nCtr]); + Object data = this.row == null ? null : this.row.get(nCtr + 1); + updateTable[nCtr].setSOldValue(data == null ? "" : data.toString()); + Column column = null; //(entity == null) ? null : getColumn(entity, columnNames[nCtr]); + if (column != null && column.isPrimaryKey()) { + updateTable[nCtr].setBPrimary(true); + } + updateTable[nCtr].setSNewValue(data == null ? "" : data.toString()); + } + + createTable(container); + + //query = new Label(container, SWT.WRAP); + query = new Text(container, SWT.V_SCROLL | SWT.MULTI | SWT.WRAP | SWT.READ_ONLY); + query.setLayoutData(comUI.createGridData(1, 10, GridData.FILL)); + query.setVisible(false); + + setControl(container); + //updateQuery(); + + setPageComplete(true); + } + + public void updateQuery() { + System.out.println("Updating query"); //$NON-NLS-1$ + query.setVisible(true); + + StringMatrix columns = new StringMatrix(); + for (int i = 0; i < columnNames.length; i++) { + if (updateTable[i].isBSetValue()) { + columns.addHeader(updateTable[i].getSColNames()); + columns.add(updateTable[i].getSNewValue(), 0); + } + } + StringMatrix key = new StringMatrix(); + for (int i = 0; i < columnNames.length; i++) { + if (updateTable[i].isBPrimary()) { + key.addHeader(updateTable[i].getSColNames()); + // It's an old value because it't the key. + key.add(updateTable[i].getSOldValue(), 0); + } + } + // Bookmark bookmark = (Bookmark) this.results.getConnectable(); + // DatabaseAdapter adapter = bookmark.getAdapter(); + // this.query.setText(adapter.buildUpdate(this.results.getEntity(), columns, key)); + } + + /* + * (non-Javadoc) + * + * @see com.quantum.wizards.BaseSQLPage#getQueryText() + */ + protected String getQueryText() { + return query.getText(); + } + + private void updateView() { + this.tableViewer.update(updateTable, null); + } + + private void createTable(Composite composite) { + System.out.println("Creating table..."); + Table table = comUI.createTablePage(composite); + colNames = new String[] { + Messages.getString("UpdateRowPage.ColumnName"), + Messages.getString("UpdateRowPage.OldValue"), + "Where", + Messages.getString("UpdateRowPage.NewValue"), + Messages.getString("UpdateRowPage.SetValue") }; + + comUI.createTableColumn(table, colNames[0], SWT.LEFT, 0, 150); + comUI.createTableColumn(table, colNames[1], SWT.LEFT, 1, 300); + comUI.createTableColumn(table, colNames[2], SWT.CENTER, 2, 60); + comUI.createTableColumn(table, colNames[3], SWT.LEFT, 3, 300); + comUI.createTableColumn(table, colNames[4], SWT.CENTER, 4, 70); + this.tableViewer = new TableViewer(table); + this.tableViewer.setColumnProperties(colNames); + + CellEditor[] editor = new CellEditor[colNames.length]; + TextCellEditor txtEditorField = new TextCellEditor(table); + txtEditorField.getControl().setEnabled(false); + editor[0] = txtEditorField; + + TextCellEditor txtEditorFieldOld = new TextCellEditor(table); + txtEditorFieldOld.getControl().setEnabled(false); + editor[1] = txtEditorFieldOld; + + editor[2] = new CheckboxCellEditor(table, SWT.NULL); + + TextCellEditor txtEditorValues = new TextCellEditor(table); + editor[3] = txtEditorValues; + + editor[4] = new CheckboxCellEditor(table, SWT.NULL); + + this.tableViewer.setCellEditors(editor); + this.tableViewer.setLabelProvider(new LabelProviderImpl()); + this.tableViewer.setContentProvider(new ContentProviderImpl()); + this.tableViewer.setCellModifier(new CellModifierImpl()); + this.tableViewer.setInput(updateTable); + } + +} \ No newline at end of file