Diff for /FM2SQL/Attic/FM2SQL.java between versions 1.9 and 1.15

version 1.9, 2004/01/12 13:23:09 version 1.15, 2004/02/10 12:52:30
Line 26  public class FM2SQL extends JFrame imple Line 26  public class FM2SQL extends JFrame imple
   private JCheckBoxMenuItem convertItem;    private JCheckBoxMenuItem convertItem;
   private JCheckBoxMenuItem appendItem;    private JCheckBoxMenuItem appendItem;
   private JCheckBoxMenuItem updateItem;    private JCheckBoxMenuItem updateItem;
     int mode = -1;
   /**    /**
   * The database Bean instance.    * The database Bean instance.
   *    *
Line 116  public class FM2SQL extends JFrame imple Line 117  public class FM2SQL extends JFrame imple
     box2 = new JComboBox();      box2 = new JComboBox();
     box3 = new JComboBox(new String[] { "jdbc:fmpro:http://141.14.237.74:8050", "jdbc:fmpro:http://localhost", "jdbc:postgresql://foxridge/test" });      box3 = new JComboBox(new String[] { "jdbc:fmpro:http://141.14.237.74:8050", "jdbc:fmpro:http://localhost", "jdbc:postgresql://foxridge/test" });
     box3.setEditable(true);      box3.setEditable(true);
       box3.setFont(new Font("Times New Roman",Font.PLAIN,12));
     box4 = new JComboBox(new String[] { "jdbc:postgresql://foxridge/test", "jdbc:postgresql://erebos/test1" });      box4 = new JComboBox(new String[] { "jdbc:postgresql://foxridge/test", "jdbc:postgresql://erebos/test1" });
     box4.setEditable(true);      box4.setEditable(true);
     box4.addActionListener(this);      box4.addActionListener(this);
       box4.setFont(new Font("Times New Roman",Font.PLAIN,12));
     table = new TableComponent();      table = new TableComponent();
     box = new JComboBox(tables);      box = new JComboBox(tables);
     box.addActionListener(this);      box.addActionListener(this);
Line 553  public class FM2SQL extends JFrame imple Line 556  public class FM2SQL extends JFrame imple
       System.out.println("Convert Mode selected");        System.out.println("Convert Mode selected");
             convert.setText("Convert Tables");              convert.setText("Convert Tables");
             convert.setActionCommand("Convert Tables");              convert.setActionCommand("Convert Tables");
         mode = Convert.DataBase.CONVERT_MODE;
     }      }
     if (command == "Append Mode")      if (command == "Append Mode")
     {      {
       System.out.println("Append Mode selected");        System.out.println("Append Mode selected");
             convert.setText("Append Tables");              convert.setText("Append Tables");
             convert.setActionCommand("Append Tables");              convert.setActionCommand("Append Tables");
         mode = Convert.DataBase.APPEND_MODE; 
     }      }
     if (command == "Update Mode")      if (command == "Update Mode")
     {      {
       System.out.println("Update Mode selected");        System.out.println("Update Mode selected");
             convert.setText("Update Tables");              convert.setText("Update Tables");
             convert.setActionCommand("Update Tables");              convert.setActionCommand("Update Tables");
         mode = Convert.DataBase.UPDATE_MODE; 
     }      }
    //writing config     //writing config
     if (command.equals("save XML Config"))      if (command.equals("save XML Config"))
Line 639  public class FM2SQL extends JFrame imple Line 643  public class FM2SQL extends JFrame imple
     }      }
               
             
     if (command.equals("Convert Tables"))      if (command.equals("Convert Tables")||command.equals("Append Tables"))
     {      {
   
       Thread thread = new Thread()        Thread thread = new Thread()
Line 654  public class FM2SQL extends JFrame imple Line 658  public class FM2SQL extends JFrame imple
       };        };
       thread.start();        thread.start();
     }      }
           if (command.equals("Update Tables"))
            {
   
                Thread thread = new Thread()
                {
                    public void run()
                    {
                        setEnabled(false);
                        update();
                        setEnabled(true);
                    }
   
                };
                thread.start();
            }
   
     if (command.equals("show Tables"))      if (command.equals("show Tables"))
     {      {
       Thread thread = new Thread()        Thread thread = new Thread()
Line 710  public class FM2SQL extends JFrame imple Line 730  public class FM2SQL extends JFrame imple
         
   }    }
   /**    /**
        * Updates the content of source to destination and makes new table if necessary
        */
   
     public void update() 
     {
       Vector vectors[] = getListFromTable();
       Convert.user = bean.user;
       Convert.passwd = bean.passwd;
       Convert.userDest = destBean.user;
       Convert.passwdDest = destBean.passwd;
       try
       {
         fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
         fmInstance.setEnabled(false);
         Convert.update(bean.url, box4.getSelectedItem().toString(), vectors[0], vectors[1], vectors[2], vectors[3],vectors[4], mode);
   
         destBean.setConnection((String) box4.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(), "Conversion of table failed");
         fmInstance.setEnabled(true);
       }
   
     }
     /**
    * Copys the content of source to destination and makes new table if necessary     * Copys the content of source to destination and makes new table if necessary
    */     */
   public void convert()    public void convert()
