Diff for /FM2SQL/Attic/FM2SQL.java between versions 1.18 and 1.44

version 1.18, 2004/02/18 13:25:24 version 1.44, 2004/10/19 11:57:26
Line 1 Line 1
   /*
    * FM2SQL.java -- Main program Filemaker to SQL Converter 
    * Copyright (C) 2003 Robert Gordesch (rogo@mpiwg-berlin.mpg.de
    * This program is free software; you can redistribute it and/or modify it
    * under the terms of the GNU General Public License as published by the Free
    * Software Foundation; either version 2 of the License, or (at your option)
    * any later version.  Please read license.txt for the full details. A copy of
    * the GPL may be found at http://www.gnu.org/copyleft/lgpl.html  You should
    * have received a copy of the GNU General Public License along with this
    * program; if not, write to the Free Software Foundation, Inc., 59 Temple
    * Place, Suite 330, Boston, MA 02111-1307 USA  Created on 15.09.2003 by
    * rogo  
    */
   
 import java.awt.Cursor;  import java.awt.Cursor;
 import java.awt.Dimension;  import java.awt.Dimension;
 import java.awt.Font;  import java.awt.Font;
Line 18  import java.io.FileWriter; Line 32  import java.io.FileWriter;
 import java.io.PrintStream;  import java.io.PrintStream;
 import java.sql.SQLException;  import java.sql.SQLException;
 import java.sql.Statement;  import java.sql.Statement;
   import java.text.ParseException;
 import java.util.Collections;  import java.util.Collections;
 import java.util.Iterator;  import java.util.Iterator;
 import java.util.Vector;  import java.util.Vector;
Line 56  import javax.swing.table.TableModel; Line 71  import javax.swing.table.TableModel;
  *   *
  * <br>   * <br>
  * <h2>FileMaker Test (JDBC Database Driver Test)</h2>   * <h2>FileMaker Test (JDBC Database Driver Test)</h2>
  * Main class :   * Main class : contains the main Frame, all event handlers etc <br>
  * contains the main Frame, all event handlers etc   * The Database access is made over DBBean class all other classes are just for
  * <br>   * the visualization of the data
  * The Database access is made over DBBean class   * 
  * all other classes are just for the visualization of the data  
  *  @version 0.3( first stable release)   *  @version 0.3( first stable release)
  *  @author rogo   *  @author rogo
  *   *
  */   */
 public class FM2SQL extends JFrame implements ActionListener, TableModelListener  public class FM2SQL extends JFrame implements ActionListener, TableModelListener
 {  {
       private JMenuItem delimiterItem;
   private JCheckBoxMenuItem convertItem;    private JCheckBoxMenuItem convertItem;
   private JCheckBoxMenuItem appendItem;    private JCheckBoxMenuItem appendItem;
   private JCheckBoxMenuItem updateItem;    private JCheckBoxMenuItem updateItem;
       private JCheckBoxMenuItem deleteItem;
       private JCheckBoxMenuItem useNormanToUnicodeMapper;
   int mode = -1;    int mode = -1;
   final static int ID_INDEX = 1;      final static int STATUS_INDEX = 0;
   final static int SELECT_INDEX = 2;      final static int NAME_INDEX = 1;
   final static int CREATE_INDEX = 3;      final static int ID_INDEX = 2;
   final static int LAYOUT_INDEX = 4;      final static int SELECT_INDEX = 3;
         final static int CREATE_INDEX = 4;
         final static int LAYOUT_INDEX = 5;
     
   /**    /**
   * The database Bean instance.    * The database Bean instance.
Line 93  public class FM2SQL extends JFrame imple Line 110  public class FM2SQL extends JFrame imple
    *  tList - Tablenames to choose from     *  tList - Tablenames to choose from
    */     */
   
   JList tList = new JList(new String[] { "no database", "connection", "" });      JList tList = new JList(new String[]
   JList tListDest = new JList(new String[] { "no database connection", "", "" });      {"no database", "connection", ""});
       JList tListDest = new JList(new String[]
       {"no database connection", "", ""});
   
   /**    /**
   *  sourceUrl - Database URL ComboBox    *  sourceUrl - Database URL ComboBox
Line 134  public class FM2SQL extends JFrame imple Line 153  public class FM2SQL extends JFrame imple
   int oldWidth = 0, oldHeight = 0;    int oldWidth = 0, oldHeight = 0;
   boolean resize = true;    boolean resize = true;
   static FileWriter logFile;    static FileWriter logFile;
       String delimiter = "";
   
   Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();    Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
   JFileChooser configExportFileChooser;    JFileChooser configExportFileChooser;
   JFileChooser configImportFileChooser;    JFileChooser configImportFileChooser;
       private JCheckBoxMenuItem synchronizeItem;
     
   /**    /**
    * tries to connect to database specified in url-Variable.       * tries to connect to database specified in url-Variable. initializes all GUI
    * initializes all GUI components, then fails throws an exception       * components, then fails throws an exception
    *     *
    */     */
   public FM2SQL() throws Exception    public FM2SQL() throws Exception
Line 151  public class FM2SQL extends JFrame imple Line 173  public class FM2SQL extends JFrame imple
   public void initializeGUI() throws Exception    public void initializeGUI() throws Exception
   {    {
     Image local = getToolkit().getImage(FM2SQL.class.getResource("icons/fm.jpg"));      Image local = getToolkit().getImage(FM2SQL.class.getResource("icons/fm.jpg"));
     if (local != null);          if (local != null)
               ;
     setIconImage(local);      setIconImage(local);
     bean = new DBBean();      bean = new DBBean();
     destBean = new DBBean();      destBean = new DBBean();
     sourceURLBox = new JComboBox(new String[] { "jdbc:fmpro:http://141.14.237.74:8050", "jdbc:fmpro:http://localhost", "jdbc:postgresql://foxridge/test" });          sourceURLBox = new JComboBox(new String[]
           {"jdbc:fmpro:http://141.14.237.74:8050", "jdbc:fmpro:http://localhost", "jdbc:postgresql://foxridge/test", "jdbc:sequelink://r583-3:2399"});
     sourceURLBox.setEditable(true);      sourceURLBox.setEditable(true);
     sourceURLBox.setFont(new Font("Times New Roman",Font.PLAIN,14));      sourceURLBox.setFont(new Font("Times New Roman",Font.PLAIN,14));
     destURLBox = new JComboBox(new String[] { "jdbc:postgresql://foxridge/test", "jdbc:postgresql://erebos/test1" });          destURLBox = new JComboBox(new String[]
           {"jdbc:postgresql://foxridge/test", "jdbc:postgresql://erebos/test1"});
     destURLBox.setEditable(true);      destURLBox.setEditable(true);
     destURLBox.addActionListener(this);      destURLBox.addActionListener(this);
     destURLBox.setFont(new Font("Times New Roman",Font.PLAIN,14));      destURLBox.setFont(new Font("Times New Roman",Font.PLAIN,14));
Line 312  public class FM2SQL extends JFrame imple Line 337  public class FM2SQL extends JFrame imple
     {      {
       public void windowClosing(WindowEvent e)        public void windowClosing(WindowEvent e)
       {        {
                   bean.closeAllConnections();
                   destBean.closeAllConnections();
         System.exit(0);          System.exit(0);
       }        }
     });      });
Line 341  public class FM2SQL extends JFrame imple Line 368  public class FM2SQL extends JFrame imple
             setSize(getWidth(), table.table.getPreferredSize().height + 2 * size);              setSize(getWidth(), table.table.getPreferredSize().height + 2 * size);
           // System.out.println("size" + size);            // System.out.println("size" + size);
         }          }
         //   listPanel.setMaximumSize(new Dimension(getPreferredSize().width - 5, 550));                  //   listPanel.setMaximumSize(new Dimension(getPreferredSize().width - 5,
         //   listPanel.setMinimumSize(new Dimension(getPreferredSize().width - 5, 200));                  // 550));
         //    listPanel.setPreferredSize(new Dimension(getPreferredSize().width - 5, 370));                  //   listPanel.setMinimumSize(new Dimension(getPreferredSize().width - 5,
                   // 200));
                   //    listPanel.setPreferredSize(new Dimension(getPreferredSize().width -
                   // 5, 370));
         tC.tableScroller.revalidate();          tC.tableScroller.revalidate();
         Dimension dim = getSize();          Dimension dim = getSize();
         tC.tableScroller.setMinimumSize(new Dimension(dim.width-400, dim.height - topPanel.getPreferredSize().height - 100));          tC.tableScroller.setMinimumSize(new Dimension(dim.width-400, dim.height - topPanel.getPreferredSize().height - 100));
