Diff for /FM2SQL/Attic/FM2SQL.java between versions 1.1 and 1.7

version 1.1, 2003/12/05 11:46:39 version 1.7, 2004/01/08 10:33:33
Line 6  import Convert.DataBase; Line 6  import Convert.DataBase;
   
 import java.awt.event.*;  import java.awt.event.*;
 import java.awt.Dimension;  import java.awt.Dimension;
 import java.awt.FlowLayout;  
 import java.awt.*;  import java.awt.*;
 import java.sql.*;  import java.sql.*;
 import java.util.*;  import java.util.*;
Line 20  import java.io.*; Line 19  import java.io.*;
  * <br>   * <br>
  * The Database access is made over DBBean class   * The Database access is made over DBBean class
  * all other classes are just for the visualization of the data   * all other classes are just for the visualization of the data
  *  @version 0.2( first stable release)   *  @version 0.3( first stable release)
  *  @author rogo   *  @author rogo
  *   *
  */   */
Line 67  public class FM2SQL extends JFrame imple Line 66  public class FM2SQL extends JFrame imple
   Vector tables = new Vector();    Vector tables = new Vector();
   Vector layouts = new Vector();    Vector layouts = new Vector();
   JPanel listPanel;    JPanel listPanel;
   JPanel topPanel, contentPanel;    JPanel topPanel,topPanel2, contentPanel;
     JScrollPane paneDest;
   FM2SQL fm = this;    FM2SQL fm = this;
   boolean noDBUpdate = false;    boolean noDBUpdate = false;
   boolean noUserUpdate = false;    boolean noUserUpdate = false;
