// Path: netbeans-project/AndroidDBvieweR/src/com/clough/android/adbv/model/Field.java
// public class Field {
//     private int fieldIndex;
//     private String fieldName;
//     private String fieldType;
//     private boolean fieldPrimarKey;
//     private boolean fieldNotNull;
//     private boolean fieldAutoIncrement;
//     private boolean fieldUnique;
//     private String fieldDefault;
// 
//     public Field() {
//     }
// 
//     public Field(int fieldIndex, String fieldName, String fieldType, boolean fieldPrimarKey, boolean fieldNotNull, boolean fieldAutoIncrement, boolean fieldUnique, String fieldDefault) {
//         this.fieldIndex = fieldIndex;
//         this.fieldName = fieldName;
//         this.fieldType = fieldType;
//         this.fieldPrimarKey = fieldPrimarKey;
//         this.fieldNotNull = fieldNotNull;
//         this.fieldAutoIncrement = fieldAutoIncrement;
//         this.fieldUnique = fieldUnique;
//         this.fieldDefault = fieldDefault;
//     }
// 
//     public String getFieldDefault() {
//         return fieldDefault;
//     }
// 
//     public void setFieldDefault(String fieldDefault) {
//         this.fieldDefault = fieldDefault;
//     }
// 
//     public int getFieldIndex() {
//         return fieldIndex;
//     }
// 
//     public void setFieldIndex(int fieldIndex) {
//         this.fieldIndex = fieldIndex;
//     }
// 
//     public String getFieldName() {
//         return fieldName;
//     }
// 
//     public void setFieldName(String fieldName) {
//         this.fieldName = fieldName;
//     }
// 
//     public String getFieldType() {
//         return fieldType;
//     }
// 
//     public void setFieldType(String fieldType) {
//         this.fieldType = fieldType;
//     }
// 
//     public boolean isFieldPrimarKey() {
//         return fieldPrimarKey;
//     }
// 
//     public void setFieldPrimarKey(boolean fieldPrimarKey) {
//         this.fieldPrimarKey = fieldPrimarKey;
//     }
// 
//     public boolean isFieldNotNull() {
//         return fieldNotNull;
//     }
// 
//     public void setFieldNotNull(boolean fieldNotNull) {
//         this.fieldNotNull = fieldNotNull;
//     }
// 
//     public boolean isFieldAutoIncrement() {
//         return fieldAutoIncrement;
//     }
// 
//     public void setFieldAutoIncrement(boolean fieldAutoIncrement) {
//         this.fieldAutoIncrement = fieldAutoIncrement;
//     }
// 
//     public boolean isFieldUnique() {
//         return fieldUnique;
//     }
// 
//     public void setFieldUnique(boolean fieldUnique) {
//         this.fieldUnique = fieldUnique;
//     }        
//     
// }


