Diff for /FM2SQL/Attic/FM2SQL.java between versions 1.17 and 1.18

version 1.17, 2004/02/17 13:16:00 version 1.18, 2004/02/18 13:25:24
Line 71  public class FM2SQL extends JFrame imple Line 71  public class FM2SQL extends JFrame imple
   private JCheckBoxMenuItem appendItem;    private JCheckBoxMenuItem appendItem;
   private JCheckBoxMenuItem updateItem;    private JCheckBoxMenuItem updateItem;
   int mode = -1;    int mode = -1;
     final static int ID_INDEX = 1;
     final static int SELECT_INDEX = 2;
     final static int CREATE_INDEX = 3;
     final static int LAYOUT_INDEX = 4;
     
     
    
   /**    /**
   * The database Bean instance.    * The database Bean instance.
   *    *
Line 794  public class FM2SQL extends JFrame imple Line 801  public class FM2SQL extends JFrame imple
       ByteArrayOutputStream b = new ByteArrayOutputStream();        ByteArrayOutputStream b = new ByteArrayOutputStream();
       PrintStream stream = new PrintStream(b);        PrintStream stream = new PrintStream(b);
       e4.printStackTrace(stream);        e4.printStackTrace(stream);
       showErrorDialog(b.toString(), "Conversion of table failed");        showErrorDialog(b.toString(), "Update of table failed");
       fmInstance.setEnabled(true);        fmInstance.setEnabled(true);
     }      }
   
Line 924  public class FM2SQL extends JFrame imple Line 931  public class FM2SQL extends JFrame imple
           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,2);            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,3);            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,4);                      tC.tableModel.setValueAt(new TableComponent.SQLCommand(bean.ids.get(i).toString()),index,ID_INDEX);
   
           Object comboBox=tC.tableModel.getValueAt(index,1);            Object comboBox=tC.tableModel.getValueAt(index,LAYOUT_INDEX);
           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));  
           tC.tableModel.fireTableDataChanged();            tC.tableModel.fireTableDataChanged();
Line 1165  public class FM2SQL extends JFrame imple Line 1172  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,0).toString();
           String layout = (model.getValueAt(row,1)!=null) ?((JComboBox)model.getValueAt(row,1)).getSelectedItem().toString():"";            String layout = (model.getValueAt(row,LAYOUT_INDEX)!=null) ?((JComboBox)model.getValueAt(row,LAYOUT_INDEX)).getSelectedItem().toString():"";
           String query =  model.getValueAt(row,2).toString();            String query =  model.getValueAt(row,SELECT_INDEX).toString();
           String create = model.getValueAt(row,3).toString();            String create = model.getValueAt(row,CREATE_INDEX).toString();
           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,3);              model.setValueAt(createStatement(table,destBean,layout,query),row,CREATE_INDEX);
           }            }
                 
                 
Line 1486  public class FM2SQL extends JFrame imple Line 1493  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();      data[1] = new Vector(5);
     data[1].add(" source Tablename  ");      data[1].setSize(5)
     data[1].add("Layouts");      data[1].set(0," source Tablename  ");
         data[1].add("select");      data[1].set(LAYOUT_INDEX,"Layouts");
     data[1].add("create");          data[1].set(SELECT_INDEX,"select");
     data[1].add(" id ");      data[1].set(CREATE_INDEX,"create");
       data[1].set(ID_INDEX," id ");
     data[0] = new Vector();      data[0] = new Vector();
     for (int i = 0; i < tableNames.size(); i++)      for (int i = 0; i < tableNames.size(); i++)
     {      {
Line 1504  public class FM2SQL extends JFrame imple Line 1512  public class FM2SQL extends JFrame imple
       {        {
         layouts = new Vector();          layouts = new Vector();
       }        }
       Vector dataRow = new Vector();        Vector dataRow = new Vector(5);
       dataRow.add(name);        
         dataRow.setSize(5);
         dataRow.set(0,name);
         
         dataRow.set(SELECT_INDEX,new TableComponent.SQLCommand("select * from " + bean.getQC() + name + bean.getQC()));
       if (!layouts.isEmpty())        if (!layouts.isEmpty())
         dataRow.add(new JComboBox(layouts));               dataRow.set(LAYOUT_INDEX,new JComboBox(layouts));
       else        else
         dataRow.add(null);               dataRow.set(LAYOUT_INDEX,null);
       dataRow.add(new TableComponent.SQLCommand("select * from " + bean.getQC() + name + bean.getQC()));  
   
       data[0].add(dataRow);  
   
       // create row        // create row
       dataRow.add(new TableComponent.SQLCommand(""));        dataRow.set(CREATE_INDEX,new TableComponent.SQLCommand(""));
       // id row        // id row
       dataRow.add(new TableComponent.SQLCommand(""));        dataRow.set(ID_INDEX,new TableComponent.SQLCommand(""));
       bean.ids.add("");        bean.ids.add("");
         data[0].add(dataRow);
   
       //System.out.println(dataRow);        //System.out.println(dataRow);
     }      }
         
     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);
       Dimension dim=listPanel.getPreferredSize();
       tC.sizeToFit(dim.width,dim.height);
     tC.revalidate();      tC.revalidate();
     tC.tableModel.fireTableDataChanged();      tC.tableModel.fireTableDataChanged();
     noDBUpdate = false;      noDBUpdate = false;
Line 1543  public class FM2SQL extends JFrame imple Line 1557  public class FM2SQL extends JFrame imple
     {      {
       //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(rows[i], 0));
       JComboBox box = ((JComboBox) tC.tableModel.getValueAt(rows[i], 1));        JComboBox box = ((JComboBox) tC.tableModel.getValueAt(rows[i], LAYOUT_INDEX));
       String layoutName = (box != null) ? box.getSelectedItem().toString() : "";        String layoutName = (box != null) ? box.getSelectedItem().toString() : "";
       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],SELECT_INDEX ).toString());
       vec[3].add(tC.tableModel.getValueAt(rows[i], 3).toString());        vec[3].add(tC.tableModel.getValueAt(rows[i], CREATE_INDEX).toString());
             vec[4].add(tC.tableModel.getValueAt(rows[i], 4).toString());              vec[4].add(tC.tableModel.getValueAt(rows[i], ID_INDEX).toString());
       
     }      }
     return vec;      return vec;

Removed from v.1.17  
changed lines
  Added in v.1.18


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