Line 398  public class FM2SQL extends JFrame imple Line 428  public class FM2SQL extends JFrame imple
       fmInstance = new FM2SQL();        fmInstance = new FM2SQL();
       fmInstance.table.tableModel.addTableModelListener(fmInstance);        fmInstance.table.tableModel.addTableModelListener(fmInstance);
       fmInstance.setVisible(true);        fmInstance.setVisible(true);
       /*   if (!new File("./html").exists())              /*
            new File("./html").mkdirs();               * if (!new File("./html").exists()) new File("./html").mkdirs(); logFile =
          logFile = new FileWriter("./html/index.html");               * new FileWriter("./html/index.html"); openLog();
          openLog();  
       */        */
     } catch (Exception e)          }
           catch (Exception e)
     {      {
       JOptionPane pane = new JOptionPane(e.getMessage() + "  \n URL: " + url, JOptionPane.ERROR_MESSAGE);        JOptionPane pane = new JOptionPane(e.getMessage() + "  \n URL: " + url, JOptionPane.ERROR_MESSAGE);
   
Line 445  public class FM2SQL extends JFrame imple Line 475  public class FM2SQL extends JFrame imple
         
         ((DefaultComboBoxModel) sourceURLBox.getModel()).insertElementAt(insObj, 0);          ((DefaultComboBoxModel) sourceURLBox.getModel()).insertElementAt(insObj, 0);
         sourceURLBox.setSelectedItem(insObj);          sourceURLBox.setSelectedItem(insObj);
       } else if (src == destURLBox)              }
               else if (src == destURLBox)
       {        {
         if (debug)          if (debug)
           System.out.println("hey" + destURLBox.getSelectedItem());            System.out.println("hey" + destURLBox.getSelectedItem());
         //((DefaultComboBoxModel) box4.getModel()).insertElementAt(box4.getSelectedItem(), 0);                  //((DefaultComboBoxModel)
                   // box4.getModel()).insertElementAt(box4.getSelectedItem(), 0);
         try          try
         {          {
           String selected = (String) destURLBox.getSelectedItem();            String selected = (String) destURLBox.getSelectedItem();
Line 462  public class FM2SQL extends JFrame imple Line 494  public class FM2SQL extends JFrame imple
           }            }
           destURLBox.setModel(new DefaultComboBoxModel(urls));            destURLBox.setModel(new DefaultComboBoxModel(urls));
           destURLBox.setSelectedItem(selected);            destURLBox.setSelectedItem(selected);
         } catch (Exception e5)                  }
                   catch (Exception e5)
         {          {
         }          }
       }        }
Line 498  public class FM2SQL extends JFrame imple Line 531  public class FM2SQL extends JFrame imple
                 fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));                  fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                                 fmInstance.setEnabled(true);                                  fmInstance.setEnabled(true);
                 //  System.out.println("hallo" + tables + " ");                  //  System.out.println("hallo" + tables + " ");
               } catch (Exception e5)                              }
                               catch (Exception e5)
               {                {
                 ByteArrayOutputStream b = new ByteArrayOutputStream();                  ByteArrayOutputStream b = new ByteArrayOutputStream();
                 PrintStream stream = new PrintStream(b);                  PrintStream stream = new PrintStream(b);
Line 521  public class FM2SQL extends JFrame imple Line 555  public class FM2SQL extends JFrame imple
             }              }
           };            };
           thread.start();            thread.start();
         } else if (src == destURLBox&&!noUserUpdate)                  }
                   else if (src == destURLBox && !noUserUpdate)
         {          {
           Thread thread = new Thread()            Thread thread = new Thread()
           {            {
Line 547  public class FM2SQL extends JFrame imple Line 582  public class FM2SQL extends JFrame imple
                 //  System.out.println("hallo" + tables + " ");                  //  System.out.println("hallo" + tables + " ");
                 fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));                  fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                                 fmInstance.setEnabled(true);                                  fmInstance.setEnabled(true);
               } catch (Exception e5)                              }
                               catch (Exception e5)
               {                {
                 ByteArrayOutputStream b = new ByteArrayOutputStream();                  ByteArrayOutputStream b = new ByteArrayOutputStream();
                 PrintStream stream = new PrintStream(b);                  PrintStream stream = new PrintStream(b);
Line 568  public class FM2SQL extends JFrame imple Line 604  public class FM2SQL extends JFrame imple
         setTitle("Filemaker 2 SQL Conversion Tool ");          setTitle("Filemaker 2 SQL Conversion Tool ");
         // pack();          // pack();
   
       } catch (Exception e4)              }
               catch (Exception e4)
       {        {
         ByteArrayOutputStream b = new ByteArrayOutputStream();          ByteArrayOutputStream b = new ByteArrayOutputStream();
         PrintStream stream = new PrintStream(b);          PrintStream stream = new PrintStream(b);
Line 588  public class FM2SQL extends JFrame imple Line 625  public class FM2SQL extends JFrame imple
         result.title = "Database features";          result.title = "Database features";
         result.setVisible(true);          result.setVisible(true);
         String name = result.writeResult();          String name = result.writeResult();
       } catch (Exception e2)              }
               catch (Exception e2)
       {        {
       }        }
     }      }
           if (command.equals("Delimiter"))
           {
               new DelimiterDialog(fmInstance).setVisible(true);
               //delimiter = JOptionPane.showInputDialog(fmInstance,"Enter delimiter
               // String",delimiter);
   
           }
   
     if (command == "Convert Mode")      if (command == "Convert Mode")
     {      {
       System.out.println("Convert Mode selected");        System.out.println("Convert Mode selected");
             convert.setText("Convert Tables");              convert.setText("Convert Tables");
             convert.setActionCommand("Convert Tables");              convert.setActionCommand("Convert Tables");
               convert.setToolTipText("Normal table conversion  existing table will be deleted");
       mode = Convert.DataBase.CONVERT_MODE;        mode = Convert.DataBase.CONVERT_MODE;
     }      }
     if (command == "Append Mode")      if (command == "Append Mode")