Line 724  public class FM2SQL extends JFrame imple Line 780  public class FM2SQL extends JFrame imple
     {      {
       fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));        fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
       fmInstance.setEnabled(false);        fmInstance.setEnabled(false);
       Convert.convert(bean.url, box4.getSelectedItem().toString(), vectors[0], vectors[1],vectors[2],vectors[3]);        Convert.convert(bean.url, box4.getSelectedItem().toString(), vectors[0], vectors[1],vectors[2],vectors[3],vectors[4],mode);
   
       destBean.setConnection((String) box4.getSelectedItem());        destBean.setConnection((String) box4.getSelectedItem());
       DefaultListModel model = new DefaultListModel();        DefaultListModel model = new DefaultListModel();
Line 750  public class FM2SQL extends JFrame imple Line 806  public class FM2SQL extends JFrame imple
     fmInstance.setEnabled(false);      fmInstance.setEnabled(false);
   
     Vector vectors[] = getListFromTable();      Vector vectors[] = getListFromTable();
     int mode =-1;  
     if(convertItem.isSelected()) mode = Convert.DataBase.CONVERT_MODE;      if(convertItem.isSelected()) mode = Convert.DataBase.CONVERT_MODE;
     else      else
         if(appendItem.isSelected()) mode = Convert.DataBase.APPEND_MODE;          if(appendItem.isSelected()) mode = Convert.DataBase.APPEND_MODE;
         else          else
         if(updateItem.isSelected()) mode = Convert.DataBase.UPDATE_MODE;          if(updateItem.isSelected()) mode = Convert.DataBase.UPDATE_MODE;
           // 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],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(),-1);      Convert.DataBase destination = new Convert.DataBase(destBean,new Vector(),new Vector(),new Vector(),new Vector(),new Vector(),-1);
         
     try      try
     {      {
Line 798  public class FM2SQL extends JFrame imple Line 853  public class FM2SQL extends JFrame imple
       for (Iterator iter = databases.iterator(); iter.hasNext();)        for (Iterator iter = databases.iterator(); iter.hasNext();)
       {        {
         Convert.DataBase database = (Convert.DataBase) iter.next();          Convert.DataBase database = (Convert.DataBase) iter.next();
         int mode = -1;          
         if (database.mode == Convert.DataBase.CONVERT_MODE)          if (database.mode == Convert.DataBase.CONVERT_MODE)
         {          {
           convertItem.setSelected(true);            convertItem.setSelected(true);
           convert.setText("Convert Tables");            convert.setText("Convert Tables");
           convert.setActionCommand("Convert Tables");            convert.setActionCommand("Convert Tables");
             mode = Convert.DataBase.CONVERT_MODE;
         } else          } else if (database.mode == Convert.DataBase.APPEND_MODE)
           if (database.mode == Convert.DataBase.APPEND_MODE)  
           {            {
             appendItem.setSelected(true);              appendItem.setSelected(true);
             convert.setText("Append Tables");              convert.setText("Append Tables");
             convert.setActionCommand("Append Tables");              convert.setActionCommand("Append Tables");
             mode = Convert.DataBase.APPEND_MODE;
           } else          } else if (database.mode == Convert.DataBase.UPDATE_MODE)
             if (database.mode == Convert.DataBase.UPDATE_MODE)  
             {              {
               updateItem.setSelected(true);                updateItem.setSelected(true);
               convert.setText("Update Tables");                convert.setText("Update Tables");
               convert.setActionCommand("Update Tables");                convert.setActionCommand("Update Tables");
             mode = Convert.DataBase.UPDATE_MODE;
             }              }
   
           
         database.bean.getConnection();          database.bean.getConnection();
                   
         bean = database.bean;          bean = database.bean;
Line 840  public class FM2SQL extends JFrame imple Line 891  public class FM2SQL extends JFrame imple
           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,2);            tC.tableModel.setValueAt(new TableComponent.SQLCommand(database.selects.get(i).toString()),index,2);
                       
           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,3);            tC.tableModel.setValueAt(new TableComponent.SQLCommand(create.equals("") ? create:"           "+create),index,3);
                       tC.tableModel.setValueAt(new TableComponent.SQLCommand(bean.ids.get(i).toString()),index,4);
   
           Object comboBox=tC.tableModel.getValueAt(index,1);            Object comboBox=tC.tableModel.getValueAt(index,1);
           indices[i] = index;            indices[i] = index;
           if(comboBox!=null) ((JComboBox)comboBox).setSelectedItem(database.layouts.get(i));              if(comboBox!=null) ((JComboBox)comboBox).setSelectedItem(database.layouts.get(i));  
Line 1185  public class FM2SQL extends JFrame imple Line 1239  public class FM2SQL extends JFrame imple
       
     menu.setBackground(fm.getBackground());      menu.setBackground(fm.getBackground());
     menubar.setBackground(fm.getBackground());      menubar.setBackground(fm.getBackground());
       convertItem.doClick();
     setJMenuBar(menubar);      setJMenuBar(menubar);
   }    }
   /**    /**
Line 1402  public class FM2SQL extends JFrame imple Line 1457  public class FM2SQL extends JFrame imple
     data[1].add("Layouts");      data[1].add("Layouts");
         data[1].add("select");          data[1].add("select");
     data[1].add("create");      data[1].add("create");
          data[1].add(" id ");
      // TODO add id vector DBBean
     data[0] = new Vector();      data[0] = new Vector();
   
     for (int i = 0; i < tableNames.size(); i++)      for (int i = 0; i < tableNames.size(); i++)
     {      {
       String name = tableNames.get(i).toString();        String name = tableNames.get(i).toString();
Line 1425  public class FM2SQL extends JFrame imple Line 1480  public class FM2SQL extends JFrame imple
       dataRow.add(new TableComponent.SQLCommand("select * from "+bean.getQC()+name+bean.getQC()));        dataRow.add(new TableComponent.SQLCommand("select * from "+bean.getQC()+name+bean.getQC()));
             
         data[0].add(dataRow);          data[0].add(dataRow);
       
       // create row
       dataRow.add(new TableComponent.SQLCommand(""));
       // id row
     dataRow.add(new TableComponent.SQLCommand(""));      dataRow.add(new TableComponent.SQLCommand(""));
           bean.ids.add("");
       //System.out.println(dataRow);        //System.out.println(dataRow);
     }      }
     tC.tableModel.setDataVector(data[0], data[1]);      tC.tableModel.setDataVector(data[0], data[1]);
Line 1436  public class FM2SQL extends JFrame imple Line 1496  public class FM2SQL extends JFrame imple
   }    }
   public Vector[] getListFromTable()    public Vector[] getListFromTable()
   {    {
     Vector[] vec = new Vector[4];      Vector[] vec = new Vector[5];
     vec[0] = new Vector();      vec[0] = new Vector();
     vec[1] = new Vector();      vec[1] = new Vector();
         vec[2] = new Vector();          vec[2] = new Vector();
     vec[3] = new Vector();      vec[3] = new Vector();
       vec[4] = new Vector();
     int[] rows = tC.table.getSelectedRows();      int[] rows = tC.table.getSelectedRows();
     for (int i = 0; i < rows.length; i++)      for (int i = 0; i < rows.length; i++)
     {      {
Line 1451  public class FM2SQL extends JFrame imple Line 1512  public class FM2SQL extends JFrame imple
       vec[1].add(layoutName);        vec[1].add(layoutName);
       vec[2].add(tC.tableModel.getValueAt(rows[i], 2).toString());        vec[2].add(tC.tableModel.getValueAt(rows[i], 2).toString());
       vec[3].add(tC.tableModel.getValueAt(rows[i], 3).toString());        vec[3].add(tC.tableModel.getValueAt(rows[i], 3).toString());
               vec[4].add(tC.tableModel.getValueAt(rows[i], 4).toString());
       
     }      }
     return vec;      return vec;

Removed from v.1.9  
changed lines
  Added in v.1.15


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