--- FM2SQL/src/FM2SQL.java 2005/01/21 11:27:03 1.1 +++ FM2SQL/src/FM2SQL.java 2005/02/07 13:01:58 1.2 @@ -34,7 +34,9 @@ import java.sql.SQLException; import java.sql.Statement; import java.text.ParseException; import java.util.Collections; +import java.util.Enumeration; import java.util.Iterator; +import java.util.Properties; import java.util.Vector; import javax.swing.Box; @@ -78,7 +80,7 @@ import javax.swing.table.TableModel; * * @version 0.3( first stable release) * @author rogo - * + * */ public class FM2SQL extends JFrame implements ActionListener, TableModelListener { @@ -98,12 +100,12 @@ public class FM2SQL extends JFrame imple /** * The database Bean instance. - * + * */ DBBean bean; /** * The database destination Bean instance. - * + * */ DBBean destBean; @@ -164,7 +166,7 @@ public class FM2SQL extends JFrame imple /** * tries to connect to database specified in url-Variable. initializes all GUI * components, then fails throws an exception - * + * */ public FM2SQL() throws Exception { @@ -189,7 +191,7 @@ public class FM2SQL extends JFrame imple destURLBox.addActionListener(this); destURLBox.setFont(new Font("Times New Roman", Font.PLAIN, 14)); table = new TableComponent(); - //box = new JComboBox(tables); + // box = new JComboBox(tables); // box.addActionListener(this); // box2.addActionListener(this); sourceURLBox.addActionListener(this); @@ -208,7 +210,7 @@ public class FM2SQL extends JFrame imple // paneDest.setPreferredSize(new Dimension(350, 365)); Dimension dim = paneDest.getPreferredSize(); paneDest.setMinimumSize(dim); - //paneDest.setMaximumSize(new Dimension(dim.width + 50, dim.height + 50)); + // paneDest.setMaximumSize(new Dimension(dim.width + 50, dim.height + 50)); tC = new TableComponent(); tC.sizeToFit(450, 250); @@ -221,7 +223,7 @@ public class FM2SQL extends JFrame imple java.awt.GridBagConstraints gbc = new java.awt.GridBagConstraints(); JScrollPane pane = new JScrollPane(tList); tC.tableScroller.setPreferredSize(new Dimension(450, 365)); - //tC.table.revalidate(); + // tC.table.revalidate(); tC.tableScroller.setMinimumSize(new Dimension(450, 250)); // tC.tableScroller.setMaximumSize(tC.tableScroller.getPreferredSize()); topPanel = new JPanel(); @@ -252,19 +254,19 @@ public class FM2SQL extends JFrame imple topPanel2.add(destURLBox, gbc); - //gbc.gridx=GridBagConstraints.RELATIVE; - //dataBasePanel.add(new JLabel(" select Tables to Convert ", JLabel.LEFT)); + // gbc.gridx=GridBagConstraints.RELATIVE; + // dataBasePanel.add(new JLabel(" select Tables to Convert ", JLabel.LEFT)); 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.anchor = GridBagConstraints.WEST; gbc.gridy = 2; gbc.gridx = 0; // gbc.weightx = 0.0; - //dataBasePanel.add(tC); + // dataBasePanel.add(tC); gbc.anchor = GridBagConstraints.NORTHWEST; gbc.gridheight = 1; gbc.fill = GridBagConstraints.BOTH; @@ -273,8 +275,8 @@ public class FM2SQL extends JFrame imple destPanel.add(paneDest, gbc); showTables1 = new JButton("show Tables"); showTables1.setActionCommand("show Tables source"); - // gbc.anchor = GridBagConstraints.NORTH; - // gbc.weightx = 0.0; + // gbc.anchor = GridBagConstraints.NORTH; + // gbc.weightx = 0.0; gbc.fill = GridBagConstraints.NONE; gbc.gridheight = 1; @@ -287,7 +289,7 @@ public class FM2SQL extends JFrame imple convert = new JButton("Convert Tables"); showTables = new JButton("show Tables"); dropTables = new JButton("drop Tables"); - // System.out.println(convert.getPreferredSize()); + // System.out.println(convert.getPreferredSize()); showTables.setMinimumSize(convert.getPreferredSize()); dropTables.setMinimumSize(convert.getPreferredSize()); showTables.setMaximumSize(convert.getPreferredSize()); @@ -313,21 +315,21 @@ public class FM2SQL extends JFrame imple topPanel2.add(buttonPanel, gbc); // gbc.anchor = GridBagConstraints.WEST; - // gbc.gridy = 1; - // gbc.gridx = 2; - // gbc.weightx = 0.2; + // gbc.gridy = 1; + // gbc.gridx = 2; + // gbc.weightx = 0.2; // gbc.gridx = 3; - // gbc.anchor = GridBagConstraints.NORTHWEST; - // gbc.gridy = 1; + // gbc.anchor = GridBagConstraints.NORTHWEST; + // gbc.gridy = 1; // gbc.weightx = 1.0; - //listPanel.add(buttonPanel, gbc); + // listPanel.add(buttonPanel, gbc); JSplitPane splitter = new JSplitPane(); splitter.setTopComponent(listPanel); splitter.setBottomComponent(destPanel); // contentPanel.add(dataBasePanel); - // contentPanel.add(listPanel); + // contentPanel.add(listPanel); listPanel.setMaximumSize(new Dimension(660, 750)); listPanel.setMinimumSize(new Dimension(660, 250)); listPanel.setPreferredSize(new Dimension(480, 500)); @@ -350,7 +352,7 @@ public class FM2SQL extends JFrame imple if (oldWidth != getWidth() || oldHeight != getHeight()) { - //table.sizeToFit(getWidth(), getHeight()); + // table.sizeToFit(getWidth(), getHeight()); Dimension dim = table.table.getPreferredSize(); int size = contentPanel.getPreferredSize().height + new JScrollBar().getPreferredSize().height + new JMenuBar().getPreferredSize().height + 10; @@ -369,11 +371,11 @@ public class FM2SQL extends JFrame imple setSize(getWidth(), table.table.getPreferredSize().height + 2 * size); // System.out.println("size" + size); } - // listPanel.setMaximumSize(new Dimension(getPreferredSize().width - 5, + // listPanel.setMaximumSize(new Dimension(getPreferredSize().width - 5, // 550)); - // listPanel.setMinimumSize(new Dimension(getPreferredSize().width - 5, + // listPanel.setMinimumSize(new Dimension(getPreferredSize().width - 5, // 200)); - // listPanel.setPreferredSize(new Dimension(getPreferredSize().width - + // listPanel.setPreferredSize(new Dimension(getPreferredSize().width - // 5, 370)); tC.tableScroller.revalidate(); Dimension dim = getSize(); @@ -397,10 +399,10 @@ public class FM2SQL extends JFrame imple }); setMenu(); - //setSize(800, 600); + // setSize(800, 600); pack(); setLocation((screenSize.width - getWidth()) / 2, (screenSize.height - getHeight()) / 2); - //setVisible(true); + // setVisible(true); validate(); // repaint(); @@ -408,31 +410,29 @@ public class FM2SQL extends JFrame imple } /** - * + * */ public static void main(String[] args) { try { System.setErr(System.out); - // Properties prop = System.getProperties(); - // Enumeration enum= prop.keys(); - // while(enum.hasMoreElements()) - //System.out.println(enum.nextElement()); - +// Properties prop = System.getProperties(); +// Enumeration enume = prop.keys(); +// Enumeration enum2 = prop.elements(); +// +// while (enume.hasMoreElements()) +// System.out.println(enume.nextElement() + " " + enum2.nextElement()); +// if (System.getProperty("os.name").startsWith("W")) - // javax.swing.UIManager.setLookAndFeel( - // new com.sun.java.swing.plaf.windows.WindowsLookAndFeel()); - javax.swing.UIManager.put("Table.focusCellHighlightBorder", new javax.swing.border.LineBorder(java.awt.Color.black)); + javax.swing.UIManager.setLookAndFeel(new com.sun.java.swing.plaf.windows.WindowsLookAndFeel()); + javax.swing.UIManager.put("Table.focusCellHighlightBorder", new javax.swing.border.LineBorder(java.awt.Color.black)); javax.swing.UIManager.put("Table.focusCellBackground", new java.awt.Color(227, 227, 227, 127)); fmInstance = new FM2SQL(); fmInstance.table.tableModel.addTableModelListener(fmInstance); fmInstance.setVisible(true); - /* - * if (!new File("./html").exists()) new File("./html").mkdirs(); logFile = - * new FileWriter("./html/index.html"); openLog(); - */ + } catch (Exception e) { @@ -456,7 +456,7 @@ public class FM2SQL extends JFrame imple System.exit(0); } }); - dialog.show(); + dialog.setVisible(true); } } public void actionPerformed(ActionEvent e) @@ -481,7 +481,7 @@ public class FM2SQL extends JFrame imple { if (debug) System.out.println("hey" + destURLBox.getSelectedItem()); - //((DefaultComboBoxModel) + // ((DefaultComboBoxModel) // box4.getModel()).insertElementAt(box4.getSelectedItem(), 0); try { @@ -505,7 +505,7 @@ public class FM2SQL extends JFrame imple { try { - //System.out.println("hallo " + (e.getSource() == box3)); + // System.out.println("hallo " + (e.getSource() == box3)); Object src = e.getSource(); if (src == sourceURLBox && !noUserUpdate) @@ -531,7 +531,7 @@ public class FM2SQL extends JFrame imple fillTable(); fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); fmInstance.setEnabled(true); - // System.out.println("hallo" + tables + " "); + // System.out.println("hallo" + tables + " "); } catch (Exception e5) { @@ -544,7 +544,7 @@ public class FM2SQL extends JFrame imple header.add("no database"); header.add("connection"); Vector rows = new Vector(); - //rows.add(header); + // rows.add(header); noDBUpdate = true; tC.tableModel.setDataVector(rows, header); tC.tableModel.setRowCount(20); @@ -578,9 +578,9 @@ public class FM2SQL extends JFrame imple Vector tables = destBean.getTableNames(); for (int j = 0; j < tables.size(); ++j) model.addElement(tables.get(j)); - // System.out.println("hallo" + tables + " "); + // System.out.println("hallo" + tables + " "); tListDest.setModel(model); - // System.out.println("hallo" + tables + " "); + // System.out.println("hallo" + tables + " "); fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); fmInstance.setEnabled(true); } @@ -634,7 +634,7 @@ public class FM2SQL extends JFrame imple if (command.equals("Delimiter")) { new DelimiterDialog(fmInstance).setVisible(true); - //delimiter = JOptionPane.showInputDialog(fmInstance,"Enter delimiter + // delimiter = JOptionPane.showInputDialog(fmInstance,"Enter delimiter // String",delimiter); } @@ -686,7 +686,7 @@ public class FM2SQL extends JFrame imple if (bean != null) bean.setUseNormanToUnicodeMapper(useNormanToUnicodeMapper.isSelected()); } - //writing config + // writing config if (command.equals("save XML Config")) { if (configExportFileChooser == null) @@ -832,7 +832,7 @@ public class FM2SQL extends JFrame imple } }; thread.start(); - // System.out.println("hello"); + // System.out.println("hello"); } if (command.equals("show Tables source")) @@ -849,7 +849,7 @@ public class FM2SQL extends JFrame imple } }; thread.start(); - // System.out.println("hello"+thread); + // System.out.println("hello"+thread); } @@ -875,7 +875,7 @@ public class FM2SQL extends JFrame imple } /** - * + * */ protected void synchronize() { @@ -1071,7 +1071,7 @@ public class FM2SQL extends JFrame imple fmInstance.setEnabled(false); Vector databases = Convert.getXMLConfig(file); Convert.DataBase destBase = (Convert.DataBase) databases.lastElement(); - //destBase.bean.getConnection(); + // destBase.bean.getConnection(); noUserUpdate = true; destBean = destBase.bean; Object destObj = destBean.url; @@ -1172,7 +1172,7 @@ public class FM2SQL extends JFrame imple tables = destBean.getTableNames(); for (int j = 0; j < tables.size(); ++j) model.addElement(tables.get(j)); - // System.out.println("hallo" + tables + " "); + // System.out.println("hallo" + tables + " "); tListDest.setModel(model); fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); fmInstance.setEnabled(true); @@ -1226,7 +1226,7 @@ public class FM2SQL extends JFrame imple dialog.setLocation(FM2SQL.fmInstance.getLocationOnScreen().x + (FM2SQL.fmInstance.getWidth() - 500) / 2, FM2SQL.fmInstance.getLocationOnScreen().y + (FM2SQL.fmInstance.getHeight() - 250) / 2); dialog.setSize(500, 250); if (!tables.isEmpty()) - dialog.show(); + dialog.setVisible(true); dialog.title.setText("Preparing tables to be diplayed"); for (int i = 0; i < tables.size(); ++i) { @@ -1251,9 +1251,9 @@ public class FM2SQL extends JFrame imple if (debug) showErrorDialog("query in show tables is " + query, "Hello"); window.title = " Table ;-) " + (String) tables.get(i); - // break; - // } else - // window.title = "Error! - No valid tablename found"; + // break; + // } else + // window.title = "Error! - No valid tablename found"; try { @@ -1270,8 +1270,8 @@ public class FM2SQL extends JFrame imple // vec.add("no Results were produced"); window.updateResult(vec3, vec); - //window.pack(); - // window.setVisible(true); + // window.pack(); + // window.setVisible(true); } else @@ -1281,12 +1281,12 @@ public class FM2SQL extends JFrame imple throw new Exception("Wrong columnname or Empty Layout"); window.updateResult(vecs[0], vecs[1]); - //window.pack(); - //String name = window.writeResult(); - //appendLog(window.title, name); + // window.pack(); + // String name = window.writeResult(); + // appendLog(window.title, name); } - //window.setVisible(true); + // window.setVisible(true); } catch (Exception e) @@ -1299,10 +1299,10 @@ public class FM2SQL extends JFrame imple vec2.add(e.getMessage()); vec3.add(vec2); vec.add("Exception occured! No results available"); - //vec.add("no Results were produced"); + // vec.add("no Results were produced"); window.updateResult(vec3, vec); - //window.pack(); + // window.pack(); // window.setVisible(true); fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); @@ -1369,11 +1369,11 @@ public class FM2SQL extends JFrame imple */ public void tableChanged(TableModelEvent e) { - // if (e.getType() == e.INSERT) - //System.out.println("Insert done"); + // if (e.getType() == e.INSERT) + // System.out.println("Insert done"); // if (e.getType() == e.UPDATE) // System.out.println("Update done"); - //if (e.getType() == e.DELETE) + // if (e.getType() == e.DELETE) // System.out.println("Delete done"); if (e.getType() == TableModelEvent.UPDATE && !noDBUpdate) { @@ -1538,8 +1538,8 @@ public class FM2SQL extends JFrame imple menu.add(delimiterItem); menubar.add(menu); - // item.addActionListener(fm); - // menu.add(item); + // item.addActionListener(fm); + // menu.add(item); menubar.add(menu); @@ -1602,8 +1602,8 @@ public class FM2SQL extends JFrame imple text.append(message); dialog.setSize(600, 300); dialog.setLocationRelativeTo(fmInstance); - dialog.show(); - //JOptionPane.showMessageDialog(null, message, title, + dialog.setVisible(true); + // JOptionPane.showMessageDialog(null, message, title, // JOptionPane.ERROR_MESSAGE); } public static class ProgressDialog extends JDialog @@ -1627,7 +1627,7 @@ public class FM2SQL extends JFrame imple this.bean = bean; content = new JPanel(true); - //content.setBorder(BorderFactory.createRaisedBevelBorder()); + // content.setBorder(BorderFactory.createRaisedBevelBorder()); content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS)); title = new JLabel("Progress of conversion"); title.setHorizontalTextPosition(SwingConstants.CENTER); @@ -1720,7 +1720,7 @@ public class FM2SQL extends JFrame imple } }); - //delimiter.setText(fmInstance.delimiter); + // delimiter.setText(fmInstance.delimiter); delimiter.addActionListener(al); content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS)); title = new JLabel("Enter Delimiter "); @@ -1748,7 +1748,7 @@ public class FM2SQL extends JFrame imple fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); fmInstance.setEnabled(true); setVisible(false); - // thread.stop(); + // thread.stop(); } }); @@ -1819,7 +1819,7 @@ public class FM2SQL extends JFrame imple setModal(true); content = new JPanel(true); this.bean = localBean; - //content.setBorder(BorderFactory.createRaisedBevelBorder()); + // content.setBorder(BorderFactory.createRaisedBevelBorder()); ActionListener al = new ActionListener() { public void actionPerformed(ActionEvent e) @@ -1855,7 +1855,7 @@ public class FM2SQL extends JFrame imple content.add(passwordPanel); content.add(buttonPanel); content.add(Box.createRigidArea(new java.awt.Dimension(0, 15))); - //labelPanel.add(table); + // labelPanel.add(table); userPanel.add(new JLabel("Username: ")); userPanel.add(user); passwordPanel.add(new JLabel("Password: ")); @@ -1939,18 +1939,18 @@ public class FM2SQL extends JFrame imple // create row dataRow.set(CREATE_INDEX, new TableComponent.SQLCommand("")); // id row - dataRow.set(ID_INDEX, new TableComponent.IDComboBox(idVec));//new + dataRow.set(ID_INDEX, new TableComponent.IDComboBox(idVec));// new // TableComponent.SQLCommand("")); bean.ids.add(""); data[0].add(dataRow); - //System.out.println(dataRow); + // System.out.println(dataRow); } tC.booleanRenderer.renderFalseEmpty = true; tC.tableModel.setDataVector(data[0], data[1]); - //@TODO new sizeToFit method needed - //tC.sizeToFit(450, 250); + // @TODO new sizeToFit method needed + // tC.sizeToFit(450, 250); Dimension dim = listPanel.getPreferredSize(); tC.sizeToFit(dim.width, dim.height); tC.revalidate(); @@ -1978,7 +1978,7 @@ public class FM2SQL extends JFrame imple 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(i, NAME_INDEX)); JComboBox box = ((JComboBox) tC.tableModel.getValueAt(i, LAYOUT_INDEX)); String layoutName = (box != null) ? box.getSelectedItem().toString() : ""; @@ -2029,7 +2029,7 @@ public class FM2SQL extends JFrame imple for (int i = 0; i < result[1].size() - 1; ++i) { type = bean.metaData.getColumnTypeName(i + 1); - // System.out.println(i+" "+result[1].get(i)+" "+type); + // System.out.println(i+" "+result[1].get(i)+" "+type); type = (type.equals("NUMBER")) ? "INT4" : type; type = (type.equals("CONTAINER")) ? "TEXT" : type; type = type.toUpperCase();