version 1.10, 2004/01/13 12:14:36
|
version 1.16, 2004/02/12 13:02:56
|
Line 117 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,14)); |
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,14)); |
table = new TableComponent(); |
table = new TableComponent(); |
box = new JComboBox(tables); |
box = new JComboBox(tables); |
box.addActionListener(this); |
box.addActionListener(this); |
Line 641 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 656 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 712 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 726 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],mode); |
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 757 public class FM2SQL extends JFrame imple
|
Line 811 public class FM2SQL extends JFrame imple
|
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 837 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 1400 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 1423 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 1434 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 1449 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; |