/* * MultiResultWindow.java -- Display results from several tables in one Window * FileMaker to SQL Converter * Copyright (C) 2003 Robert Gordesch (rogo@mpiwg-berlin.mpg.de) * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation; either version 2 of the License, or (at your option) * any later version. Please read license.txt for the full details. A copy of * the GPL may be found at http://www.gnu.org/copyleft/lgpl.html You should * have received a copy of the GNU General Public License along with this * program; if not, write to the Free Software Foundation, Inc., 59 Temple * Place, Suite 330, Boston, MA 02111-1307 USA Created on 15.09.2003 by * rogo */ import javax.swing.*; import java.util.*; import java.awt.event.*; import java.awt.*; import java.text.*; import java.io.*; /** * * ResultWindow - used to display the results of the query * * @author rogo */ public class MultiResultWindow extends JDialog { /** * FM reference */ JFrame fm; /** * TableComponent instance used to display the data */ TableComponent table = new TableComponent(); /** * Vector for mutltiple TableComponents */ Vector tables = new Vector(); JTabbedPane pane = new JTabbedPane(); /** * window title */ String title = ""; boolean update = true; int oldWidth = 0; int oldHeight = 0; int oldTabCount = 0; static int counter = 0; /** * Constructs the result Window with the JFrame argument as parent * @param parent frame of the JDialog */ public MultiResultWindow(JFrame frame) { super(frame); fm = (JFrame) frame; getContentPane().setLayout(new FlowLayout(FlowLayout.LEFT, 5, 5)); // pane.addTab("no Name",table); getContentPane().add(pane); // getContentPane().setBackground(Color.white); addComponentListener(new ComponentAdapter() { public void componentResized(ComponentEvent e) { // System.out.println("Window resized " + getWidth() + " " + getHeight()); setTitle("show Tables"); //if(table.tableScroller.getPreferredSize().width"); buff.append(""); buff.append(""); buff.append(query); buff.append(""); buff.append(""); buff.append(""); buff.append("
"); buff.append("

"); buff.append(query); buff.append("

"); buff.append(table.exportToHTML()); buff.append(""); buff.append(""); return TableComponent.convertUml(buff); } /** * Actual write the result to a file( in HTML) */ public String writeResult() { String name = ""; try { NumberFormat nf = new DecimalFormat("0000"); name = "./html/query" + nf.format(counter++) + ".html"; FileWriter file = new FileWriter(new File(name)); file.write(exportQueryToHTML(title).toString()); file.close(); } catch (Exception e) { System.out.println("Error while writing html\n" + e); } return name; } }