01: package net.sourceforge.squirrel_sql.plugins.sqlscript.table_script;
02:
03: import net.sourceforge.squirrel_sql.fw.gui.GUIUtils;
04:
05: import javax.swing.*;
06: import java.awt.event.ActionEvent;
07: import java.awt.event.ActionListener;
08: import java.util.prefs.Preferences;
09:
10: public class TableScriptConfigCtrl {
11: private JFrame _mainFrame;
12: private TableScriptConfigFrame _dlg;
13:
14: private static final String PREFS_KEY_CONSTRAINTS_AND_INDEXES_AT_END = "Squirrel.sqlscript.constAndIndAtEnd";
15: private static final String PREFS_KEY_CONSTRAINTS_TO_TABLES_NOT_IN_SCRIPT = "Squirrel.sqlscript.constToTablesNotInScript";
16:
17: private boolean _constAndIndAtEnd = true;
18: private boolean _constToTablesNotInScript = true;
19: private boolean _isOk = false;
20:
21: public TableScriptConfigCtrl(JFrame mainFrame) {
22: this ._mainFrame = mainFrame;
23: }
24:
25: public void doModal() {
26: _dlg = new TableScriptConfigFrame(_mainFrame);
27:
28: String buf;
29: buf = Preferences.userRoot().get(
30: PREFS_KEY_CONSTRAINTS_AND_INDEXES_AT_END,
31: "" + _constAndIndAtEnd);
32: _dlg.optConstAndIndAtEnd.setSelected(Boolean.valueOf(buf)
33: .booleanValue());
34: _dlg.optConstAndIndAfterTable.setSelected(!Boolean.valueOf(buf)
35: .booleanValue());
36:
37: buf = Preferences.userRoot().get(
38: PREFS_KEY_CONSTRAINTS_TO_TABLES_NOT_IN_SCRIPT,
39: "" + _constToTablesNotInScript);
40: _dlg.constToTablesNotInScript.setSelected(Boolean.valueOf(buf)
41: .booleanValue());
42:
43: _dlg.btnOk.addActionListener(new ActionListener() {
44: public void actionPerformed(ActionEvent e) {
45: onOk();
46: }
47: });
48:
49: _dlg.btnCancel.addActionListener(new ActionListener() {
50: public void actionPerformed(ActionEvent e) {
51: _dlg.setVisible(false);
52: _dlg.dispose();
53: }
54: });
55:
56: GUIUtils.centerWithinParent(_dlg);
57:
58: _dlg.setVisible(true);
59: }
60:
61: private void onOk() {
62: _constAndIndAtEnd = _dlg.optConstAndIndAtEnd.isSelected();
63: _constToTablesNotInScript = _dlg.constToTablesNotInScript
64: .isSelected();
65:
66: Preferences.userRoot().put(
67: PREFS_KEY_CONSTRAINTS_AND_INDEXES_AT_END,
68: "" + _constAndIndAtEnd);
69: Preferences.userRoot().put(
70: PREFS_KEY_CONSTRAINTS_TO_TABLES_NOT_IN_SCRIPT,
71: "" + _constToTablesNotInScript);
72:
73: _isOk = true;
74:
75: _dlg.setVisible(false);
76: _dlg.dispose();
77:
78: }
79:
80: public boolean isConstAndIndAtEnd() {
81: return _constAndIndAtEnd;
82: }
83:
84: public boolean includeConstToTablesNotInScript() {
85: return _constToTablesNotInScript;
86: }
87:
88: public boolean isOk() {
89: return _isOk;
90: }
91:
92: }
|