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

version 1.42, 2004/09/22 11:14:10 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 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","jdbc:sequelink://r583-3:2399" });          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 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 422  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 469  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 486  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 522  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 545  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 571  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 592  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 612  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 656  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(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 755  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 800  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 874  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 939  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 973  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 1010  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 1026  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 1048  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 1085  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();
         }          }
Line 1014  if(command.equals("use NormanToUnicodeMa Line 1102  if(command.equals("use NormanToUnicodeMa
         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 1116  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 1146  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 1173  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 1197  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 1231  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 1251  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 1267  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 1282  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 1333  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 1352  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 1282  if(command.equals("use NormanToUnicodeMa Line 1377  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 1394  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 1417  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 1508  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 1597  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 1547  if(command.equals("use NormanToUnicodeMa Line 1657  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 1665  if(command.equals("use NormanToUnicodeMa Line 1777  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 1789  if(command.equals("use NormanToUnicodeMa Line 1903  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();
       }        }
               
       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 1925  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 1879  if(command.equals("use NormanToUnicodeMa Line 1995  if(command.equals("use NormanToUnicodeMa
   {    {
     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.42  
changed lines
  Added in v.1.43


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