Line 604  public class FM2SQL extends JFrame imple Line 651  public class FM2SQL extends JFrame imple
       System.out.println("Append Mode selected");        System.out.println("Append Mode selected");
             convert.setText("Append Tables");              convert.setText("Append Tables");
             convert.setActionCommand("Append Tables");              convert.setActionCommand("Append Tables");
               convert.setToolTipText("Appends data to an existing table");
   
       mode = Convert.DataBase.APPEND_MODE;         mode = Convert.DataBase.APPEND_MODE; 
     }      }
     if (command == "Update Mode")      if (command == "Update Mode")
Line 611  public class FM2SQL extends JFrame imple Line 660  public class FM2SQL extends JFrame imple
       System.out.println("Update Mode selected");        System.out.println("Update Mode selected");
             convert.setText("Update Tables");              convert.setText("Update Tables");
             convert.setActionCommand("Update Tables");              convert.setActionCommand("Update Tables");
               convert.setToolTipText("Updates data that has been changed in source");
       mode = Convert.DataBase.UPDATE_MODE;         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;
           }
           if (command == "Synchronize Mode")
           {
               System.out.println("Synchronize Mode selected");
               convert.setText("Synchronize Tables");
               convert.setActionCommand("Synchronize Tables");
               convert.setToolTipText("Synchronize data with destination table");
               mode = Convert.DataBase.SYNCHRONIZE_MODE;
           }
   
           if (command.equals("use NormanToUnicodeMapper"))
           {
               if (bean != null)
                   bean.setUseNormanToUnicodeMapper(useNormanToUnicodeMapper.isSelected());
           }
    //writing config     //writing config
     if (command.equals("save XML Config"))      if (command.equals("save XML Config"))
     {      {
Line 683  public class FM2SQL extends JFrame imple Line 755  public class FM2SQL extends JFrame imple
         
     }      }
               
        
     if (command.equals("Convert Tables")||command.equals("Append Tables"))      if (command.equals("Convert Tables")||command.equals("Append Tables"))
     {      {
   
Line 714  public class FM2SQL extends JFrame imple Line 785  public class FM2SQL extends JFrame imple
              };               };
              thread.start();               thread.start();
          }           }
           if (command.equals("Delete Tables"))
           {
   
               Thread thread = new Thread()
               {
                   public void run()
                   {
                       setEnabled(false);
                       delete();
                       setEnabled(true);
                   }
   
               };
               thread.start();
           }
           if (command.equals("Synchronize Tables"))
           {
   
               Thread thread = new Thread()
               {
                   public void run()
                   {
                       setEnabled(false);
                       synchronize();
                       setEnabled(true);
                   }
   
               };
               thread.start();
           }
   
     if (command.equals("show Tables"))      if (command.equals("show Tables"))
     {      {
Line 764  public class FM2SQL extends JFrame imple Line 865  public class FM2SQL extends JFrame imple
     }      }
   if(command.equals("Quit"))    if(command.equals("Quit"))
    {     {
               bean.closeAllConnections();
               destBean.closeAllConnections();
      fmInstance.dispose();       fmInstance.dispose();
      System.exit(0);       System.exit(0);
       
Line 771  public class FM2SQL extends JFrame imple Line 874  public class FM2SQL extends JFrame imple
         
   }    }
     /**      /**
      * Updates the content of source to destination and makes new table if necessary       *  
        */
       protected void synchronize()
       {
           Vector vectors[] = getListFromTable();
           Convert.user = bean.user;
           Convert.passwd = bean.passwd;
           Convert.userDest = destBean.user;
           Convert.passwdDest = destBean.passwd;
           try
           {
   
               fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
               fmInstance.setEnabled(false);
               // TODO indexList vector weiter reichen
               Convert.synchronize(bean.url, destURLBox.getSelectedItem().toString(), vectors[0], vectors[1], vectors[2], vectors[3], vectors[4], mode, delimiter, new Vector());
   
               destBean.setConnection((String) destURLBox.getSelectedItem());
               DefaultListModel model = new DefaultListModel();
               tables = destBean.getTableNames();
               for (int j = 0; j < tables.size(); ++j)
                   model.addElement(tables.get(j));
               if (debug)
                   System.out.println("hallo" + tables + " ");
               tListDest.setModel(model);
               fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
           }
           catch (Exception e4)
           {
               ByteArrayOutputStream b = new ByteArrayOutputStream();
               PrintStream stream = new PrintStream(b);
               e4.printStackTrace(stream);
               showErrorDialog(b.toString(), "Synchronize of table failed");
               fmInstance.setEnabled(true);
           }
   
       }
       /**
        * Updates the content of source to destination and makes new table if
        * necessary
      */       */
   
   public void update()     public void update() 
Line 783  public class FM2SQL extends JFrame imple Line 925  public class FM2SQL extends JFrame imple
     Convert.passwdDest = destBean.passwd;      Convert.passwdDest = destBean.passwd;
     try      try
     {      {
   
       fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));        fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
       fmInstance.setEnabled(false);        fmInstance.setEnabled(false);
       Convert.update(bean.url, destURLBox.getSelectedItem().toString(), vectors[0], vectors[1], vectors[2], vectors[3],vectors[4], mode);        Convert.update(bean.url, destURLBox.getSelectedItem().toString(), vectors[0], vectors[1], vectors[2], vectors[3],vectors[4], mode);
