--- FM2SQL/Attic/FM2SQL.java 2004/02/19 10:35:06 1.19 +++ FM2SQL/Attic/FM2SQL.java 2004/03/03 12:14:47 1.24 @@ -70,6 +70,8 @@ public class FM2SQL extends JFrame imple private JCheckBoxMenuItem convertItem; private JCheckBoxMenuItem appendItem; private JCheckBoxMenuItem updateItem; + private JCheckBoxMenuItem deleteItem; + int mode = -1; final static int ID_INDEX = 1; final static int SELECT_INDEX = 2; @@ -134,6 +136,8 @@ public class FM2SQL extends JFrame imple int oldWidth = 0, oldHeight = 0; boolean resize = true; static FileWriter logFile; + String delimiter = ""; + Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize(); JFileChooser configExportFileChooser; JFileChooser configImportFileChooser; @@ -597,6 +601,7 @@ public class FM2SQL extends JFrame imple System.out.println("Convert Mode selected"); convert.setText("Convert Tables"); convert.setActionCommand("Convert Tables"); + convert.setToolTipText("Normal table conversion existing table will be deleted"); mode = Convert.DataBase.CONVERT_MODE; } if (command == "Append Mode") @@ -604,6 +609,8 @@ public class FM2SQL extends JFrame imple System.out.println("Append Mode selected"); convert.setText("Append Tables"); convert.setActionCommand("Append Tables"); + convert.setToolTipText("Appends data to an existing table"); + mode = Convert.DataBase.APPEND_MODE; } if (command == "Update Mode") @@ -611,8 +618,18 @@ public class FM2SQL extends JFrame imple System.out.println("Update Mode selected"); convert.setText("Update Tables"); convert.setActionCommand("Update Tables"); + convert.setToolTipText("Updates data that has been changed in source"); mode = Convert.DataBase.UPDATE_MODE; } + if (command == "Delete Mode") + { + System.out.println("Delete Mode selected"); + convert.setText("Delete Tables"); + convert.setActionCommand("Delete Tables"); + convert.setToolTipText("Deletes data that has been deleted in source"); + mode = Convert.DataBase.DELETE_MODE; + } + //writing config if (command.equals("save XML Config")) { @@ -822,8 +839,7 @@ public class FM2SQL extends JFrame imple { fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); fmInstance.setEnabled(false); - Convert.convert(bean.url, destURLBox.getSelectedItem().toString(), vectors[0], vectors[1],vectors[2],vectors[3],vectors[4],mode); - + Convert.convert(bean.url, destURLBox.getSelectedItem().toString(), vectors[0], vectors[1],vectors[2],vectors[3],vectors[4],mode,delimiter); destBean.setConnection((String) destURLBox.getSelectedItem()); DefaultListModel model = new DefaultListModel(); tables = destBean.getTableNames(); @@ -856,7 +872,7 @@ public class FM2SQL extends JFrame imple // TODO add id vector in table and write it out Convert.DataBase source = new Convert.DataBase(bean,vectors[0],vectors[1],vectors[2],vectors[3],vectors[4],mode); Convert.DataBase destination = new Convert.DataBase(destBean,new Vector(),new Vector(),new Vector(),new Vector(),new Vector(),-1); - + source.delimiter =delimiter; try { Convert.writeConfig(file,source,destination); @@ -915,8 +931,9 @@ public class FM2SQL extends JFrame imple convert.setActionCommand("Update Tables"); mode = Convert.DataBase.UPDATE_MODE; } + delimiter=database.delimiter; database.bean.getConnection(); - + bean = database.bean; Object obj =bean.url; ((DefaultComboBoxModel) sourceURLBox.getModel()).removeElement(obj); @@ -1179,6 +1196,8 @@ public class FM2SQL extends JFrame imple String layout = (model.getValueAt(row,LAYOUT_INDEX)!=null) ?((JComboBox)model.getValueAt(row,LAYOUT_INDEX)).getSelectedItem().toString():""; String query = model.getValueAt(row,SELECT_INDEX).toString(); String create = model.getValueAt(row,CREATE_INDEX).toString(); + String id = (model.getValueAt(row,ID_INDEX)!=null) ?((JComboBox)model.getValueAt(row,ID_INDEX)).getSelectedItem().toString():""; + System.out.println("table" +table+" layout "+layout+" query "+query); if(!create.equals("")) { @@ -1187,7 +1206,19 @@ public class FM2SQL extends JFrame imple if(option==0) model.setValueAt(createStatement(table,destBean,layout,query),row,CREATE_INDEX); } - + if (columnName.equals("Layouts")) + { + + bean.makeQuery("select * from"+bean.getQC()+table+bean.getQC(),1); + + Vector idVec = bean.getColumnNames(); + if (idVec == null) + idVec = new Vector(); + idVec.add(0, ""); + JComboBox box = ((JComboBox) model.getValueAt(row, ID_INDEX)); + box.setModel(new DefaultComboBoxModel(idVec)); + box.setSelectedItem(id); + } } /* Statement stm = bean.getConnection().createStatement(); @@ -1275,6 +1306,14 @@ public class FM2SQL extends JFrame imple bgrp.add(updateItem); menu.add(updateItem); + deleteItem = new JCheckBoxMenuItem("Delete Mode"); + deleteItem.setToolTipText("Deletes data in an existing table \n that has been deleted in source table"); + deleteItem.addActionListener(fm); + + bgrp.add(deleteItem); + + menu.add(deleteItem); + menubar.add(menu); item.addActionListener(fm);