Source Code Cross Referenced for SQLPreferencesPanel.java in  » Database-Client » squirrel-sql-2.6.5a » net » sourceforge » squirrel_sql » client » preferences » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Database Client » squirrel sql 2.6.5a » net.sourceforge.squirrel_sql.client.preferences 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package net.sourceforge.squirrel_sql.client.preferences;
002:
003:        /*
004:         * Copyright (C) 2001-2003 Colin Bell
005:         * colbell@users.sourceforge.net
006:         *
007:         * This library is free software; you can redistribute it and/or
008:         * modify it under the terms of the GNU Lesser General Public
009:         * License as published by the Free Software Foundation; either
010:         * version 2.1 of the License, or (at your option) any later version.
011:         *
012:         * This library is distributed in the hope that it will be useful,
013:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
014:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
015:         * Lesser General Public License for more details.
016:         *
017:         * You should have received a copy of the GNU Lesser General Public
018:         * License along with this library; if not, write to the Free Software
019:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
020:         */
021:        import java.awt.Component;
022:        import java.awt.GridBagConstraints;
023:        import java.awt.GridBagLayout;
024:        import java.awt.Insets;
025:        import java.awt.event.ActionListener;
026:        import java.awt.event.ActionEvent;
027:
028:        import javax.swing.*;
029:
030:        import net.sourceforge.squirrel_sql.fw.gui.IntegerField;
031:        import net.sourceforge.squirrel_sql.fw.gui.OutputLabel;
032:        import net.sourceforge.squirrel_sql.fw.util.StringManager;
033:        import net.sourceforge.squirrel_sql.fw.util.StringManagerFactory;
034:
035:        import net.sourceforge.squirrel_sql.client.IApplication;
036:        import net.sourceforge.squirrel_sql.client.gui.mainframe.MainFrame;
037:        import net.sourceforge.squirrel_sql.client.util.ApplicationFiles;
038:
039:        /**
040:         * This preferences panel allows maintenance of SQL preferences.
041:         * @author <A HREF="mailto:colbell@users.sourceforge.net">Colin Bell</A>
042:         */
043:        public class SQLPreferencesPanel implements  IGlobalPreferencesPanel {
044:            /** Internationalized strings for this class. */
045:            private static final StringManager s_stringMgr = StringManagerFactory
046:                    .getStringManager(SQLPreferencesPanel.class);
047:
048:            /** Panel to be displayed in preferences dialog. */
049:            private SQLPrefsPanel _myPanel;
050:            private JScrollPane _myScrollPane;
051:
052:            /** Application API. */
053:            private IApplication _app;
054:            private MainFrame _mainFrame;
055:
056:            /**
057:             * Default ctor.
058:             * @param mainFrame
059:             */
060:            public SQLPreferencesPanel(MainFrame mainFrame) {
061:                super ();
062:                _mainFrame = mainFrame;
063:            }
064:
065:            /**
066:             * Initialize this panel. Called prior to it being displayed.
067:             *
068:             * @param	app	Application API.
069:             *
070:             * @throws	IllegalArgumentException
071:             * 			if <TT>null</TT> <TT>IApplication</TT> passed.
072:             */
073:            public void initialize(IApplication app) {
074:                if (app == null) {
075:                    throw new IllegalArgumentException(
076:                            "Null IApplication passed");
077:                }
078:
079:                _app = app;
080:
081:                getPanelComponent();
082:                _myPanel.loadData(_app, _app.getSquirrelPreferences());
083:
084:                _myPanel._fileOpenInPreviousDir
085:                        .addActionListener(new ActionListener() {
086:                            public void actionPerformed(ActionEvent e) {
087:                                updateFilePanel(_myPanel);
088:                            }
089:                        });
090:
091:                _myPanel._fileOpenInSpecifiedDir
092:                        .addActionListener(new ActionListener() {
093:                            public void actionPerformed(ActionEvent e) {
094:                                updateFilePanel(_myPanel);
095:                            }
096:                        });
097:
098:                updateFilePanel(_myPanel);
099:
100:                _myPanel._fileChooseDir.addActionListener(new ActionListener() {
101:                    public void actionPerformed(ActionEvent e) {
102:                        onChooseDir(_myPanel);
103:                    }
104:                });
105:
106:            }
107:
108:            public void uninitialize(IApplication app) {
109:
110:            }
111:
112:            public void onChooseDir(SQLPrefsPanel pnl) {
113:                JFileChooser chooser = new JFileChooser(pnl._fileSpecifiedDir
114:                        .getText());
115:                chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
116:                int returnVal = chooser.showOpenDialog(_mainFrame);
117:                if (returnVal == JFileChooser.APPROVE_OPTION) {
118:                    pnl._fileSpecifiedDir.setText(chooser.getSelectedFile()
119:                            .getAbsolutePath());
120:                }
121:            }
122:
123:            private void updateFilePanel(SQLPrefsPanel pnl) {
124:                pnl._fileChooseDir.setEnabled(pnl._fileOpenInSpecifiedDir
125:                        .isSelected());
126:                pnl._fileSpecifiedDir.setEnabled(pnl._fileOpenInSpecifiedDir
127:                        .isSelected());
128:            }
129:
130:            public synchronized Component getPanelComponent() {
131:                if (_myPanel == null) {
132:                    _myPanel = new SQLPrefsPanel();
133:                    _myScrollPane = new JScrollPane(_myPanel);
134:                }
135:                return _myScrollPane;
136:            }
137:
138:            public void applyChanges() {
139:                _myPanel.applyChanges(_app.getSquirrelPreferences());
140:            }
141:
142:            public String getTitle() {
143:                return s_stringMgr.getString("SQLPreferencesPanel.title");
144:            }
145:
146:            public String getHint() {
147:                return s_stringMgr.getString("SQLPreferencesPanel.hint");
148:            }
149:
150:            private static final class SQLPrefsPanel extends JPanel {
151:
152:                private IntegerField _loginTimeout = new IntegerField();
153:                private IntegerField _largeScriptStmtCount = new IntegerField();
154:                //		private JCheckBox _debugJdbc = new JCheckBox(s_stringMgr.getString("SQLPreferencesPanel.jdbcdebug"));
155:                private JRadioButton _debugJdbcDont = new JRadioButton(
156:                        s_stringMgr
157:                                .getString("SQLPreferencesPanel.jdbcdebugdont"));
158:                private JRadioButton _debugJdbcStream = new JRadioButton(
159:                        s_stringMgr
160:                                .getString("SQLPreferencesPanel.jdbcdebugstream"));
161:                private JRadioButton _debugJdbcWriter = new JRadioButton(
162:                        s_stringMgr
163:                                .getString("SQLPreferencesPanel.jdbcdebugwriter"));
164:                private JLabel _jdbcDebugLogFileNameLbl = new OutputLabel(" ");
165:                private JRadioButton _fileOpenInPreviousDir = new JRadioButton(
166:                        s_stringMgr
167:                                .getString("SQLPreferencesPanel.fileOpenInPreviousDir"));
168:                private JRadioButton _fileOpenInSpecifiedDir = new JRadioButton(
169:                        s_stringMgr
170:                                .getString("SQLPreferencesPanel.fileOpenInSpecifiedDir"));;
171:                private JTextField _fileSpecifiedDir = new JTextField();
172:                private JButton _fileChooseDir = new JButton("...");
173:
174:                SQLPrefsPanel() {
175:                    super (new GridBagLayout());
176:                    createUserInterface();
177:                }
178:
179:                void loadData(IApplication app, SquirrelPreferences prefs) {
180:                    final ApplicationFiles appFiles = new ApplicationFiles();
181:                    _loginTimeout.setInt(prefs.getLoginTimeout());
182:                    _largeScriptStmtCount.setInt(prefs
183:                            .getLargeScriptStmtCount());
184:                    _debugJdbcStream.setSelected(prefs.isJdbcDebugToStream());
185:                    _debugJdbcWriter.setSelected(prefs.isJdbcDebugToWriter());
186:                    _debugJdbcDont.setSelected(prefs.isJdbcDebugDontDebug());
187:                    _jdbcDebugLogFileNameLbl.setText(appFiles
188:                            .getJDBCDebugLogFile().getPath());
189:                    _fileOpenInPreviousDir.setSelected(prefs
190:                            .isFileOpenInPreviousDir());
191:                    _fileOpenInSpecifiedDir.setSelected(prefs
192:                            .isFileOpenInSpecifiedDir());
193:                    _fileSpecifiedDir.setText(prefs.getFileSpecifiedDir());
194:                }
195:
196:                void applyChanges(SquirrelPreferences prefs) {
197:                    prefs.setLoginTimeout(_loginTimeout.getInt());
198:                    prefs.setLargeScriptStmtCount(_largeScriptStmtCount
199:                            .getInt());
200:                    if (_debugJdbcStream.isSelected()) {
201:                        prefs.doJdbcDebugToStream();
202:                    } else if (_debugJdbcWriter.isSelected()) {
203:                        prefs.doJdbcDebugToWriter();
204:                    } else {
205:                        prefs.dontDoJdbcDebug();
206:                    }
207:
208:                    prefs.setFileOpenInPreviousDir(_fileOpenInPreviousDir
209:                            .isSelected());
210:                    prefs.setFileOpenInSpecifiedDir(_fileOpenInSpecifiedDir
211:                            .isSelected());
212:                    String specDir = _fileSpecifiedDir.getText();
213:                    prefs.setFileSpecifiedDir(null == specDir ? "" : specDir);
214:
215:                }
216:
217:                private void createUserInterface() {
218:                    final GridBagConstraints gbc = new GridBagConstraints();
219:                    gbc.fill = GridBagConstraints.HORIZONTAL;
220:                    gbc.insets = new Insets(4, 4, 4, 4);
221:                    gbc.gridx = 0;
222:                    gbc.gridy = 0;
223:                    gbc.weightx = 1;
224:                    add(createGeneralPanel(), gbc);
225:                    ++gbc.gridy;
226:                    add(createDebugPanel(), gbc);
227:                    ++gbc.gridy;
228:                    add(createFilePanel(), gbc);
229:                }
230:
231:                private JPanel createGeneralPanel() {
232:                    JPanel pnl = new JPanel(new GridBagLayout());
233:                    pnl.setBorder(BorderFactory.createTitledBorder(s_stringMgr
234:                            .getString("SQLPreferencesPanel.general")));
235:
236:                    _loginTimeout.setColumns(4);
237:
238:                    GridBagConstraints gbc = new GridBagConstraints();
239:                    gbc.anchor = GridBagConstraints.WEST;
240:                    gbc.fill = GridBagConstraints.NONE;
241:                    gbc.insets = new Insets(4, 4, 4, 4);
242:
243:                    gbc.gridx = 0;
244:                    gbc.gridy = 0;
245:                    pnl.add(new JLabel(s_stringMgr
246:                            .getString("SQLPreferencesPanel.logintimeout")),
247:                            gbc);
248:
249:                    ++gbc.gridx;
250:                    pnl.add(_loginTimeout, gbc);
251:
252:                    ++gbc.gridx;
253:                    gbc.weightx = 1;
254:                    pnl.add(new JLabel(s_stringMgr
255:                            .getString("SQLPreferencesPanel.zerounlimited")),
256:                            gbc);
257:
258:                    _largeScriptStmtCount.setColumns(4);
259:
260:                    gbc = new GridBagConstraints();
261:                    gbc.anchor = GridBagConstraints.WEST;
262:                    gbc.fill = GridBagConstraints.NONE;
263:                    gbc.insets = new Insets(4, 4, 4, 4);
264:
265:                    gbc.gridx = 0;
266:                    gbc.gridy = 1;
267:                    // i18n[SQLPreferencesPanel.largeScriptStmtCount=Large Script Statement Count: ]
268:                    pnl
269:                            .add(
270:                                    new JLabel(
271:                                            s_stringMgr
272:                                                    .getString("SQLPreferencesPanel.largeScriptStmtCount")),
273:                                    gbc);
274:
275:                    ++gbc.gridx;
276:                    pnl.add(_largeScriptStmtCount, gbc);
277:
278:                    return pnl;
279:                }
280:
281:                private JPanel createDebugPanel() {
282:                    final ButtonGroup btnGroup = new ButtonGroup();
283:                    btnGroup.add(_debugJdbcDont);
284:                    btnGroup.add(_debugJdbcStream);
285:                    btnGroup.add(_debugJdbcWriter);
286:
287:                    JPanel pnl = new JPanel(new GridBagLayout());
288:                    pnl.setBorder(BorderFactory.createTitledBorder(s_stringMgr
289:                            .getString("SQLPreferencesPanel.debug")));
290:
291:                    final GridBagConstraints gbc = new GridBagConstraints();
292:                    gbc.anchor = GridBagConstraints.WEST;
293:                    gbc.insets = new Insets(4, 4, 4, 4);
294:
295:                    gbc.gridx = 0;
296:                    gbc.gridy = 0;
297:                    gbc.fill = GridBagConstraints.HORIZONTAL;
298:                    gbc.gridx = 0;
299:                    ++gbc.gridy;
300:                    gbc.gridwidth = GridBagConstraints.REMAINDER;
301:                    pnl.add(_debugJdbcDont, gbc);
302:
303:                    ++gbc.gridy;
304:                    pnl.add(_debugJdbcStream, gbc);
305:
306:                    ++gbc.gridy;
307:                    pnl.add(_debugJdbcWriter, gbc);
308:
309:                    gbc.gridx = 0;
310:                    ++gbc.gridy;
311:                    gbc.gridwidth = 1;
312:                    pnl.add(new JLabel(s_stringMgr
313:                            .getString("SQLPreferencesPanel.jdbcdebugfile"),
314:                            SwingConstants.RIGHT), gbc);
315:
316:                    ++gbc.gridx;
317:                    gbc.weightx = 1;
318:                    gbc.gridwidth = GridBagConstraints.REMAINDER;
319:                    pnl.add(_jdbcDebugLogFileNameLbl, gbc);
320:
321:                    return pnl;
322:                }
323:
324:                private Component createFilePanel() {
325:                    final ButtonGroup btnGroup = new ButtonGroup();
326:                    btnGroup.add(_fileOpenInPreviousDir);
327:                    btnGroup.add(_fileOpenInSpecifiedDir);
328:
329:                    JPanel pnl = new JPanel(new GridBagLayout());
330:                    pnl.setBorder(BorderFactory.createTitledBorder(s_stringMgr
331:                            .getString("SQLPreferencesPanel.file")));
332:
333:                    GridBagConstraints gbc;
334:
335:                    gbc = new GridBagConstraints(0, 0, 1, 1, 0, 0,
336:                            GridBagConstraints.NORTHWEST,
337:                            GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0,
338:                            0);
339:                    pnl.add(_fileOpenInPreviousDir, gbc);
340:
341:                    gbc = new GridBagConstraints(1, 0, 2, 1, 1, 0,
342:                            GridBagConstraints.NORTHWEST,
343:                            GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5,
344:                                    5), 0, 0);
345:                    pnl.add(new JPanel(), gbc);
346:
347:                    gbc = new GridBagConstraints(0, 1, 1, 1, 0, 0,
348:                            GridBagConstraints.NORTHWEST,
349:                            GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0,
350:                            0);
351:                    pnl.add(_fileOpenInSpecifiedDir, gbc);
352:
353:                    gbc = new GridBagConstraints(1, 1, 1, 1, 1, 0,
354:                            GridBagConstraints.NORTHWEST,
355:                            GridBagConstraints.HORIZONTAL, new Insets(0, 5, 5,
356:                                    5), 0, 0);
357:                    pnl.add(_fileSpecifiedDir, gbc);
358:
359:                    gbc = new GridBagConstraints(2, 1, 1, 1, 0, 0,
360:                            GridBagConstraints.NORTHWEST,
361:                            GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0,
362:                            0);
363:                    pnl.add(_fileChooseDir, gbc);
364:
365:                    return pnl;
366:
367:                }
368:
369:            }
370:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.