Line 796  public class FM2SQL extends JFrame imple Line 939  public class FM2SQL extends JFrame imple
         System.out.println("hallo" + tables + " ");          System.out.println("hallo" + tables + " ");
       tListDest.setModel(model);        tListDest.setModel(model);
       fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));        fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
     } catch (Exception e4)          }
           catch (Exception e4)
     {      {
       ByteArrayOutputStream b = new ByteArrayOutputStream();        ByteArrayOutputStream b = new ByteArrayOutputStream();
       PrintStream stream = new PrintStream(b);        PrintStream stream = new PrintStream(b);
Line 806  public class FM2SQL extends JFrame imple Line 950  public class FM2SQL extends JFrame imple
     }      }
   
   }    }
       public void delete()
       {
           Vector vectors[] = getListFromTable();
           Convert.user = bean.user;
           Convert.passwd = bean.passwd;
           Convert.userDest = destBean.user;
           Convert.passwdDest = destBean.passwd;
           try
           {
   
               fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
               fmInstance.setEnabled(false);
               Convert.delete(bean.url, destURLBox.getSelectedItem().toString(), vectors[0], vectors[1], vectors[2], vectors[3], vectors[4], mode);
   
               destBean.setConnection((String) destURLBox.getSelectedItem());
               DefaultListModel model = new DefaultListModel();
               tables = destBean.getTableNames();
               for (int j = 0; j < tables.size(); ++j)
                   model.addElement(tables.get(j));
               if (debug)
                   System.out.println("hallo" + tables + " ");
               tListDest.setModel(model);
               fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
           }
           catch (Exception e4)
           {
               ByteArrayOutputStream b = new ByteArrayOutputStream();
               PrintStream stream = new PrintStream(b);
               e4.printStackTrace(stream);
               showErrorDialog(b.toString(), "Delete of table failed");
               fmInstance.setEnabled(true);
           }
   
       }
   
   /**    /**
    * Copys the content of source to destination and makes new table if necessary     * Copys the content of source to destination and makes new table if necessary
    */     */
Line 821  public class FM2SQL extends JFrame imple Line 1000  public class FM2SQL extends JFrame imple
     {      {
       fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));        fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
       fmInstance.setEnabled(false);        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());        destBean.setConnection((String) destURLBox.getSelectedItem());
       DefaultListModel model = new DefaultListModel();        DefaultListModel model = new DefaultListModel();
       tables = destBean.getTableNames();        tables = destBean.getTableNames();
Line 832  public class FM2SQL extends JFrame imple Line 1010  public class FM2SQL extends JFrame imple
         System.out.println("hallo" + tables + " ");          System.out.println("hallo" + tables + " ");
       tListDest.setModel(model);        tListDest.setModel(model);
       fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));        fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
     } catch (Exception e4)          }
           catch (Exception e4)
     {      {
       ByteArrayOutputStream b = new ByteArrayOutputStream();        ByteArrayOutputStream b = new ByteArrayOutputStream();
       PrintStream stream = new PrintStream(b);        PrintStream stream = new PrintStream(b);
Line 847  public class FM2SQL extends JFrame imple Line 1026  public class FM2SQL extends JFrame imple
     fmInstance.setEnabled(false);      fmInstance.setEnabled(false);
   
     Vector vectors[] = getListFromTable();      Vector vectors[] = getListFromTable();
     if(convertItem.isSelected()) mode = Convert.DataBase.CONVERT_MODE;          if (convertItem.isSelected())
     else              mode = Convert.DataBase.CONVERT_MODE;
         if(appendItem.isSelected()) mode = Convert.DataBase.APPEND_MODE;          else if (appendItem.isSelected())
         else              mode = Convert.DataBase.APPEND_MODE;
         if(updateItem.isSelected()) mode = Convert.DataBase.UPDATE_MODE;          else if (updateItem.isSelected())
               mode = Convert.DataBase.UPDATE_MODE;
           else if (deleteItem.isSelected())
               mode = Convert.DataBase.DELETE_MODE;
           else if (synchronizeItem.isSelected())
               mode = Convert.DataBase.SYNCHRONIZE_MODE;
   
     // TODO add id vector in table and write it out      // 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 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);      Convert.DataBase destination = new Convert.DataBase(destBean,new Vector(),new Vector(),new Vector(),new Vector(),new Vector(),-1);
              source.delimiter = delimiter;
           source.useNormanToUnicodeMapper = useNormanToUnicodeMapper.isSelected();
     try      try
     {      {
       Convert.writeConfig(file,source,destination);        Convert.writeConfig(file,source,destination);
       fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));        fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
       fmInstance.setEnabled(true);        fmInstance.setEnabled(true);
   
     } catch (Exception e)          }
           catch (Exception e)
     {      {
       fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));        fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
       fmInstance.setEnabled(true);        fmInstance.setEnabled(true);
Line 897  public class FM2SQL extends JFrame imple Line 1084  public class FM2SQL extends JFrame imple
                   
         if (database.mode == Convert.DataBase.CONVERT_MODE)          if (database.mode == Convert.DataBase.CONVERT_MODE)
         {          {
           convertItem.setSelected(true);                      convertItem.doClick();
           convert.setText("Convert Tables");                  }
           convert.setActionCommand("Convert Tables");                  else if (database.mode == Convert.DataBase.APPEND_MODE)
           mode = Convert.DataBase.CONVERT_MODE;  
         } else if (database.mode == Convert.DataBase.APPEND_MODE)  
         {          {
           appendItem.setSelected(true);                      appendItem.doClick();
           convert.setText("Append Tables");                  }
           convert.setActionCommand("Append Tables");                  else if (database.mode == Convert.DataBase.UPDATE_MODE)
           mode = Convert.DataBase.APPEND_MODE;  
         } else if (database.mode == Convert.DataBase.UPDATE_MODE)  
         {          {
           updateItem.setSelected(true);                      updateItem.doClick();
           convert.setText("Update Tables");                  }
           convert.setActionCommand("Update Tables");                  else if (database.mode == Convert.DataBase.DELETE_MODE)
           mode = Convert.DataBase.UPDATE_MODE;                  {
                       deleteItem.doClick();
                   }
                   else if (database.mode == Convert.DataBase.SYNCHRONIZE_MODE)
                   {
                       synchronizeItem.doClick();
         }          }
   
                   delimiter = database.delimiter;
         database.bean.getConnection();          database.bean.getConnection();
                   
         bean = database.bean;          bean = database.bean;
                   if (bean.isUseNormanToUnicodeMapper())
                       useNormanToUnicodeMapper.setSelected(true);
         Object obj =bean.url;          Object obj =bean.url;
         ((DefaultComboBoxModel) sourceURLBox.getModel()).removeElement(obj);          ((DefaultComboBoxModel) sourceURLBox.getModel()).removeElement(obj);
         ((DefaultComboBoxModel) sourceURLBox.getModel()).insertElementAt(obj,0);          ((DefaultComboBoxModel) sourceURLBox.getModel()).insertElementAt(obj,0);
