01: package net.sourceforge.squirrel_sql.plugins.sqlscript.table_script;
02:
03: import net.sourceforge.squirrel_sql.fw.util.StringManager;
04: import net.sourceforge.squirrel_sql.fw.util.StringManagerFactory;
05:
06: import javax.swing.*;
07: import java.awt.*;
08: import java.awt.event.ActionEvent;
09: import java.awt.event.KeyEvent;
10:
11: public class CreateTableOfCurrentSQLDialog extends JDialog {
12: private static final StringManager s_stringMgr = StringManagerFactory
13: .getStringManager(CreateTableOfCurrentSQLDialog.class);
14:
15: JButton btnOK;
16: JButton btnCancel;
17: JTextField txtTableName;
18: JCheckBox chkScriptOnly;
19: JCheckBox chkDropTable;
20:
21: public CreateTableOfCurrentSQLDialog(JFrame parentFrame) {
22: // i18n[sqlscript.dlgCreatTableOfSql=Create table of SQL]
23: super (parentFrame, s_stringMgr
24: .getString("sqlscript.dlgCreatTableOfSql"), true);
25:
26: getContentPane().setLayout(new GridLayout(5, 1, 5, 0));
27:
28: // i18n[sqlscript.enterNameOfTable=Enter name of table:]
29: getContentPane().add(
30: new JLabel(s_stringMgr
31: .getString("sqlscript.enterNameOfTable")));
32:
33: txtTableName = new JTextField();
34: getContentPane().add(txtTableName);
35:
36: // i18n[sqlscript.dropIfExists=Drop table if exists]
37: chkDropTable = new JCheckBox(s_stringMgr
38: .getString("sqlscript.dropIfExists"));
39: getContentPane().add(chkDropTable);
40:
41: // i18n[sqlscript.scriptOnly=Generate script only]
42: chkScriptOnly = new JCheckBox(s_stringMgr
43: .getString("sqlscript.scriptOnly"));
44: getContentPane().add(chkScriptOnly);
45:
46: JPanel pnlButtons = new JPanel();
47: pnlButtons.setLayout(new GridLayout(1, 2, 0, 5));
48:
49: // i18n[sqlscript.tableScriptOk=OK]
50: btnOK = new JButton(s_stringMgr
51: .getString("sqlscript.tableScriptOk"));
52: pnlButtons.add(btnOK);
53: // i18n[sqlscript.tableScriptCancel=Cancel]
54: btnCancel = new JButton(s_stringMgr
55: .getString("sqlscript.tableScriptCancel"));
56: pnlButtons.add(btnCancel);
57:
58: getContentPane().add(pnlButtons);
59:
60: getRootPane().setDefaultButton(btnOK);
61:
62: AbstractAction closeAction = new AbstractAction() {
63: public void actionPerformed(ActionEvent actionEvent) {
64: setVisible(false);
65: dispose();
66: }
67: };
68: KeyStroke escapeStroke = KeyStroke.getKeyStroke(
69: KeyEvent.VK_ESCAPE, 0);
70: getRootPane().getInputMap(
71: JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(
72: escapeStroke, "CloseAction");
73: getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
74: .put(escapeStroke, "CloseAction");
75: getRootPane().getInputMap(JComponent.WHEN_FOCUSED).put(
76: escapeStroke, "CloseAction");
77: getRootPane().getActionMap().put("CloseAction", closeAction);
78:
79: }
80: }
|