Diff for /FM2SQL/Attic/FM2SQL.java between versions 1.37 and 1.43

version 1.37, 2004/06/01 18:58:08 version 1.43, 2004/10/19 11:12:19
Line 71  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
  *   *
Line 87  public class FM2SQL extends JFrame imple Line 86  public class FM2SQL extends JFrame imple
   private JCheckBoxMenuItem appendItem;    private JCheckBoxMenuItem appendItem;
   private JCheckBoxMenuItem updateItem;    private JCheckBoxMenuItem updateItem;
   private JCheckBoxMenuItem deleteItem;    private JCheckBoxMenuItem deleteItem;
         private JCheckBoxMenuItem useNormanToUnicodeMapper;
   int mode = -1;    int mode = -1;
   final static int STATUS_INDEX = 0;    final static int STATUS_INDEX = 0;
   final static int NAME_INDEX = 1;    final static int NAME_INDEX = 1;
Line 96  public class FM2SQL extends JFrame imple Line 95  public class FM2SQL extends JFrame imple
   final static int CREATE_INDEX = 4;    final static int CREATE_INDEX = 4;
   final static int LAYOUT_INDEX = 5;    final static int LAYOUT_INDEX = 5;
       
     
    
   /**    /**
   * The database Bean instance.    * The database Bean instance.
   *    *
Line 113  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 159  public class FM2SQL extends JFrame imple Line 158  public class FM2SQL extends JFrame imple
   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 173  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 334  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 363  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 420  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 467  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 484  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 520  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 543  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 569  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 590  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 610  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"))      if (command.equals("Delimiter"))
     {      {
             new DelimiterDialog(fmInstance).setVisible(true);               new DelimiterDialog(fmInstance).setVisible(true); 
       //delimiter =  JOptionPane.showInputDialog(fmInstance,"Enter delimiter String",delimiter);               //delimiter = JOptionPane.showInputDialog(fmInstance,"Enter delimiter
               // String",delimiter);
               
     }      }
   
Line 654  public class FM2SQL extends JFrame imple Line 671  public class FM2SQL extends JFrame imple
       convert.setToolTipText("Deletes data that has been deleted in source");        convert.setToolTipText("Deletes data that has been deleted in source");
       mode = Convert.DataBase.DELETE_MODE;         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 725  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 771  public class FM2SQL extends JFrame imple Line 800  public class FM2SQL extends JFrame imple
        };         };
        thread.start();         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 821  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 828  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 854  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 887  public class FM2SQL extends JFrame imple Line 973  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 923  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 938  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())
     else              mode = Convert.DataBase.UPDATE_MODE;
     if(deleteItem.isSelected()) mode = Convert.DataBase.DELETE_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.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 992  public class FM2SQL extends JFrame imple Line 1085  public class FM2SQL extends JFrame imple
         if (database.mode == Convert.DataBase.CONVERT_MODE)          if (database.mode == Convert.DataBase.CONVERT_MODE)
         {          {
           convertItem.doClick();            convertItem.doClick();
         } else if (database.mode == Convert.DataBase.APPEND_MODE)                  }
                   else if (database.mode == Convert.DataBase.APPEND_MODE)
         {          {
           appendItem.doClick();            appendItem.doClick();
         } else if (database.mode == Convert.DataBase.UPDATE_MODE)                  }
                   else if (database.mode == Convert.DataBase.UPDATE_MODE)
         {          {
           updateItem.doClick();            updateItem.doClick();
         } else if (database.mode == Convert.DataBase.DELETE_MODE)                  }
                   else if (database.mode == Convert.DataBase.DELETE_MODE)
         {          {
           deleteItem.doClick();            deleteItem.doClick();
         }          }
Line 1006  public class FM2SQL extends JFrame imple Line 1102  public class FM2SQL extends JFrame imple
         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 1018  public class FM2SQL extends JFrame imple Line 1116  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);            Object idcomboBox=tC.tableModel.getValueAt(index,ID_INDEX);
Line 1046  public class FM2SQL extends JFrame imple Line 1146  public class FM2SQL extends JFrame imple
             }              }
                       
           }            }
           if(idcomboBox!=null)((JComboBox)idcomboBox).setSelectedItem(bean.ids.get(i));                      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 1072  public class FM2SQL extends JFrame imple Line 1173  public class FM2SQL extends JFrame imple
                             
       }        }
                 
     } catch (Exception e)          }
           catch (Exception e)
     {      {
       noUserUpdate = false;        noUserUpdate = false;
       noDBUpdate = false;        noDBUpdate = false;
Line 1095  public class FM2SQL extends JFrame imple Line 1197  public class FM2SQL extends JFrame imple
     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 1129  public class FM2SQL extends JFrame imple Line 1231  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 1148  public class FM2SQL extends JFrame imple Line 1251  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 1167  public class FM2SQL extends JFrame imple Line 1267  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 1181  public class FM2SQL extends JFrame imple Line 1282  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 1231  public class FM2SQL extends JFrame imple Line 1333  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 1249  public class FM2SQL extends JFrame imple Line 1352  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 1273  public class FM2SQL extends JFrame imple Line 1377  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
Line 1289  public class FM2SQL extends JFrame imple Line 1394  public class FM2SQL extends JFrame imple
           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);
Line 1311  public class FM2SQL extends JFrame imple Line 1417  public class FM2SQL extends JFrame imple
           }            }
                 
         }          }
 /*        Statement stm = bean.getConnection().createStatement();                  /*
         //  stm.executeUpdate("DELETE FROM \""+fm.tables.get(0)+"\" WHERE \"erstellt von\"='rogo') ");                   * Statement stm = bean.getConnection().createStatement(); //
                    * stm.executeUpdate("DELETE FROM \""+fm.tables.get(0)+"\" WHERE
         if (idVal == "")                   * \"erstellt von\"='rogo') ");
           stm.executeUpdate("INSERT  INTO " + DBBean.quoteChar + box.getSelectedItem() + DBBean.quoteChar + " (" + DBBean.quoteChar + columnName + DBBean.quoteChar + ")  VALUES ('" + value + "') ");                   * 
         else                   * if (idVal == "") stm.executeUpdate("INSERT INTO " + DBBean.quoteChar +
           stm.executeUpdate(                   * box.getSelectedItem() + DBBean.quoteChar + " (" + DBBean.quoteChar +
             "UPDATE   " + DBBean.quoteChar + box.getSelectedItem() + DBBean.quoteChar + " SET  " + DBBean.quoteChar + columnName + DBBean.quoteChar + "='" + value + "' WHERE ID='" + idVal + "' ");                   * 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 1397  public class FM2SQL extends JFrame imple Line 1508  public class FM2SQL extends JFrame imple
     bgrp.add(deleteItem);      bgrp.add(deleteItem);
   
     menu.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);          menubar.add(menu);
     item = new JMenuItem("show Driver features");      item = new JMenuItem("show Driver features");
Line 1475  public class FM2SQL extends JFrame imple Line 1597  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 1534  public class FM2SQL extends JFrame imple Line 1657  public class FM2SQL extends JFrame imple
           try            try
           {            {
             ProgressDialog.this.bean.getConnection().close();              ProgressDialog.this.bean.getConnection().close();
           } catch (SQLException e1)                      }
                       catch (SQLException e1)
           {            {
             // TODO Auto-generated catch block              // TODO Auto-generated catch block
             e1.printStackTrace();              e1.printStackTrace();
           } catch (Exception e1)                      }
                       catch (Exception e1)
           {            {
             // TODO Auto-generated catch block              // TODO Auto-generated catch block
             e1.printStackTrace();              e1.printStackTrace();
Line 1652  public class FM2SQL extends JFrame imple Line 1777  public class FM2SQL extends JFrame imple
                 sbuff.append("\\");                  sbuff.append("\\");
               }                }
                                           
                     if(i<length-1) ++i;                      if (i < length - 1)
                           ++i;
                   
         } else sbuff.append(str.charAt(i));                  }
                   else
                       sbuff.append(str.charAt(i));
             }              }
           
       return sbuff.toString();        return sbuff.toString();
     }      }
     }      }
   
   
   public static class PasswordDialog extends JDialog    public static class PasswordDialog extends JDialog
   {    {
     JLabel table = new JLabel("    ");      JLabel table = new JLabel("    ");
Line 1753  public class FM2SQL extends JFrame imple Line 1880  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];
Line 1775  public class FM2SQL extends JFrame imple Line 1903  public class FM2SQL extends JFrame imple
       {        {
         bean.makeQuery("select * from"+bean.getQC()+name+bean.getQC(),1);          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();
       }        }
               
       idVec = bean.getColumnNames();         idVec = bean.getColumnNames(); 
       if(idVec==null) idVec=new Vector();              if (idVec == null)
                   idVec = new Vector();
       idVec.add(0,"");        idVec.add(0,"");
       Vector dataRow = new Vector(6);        Vector dataRow = new Vector(6);
               
Line 1795  public class FM2SQL extends JFrame imple Line 1925  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.IDComboBox(idVec));//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);
   
Line 1865  public class FM2SQL extends JFrame imple Line 1995  public class FM2SQL extends JFrame imple
   {    {
     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.37  
changed lines
  Added in v.1.43


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