Line 929  public class FM2SQL extends JFrame imple Line 1121  public class FM2SQL extends JFrame imple
         {          {
           String table = (String) database.tables.get(i);            String table = (String) database.tables.get(i);
           int index=tables.indexOf(table);            int index=tables.indexOf(table);
           if(index<0) throw new RuntimeException("Error table \""+table+"\" does no longer exist\n at server "+bean.url +"\n or you mispelled the tablename.");                      if (index < 0)
                           throw new RuntimeException("Error table \"" + table + "\" does no longer exist\n at server " + bean.url + "\n or you mispelled the tablename.");
           noDBUpdate = true;            noDBUpdate = true;
           tC.tableModel.setValueAt(new TableComponent.SQLCommand(database.selects.get(i).toString()),index,SELECT_INDEX);            tC.tableModel.setValueAt(new TableComponent.SQLCommand(database.selects.get(i).toString()),index,SELECT_INDEX);
                                           
           String create =database.creates.get(i).toString();            String create =database.creates.get(i).toString();
           tC.tableModel.setValueAt(new TableComponent.SQLCommand(create.equals("") ? create:"           "+create),index,CREATE_INDEX);            tC.tableModel.setValueAt(new TableComponent.SQLCommand(create.equals("") ? create:"           "+create),index,CREATE_INDEX);
                     tC.tableModel.setValueAt(new TableComponent.SQLCommand(bean.ids.get(i).toString()),index,ID_INDEX);                      // tC.tableModel.setValueAt(new
                       // TableComponent.SQLCommand(bean.ids.get(i).toString()),index,ID_INDEX);
   
           Object comboBox=tC.tableModel.getValueAt(index,LAYOUT_INDEX);            Object comboBox=tC.tableModel.getValueAt(index,LAYOUT_INDEX);
                       Object idcomboBox = tC.tableModel.getValueAt(index, ID_INDEX);
   
           indices[i] = index;            indices[i] = index;
           if(comboBox!=null) ((JComboBox)comboBox).setSelectedItem(database.layouts.get(i));                        if (comboBox != null)
                       {
                           String layout = database.layouts.get(i).toString();
                           ((JComboBox) comboBox).setSelectedItem(layout);
                           if (layout != "")
                           {
                               bean.makeQuery("select * from" + bean.getQC() + table + bean.getQC() + " layout " + bean.getQC() + layout + bean.getQC(), 1);
   
                               Vector idVec = bean.getColumnNames();
                               if (idVec == null)
                                   idVec = new Vector();
                               idVec.add(0, "");
                               ((JComboBox) idcomboBox).setModel(new DefaultComboBoxModel(idVec));
                           }
   
                       }
                       if (idcomboBox != null)
                           ((JComboBox) idcomboBox).setSelectedItem(bean.ids.get(i));
           tC.tableModel.fireTableDataChanged();            tC.tableModel.fireTableDataChanged();
           noDBUpdate = false;            noDBUpdate = false;
           noUserUpdate = false;            noUserUpdate = false;
Line 948  public class FM2SQL extends JFrame imple Line 1161  public class FM2SQL extends JFrame imple
         // add Selections          // add Selections
         ListSelectionModel lm = tC.table.getSelectionModel();          ListSelectionModel lm = tC.table.getSelectionModel();
         for(int i=0;i<indices.length;++i)          for(int i=0;i<indices.length;++i)
                   {
         lm.addSelectionInterval(indices[i],indices[i]);          lm.addSelectionInterval(indices[i],indices[i]);
                                tC.tableModel.setValueAt(Boolean.TRUE, indices[i], STATUS_INDEX);
                   }
        destBean.getConnection();         destBean.getConnection();
               
         DefaultListModel model = new DefaultListModel();          DefaultListModel model = new DefaultListModel();
Line 963  public class FM2SQL extends JFrame imple Line 1178  public class FM2SQL extends JFrame imple
                             
       }        }
                 
     } catch (Exception e)          }
           catch (Exception e)
     {      {
       noUserUpdate = false;        noUserUpdate = false;
       noDBUpdate = false;        noDBUpdate = false;
Line 979  public class FM2SQL extends JFrame imple Line 1195  public class FM2SQL extends JFrame imple
   }    }
   public boolean showTable(int list)    public boolean showTable(int list)
   {    {
     ProgressDialog dialog = new ProgressDialog(fm);          ProgressDialog dialog = new ProgressDialog(fm, bean);
     dialog.setTitle("Preparing tables to be displayed");      dialog.setTitle("Preparing tables to be displayed");
     dialog.thread = Thread.currentThread();      dialog.thread = Thread.currentThread();
     dialog.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));      dialog.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
     fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));      fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
     String query = new String();      String query = new String();
     Object[] objs = tListDest.getSelectedValues();      Object[] objs = tListDest.getSelectedValues();
     Vector[] vectors = getListFromTable();          Vector[] vectors = (list == 0) ? getListFromTable() : null;
     Vector tables = (list == 0) ? vectors[0] : new Vector();      Vector tables = (list == 0) ? vectors[0] : new Vector();
     if (list > 0)      if (list > 0)
       for (int i = 0; i < objs.length; ++i)        for (int i = 0; i < objs.length; ++i)
