package com.quantum.wizards; 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.Label; import org.eclipse.swt.widgets.Table; import org.eclipse.swt.widgets.TableItem; import com.quantum.ImageStore; import com.quantum.Messages; import com.quantum.model.Column; import com.quantum.model.Entity; import com.quantum.util.StringMatrix; import com.quantum.util.sql.SQLInstructionBuilder; /** * @author BC Holmes * @author Elvin E. Ebora */ public class DeleteRowPage extends BaseSQLPage implements SQLPage { class DeleteRowPageValues { private String sColNames = null; private String sValues = null; private boolean bPrimary = false; public DeleteRowPageValues() { } /** * @return Returns the bPrimary. */ public boolean isBPrimary() { return bPrimary; } /** * @param primary The bPrimary to set. */ public void setBPrimary(boolean primary) { bPrimary = primary; } /** * @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 sValues. */ public String getSValues() { return sValues; } /** * @param values The sValues to set. */ public void setSValues(String values) { sValues = values; } } class LabelProviderImpl implements ITableLabelProvider { public Image getColumnImage(Object element, int columnIndex) { if (columnIndex == 2) { return ((DeleteRowPageValues)element).isBPrimary() ? imgCheck : imgUncheck; } else { return null; } } public String getColumnText(Object element, int columnIndex) { String sReturn = ""; DeleteRowPageValues deleteRow = (DeleteRowPageValues)element; switch (columnIndex) { case 0: // column names sReturn = deleteRow.getSColNames(); break; case 1: // values sReturn = deleteRow.getSValues(); break; case 2: // set 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 deleteTable; } 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; DeleteRowPageValues deleteVal = (DeleteRowPageValues)element; switch (colIndx) { case 0: // column names rResult = deleteVal.getSColNames(); break; case 1: // values rResult = deleteVal.getSValues(); break; case 2: // checkbox rResult = new Boolean(deleteVal.isBPrimary()); 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; DeleteRowPageValues deleteVal = (DeleteRowPageValues)item.getData(); switch (colIndx) { case 0: // column names break; case 1: // values deleteVal.setSValues(value.toString()); break; case 2: // checkbox deleteVal.setBPrimary(((Boolean)value).booleanValue()); break; default: break; } updateView(); updateQuery(); } } String[] columnNames; String[] colNames; Label query; DeleteRowPageValues[] deleteTable = 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 DeleteRowPage(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 = columnNames.length; deleteTable = new DeleteRowPageValues[nLen]; for(int nCtr=0; nCtr