Diff for /FM2SQL/Attic/FM2SQL.java between versions 1.33 and 1.38

version 1.33, 2004/03/23 11:57:06 version 1.38, 2004/06/21 11:31:34
Line 32  import java.io.FileWriter; Line 32  import java.io.FileWriter;
 import java.io.PrintStream;  import java.io.PrintStream;
 import java.sql.SQLException;  import java.sql.SQLException;
 import java.sql.Statement;  import java.sql.Statement;
   import java.text.ParseException;
 import java.util.Collections;  import java.util.Collections;
 import java.util.Iterator;  import java.util.Iterator;
 import java.util.Vector;  import java.util.Vector;
Line 88  public class FM2SQL extends JFrame imple Line 89  public class FM2SQL extends JFrame imple
   private JCheckBoxMenuItem deleteItem;    private JCheckBoxMenuItem deleteItem;
       
   int mode = -1;    int mode = -1;
   final static int ID_INDEX = 1;    final static int STATUS_INDEX = 0;
   final static int SELECT_INDEX = 2;    final static int NAME_INDEX = 1;
   final static int CREATE_INDEX = 3;    final static int ID_INDEX = 2;
   final static int LAYOUT_INDEX = 4;    final static int SELECT_INDEX = 3;
     final static int CREATE_INDEX = 4;
     final static int LAYOUT_INDEX = 5;
       
       
     
Line 1052  public class FM2SQL extends JFrame imple Line 1055  public class FM2SQL extends JFrame imple
         // add Selections          // add Selections
         ListSelectionModel lm = tC.table.getSelectionModel();          ListSelectionModel lm = tC.table.getSelectionModel();
         for(int i=0;i<indices.length;++i)          for(int i=0;i<indices.length;++i)
           {
         lm.addSelectionInterval(indices[i],indices[i]);          lm.addSelectionInterval(indices[i],indices[i]);
                      tC.tableModel.setValueAt(Boolean.TRUE,indices[i],STATUS_INDEX);
           }    
        destBean.getConnection();         destBean.getConnection();
               
         DefaultListModel model = new DefaultListModel();          DefaultListModel model = new DefaultListModel();
Line 1083  public class FM2SQL extends JFrame imple Line 1088  public class FM2SQL extends JFrame imple
   }    }
   public boolean showTable(int list)    public boolean showTable(int list)
   {    {
     ProgressDialog dialog = new ProgressDialog(fm);      ProgressDialog dialog = new ProgressDialog(fm,bean);
     dialog.setTitle("Preparing tables to be displayed");      dialog.setTitle("Preparing tables to be displayed");
     dialog.thread = Thread.currentThread();      dialog.thread = Thread.currentThread();
     dialog.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));      dialog.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
Line 1164  public class FM2SQL extends JFrame imple Line 1169  public class FM2SQL extends JFrame imple
   
         } else          } else
         {          {
           Vector[] vecs = (list > 0) ? destBean.getQueryData(query, dialog, 50) : bean.getQueryData(query, dialog, 50);            Vector[] vecs = (list > 0) ? destBean.getQueryData(query, dialog, 0) : bean.getQueryData(query, dialog, 0);
           if (vecs[1].isEmpty())            if (vecs[1].isEmpty())
             throw new Exception("Wrong columnname or Empty Layout");              throw new Exception("Wrong columnname or Empty Layout");
           window.updateResult(vecs[0], vecs[1]);            window.updateResult(vecs[0], vecs[1]);
Line 1275  public class FM2SQL extends JFrame imple Line 1280  public class FM2SQL extends JFrame imple
       {        {
         if(columnName.equals("select")||columnName.equals("Layouts"))          if(columnName.equals("select")||columnName.equals("Layouts"))
         {          {
           String table = model.getValueAt(row,0).toString();            String table = model.getValueAt(row,NAME_INDEX).toString();
           String layout = (model.getValueAt(row,LAYOUT_INDEX)!=null) ?((JComboBox)model.getValueAt(row,LAYOUT_INDEX)).getSelectedItem().toString():"";            String layout = (model.getValueAt(row,LAYOUT_INDEX)!=null) ?((JComboBox)model.getValueAt(row,LAYOUT_INDEX)).getSelectedItem().toString():"";
           String query =  model.getValueAt(row,SELECT_INDEX).toString();            String query =  model.getValueAt(row,SELECT_INDEX).toString();
           String create = model.getValueAt(row,CREATE_INDEX).toString();            String create = model.getValueAt(row,CREATE_INDEX).toString();
Line 1486  public class FM2SQL extends JFrame imple Line 1491  public class FM2SQL extends JFrame imple
     JProgressBar progress = new JProgressBar();      JProgressBar progress = new JProgressBar();
     JButton cancel = new JButton("Cancel");      JButton cancel = new JButton("Cancel");
     Thread thread;      Thread thread;
     public ProgressDialog(JFrame frame)      DBBean bean;
       public ProgressDialog(JFrame frame,DBBean bean)
     {      {
       super(frame);        super(frame);
         this.bean = bean; 
         
       content = new JPanel(true);        content = new JPanel(true);
       //content.setBorder(BorderFactory.createRaisedBevelBorder());        //content.setBorder(BorderFactory.createRaisedBevelBorder());
       content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS));        content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS));
Line 1523  public class FM2SQL extends JFrame imple Line 1531  public class FM2SQL extends JFrame imple
           fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));            fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                     fmInstance.setEnabled(true);                      fmInstance.setEnabled(true);
           setVisible(false);            setVisible(false);
             try
             {
               ProgressDialog.this.bean.getConnection().close();
             } catch (SQLException e1)
             {
               // TODO Auto-generated catch block
               e1.printStackTrace();
             } catch (Exception e1)
             {
               // TODO Auto-generated catch block
               e1.printStackTrace();
             }
           thread.stop();            thread.stop();
         }          }
       });        });