Line 1020  public class FM2SQL extends JFrame imple Line 1236  public class FM2SQL extends JFrame imple
        query = "select * from " + bean.getQC() +tables.get(i).toString() + bean.getQC();         query = "select * from " + bean.getQC() +tables.get(i).toString() + bean.getQC();
     else      else
     query = "select * from " + destBean.getQC() +tables.get(i).toString() + destBean.getQC();      query = "select * from " + destBean.getQC() +tables.get(i).toString() + destBean.getQC();
  if(list==0) query = vectors[2].get(i).toString();              if (list == 0)
                   query = vectors[2].get(i).toString();
       if (list == 0 && vectors[1].get(i) != null)        if (list == 0 && vectors[1].get(i) != null)
         if (vectors[1].get(i).toString() != "")          if (vectors[1].get(i).toString() != "")
           {            {
Line 1039  public class FM2SQL extends JFrame imple Line 1256  public class FM2SQL extends JFrame imple
   
       try        try
       {        {
         if ((query.toLowerCase().indexOf("insert") >= 0)                  if ((query.toLowerCase().indexOf("insert") >= 0) || (query.toLowerCase().indexOf("delete") >= 0) || (query.toLowerCase().indexOf("alter") >= 0) || (query.toLowerCase().indexOf("update") >= 0))
           || (query.toLowerCase().indexOf("delete") >= 0)  
           || (query.toLowerCase().indexOf("alter") >= 0)  
           || (query.toLowerCase().indexOf("update") >= 0))  
         {          {
           Statement stm = (list > 0) ? destBean.getConnection().createStatement() : bean.getConnection().createStatement();            Statement stm = (list > 0) ? destBean.getConnection().createStatement() : bean.getConnection().createStatement();
           stm.executeUpdate(query);            stm.executeUpdate(query);
Line 1058  public class FM2SQL extends JFrame imple Line 1272  public class FM2SQL extends JFrame imple
           //window.pack();            //window.pack();
           //  window.setVisible(true);            //  window.setVisible(true);
   
         } else                  }
                   else
         {          {
           Vector[] vecs = (list > 0) ? destBean.getQueryData(query, dialog, 50) : bean.getQueryData(query, dialog, 50);            Vector[] vecs = (list > 0) ? destBean.getQueryData(query, dialog, 50) : bean.getQueryData(query, dialog, 50);
           if (vecs[1].isEmpty())            if (vecs[1].isEmpty())
Line 1072  public class FM2SQL extends JFrame imple Line 1287  public class FM2SQL extends JFrame imple
   
         //window.setVisible(true);          //window.setVisible(true);
   
       } catch (Exception e)              }
               catch (Exception e)
       {        {
         System.out.println("Exception occured");          System.out.println("Exception occured");
         e.printStackTrace();          e.printStackTrace();
Line 1122  public class FM2SQL extends JFrame imple Line 1338  public class FM2SQL extends JFrame imple
       {        {
         Statement stm = destBean.getConnection().createStatement();          Statement stm = destBean.getConnection().createStatement();
         stm.executeUpdate(query);          stm.executeUpdate(query);
       } catch (Exception e)              }
               catch (Exception e)
       {        {
         ByteArrayOutputStream b = new ByteArrayOutputStream();          ByteArrayOutputStream b = new ByteArrayOutputStream();
         PrintStream stream = new PrintStream(b);          PrintStream stream = new PrintStream(b);
Line 1140  public class FM2SQL extends JFrame imple Line 1357  public class FM2SQL extends JFrame imple
         model.addElement(tables.get(j));          model.addElement(tables.get(j));
       System.out.println("hallo" + tables + " ");        System.out.println("hallo" + tables + " ");
       tListDest.setModel(model);        tListDest.setModel(model);
     } catch (Exception e4)          }
           catch (Exception e4)
     {      {
     }      }
   
Line 1164  public class FM2SQL extends JFrame imple Line 1382  public class FM2SQL extends JFrame imple
       String columnName = model.getColumnName(col);        String columnName = model.getColumnName(col);
       Object test = model.getValueAt(row, col);        Object test = model.getValueAt(row, col);
       String idVal = (test == null) ? "" : test.toString();        String idVal = (test == null) ? "" : test.toString();
       String value = (test == null) ? "" : test.toString();;              String value = (test == null) ? "" : test.toString();
               ;
   
       System.out.println("Got in " + columnName +" "+idVal);        System.out.println("Got in " + columnName +" "+idVal);
       try        try
       {        {
         if(columnName.equals("select")||columnName.equals("Layouts"))          if(columnName.equals("select")||columnName.equals("Layouts"))
         {          {
           String table = model.getValueAt(row,0).toString();                      String table = model.getValueAt(row, NAME_INDEX).toString();
           String layout = (model.getValueAt(row,LAYOUT_INDEX)!=null) ?((JComboBox)model.getValueAt(row,LAYOUT_INDEX)).getSelectedItem().toString():"";            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 query =  model.getValueAt(row,SELECT_INDEX).toString();
           String create = model.getValueAt(row,CREATE_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);            System.out.println("table" +table+" layout "+layout+" query "+query);
           if(!create.equals(""))            if(!create.equals(""))
           {            {
             Object[] options = { "Yes","No"};                          Object[] options =
                           {"Yes", "No"};
             int option=showDialog("Create Statement not empty! Do you want to overwrite?","create statement",options );               int option=showDialog("Create Statement not empty! Do you want to overwrite?","create statement",options ); 
             if(option==0)               if(option==0) 
             model.setValueAt(createStatement(table,destBean,layout,query),row,CREATE_INDEX);              model.setValueAt(createStatement(table,destBean,layout,query),row,CREATE_INDEX);
           }            }
                       if (columnName.equals("Layouts"))
                       {
                 
                           bean.makeQuery("select * from" + bean.getQC() + table + bean.getQC() + " layout " + bean.getQC() + layout + 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);
   
                           tC.tableModel.fireTableCellUpdated(row, ID_INDEX);
         }          }
 /*        Statement stm = bean.getConnection().createStatement();  
         //  stm.executeUpdate("DELETE FROM \""+fm.tables.get(0)+"\" WHERE \"erstellt von\"='rogo') ");  
   
         if (idVal == "")                  }
           stm.executeUpdate("INSERT  INTO " + DBBean.quoteChar + box.getSelectedItem() + DBBean.quoteChar + " (" + DBBean.quoteChar + columnName + DBBean.quoteChar + ")  VALUES ('" + value + "') ");                  /*
         else                   * Statement stm = bean.getConnection().createStatement(); //
           stm.executeUpdate(                   * stm.executeUpdate("DELETE FROM \""+fm.tables.get(0)+"\" WHERE
             "UPDATE   " + DBBean.quoteChar + box.getSelectedItem() + DBBean.quoteChar + " SET  " + DBBean.quoteChar + columnName + DBBean.quoteChar + "='" + value + "' WHERE ID='" + idVal + "' ");                   * \"erstellt von\"='rogo') ");
                    * 
                    * if (idVal == "") stm.executeUpdate("INSERT INTO " + DBBean.quoteChar +
                    * box.getSelectedItem() + DBBean.quoteChar + " (" + DBBean.quoteChar +
                    * columnName + DBBean.quoteChar + ") VALUES ('" + value + "') "); else
                    * stm.executeUpdate( "UPDATE " + DBBean.quoteChar +
                    * box.getSelectedItem() + DBBean.quoteChar + " SET " + DBBean.quoteChar +
                    * columnName + DBBean.quoteChar + "='" + value + "' WHERE ID='" + idVal + "'
                    * ");
   */    */
           } catch (Exception e2)              }
               catch (Exception e2)
            {             {
              fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));               fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
              ByteArrayOutputStream b = new ByteArrayOutputStream();               ByteArrayOutputStream b = new ByteArrayOutputStream();
Line 1239  public class FM2SQL extends JFrame imple Line 1480  public class FM2SQL extends JFrame imple
     menu = new JMenu("Options");      menu = new JMenu("Options");
     menu.setMnemonic('O');      menu.setMnemonic('O');
         
     item = new JMenuItem("show Driver features");  
         item.setToolTipText("shows the features of the selected driver");  
     item.addActionListener(fm);  
     menu.add(item);  
     menubar.add(menu);  
   
     ButtonGroup bgrp = new ButtonGroup();      ButtonGroup bgrp = new ButtonGroup();
     convertItem = new JCheckBoxMenuItem("Convert Mode");      convertItem = new JCheckBoxMenuItem("Convert Mode");
         convertItem.setToolTipText("Normal table conversion  existing table will be deleted");          convertItem.setToolTipText("Normal table conversion  existing table will be deleted");
Line 1271  public class FM2SQL extends JFrame imple Line 1506  public class FM2SQL extends JFrame imple
         bgrp.add(updateItem);          bgrp.add(updateItem);
   
         menu.add(updateItem);          menu.add(updateItem);
         menubar.add(menu);          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);
           synchronizeItem = new JCheckBoxMenuItem("Synchronize Mode");
           synchronizeItem.setToolTipText("Synchronizes data with an existing table \n Data wich has been added or removed will be deleted or addded to the destination table. The rest will be updated");
           synchronizeItem.addActionListener(fm);
   
           bgrp.add(synchronizeItem);
   
           menu.add(synchronizeItem);
           useNormanToUnicodeMapper = new JCheckBoxMenuItem("use NormanToUnicodeMapper");
           useNormanToUnicodeMapper.setToolTipText("maps characters in norman encoding to unicode characters");
           useNormanToUnicodeMapper.addActionListener(fm);
           menu.add(useNormanToUnicodeMapper);
       
           menubar.add(menu);
           item = new JMenuItem("show Driver features");
           item.setToolTipText("shows the features of the selected driver");
     item.addActionListener(fm);      item.addActionListener(fm);
     menu.add(item);      menu.add(item);
           menubar.add(menu);
           delimiterItem = new JMenuItem("Delimiter");
           delimiterItem.setToolTipText("Delimiter for FM Arrayfields");
           delimiterItem.addActionListener(fm);
           menu.add(delimiterItem);
           menubar.add(menu);
   
           //   item.addActionListener(fm);
           //    menu.add(item);
       
     menubar.add(menu);      menubar.add(menu);
       
Line 1338  public class FM2SQL extends JFrame imple Line 1602  public class FM2SQL extends JFrame imple
     dialog.setSize(600, 300);      dialog.setSize(600, 300);
     dialog.setLocationRelativeTo(fmInstance);      dialog.setLocationRelativeTo(fmInstance);
     dialog.show();      dialog.show();
     //JOptionPane.showMessageDialog(null, message, title, JOptionPane.ERROR_MESSAGE);          //JOptionPane.showMessageDialog(null, message, title,
           // JOptionPane.ERROR_MESSAGE);
   }    }
   public static class ProgressDialog extends JDialog    public static class ProgressDialog extends JDialog
   {    {
Line 1354  public class FM2SQL extends JFrame imple Line 1619  public class FM2SQL extends JFrame imple
     JProgressBar progress = new JProgressBar();      JProgressBar progress = new JProgressBar();
     JButton cancel = new JButton("Cancel");      JButton cancel = new JButton("Cancel");
     Thread thread;      Thread thread;
     public ProgressDialog(JFrame frame)          DBBean bean;
           public ProgressDialog(JFrame frame, DBBean bean)
     {      {
       super(frame);        super(frame);
               this.bean = bean;
   
       content = new JPanel(true);        content = new JPanel(true);
       //content.setBorder(BorderFactory.createRaisedBevelBorder());        //content.setBorder(BorderFactory.createRaisedBevelBorder());
       content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS));        content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS));
Line 1391  public class FM2SQL extends JFrame imple Line 1659  public class FM2SQL extends JFrame imple
           fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));            fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                     fmInstance.setEnabled(true);                      fmInstance.setEnabled(true);
           setVisible(false);            setVisible(false);
                       try
                       {
                           ProgressDialog.this.bean.getConnection().close();
                       }
                       catch (SQLException e1)
                       {
                           // TODO Auto-generated catch block
                           e1.printStackTrace();
                       }
                       catch (Exception e1)
                       {
                           // TODO Auto-generated catch block
                           e1.printStackTrace();
                       }
           thread.stop();            thread.stop();
         }          }
       });        });
