01: package jimm.datavision.gui.sql;
02:
03: import java.awt.Frame;
04: import java.awt.Dimension;
05: import java.awt.BorderLayout;
06: import java.awt.event.ActionListener;
07: import java.awt.event.ActionEvent;
08: import jimm.util.I18N;
09: import javax.swing.*;
10:
11: public class SQLQueryWin extends JDialog {
12:
13: protected static final int PREFERRED_COLUMNS = 40;
14: protected static final Dimension PREFERRED_SIZE = new Dimension(
15: 340, 275);
16:
17: public SQLQueryWin(Frame owner, String queryString) {
18: super (owner, I18N.get("SQLQueryWin.title"));
19: buildWindow(queryString);
20: pack();
21: show();
22: }
23:
24: protected void buildWindow(String queryString) {
25: getContentPane().setLayout(new BorderLayout());
26:
27: // Copy the string and add some newlines
28: char[] queryChars = queryString.toCharArray();
29:
30: int pos = queryString.indexOf(" from ");
31: if (pos >= 0)
32: queryChars[pos] = '\n';
33: else
34: pos = 0;
35:
36: pos = queryString.indexOf(" where ", pos);
37: if (pos >= 0)
38: queryChars[pos] = '\n';
39: else
40: pos = 0;
41:
42: pos = queryString.indexOf(" order by ", pos);
43: if (pos >= 0)
44: queryChars[pos] = '\n';
45:
46: JTextArea text = new JTextArea(new String(queryChars), 0,
47: PREFERRED_COLUMNS);
48: text.setEditable(false);
49: text.setLineWrap(true);
50: text.setWrapStyleWord(true);
51:
52: JScrollPane scroller = new JScrollPane(text);
53: scroller.setPreferredSize(PREFERRED_SIZE);
54: getContentPane().add(scroller, BorderLayout.CENTER);
55:
56: JPanel buttonPanel = new JPanel();
57: JButton button = new JButton(I18N.get("GUI.ok"));
58: button.addActionListener(new ActionListener() {
59: public void actionPerformed(ActionEvent e) {
60: dispose();
61: }
62: });
63: buttonPanel.add(button);
64: getContentPane().add(buttonPanel, BorderLayout.SOUTH);
65: }
66:
67: }
|