Diff for /FM2SQL/Attic/FM2SQL.java between versions 1.41 and 1.46

version 1.41, 2004/07/19 11:01:29 version 1.46, 2004/11/18 11:17:42
Line 64  import javax.swing.JTextArea; Line 64  import javax.swing.JTextArea;
 import javax.swing.JTextField;  import javax.swing.JTextField;
 import javax.swing.KeyStroke;  import javax.swing.KeyStroke;
 import javax.swing.ListSelectionModel;  import javax.swing.ListSelectionModel;
   import javax.swing.SwingConstants;
 import javax.swing.event.TableModelEvent;  import javax.swing.event.TableModelEvent;
 import javax.swing.event.TableModelListener;  import javax.swing.event.TableModelListener;
 import javax.swing.table.TableModel;  import javax.swing.table.TableModel;
Line 71  import javax.swing.table.TableModel; Line 72  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 96  public class FM2SQL extends JFrame imple Line 96  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 111  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 159  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 174  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 365  public class FM2SQL extends JFrame imple Line 369  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 422  public class FM2SQL extends JFrame imple Line 429  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 469  public class FM2SQL extends JFrame imple Line 476  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 486  public class FM2SQL extends JFrame imple Line 495  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 522  public class FM2SQL extends JFrame imple Line 532  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 545  public class FM2SQL extends JFrame imple Line 556  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 571  public class FM2SQL extends JFrame imple Line 583  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 592  public class FM2SQL extends JFrame imple Line 605  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 612  public class FM2SQL extends JFrame imple Line 626  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 656  public class FM2SQL extends JFrame imple Line 672  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(command.equals("use NormanToUnicodeMapper"))
 {  {
   if(bean!=null) bean.setUseNormanToUnicodeMapper(useNormanToUnicodeMapper.isSelected());              if (bean != null)
                   bean.setUseNormanToUnicodeMapper(useNormanToUnicodeMapper.isSelected());
 }  }
    //writing config     //writing config
     if (command.equals("save XML Config"))      if (command.equals("save XML Config"))