Line 1399  public class FM2SQL extends JFrame imple Line 1681  public class FM2SQL extends JFrame imple
     }      }
   
   }    }
       public static class DelimiterDialog extends JDialog
       {
           JLabel table = new JLabel("    ");
           JLabel status = new JLabel("    ");
           JLabel title = new JLabel("     ");
           JPanel content = new JPanel();
           JPanel titlePanel = new JPanel();
           JPanel delimiterPanel = new JPanel();
           JPanel buttonPanel = new JPanel();
           JTextField delimiter = new JTextField(10);
   
           JButton cancel = new JButton("Cancel");
           JButton ok = new JButton("Ok");
           Thread thread;
           public DelimiterDialog(JFrame frame)
           {
               super(frame);
               setTitle("Delimiter Editor");
               setModal(true);
               content = new JPanel(true);
               delimiter.setText(fmInstance.delimiter);
               ActionListener al = new ActionListener()
               {
                   public void actionPerformed(ActionEvent e)
                   {
                       fmInstance.delimiter = parseDelimiter(delimiter.getText());
                       setVisible(false);
                   }
   
               };
               this.addWindowListener(new WindowAdapter()
               {
                   public void windowClosing(WindowEvent e)
                   {
                       cancel.doClick();
                   }
               });
   
               //delimiter.setText(fmInstance.delimiter);
               delimiter.addActionListener(al);
               content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS));
               title = new JLabel("Enter Delimiter ");
               title.setHorizontalTextPosition(title.CENTER);
               titlePanel.add(title);
               buttonPanel.add(ok);
               buttonPanel.add(cancel);
               content.add(titlePanel);
               content.add(Box.createRigidArea(new java.awt.Dimension(0, 15)));
   
               content.add(new JLabel(""));
               content.add(delimiterPanel);
               content.add(buttonPanel);
               content.add(Box.createRigidArea(new java.awt.Dimension(0, 15)));
   
               delimiterPanel.add(new JLabel("Delimiter:  "));
               delimiterPanel.add(delimiter);
               getContentPane().add(titlePanel, "North");
               getContentPane().add(content, "Center");
               ok.addActionListener(al);
               cancel.addActionListener(new ActionListener()
               {
                   public void actionPerformed(ActionEvent e)
                   {
                       fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                       fmInstance.setEnabled(true);
                       setVisible(false);
                       //  thread.stop();
                   }
   
               });
               pack();
               setLocationRelativeTo(fmInstance);
           }
           public String parseDelimiter(Object o)
           {
               String str = o.toString();
               StringBuffer sbuff = new StringBuffer();
               int length = str.length();
               for (int i = 0; i < length; ++i)
               {
   
                   if (str.charAt(i) == '\\')
                   {
                       System.out.println(str.charAt(i));
                       if (str.charAt(i + 1) == 'r')
                       {
                           sbuff.append("\r");
                       }
                       if (str.charAt(i + 1) == 't')
                       {
                           sbuff.append("\t");
                       }
                       if (str.charAt(i + 1) == 'n')
                       {
                           sbuff.append("\n");
                       }
                       if (str.charAt(i + 1) == '\\')
                       {
                           sbuff.append("\\");
                       }
   
                       if (i < length - 1)
                           ++i;
   
                   }
                   else
                       sbuff.append(str.charAt(i));
               }
   
               return sbuff.toString();
           }
       }
   
   public static class PasswordDialog extends JDialog    public static class PasswordDialog extends JDialog
   {    {
     JLabel table = new JLabel("    ");      JLabel table = new JLabel("    ");
Line 1490  public class FM2SQL extends JFrame imple Line 1885  public class FM2SQL extends JFrame imple
   public void fillTable()    public void fillTable()
   {    {
     noDBUpdate = true;      noDBUpdate = true;
           bean.setUseNormanToUnicodeMapper(useNormanToUnicodeMapper.isSelected());
     Vector tableNames = bean.getTableNames();      Vector tableNames = bean.getTableNames();
     Collections.sort(tableNames, String.CASE_INSENSITIVE_ORDER);      Collections.sort(tableNames, String.CASE_INSENSITIVE_ORDER);
     Vector[] data = new Vector[2];      Vector[] data = new Vector[2];
     data[1] = new Vector(5);          data[1] = new Vector(6);
     data[1].setSize(5)          data[1].setSize(6);
     data[1].set(0," source Tablename  ");          data[1].set(STATUS_INDEX, " ");
           data[1].set(NAME_INDEX, " source Tablename  ");
     data[1].set(LAYOUT_INDEX,"Layouts");      data[1].set(LAYOUT_INDEX,"Layouts");
         data[1].set(SELECT_INDEX,"select");          data[1].set(SELECT_INDEX,"select");
     data[1].set(CREATE_INDEX,"create");      data[1].set(CREATE_INDEX,"create");
Line 1505  public class FM2SQL extends JFrame imple Line 1902  public class FM2SQL extends JFrame imple
     {      {
       String name = tableNames.get(i).toString();        String name = tableNames.get(i).toString();
       Vector layouts = new Vector();        Vector layouts = new Vector();
               Vector idVec = new Vector();
   
       try        try
       {        {
                   bean.makeQuery("select * from" + bean.getQC() + name + bean.getQC(), 1);
         layouts = bean.getLayoutNames(name);          layouts = bean.getLayoutNames(name);
       } catch (SQLException e)              }
               catch (SQLException e)
       {        {
         layouts = new Vector();          layouts = new Vector();
       }        }
       Vector dataRow = new Vector(5);  
               
       dataRow.setSize(5);              idVec = bean.getColumnNames();
       dataRow.set(0,name);              if (idVec == null)
                   idVec = new Vector();
               idVec.add(0, "");
               Vector dataRow = new Vector(6);
   
               dataRow.setSize(6);
               dataRow.set(STATUS_INDEX, Boolean.FALSE);
               dataRow.set(NAME_INDEX, name);
               
       dataRow.set(SELECT_INDEX,new TableComponent.SQLCommand("select * from " + bean.getQC() + name + bean.getQC()));        dataRow.set(SELECT_INDEX,new TableComponent.SQLCommand("select * from " + bean.getQC() + name + bean.getQC()));
       if (!layouts.isEmpty())        if (!layouts.isEmpty())
Line 1523  public class FM2SQL extends JFrame imple Line 1930  public class FM2SQL extends JFrame imple
            else             else
              dataRow.set(LAYOUT_INDEX,null);               dataRow.set(LAYOUT_INDEX,null);
             
   
       // create row        // create row
       dataRow.set(CREATE_INDEX,new TableComponent.SQLCommand(""));        dataRow.set(CREATE_INDEX,new TableComponent.SQLCommand(""));
       // id row        // id row
       dataRow.set(ID_INDEX,new TableComponent.SQLCommand(""));              dataRow.set(ID_INDEX, new TableComponent.IDComboBox(idVec));//new
               // TableComponent.SQLCommand(""));
       bean.ids.add("");        bean.ids.add("");
       data[0].add(dataRow);        data[0].add(dataRow);
   
       //System.out.println(dataRow);        //System.out.println(dataRow);
     }      }
         
           tC.booleanRenderer.renderFalseEmpty = true;
     tC.tableModel.setDataVector(data[0], data[1]);      tC.tableModel.setDataVector(data[0], data[1]);
    //@TODO new sizeToFit method needed     //@TODO new sizeToFit method needed
     //tC.sizeToFit(450, 250);      //tC.sizeToFit(450, 250);
Line 1552  public class FM2SQL extends JFrame imple Line 1960  public class FM2SQL extends JFrame imple
         vec[2] = new Vector();          vec[2] = new Vector();
     vec[3] = new Vector();      vec[3] = new Vector();
     vec[4] = new Vector();      vec[4] = new Vector();
           for (int i = 0; i < tC.tableModel.getRowCount(); ++i)
           {
           }
     int[] rows = tC.table.getSelectedRows();      int[] rows = tC.table.getSelectedRows();
     for (int i = 0; i < rows.length; i++)          for (int i = 0; i < tC.tableModel.getRowCount(); i++)
     {      {
               if (((Boolean) tC.tableModel.getValueAt(i, STATUS_INDEX)) == Boolean.FALSE)
               {
                   System.out.println("skipped row " + i);
                   continue;
               }
   
       //System.out.println(tC.tableModel.getValueAt(rows[i],1));        //System.out.println(tC.tableModel.getValueAt(rows[i],1));
       vec[0].add(tC.tableModel.getValueAt(rows[i], 0));              vec[0].add(tC.tableModel.getValueAt(i, NAME_INDEX));
       JComboBox box = ((JComboBox) tC.tableModel.getValueAt(rows[i], LAYOUT_INDEX));              JComboBox box = ((JComboBox) tC.tableModel.getValueAt(i, LAYOUT_INDEX));
       String layoutName = (box != null) ? box.getSelectedItem().toString() : "";        String layoutName = (box != null) ? box.getSelectedItem().toString() : "";
   
               String idName = ((JComboBox) tC.tableModel.getValueAt(i, ID_INDEX)).getSelectedItem().toString();
       vec[1].add(layoutName);        vec[1].add(layoutName);
       vec[2].add(tC.tableModel.getValueAt(rows[i],SELECT_INDEX ).toString());              vec[2].add(tC.tableModel.getValueAt(i, SELECT_INDEX).toString());
       vec[3].add(tC.tableModel.getValueAt(rows[i], CREATE_INDEX).toString());              vec[3].add(tC.tableModel.getValueAt(i, CREATE_INDEX).toString());
             vec[4].add(tC.tableModel.getValueAt(rows[i], ID_INDEX).toString());              vec[4].add(idName);
       
     }      }
     return vec;      return vec;
Line 1577  public class FM2SQL extends JFrame imple Line 1996  public class FM2SQL extends JFrame imple
     destURLBox.setEnabled(state);      destURLBox.setEnabled(state);
   
   }    }
   public TableComponent.SQLCommand createStatement(String table,DBBean beanDest,String layout,String query)  throws SQLException      public TableComponent.SQLCommand createStatement(String table, DBBean beanDest, String layout, String query) throws SQLException, ParseException
   {    {
     fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));      fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                   
     if(beanDest.url.equals("")) beanDest.url=destURLBox.getSelectedItem().toString();          if (beanDest.url.equals(""))
               beanDest.url = destURLBox.getSelectedItem().toString();
     StringBuffer command = new StringBuffer(50);      StringBuffer command = new StringBuffer(50);
     command.append("\n           CREATE TABLE ");      command.append("\n           CREATE TABLE ");
     command.append(beanDest.getQC());      command.append(beanDest.getQC());

Removed from v.1.18  
changed lines
  Added in v.1.44


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>