Line 102  public class FM2SQL extends JFrame imple Line 102  public class FM2SQL extends JFrame imple
    */     */
   public FM2SQL() throws Exception    public FM2SQL() throws Exception
   {    {
       
       initializeGUI();
     }
     public void initializeGUI() throws Exception
     {
     Image local = getToolkit().getImage(getClass().getResource("icons/fm.jpg"));      Image local = getToolkit().getImage(getClass().getResource("icons/fm.jpg"));
     if (local != null);      if (local != null);
     setIconImage(local);      setIconImage(local);
Line 121  public class FM2SQL extends JFrame imple Line 126  public class FM2SQL extends JFrame imple
   
     contentPanel = new JPanel();      contentPanel = new JPanel();
     contentPanel.setLayout(new BoxLayout(contentPanel, BoxLayout.Y_AXIS));      contentPanel.setLayout(new BoxLayout(contentPanel, BoxLayout.Y_AXIS));
     topPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 5));  
     topPanel.add(Box.createRigidArea(new Dimension(10, 0)));      box3.setMinimumSize(new Dimension(450, 20));
     topPanel.add(new JLabel("FileMaker DB "));      box3.setMaximumSize(new Dimension(550, 20));
     topPanel.add(new JLabel("PostgresSQL "));      box3.setPreferredSize(new Dimension(450, 20));
     //tListDest.setMinimumSize(new Dimension(120, 250));      box4.setMinimumSize(new Dimension(450, 20));
     //tListDest.setMaximumSize(new Dimension(230, 250));      box4.setMaximumSize(new Dimension(550, 20));
     //tListDest.setPreferredSize(new Dimension(230, 250));      box4.setPreferredSize(new Dimension(450, 20));
       paneDest = new JScrollPane(tListDest);
     box3.setMinimumSize(new Dimension(200, 20));     // tListDest.setPreferredSize(paneDest.getPreferredSize());
     box3.setMaximumSize(new Dimension(320, 20));     // paneDest.setPreferredSize(new Dimension(350, 365));
     box3.setPreferredSize(new Dimension(320, 20));      Dimension dim = paneDest.getPreferredSize();
     box4.setMinimumSize(new Dimension(200, 20));      paneDest.setMinimumSize(dim);
     box4.setMaximumSize(new Dimension(320, 20));      //paneDest.setMaximumSize(new Dimension(dim.width + 50, dim.height + 50));
     box4.setPreferredSize(new Dimension(330, 20));  
   
     tC = new TableComponent();      tC = new TableComponent();
     tC.sizeToFit(450, 250);      tC.sizeToFit(450, 250);
     tC.tableModel.addTableModelListener(this);      tC.tableModel.addTableModelListener(this);
     JPanel dataBasePanel = new JPanel();      JPanel destPanel = new JPanel();
     dataBasePanel.setLayout(new FlowLayout(FlowLayout.LEFT, 2, 2));      destPanel.setLayout(new java.awt.GridBagLayout());
     dataBasePanel.add(Box.createRigidArea(new Dimension(10, 0)));  
     dataBasePanel.add(new JLabel("Choose src database: "));  
     dataBasePanel.add(box3);  
     dataBasePanel.add(Box.createRigidArea(new Dimension(10, 0)));  
     dataBasePanel.add(new JLabel("Choose dest database : "));  
     dataBasePanel.add(Box.createRigidArea(new Dimension(5, 0)));  
   
     dataBasePanel.add(box4);  
     dataBasePanel.add(Box.createRigidArea(new Dimension(10, 0)));  
     listPanel = new JPanel();      listPanel = new JPanel();
     listPanel.setLayout(new java.awt.GridBagLayout());      listPanel.setLayout(new java.awt.GridBagLayout());
     java.awt.GridBagConstraints gbc = new java.awt.GridBagConstraints();      java.awt.GridBagConstraints gbc = new java.awt.GridBagConstraints();
     JScrollPane pane = new JScrollPane(tList);      JScrollPane pane = new JScrollPane(tList);
     tC.tableScroller.setPreferredSize(new Dimension(450, 265));      tC.tableScroller.setPreferredSize(new Dimension(450, 365));
     tC.table.revalidate();      //tC.table.revalidate();
     tC.setMinimumSize(tC.tableScroller.getPreferredSize());      tC.tableScroller.setMinimumSize(new Dimension(450, 250));
     tC.setMaximumSize(tC.tableScroller.getPreferredSize());      // tC.tableScroller.setMaximumSize(tC.tableScroller.getPreferredSize());
       topPanel = new JPanel();
       topPanel.setLayout(new GridBagLayout());
       topPanel2 = new JPanel();
       topPanel2.setLayout(new GridBagLayout());
   
     //gbc.gridx=GridBagConstraints.RELATIVE;     
     gbc.gridx = 0;      gbc.gridx = 0;
     gbc.weightx = 1.0;      gbc.gridy = 0;
     gbc.weighty = 0.0;      gbc.weightx = 0.1;
     gbc.gridwidth = 2;      gbc.weighty = 0.1;
       gbc.gridwidth = 1;
     gbc.gridheight = 1;      gbc.gridheight = 1;
     gbc.anchor = GridBagConstraints.NORTHWEST;      gbc.insets = new Insets(2, 2, 5, 5);
     listPanel.add(new JLabel("  select Tables to Convert  ", JLabel.LEFT), gbc);      gbc.ipadx = 1;
     gbc.gridx = 2;      gbc.ipady = 1;
     listPanel.add(new JLabel("  Tables in database  ", JLabel.CENTER), gbc);  
   
     gbc.anchor = GridBagConstraints.WEST;      gbc.anchor = GridBagConstraints.WEST;
       listPanel.add(topPanel, gbc);
       destPanel.add(topPanel2, gbc);
      
       topPanel.add(new JLabel("Choose src database: ", JLabel.CENTER), gbc);
       topPanel2.add(new JLabel("Choose dest database : ", JLabel.CENTER), gbc);
   
       gbc.anchor = GridBagConstraints.NORTHWEST;
       gbc.gridy = 1;
       topPanel.add(box3, gbc);
   
       topPanel2.add(box4, gbc);
   
       //gbc.gridx=GridBagConstraints.RELATIVE;   
       //dataBasePanel.add(new JLabel("  select Tables to Convert  ", JLabel.LEFT));
     gbc.gridy = 1;      gbc.gridy = 1;
       gbc.anchor = GridBagConstraints.SOUTHWEST;
   
       listPanel.add(new JLabel(" select Tables to Convert  ", JLabel.LEFT), gbc);
       destPanel.add(new JLabel("  Tables in database  ", JLabel.LEFT), gbc);
   
       //  gbc.anchor = GridBagConstraints.WEST;
       gbc.gridy = 2;
     gbc.gridx = 0;      gbc.gridx = 0;
     gbc.gridwidth = 1;      // gbc.weightx = 0.0;
     gbc.weightx = 0.0;      //dataBasePanel.add(tC);
     listPanel.add(tC, gbc);      gbc.anchor = GridBagConstraints.NORTHWEST;
     JScrollPane paneDest = new JScrollPane(tListDest);      gbc.gridheight = 1;
       gbc.fill = GridBagConstraints.BOTH;
       listPanel.add(tC.tableScroller, gbc);
      // gbc.fill = GridBagConstraints.VERTICAL;
       destPanel.add(paneDest, gbc);
     showTables1 = new JButton("show Tables");      showTables1 = new JButton("show Tables");
     showTables1.setActionCommand("show Tables source");      showTables1.setActionCommand("show Tables source");
     gbc.anchor = GridBagConstraints.NORTH;      //  gbc.anchor = GridBagConstraints.NORTH;
     gbc.weightx = 0.0;      //  gbc.weightx = 0.0;
     gbc.gridx = 1;      gbc.fill = GridBagConstraints.NONE;
     listPanel.add(showTables1, gbc);      gbc.gridheight = 1;
     paneDest.setPreferredSize(new Dimension(250, 265));  
     paneDest.setMinimumSize(paneDest.getPreferredSize());      gbc.gridx = 0;
     paneDest.setMaximumSize(paneDest.getPreferredSize());      gbc.gridy = 2;
     gbc.anchor = GridBagConstraints.WEST;     // topPanel.add(showTables1, gbc);
     gbc.gridy = 1;  
     gbc.gridx = 2;  
     gbc.weightx = 0.2;  
     listPanel.add(paneDest, gbc);  
     JPanel buttonPanel = new JPanel();      JPanel buttonPanel = new JPanel();
     buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.Y_AXIS));      buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS));
       buttonPanel.setMinimumSize(new Dimension(380, 30));
     convert = new JButton("Convert Tables");      convert = new JButton("Convert Tables");
     showTables = new JButton("show Tables");      showTables = new JButton("show Tables");
     dropTables = new JButton("drop Tables");      dropTables = new JButton("drop Tables");
