1 package net.sourceforge.phpeclipse.wizards.actions.metadata;
3 import java.util.ArrayList;
5 import java.util.Vector;
7 import net.sourceforge.phpeclipse.wizards.xml.ModelUtil;
9 import org.eclipse.jface.wizard.WizardDialog;
10 import org.w3c.dom.Document;
11 import org.w3c.dom.Element;
13 import com.quantum.extensions.IMetadataExtension;
14 import com.quantum.model.Column;
15 import com.quantum.model.xml.XMLToModelConverter;
17 public class PHPMetadataWizard implements IMetadataExtension {
22 * @see com.quantum.extensions.IDataExtension#run(org.w3c.dom.Document)
24 public void run(Document doc) {
25 // System.out.println(doc);
27 Element root = doc.getDocumentElement();
29 XMLToModelConverter c = new XMLToModelConverter(root);
30 String name = ModelUtil.getTableName(root);
31 System.out.print("Table-name: ");
32 System.out.println(name);
33 Column[] cols = c.getColumns();
34 for (int i = 0; i < cols.length; i++) {
35 System.out.print("Column-name: " + i + " ");
36 System.out.println(cols[i].getName());
39 UpdateRowPage page = new UpdateRowPage(""); //$NON-NLS-1$
40 SQLRowWizard wizard = new SQLRowWizard();
42 List rowList = new ArrayList();
43 for (int i = 1; i < cols.length; i++) {
44 Vector row = new Vector();
45 row.addElement(cols[i].getName());
46 row.addElement(cols[i].getTypeName());
49 precision = cols[i].getSize();// metaData.getPrecision(i);
50 } catch (Throwable t) {
51 // Do nothing. An exception can be generated by some very large row sizes, like BLOB in Oracle.
52 // Then getPrecision() will generate an exception. So we ignore it and go on.
54 // if (precision == 0) {
55 // precision = cols[i].getSize();
57 int scale = cols[i].getNumberOfFractionalDigits();// metaData.getScale(i);
59 row.addElement(new Long(precision));
60 row.addElement(new Integer(scale));
62 boolean nullable = cols[i].isNullable();// metaData.isNullable(i);
63 // if (nullable == ResultSetMetaData.columnNoNulls) {
64 // row.addElement("Not Null"); //$NON-NLS-1$
65 // } else if (nullable == ResultSetMetaData.columnNullable) {
66 // row.addElement("Nullable"); //$NON-NLS-1$
67 // } else if (nullable == ResultSetMetaData.columnNullableUnknown) {
68 // row.addElement("Nullable"); //$NON-NLS-1$
70 // row.addElement("<Error>"); //$NON-NLS-1$
73 row.addElement("Nullable"); //$NON-NLS-1$
75 row.addElement("<Error>"); //$NON-NLS-1$
77 // row.addElement(metaData.isAutoIncrement(i) ? Boolean.TRUE : Boolean.FALSE);
78 rowList.add(new Row(row));
79 row.addElement(new Integer(cols[i].getType()));// metaData.getColumnType(i)));
82 Row rrow = new Row(rowList);
83 wizard.init(Messages.getString("TableView.UpdateRow"), page, rrow, cols); //$NON-NLS-1$
84 WizardDialog dialog = new WizardDialog(null, wizard);
87 } catch (Exception e) {