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;
* @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);
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("<Error>"); //$NON-NLS-1$
+ // }
+ if (nullable) {
+ row.addElement("Nullable"); //$NON-NLS-1$
+ } else {
+ row.addElement("<Error>"); //$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
+}
+