01: package net.sourceforge.squirrel_sql.plugins.hibernate.configuration;
02:
03: import net.sourceforge.squirrel_sql.fw.util.StringManager;
04: import net.sourceforge.squirrel_sql.fw.util.StringManagerFactory;
05: import net.sourceforge.squirrel_sql.fw.gui.MultipleLineLabel;
06:
07: import javax.swing.*;
08: import java.awt.*;
09: import java.awt.event.ActionEvent;
10: import java.awt.event.KeyEvent;
11:
12: public class FactoryProviderDialog extends JDialog {
13: private static final StringManager s_stringMgr = StringManagerFactory
14: .getStringManager(FactoryProviderDialog.class);
15:
16: JTextField txtClassName;
17: JButton btnWriteExampleFactorProvider;
18: JButton btnOk;
19: JButton btnCancel;
20:
21: public FactoryProviderDialog(JFrame mainFrame) {
22: // i18n[FactoryProviderDialog.title=Name of SessionFactorImpl provider]
23: super (mainFrame, s_stringMgr
24: .getString("FactoryProviderDialog.title"), true);
25:
26: getContentPane().setLayout(new GridBagLayout());
27:
28: GridBagConstraints gbc;
29:
30: // i18n[FactoryProviderDialog.desc=Please enter the fully qualified class name of a SessionFactorImpl provider class.
31: // The compiled class file must be in one of your additional classpath entries.]
32: MultipleLineLabel lbl = new MultipleLineLabel(s_stringMgr
33: .getString("FactoryProviderDialog.desc"));
34: gbc = new GridBagConstraints(0, 0, 2, 1, 0, 0,
35: GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH,
36: new Insets(5, 5, 5, 5), 0, 0);
37: getContentPane().add(lbl, gbc);
38:
39: txtClassName = new JTextField();
40: gbc = new GridBagConstraints(0, 1, 2, 1, 0, 0,
41: GridBagConstraints.NORTHWEST,
42: GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5),
43: 0, 0);
44: getContentPane().add(txtClassName, gbc);
45:
46: // i18n[FactoryProviderDialog.example=Save example code for a SessionFactorImpl provider class to ...]
47: btnWriteExampleFactorProvider = new JButton(s_stringMgr
48: .getString("FactoryProviderDialog.example"));
49: gbc = new GridBagConstraints(0, 2, 2, 1, 0, 0,
50: GridBagConstraints.NORTHWEST,
51: GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5),
52: 0, 0);
53: getContentPane().add(btnWriteExampleFactorProvider, gbc);
54:
55: // i18n[FactoryProviderDialog.ok=OK]
56: btnOk = new JButton(s_stringMgr
57: .getString("FactoryProviderDialog.ok"));
58: gbc = new GridBagConstraints(0, 3, 1, 1, 0, 0,
59: GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
60: new Insets(15, 5, 5, 5), 0, 0);
61: getContentPane().add(btnOk, gbc);
62:
63: // i18n[FactoryProviderDialog.cancel=Cancel]
64: btnCancel = new JButton(s_stringMgr
65: .getString("FactoryProviderDialog.cancel"));
66: gbc = new GridBagConstraints(1, 3, 1, 1, 0, 0,
67: GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
68: new Insets(15, 5, 5, 5), 0, 0);
69: getContentPane().add(btnCancel, gbc);
70:
71: setSize(500, 250);
72:
73: AbstractAction closeAction = new AbstractAction() {
74: public void actionPerformed(ActionEvent actionEvent) {
75: setVisible(false);
76: dispose();
77: }
78: };
79: KeyStroke escapeStroke = KeyStroke.getKeyStroke(
80: KeyEvent.VK_ESCAPE, 0);
81: getRootPane().getInputMap(
82: JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(
83: escapeStroke, "CloseAction");
84: getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
85: .put(escapeStroke, "CloseAction");
86: getRootPane().getInputMap(JComponent.WHEN_FOCUSED).put(
87: escapeStroke, "CloseAction");
88: getRootPane().getActionMap().put("CloseAction", closeAction);
89:
90: }
91: }
|