Line 212  public class FM2SQL extends JFrame imple Line 233  public class FM2SQL extends JFrame imple
     convert.addActionListener(fm);      convert.addActionListener(fm);
     dropTables.addActionListener(fm);      dropTables.addActionListener(fm);
     buttonPanel.add(dropTables);      buttonPanel.add(dropTables);
     gbc.gridx = 3;  
     gbc.anchor = GridBagConstraints.NORTHWEST;  
     gbc.gridy = 1;  
     gbc.weightx = 1.0;  
     listPanel.add(buttonPanel, gbc);  
     contentPanel.add(dataBasePanel);  
     contentPanel.add(listPanel);  
     listPanel.setMaximumSize(new Dimension(getPreferredSize().width, 550));  
     listPanel.setMinimumSize(new Dimension(getPreferredSize().width, 150));  
     listPanel.setPreferredSize(new Dimension(getPreferredSize().width, 350));  
   
     getContentPane().add(contentPanel, "Center");      JPanel buttonPanelSrc = new JPanel();
       buttonPanelSrc.setLayout(new BoxLayout(buttonPanelSrc, BoxLayout.X_AXIS));
       buttonPanelSrc.setMinimumSize(new Dimension(200, 30));
       buttonPanelSrc.add(showTables1);
       
       topPanel.add(buttonPanelSrc, gbc);
       topPanel2.add(buttonPanel, gbc);
      
       // gbc.anchor = GridBagConstraints.WEST;
       //   gbc.gridy = 1;
       //   gbc.gridx = 2;
       //   gbc.weightx = 0.2;
   
       // gbc.gridx = 3;
       //  gbc.anchor = GridBagConstraints.NORTHWEST;
       //  gbc.gridy = 1;
       // gbc.weightx = 1.0;
       //listPanel.add(buttonPanel, gbc);
       JSplitPane splitter = new JSplitPane();
       splitter.setTopComponent(listPanel);
       splitter.setBottomComponent(destPanel);
   
       // contentPanel.add(dataBasePanel);
       //   contentPanel.add(listPanel);
       listPanel.setMaximumSize(new Dimension(660, 750));
       listPanel.setMinimumSize(new Dimension(660, 250));
       listPanel.setPreferredSize(new Dimension(480, 500));
       paneDest.setPreferredSize(new Dimension(250, 285));
   
       getContentPane().add(splitter, "Center");
     this.addWindowListener(new WindowAdapter()      this.addWindowListener(new WindowAdapter()
     {      {
       public void windowClosing(WindowEvent e)        public void windowClosing(WindowEvent e)
Line 257  public class FM2SQL extends JFrame imple Line 297  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, 550));
         listPanel.setMinimumSize(new Dimension(getPreferredSize().width - 5, 200));          //   listPanel.setMinimumSize(new Dimension(getPreferredSize().width - 5, 200));
         listPanel.setPreferredSize(new Dimension(getPreferredSize().width - 5, 370));          //    listPanel.setPreferredSize(new Dimension(getPreferredSize().width - 5, 370));
           tC.tableScroller.revalidate();
           Dimension dim = getSize();
           tC.tableScroller.setMinimumSize(new Dimension(dim.width-400, dim.height - topPanel.getPreferredSize().height - 100));
           tC.tableScroller.setMaximumSize(getSize());
           tC.tableScroller.setPreferredSize(tC.tableScroller.getMinimumSize());
        
           paneDest.setMinimumSize(new Dimension(400, dim.height - topPanel2.getPreferredSize().height - 100));
           paneDest.setMaximumSize(tC.tableScroller.getMaximumSize());
           paneDest.setPreferredSize(new Dimension(400, dim.height - topPanel2.getPreferredSize().height - 100));
       
           paneDest.validate();
           // tC.tableScroller.setPreferredSize(getSize());
           tC.sizeToFit(getWidth(), getHeight());
         ((JPanel) getContentPane()).revalidate();          ((JPanel) getContentPane()).revalidate();
         repaint();          repaint();
         setTitle("Filemaker To Postgres Conversion Tool ");          setTitle("Filemaker 2 SQL Conversion Tool ");
   
       }        }
     });      });
