package com.quantum.wizards; import org.eclipse.jface.viewers.CellEditor; 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.Label; import org.eclipse.swt.widgets.Table; import org.eclipse.swt.widgets.TableItem; import com.quantum.Messages; import com.quantum.util.StringMatrix; import com.quantum.util.sql.SQLInstructionBuilder; /** * @author BC Holmes * @author Elvin E. Ebora */ public class InsertRowPage extends BaseSQLPage implements SQLPage { class InsertRowTableValues { private String colNames = null; private String values = null; public InsertRowTableValues() { } /** * @return Returns the colNames. */ public String getColNames() { return colNames; } /** * @param colNames The colNames to set. */ public void setColNames(String colNames) { this.colNames = colNames; } /** * @return Returns the values. */ public String getValues() { return values; } /** * @param values The values to set. */ public void setValues(String values) { this.values = values; } } class LabelProviderImpl implements ITableLabelProvider { public Image getColumnImage(Object element, int columnIndex) { return null; } public String getColumnText(Object element, int columnIndex) { String sReturn = ""; InsertRowTableValues insertRow = (InsertRowTableValues)element; switch (columnIndex) { case 0: sReturn = insertRow.getColNames(); break; case 1: sReturn = insertRow.getValues(); 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 insertTable; } 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; InsertRowTableValues insertVal = (InsertRowTableValues)element; switch (colIndx) { case 0: rResult = insertVal.getColNames(); break; case 1: rResult = insertVal.getValues(); break; default: rResult = ""; break; } return rResult; } public void modify(Object element, String property, Object value) { int colIndx = comUI.getColumnNamesAsList(colNames).indexOf(property); TableItem item = (TableItem) element; InsertRowTableValues insertVal = (InsertRowTableValues)item.getData(); switch (colIndx) { case 0: // field names break; case 1: // field values insertVal.setValues(value.toString()); updateView(); updateQuery(); break; default: break; } } } String[] columnNames; String[] colNames; Label query; InsertRowTableValues[] insertTable = null; CommonWizardUI comUI; TableViewer tableViewer = null; int numColumns = 0; public InsertRowPage(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)); comUI = new CommonWizardUI(); // init values to be displayed on the table columnNames = this.results.getColumnNames(); int nLen = columnNames.length; insertTable = new InsertRowTableValues[nLen]; for (int nCtr=0; nCtr