Line 730  if(command.equals("use NormanToUnicodeMa Line 756  if(command.equals("use NormanToUnicodeMa
         
     }      }
               
        
     if (command.equals("Convert Tables")||command.equals("Append Tables"))      if (command.equals("Convert Tables")||command.equals("Append Tables"))
     {      {
   
Line 776  if(command.equals("use NormanToUnicodeMa Line 801  if(command.equals("use NormanToUnicodeMa
        };         };
        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 835  if(command.equals("use NormanToUnicodeMa Line 875  if(command.equals("use NormanToUnicodeMa
         
   }    }
     /**      /**
      * 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 861  if(command.equals("use NormanToUnicodeMa Line 940  if(command.equals("use NormanToUnicodeMa
         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 894  if(command.equals("use NormanToUnicodeMa Line 974  if(command.equals("use NormanToUnicodeMa
          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 930  if(command.equals("use NormanToUnicodeMa Line 1011  if(command.equals("use NormanToUnicodeMa
         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 945  if(command.equals("use NormanToUnicodeMa Line 1027  if(command.equals("use NormanToUnicodeMa
     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);
Line 964  if(command.equals("use NormanToUnicodeMa Line 1049  if(command.equals("use NormanToUnicodeMa
       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 1000  if(command.equals("use NormanToUnicodeMa Line 1086  if(command.equals("use NormanToUnicodeMa
         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();
         }          }
                   else if (database.mode == Convert.DataBase.SYNCHRONIZE_MODE)
                   {
                       synchronizeItem.doClick();
                   }
   
         delimiter=database.delimiter;          delimiter=database.delimiter;
         database.bean.getConnection();          database.bean.getConnection();
                         
         bean = database.bean;          bean = database.bean;
         if(bean.isUseNormanToUnicodeMapper()) useNormanToUnicodeMapper.setSelected(true);                  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 1027  if(command.equals("use NormanToUnicodeMa Line 1122  if(command.equals("use NormanToUnicodeMa
         {          {
           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 1055  if(command.equals("use NormanToUnicodeMa Line 1152  if(command.equals("use NormanToUnicodeMa
             }              }
                       
           }            }
           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 1081  if(command.equals("use NormanToUnicodeMa Line 1179  if(command.equals("use NormanToUnicodeMa
                             
       }        }
                 
     } catch (Exception e)          }
           catch (Exception e)
     {      {
       noUserUpdate = false;        noUserUpdate = false;
       noDBUpdate = false;        noDBUpdate = false;
Line 1104  if(command.equals("use NormanToUnicodeMa Line 1203  if(command.equals("use NormanToUnicodeMa
     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 1138  if(command.equals("use NormanToUnicodeMa Line 1237  if(command.equals("use NormanToUnicodeMa
        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 1157  if(command.equals("use NormanToUnicodeMa Line 1257  if(command.equals("use NormanToUnicodeMa
   
       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 1176  if(command.equals("use NormanToUnicodeMa Line 1273  if(command.equals("use NormanToUnicodeMa
           //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 1190  if(command.equals("use NormanToUnicodeMa Line 1288  if(command.equals("use NormanToUnicodeMa
   
         //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 1240  if(command.equals("use NormanToUnicodeMa Line 1339  if(command.equals("use NormanToUnicodeMa
       {        {
         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 1258  if(command.equals("use NormanToUnicodeMa Line 1358  if(command.equals("use NormanToUnicodeMa
         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 1274  if(command.equals("use NormanToUnicodeMa Line 1375  if(command.equals("use NormanToUnicodeMa
     // System.out.println("Update done");      // System.out.println("Update done");
     //if (e.getType() == e.DELETE)      //if (e.getType() == e.DELETE)
    // System.out.println("Delete done");     // System.out.println("Delete done");
     if (e.getType() == e.UPDATE && !noDBUpdate)          if (e.getType() == TableModelEvent.UPDATE && !noDBUpdate)
     {      {
       int row = e.getFirstRow(), col = e.getColumn();        int row = e.getFirstRow(), col = e.getColumn();
       System.out.println("Got in " + row + " " + col );        System.out.println("Got in " + row + " " + col );
Line 1282  if(command.equals("use NormanToUnicodeMa Line 1383  if(command.equals("use NormanToUnicodeMa
       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 1298  if(command.equals("use NormanToUnicodeMa Line 1400  if(command.equals("use NormanToUnicodeMa
           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 1320  if(command.equals("use NormanToUnicodeMa Line 1423  if(command.equals("use NormanToUnicodeMa
           }            }
                 
         }          }
 /*        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 1406  if(command.equals("use NormanToUnicodeMa Line 1514  if(command.equals("use NormanToUnicodeMa
     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 = new JCheckBoxMenuItem("use NormanToUnicodeMapper");
     useNormanToUnicodeMapper.setToolTipText("maps characters in norman encoding to unicode characters");      useNormanToUnicodeMapper.setToolTipText("maps characters in norman encoding to unicode characters");
     useNormanToUnicodeMapper.addActionListener(fm);      useNormanToUnicodeMapper.addActionListener(fm);
Line 1488  if(command.equals("use NormanToUnicodeMa Line 1603  if(command.equals("use NormanToUnicodeMa
     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 1514  if(command.equals("use NormanToUnicodeMa Line 1630  if(command.equals("use NormanToUnicodeMa
       //content.setBorder(BorderFactory.createRaisedBevelBorder());        //content.setBorder(BorderFactory.createRaisedBevelBorder());
       content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS));        content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS));
       title = new JLabel("Progress of conversion");        title = new JLabel("Progress of conversion");
       title.setHorizontalTextPosition(title.CENTER);              title.setHorizontalTextPosition(SwingConstants.CENTER);
       titlePanel.add(title);        titlePanel.add(title);
       buttonPanel.add(cancel);        buttonPanel.add(cancel);
       // content.add(titlePanel);        // content.add(titlePanel);
Line 1547  if(command.equals("use NormanToUnicodeMa Line 1663  if(command.equals("use NormanToUnicodeMa
           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 1606  if(command.equals("use NormanToUnicodeMa Line 1724  if(command.equals("use NormanToUnicodeMa
             delimiter.addActionListener(al);              delimiter.addActionListener(al);
             content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS));              content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS));
             title = new JLabel("Enter Delimiter ");              title = new JLabel("Enter Delimiter ");
             title.setHorizontalTextPosition(title.CENTER);              title.setHorizontalTextPosition(SwingConstants.CENTER);
             titlePanel.add(title);              titlePanel.add(title);
             buttonPanel.add(ok);              buttonPanel.add(ok);
             buttonPanel.add(cancel);              buttonPanel.add(cancel);
Line 1665  if(command.equals("use NormanToUnicodeMa Line 1783  if(command.equals("use NormanToUnicodeMa
                 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 1723  if(command.equals("use NormanToUnicodeMa Line 1843  if(command.equals("use NormanToUnicodeMa
       passwd.addActionListener(al);        passwd.addActionListener(al);
       content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS));        content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS));
       title = new JLabel("Enter user and password ");        title = new JLabel("Enter user and password ");
       title.setHorizontalTextPosition(title.CENTER);              title.setHorizontalTextPosition(SwingConstants.CENTER);
       titlePanel.add(title);        titlePanel.add(title);
       buttonPanel.add(ok);        buttonPanel.add(ok);
       buttonPanel.add(cancel);        buttonPanel.add(cancel);
Line 1789  if(command.equals("use NormanToUnicodeMa Line 1909  if(command.equals("use NormanToUnicodeMa
       {        {
         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();
       }        }
               catch (Exception e)
               {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
               }
               
       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 1809  if(command.equals("use NormanToUnicodeMa Line 1936  if(command.equals("use NormanToUnicodeMa
            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 1875  if(command.equals("use NormanToUnicodeMa Line 2002  if(command.equals("use NormanToUnicodeMa
     destURLBox.setEnabled(state);      destURLBox.setEnabled(state);
   
   }    }
   public TableComponent.SQLCommand createStatement(String table,DBBean beanDest,String layout,String query)  throws SQLException, ParseException      public TableComponent.SQLCommand createStatement(String table, DBBean beanDest, String layout, String query) throws SQLException, ParseException, Exception
   {    {
     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.41  
changed lines
  Added in v.1.46


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