import com.clough.android.adbv.model.Field;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import javax.swing.DefaultCellEditor;
import javax.swing.JComboBox;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableColumn;
import javax.swing.table.TableColumnModel;
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 163, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(createTablesButton)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void addFieldButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addFieldButtonActionPerformed
        // TODO add your handling code here:
        databaseConfigDefaultTable.addRow(new Object[]{databaseConfigTable.getRowCount(), "Field" + databaseConfigTable.getRowCount(), "INTEGER", false, false, false, false, ""});
    }//GEN-LAST:event_addFieldButtonActionPerformed

    private void generateCreateStatementButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_generateCreateStatementButtonActionPerformed
        // TODO add your handling code here:                
        ArrayList<Field> fieldList = new ArrayList<Field>();
        String tableName = tableNameTextField.getText();
        String tableFieldQuery = "";
        boolean autoincrementFiledFound = false;
        for (int rowIndex = 0; rowIndex < databaseConfigTable.getRowCount(); rowIndex++) {
            int fieldIndex = Integer.parseInt(databaseConfigTable.getValueAt(rowIndex, 0).toString());
            String fieldName = databaseConfigTable.getValueAt(rowIndex, 1).toString().trim();
            String fieldType = databaseConfigTable.getValueAt(rowIndex, 2).toString().trim();
            boolean isPrimaryKey = Boolean.parseBoolean(databaseConfigTable.getValueAt(rowIndex, 3).toString());
            boolean isNotNull = Boolean.parseBoolean(databaseConfigTable.getValueAt(rowIndex, 4).toString());
            boolean isAutoIncrementing = Boolean.parseBoolean(databaseConfigTable.getValueAt(rowIndex, 5).toString());
            boolean isUnique = Boolean.parseBoolean(databaseConfigTable.getValueAt(rowIndex, 6).toString());
            String defaultValue = databaseConfigTable.getValueAt(rowIndex, 7).toString().trim();
// Path: netbeans-project/AndroidDBvieweR/src/com/clough/android/adbv/model/Field.java
// public class Field {
//     private int fieldIndex;
//     private String fieldName;
//     private String fieldType;
//     private boolean fieldPrimarKey;
//     private boolean fieldNotNull;
//     private boolean fieldAutoIncrement;
//     private boolean fieldUnique;
//     private String fieldDefault;
// 
//     public Field() {
//     }
// 
//     public Field(int fieldIndex, String fieldName, String fieldType, boolean fieldPrimarKey, boolean fieldNotNull, boolean fieldAutoIncrement, boolean fieldUnique, String fieldDefault) {
//         this.fieldIndex = fieldIndex;
//         this.fieldName = fieldName;
//         this.fieldType = fieldType;
//         this.fieldPrimarKey = fieldPrimarKey;
//         this.fieldNotNull = fieldNotNull;
//         this.fieldAutoIncrement = fieldAutoIncrement;
//         this.fieldUnique = fieldUnique;
//         this.fieldDefault = fieldDefault;
//     }
// 
//     public String getFieldDefault() {
//         return fieldDefault;
//     }
// 
//     public void setFieldDefault(String fieldDefault) {
//         this.fieldDefault = fieldDefault;
//     }
// 
//     public int getFieldIndex() {
//         return fieldIndex;
//     }
// 
//     public void setFieldIndex(int fieldIndex) {
//         this.fieldIndex = fieldIndex;
//     }
// 
//     public String getFieldName() {
//         return fieldName;
//     }
// 
//     public void setFieldName(String fieldName) {
//         this.fieldName = fieldName;
//     }
// 
//     public String getFieldType() {
//         return fieldType;
//     }
// 
//     public void setFieldType(String fieldType) {
//         this.fieldType = fieldType;
//     }
// 
//     public boolean isFieldPrimarKey() {
//         return fieldPrimarKey;
//     }
// 
//     public void setFieldPrimarKey(boolean fieldPrimarKey) {
//         this.fieldPrimarKey = fieldPrimarKey;
//     }
// 
//     public boolean isFieldNotNull() {
//         return fieldNotNull;
//     }
// 
//     public void setFieldNotNull(boolean fieldNotNull) {
//         this.fieldNotNull = fieldNotNull;
//     }
// 
//     public boolean isFieldAutoIncrement() {
//         return fieldAutoIncrement;
//     }
// 
//     public void setFieldAutoIncrement(boolean fieldAutoIncrement) {
//         this.fieldAutoIncrement = fieldAutoIncrement;
//     }
// 
//     public boolean isFieldUnique() {
//         return fieldUnique;
//     }
// 
//     public void setFieldUnique(boolean fieldUnique) {
//         this.fieldUnique = fieldUnique;
//     }        
//     
// }


// Path: netbeans-project/AndroidDBvieweR/src/com/clough/android/adbv/view/CreateTableDialog.java
import com.clough.android.adbv.model.Field;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import javax.swing.DefaultCellEditor;
import javax.swing.JComboBox;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableColumn;
import javax.swing.table.TableColumnModel;

                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 163, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(createTablesButton)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void addFieldButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addFieldButtonActionPerformed
        // TODO add your handling code here:
        databaseConfigDefaultTable.addRow(new Object[]{databaseConfigTable.getRowCount(), "Field" + databaseConfigTable.getRowCount(), "INTEGER", false, false, false, false, ""});
    }//GEN-LAST:event_addFieldButtonActionPerformed

    private void generateCreateStatementButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_generateCreateStatementButtonActionPerformed
        // TODO add your handling code here:                
        ArrayList<Field> fieldList = new ArrayList<Field>();
        String tableName = tableNameTextField.getText();
        String tableFieldQuery = "";
        boolean autoincrementFiledFound = false;
        for (int rowIndex = 0; rowIndex < databaseConfigTable.getRowCount(); rowIndex++) {
            int fieldIndex = Integer.parseInt(databaseConfigTable.getValueAt(rowIndex, 0).toString());
            String fieldName = databaseConfigTable.getValueAt(rowIndex, 1).toString().trim();
            String fieldType = databaseConfigTable.getValueAt(rowIndex, 2).toString().trim();
            boolean isPrimaryKey = Boolean.parseBoolean(databaseConfigTable.getValueAt(rowIndex, 3).toString());
            boolean isNotNull = Boolean.parseBoolean(databaseConfigTable.getValueAt(rowIndex, 4).toString());
            boolean isAutoIncrementing = Boolean.parseBoolean(databaseConfigTable.getValueAt(rowIndex, 5).toString());
            boolean isUnique = Boolean.parseBoolean(databaseConfigTable.getValueAt(rowIndex, 6).toString());
            String defaultValue = databaseConfigTable.getValueAt(rowIndex, 7).toString().trim();
            Field field = new Field(fieldIndex, fieldName, fieldType, isPrimaryKey, isNotNull, isAutoIncrementing, isUnique, defaultValue);