Line 1736  public class FM2SQL extends JFrame imple Line 1756  public class FM2SQL extends JFrame imple
     Vector tableNames = bean.getTableNames();      Vector tableNames = bean.getTableNames();
     Collections.sort(tableNames, String.CASE_INSENSITIVE_ORDER);      Collections.sort(tableNames, String.CASE_INSENSITIVE_ORDER);
     Vector[] data = new Vector[2];      Vector[] data = new Vector[2];
     data[1] = new Vector(5);      data[1] = new Vector(6);
     data[1].setSize(5)      data[1].setSize(6)
     data[1].set(0," source Tablename  ");      data[1].set(STATUS_INDEX," ");
       data[1].set(NAME_INDEX," source Tablename  ");
     data[1].set(LAYOUT_INDEX,"Layouts");      data[1].set(LAYOUT_INDEX,"Layouts");
         data[1].set(SELECT_INDEX,"select");          data[1].set(SELECT_INDEX,"select");
     data[1].set(CREATE_INDEX,"create");      data[1].set(CREATE_INDEX,"create");
Line 1762  public class FM2SQL extends JFrame imple Line 1783  public class FM2SQL extends JFrame imple
       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(5);        Vector dataRow = new Vector(6);
               
       dataRow.setSize(5);        dataRow.setSize(6);
       dataRow.set(0,name);        dataRow.set(STATUS_INDEX,Boolean.FALSE);
         dataRow.set(NAME_INDEX,name);
               
       dataRow.set(SELECT_INDEX,new TableComponent.SQLCommand("select * from " + bean.getQC() + name + bean.getQC()));        dataRow.set(SELECT_INDEX,new TableComponent.SQLCommand("select * from " + bean.getQC() + name + bean.getQC()));
       if (!layouts.isEmpty())        if (!layouts.isEmpty())
Line 1784  public class FM2SQL extends JFrame imple Line 1806  public class FM2SQL extends JFrame imple
       //System.out.println(dataRow);        //System.out.println(dataRow);
     }      }
         
       tC.booleanRenderer.renderFalseEmpty=true;
     tC.tableModel.setDataVector(data[0], data[1]);      tC.tableModel.setDataVector(data[0], data[1]);
    //@TODO new sizeToFit method needed     //@TODO new sizeToFit method needed
     //tC.sizeToFit(450, 250);      //tC.sizeToFit(450, 250);
Line 1802  public class FM2SQL extends JFrame imple Line 1825  public class FM2SQL extends JFrame imple
         vec[2] = new Vector();          vec[2] = new Vector();
     vec[3] = new Vector();      vec[3] = new Vector();
     vec[4] = new Vector();      vec[4] = new Vector();
       for(int i=0;i<tC.tableModel.getRowCount();++i)
       {
       }
     int[] rows = tC.table.getSelectedRows();      int[] rows = tC.table.getSelectedRows();
     for (int i = 0; i < rows.length; i++)      for (int i = 0; i < tC.tableModel.getRowCount(); i++)
     {      {
         if(((Boolean)tC.tableModel.getValueAt(i,STATUS_INDEX))==Boolean.FALSE)
         { 
           System.out.println("skipped row "+i);
           continue; 
           }
     
       //System.out.println(tC.tableModel.getValueAt(rows[i],1));        //System.out.println(tC.tableModel.getValueAt(rows[i],1));
       vec[0].add(tC.tableModel.getValueAt(rows[i], 0));        vec[0].add(tC.tableModel.getValueAt(i, NAME_INDEX));
       JComboBox box = ((JComboBox) tC.tableModel.getValueAt(rows[i], LAYOUT_INDEX));        JComboBox box = ((JComboBox) tC.tableModel.getValueAt(i, LAYOUT_INDEX));
       String layoutName = (box != null) ? box.getSelectedItem().toString() : "";        String layoutName = (box != null) ? box.getSelectedItem().toString() : "";
               
       String idName = ((JComboBox)tC.tableModel.getValueAt(rows[i], ID_INDEX)).getSelectedItem().toString();        String idName = ((JComboBox)tC.tableModel.getValueAt(i, ID_INDEX)).getSelectedItem().toString();
       vec[1].add(layoutName);        vec[1].add(layoutName);
       vec[2].add(tC.tableModel.getValueAt(rows[i],SELECT_INDEX ).toString());        vec[2].add(tC.tableModel.getValueAt(i,SELECT_INDEX ).toString());
       vec[3].add(tC.tableModel.getValueAt(rows[i], CREATE_INDEX).toString());        vec[3].add(tC.tableModel.getValueAt(i, CREATE_INDEX).toString());
             vec[4].add(idName);              vec[4].add(idName);
       
     }      }
Line 1829  public class FM2SQL extends JFrame imple Line 1861  public class FM2SQL extends JFrame imple
     destURLBox.setEnabled(state);      destURLBox.setEnabled(state);
   
   }    }
   public TableComponent.SQLCommand createStatement(String table,DBBean beanDest,String layout,String query)  throws SQLException    public TableComponent.SQLCommand createStatement(String table,DBBean beanDest,String layout,String query)  throws SQLException, ParseException
   {    {
     fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));      fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                   

Removed from v.1.33  
changed lines
  Added in v.1.38


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