001: package net.sourceforge.squirrel_sql.plugins.codecompletion.prefs;
002:
003: import net.sourceforge.squirrel_sql.fw.util.StringManager;
004: import net.sourceforge.squirrel_sql.fw.util.StringManagerFactory;
005: import net.sourceforge.squirrel_sql.fw.gui.MultipleLineLabel;
006:
007: import javax.swing.*;
008: import java.awt.*;
009: import java.text.NumberFormat;
010:
011: public class CodeCompletionPreferencesPanel extends JPanel {
012: private static final StringManager s_stringMgr = StringManagerFactory
013: .getStringManager(CodeCompletionPreferencesPanel.class);
014:
015: JRadioButton optSPWithParams;
016: JRadioButton optSPWithoutParams;
017: JRadioButton optUDFWithParams;
018: JRadioButton optUDFWithoutParams;
019:
020: JTable tblPrefixes;
021:
022: JButton btnNewRow;
023: JButton btnDeleteRows;
024: JTextField txtMaxLastSelectedCompletionNamesPanel;
025:
026: public CodeCompletionPreferencesPanel() {
027: setLayout(new GridBagLayout());
028:
029: GridBagConstraints gbc;
030:
031: gbc = new GridBagConstraints(0, 0, 1, 1, 0, 0,
032: GridBagConstraints.NORTHWEST,
033: GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5),
034: 0, 0);
035: // i18n[codeCompletion.prefsExplain=When completing functions SQuirreL doesn't know
036: // if a function is a stored procedure or a user defined function.
037: // To make code completion of these two kinds of functions convenient SQuirreL offers to
038: // configure which way completion should work.]
039: add(new MultipleLineLabel(s_stringMgr
040: .getString("codeCompletion.prefsExplain")), gbc);
041:
042: gbc = new GridBagConstraints(0, 1, 1, 1, 0, 0,
043: GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
044: new Insets(5, 5, 5, 5), 0, 0);
045: // i18n[codeCompletion.globalFunctCompltion=If there is no matching prefix configuration functions should complete like:]
046: add(new JLabel(s_stringMgr
047: .getString("codeCompletion.globalFunctCompltion")), gbc);
048:
049: ButtonGroup grp = new ButtonGroup();
050:
051: // i18n[codeCompletion.spWithParams=stored procedure with parameter info: {call mySP(<IN INTEGER tid>)}]
052: optSPWithParams = new JRadioButton(s_stringMgr
053: .getString("codeCompletion.spWithParams"));
054: gbc = new GridBagConstraints(0, 2, 1, 1, 0, 0,
055: GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
056: new Insets(0, 5, 5, 5), 0, 0);
057: add(optSPWithParams, gbc);
058: grp.add(optSPWithParams);
059:
060: // i18n[codeCompletion.spWithoutParams=stored procedure without parameter info: {call mySP()}]
061: optSPWithoutParams = new JRadioButton(s_stringMgr
062: .getString("codeCompletion.spWithoutParams"));
063: gbc = new GridBagConstraints(0, 3, 1, 1, 0, 0,
064: GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
065: new Insets(0, 5, 5, 5), 0, 0);
066: add(optSPWithoutParams, gbc);
067: grp.add(optSPWithoutParams);
068:
069: // i18n[codeCompletion.UDFWithParams=user defined function with parameter info: myFunct(<IN INTEGER tid>)]
070: optUDFWithParams = new JRadioButton(s_stringMgr
071: .getString("codeCompletion.UDFWithParams"));
072: gbc = new GridBagConstraints(0, 4, 1, 1, 0, 0,
073: GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
074: new Insets(0, 5, 5, 5), 0, 0);
075: add(optUDFWithParams, gbc);
076: grp.add(optUDFWithParams);
077:
078: // i18n[codeCompletion.UDFWithoutParams=user defined function without parameter info: myFunct()]
079: optUDFWithoutParams = new JRadioButton(s_stringMgr
080: .getString("codeCompletion.UDFWithoutParams"));
081: gbc = new GridBagConstraints(0, 5, 1, 1, 0, 0,
082: GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
083: new Insets(0, 5, 5, 5), 0, 0);
084: add(optUDFWithoutParams, gbc);
085: grp.add(optUDFWithoutParams);
086:
087: gbc = new GridBagConstraints(0, 6, 1, 1, 0, 0,
088: GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
089: new Insets(10, 5, 5, 5), 0, 0);
090: // i18n[codeCompletion.prefixConfig=Configure function completion for function name prefixes:]
091: add(new JLabel(s_stringMgr
092: .getString("codeCompletion.prefixConfig")), gbc);
093:
094: tblPrefixes = new JTable();
095: gbc = new GridBagConstraints(0, 7, 1, 1, 1, 1,
096: GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH,
097: new Insets(0, 5, 5, 5), 0, 0);
098: add(new JScrollPane(tblPrefixes), gbc);
099:
100: gbc = new GridBagConstraints(0, 8, 1, 1, 0, 0,
101: GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
102: new Insets(0, 5, 5, 5), 0, 0);
103: add(createButtonsPanel(), gbc);
104:
105: gbc = new GridBagConstraints(0, 9, 1, 1, 1, 0,
106: GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH,
107: new Insets(15, 5, 5, 5), 0, 0);
108: add(createMaxLastSelectedCompletionNamesPanel(), gbc);
109: }
110:
111: private JPanel createMaxLastSelectedCompletionNamesPanel() {
112: JPanel ret = new JPanel();
113:
114: ret.setLayout(new GridBagLayout());
115:
116: GridBagConstraints gbc;
117:
118: // i18n[CodeCompletionPreferencesPanel.maxLastSelectedCompletionNames=If you call code completion without being in the scope of a table,
119: //for which number of tables the parser last found would you like to see colums on top of the completion list?]
120: MultipleLineLabel lbl = new MultipleLineLabel(
121: s_stringMgr
122: .getString("CodeCompletionPreferencesPanel.maxLastSelectedCompletionNames"));
123: //JLabel lbl = new JLabel(s_stringMgr.getString("CodeCompletionPreferencesPanel.maxLastSelectedCompletionNames"));
124: gbc = new GridBagConstraints(0, 0, 2, 1, 1, 0,
125: GridBagConstraints.NORTHWEST,
126: GridBagConstraints.HORIZONTAL, new Insets(0, 5, 5, 5),
127: 0, 0);
128: ret.add(lbl, gbc);
129:
130: gbc = new GridBagConstraints(0, 1, 1, 1, 0, 0,
131: GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
132: new Insets(0, 5, 5, 5), 0, 0);
133: NumberFormat format = NumberFormat.getIntegerInstance();
134: txtMaxLastSelectedCompletionNamesPanel = new JFormattedTextField(
135: format);
136: txtMaxLastSelectedCompletionNamesPanel
137: .setPreferredSize(new Dimension(30,
138: txtMaxLastSelectedCompletionNamesPanel
139: .getPreferredSize().height));
140:
141: ret.add(txtMaxLastSelectedCompletionNamesPanel, gbc);
142:
143: // i18n[CodeCompletionPreferencesPanel.numberOfTables=number of tables]
144: gbc = new GridBagConstraints(1, 1, 1, 1, 0, 0,
145: GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
146: new Insets(0, 0, 5, 5), 0, 0);
147: ret
148: .add(
149: new JLabel(
150: s_stringMgr
151: .getString("CodeCompletionPreferencesPanel.numberOfTables")),
152: gbc);
153:
154: ret.setBorder(BorderFactory.createEtchedBorder());
155:
156: return ret;
157: }
158:
159: private JPanel createButtonsPanel() {
160: GridBagConstraints gbc;
161: JPanel pnlButtons = new JPanel(new GridBagLayout());
162:
163: // i18n[codeCompletion.prefixConfig.newRow=Add new row]
164: btnNewRow = new JButton(s_stringMgr
165: .getString("codeCompletion.prefixConfig.newRow"));
166: gbc = new GridBagConstraints(0, 0, 1, 1, 1, 0,
167: GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
168: new Insets(0, 0, 5, 5), 0, 0);
169: pnlButtons.add(btnNewRow, gbc);
170:
171: // i18n[codeCompletion.prefixConfig.deleteSelRows=Delete selected rows]
172: btnDeleteRows = new JButton(s_stringMgr
173: .getString("codeCompletion.prefixConfig.deleteSelRows"));
174: gbc = new GridBagConstraints(1, 0, 1, 1, 0, 0,
175: GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
176: new Insets(0, 5, 5, 5), 0, 0);
177: pnlButtons.add(btnDeleteRows, gbc);
178: return pnlButtons;
179: }
180:
181: }
|