Line 468  public class FM2SQL extends JFrame imple Line 520  public class FM2SQL extends JFrame imple
           thread.start();            thread.start();
   
         }          }
         setTitle("Filemaker To Postgres Conversion Tool ");          setTitle("Filemaker 2 SQL Conversion Tool ");
         // pack();          // pack();
   
       } catch (Exception e4)        } catch (Exception e4)
Line 496  public class FM2SQL extends JFrame imple Line 548  public class FM2SQL extends JFrame imple
       }        }
     }      }
    //writing config     //writing config
     if (command.equals("export XML Config"))      if (command.equals("save XML Config"))
     {      {
       if (configExportFileChooser == null)        if (configExportFileChooser == null)
       {        {
Line 530  public class FM2SQL extends JFrame imple Line 582  public class FM2SQL extends JFrame imple
       configExportFileChooser.showDialog(fmInstance, " Save ");        configExportFileChooser.showDialog(fmInstance, " Save ");
         
     }      }
     if (command.equals("import XML Config"))      if (command.equals("open XML Config"))
     {      {
       if (configImportFileChooser == null)        if (configImportFileChooser == null)
       {        {
Line 628  public class FM2SQL extends JFrame imple Line 680  public class FM2SQL extends JFrame imple
       };        };
       thread.start();        thread.start();
     }      }
     if(command.equals("Quit"))
      {
        fmInstance.dispose();
        System.exit(0);
     
      }
      
   }    }
   /**    /**
    * 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
Line 707  public class FM2SQL extends JFrame imple Line 766  public class FM2SQL extends JFrame imple
       ((DefaultComboBoxModel) box4.getModel()).removeElement(destObj);        ((DefaultComboBoxModel) box4.getModel()).removeElement(destObj);
       ((DefaultComboBoxModel) box4.getModel()).insertElementAt(destObj,0);        ((DefaultComboBoxModel) box4.getModel()).insertElementAt(destObj,0);
        box4.setSelectedItem(destObj);         box4.setSelectedItem(destObj);
       //@TODO comboBox action Events should do nothing on config file read+combox in table should be updated  
       databases.remove(destBase);        databases.remove(destBase);
       for (Iterator iter = databases.iterator(); iter.hasNext();)        for (Iterator iter = databases.iterator(); iter.hasNext();)
       {        {
Line 721  public class FM2SQL extends JFrame imple Line 779  public class FM2SQL extends JFrame imple
         fillTable();          fillTable();
         Vector tables=database.bean.getTableNames();          Vector tables=database.bean.getTableNames();
         Collections.sort(tables,String.CASE_INSENSITIVE_ORDER);          Collections.sort(tables,String.CASE_INSENSITIVE_ORDER);
           int[] indices = new int[database.tables.size()];
         for (int i =0;i<database.tables.size();++i)          for (int i =0;i<database.tables.size();++i)
         {          {
           String table = (String) database.tables.get(i);            String table = (String) database.tables.get(i);
Line 731  public class FM2SQL extends JFrame imple Line 790  public class FM2SQL extends JFrame imple
           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);
           Object comboBox=tC.tableModel.getValueAt(index,1);            Object comboBox=tC.tableModel.getValueAt(index,1);
             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();
           noDBUpdate = false;            noDBUpdate = false;
           noUserUpdate = false;            noUserUpdate = false;
                   
         }          }
           // add Selections
           ListSelectionModel lm = tC.table.getSelectionModel();
           for(int i=0;i<indices.length;++i)
           lm.addSelectionInterval(indices[i],indices[i]);
            
        destBean.getConnection();         destBean.getConnection();
               
         DefaultListModel model = new DefaultListModel();          DefaultListModel model = new DefaultListModel();
Line 1000  public class FM2SQL extends JFrame imple Line 1065  public class FM2SQL extends JFrame imple
   {    {
     JMenuBar menubar = new JMenuBar();      JMenuBar menubar = new JMenuBar();
     JMenu menu = new JMenu("File");      JMenu menu = new JMenu("File");
        menu.setMnemonic('F');
       JMenuItem item = new JMenuItem("open XML Config");
       item.setMnemonic('i');
       item.setAccelerator(KeyStroke.getKeyStroke('O',InputEvent.CTRL_DOWN_MASK));
         
     JMenuItem item = new JMenuItem("import XML Config");  
     item.addActionListener(fm);      item.addActionListener(fm);
     menu.add(item);      menu.add(item);
     item = new JMenuItem("export XML Config");      item = new JMenuItem("save XML Config");
       item.setAccelerator(KeyStroke.getKeyStroke('S',InputEvent.CTRL_DOWN_MASK));
       item.setMnemonic('x');
      
     item.addActionListener(fm);      item.addActionListener(fm);
     menu.add(item);      menu.add(item);
       item = new JMenuItem("Quit");
       item.setMnemonic('Q');
       item.setAccelerator(KeyStroke.getKeyStroke('Q',InputEvent.CTRL_DOWN_MASK));
       item.addActionListener(fm);
        menu.add(item);
    
     menubar.add(menu);      menubar.add(menu);
     menu = new JMenu("Options");      menu = new JMenu("Options");
       menu.setMnemonic('O');
       
     item = new JMenuItem("show Driver features");      item = new JMenuItem("show Driver features");
     item.addActionListener(fm);      item.addActionListener(fm);

Removed from v.1.1  
changed lines
  Added in v.1.7


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