Source Code Cross Referenced for SQLScriptPreferencesPanel.java in  » Database-Client » squirrel-sql-2.6.5a » net » sourceforge » squirrel_sql » plugins » sqlscript » prefs » 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.plugins.sqlscript.prefs 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (C) 2006 Rob Manning
003:         * manningr@users.sourceforge.net
004:         *
005:         * This library is free software; you can redistribute it and/or
006:         * modify it under the terms of the GNU Lesser General Public
007:         * License as published by the Free Software Foundation; either
008:         * version 2.1 of the License, or (at your option) any later version.
009:         *
010:         * This library is distributed in the hope that it will be useful,
011:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
012:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
013:         * Lesser General Public License for more details.
014:         *
015:         * You should have received a copy of the GNU Lesser General Public
016:         * License along with this library; if not, write to the Free Software
017:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
018:         */
019:        package net.sourceforge.squirrel_sql.plugins.sqlscript.prefs;
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.ActionEvent;
026:        import java.awt.event.ActionListener;
027:
028:        import javax.swing.DefaultComboBoxModel;
029:        import javax.swing.JCheckBox;
030:        import javax.swing.JComboBox;
031:        import javax.swing.JLabel;
032:        import javax.swing.JPanel;
033:        import javax.swing.border.Border;
034:        import javax.swing.border.CompoundBorder;
035:        import javax.swing.border.EmptyBorder;
036:        import javax.swing.border.TitledBorder;
037:
038:        import net.sourceforge.squirrel_sql.fw.util.StringManager;
039:        import net.sourceforge.squirrel_sql.fw.util.StringManagerFactory;
040:        import net.sourceforge.squirrel_sql.fw.util.log.ILogger;
041:        import net.sourceforge.squirrel_sql.fw.util.log.LoggerController;
042:
043:        public class SQLScriptPreferencesPanel extends JPanel {
044:
045:            private static final StringManager s_stringMgr = StringManagerFactory
046:                    .getStringManager(SQLScriptPreferencesPanel.class);
047:
048:            /** Logger for this class. */
049:            private final static ILogger log = LoggerController
050:                    .createLogger(SQLScriptPreferencesPanel.class);
051:
052:            SQLScriptPreferenceBean _prefs = null;
053:
054:            JCheckBox qualifyTableNamesCheckBox = null;
055:
056:            JCheckBox deleteReferentialActionCheckbox = null;
057:
058:            JCheckBox updateReferentialActionCheckbox = null;
059:
060:            JComboBox deleteActionComboBox = null;
061:
062:            JComboBox updateActionComboBox = null;
063:
064:            JLabel deleteActionLabel = null;
065:
066:            JLabel updateActionLabel = null;
067:
068:            public SQLScriptPreferencesPanel(SQLScriptPreferenceBean prefs) {
069:                super ();
070:                _prefs = prefs;
071:                createGUI();
072:                loadData();
073:            }
074:
075:            private void createGUI() {
076:                this .setLayout(new GridBagLayout());
077:                GridBagConstraints c = new GridBagConstraints();
078:                c.gridx = 0; // Column 0
079:                c.gridy = 0; // Row 0
080:                c.fill = GridBagConstraints.BOTH;
081:                c.weightx = 1;
082:                c.weighty = .60;
083:                add(createBottomPanel(), c);
084:            }
085:
086:            private JPanel createBottomPanel() {
087:                JPanel result = new JPanel(new GridBagLayout());
088:                //i18n[SQLScriptPreferencesPanel.borderTitle=SQL Script Preferences]
089:                String borderTitle = s_stringMgr
090:                        .getString("SQLScriptPreferencesPanel.borderTitle");
091:                result.setBorder(getTitledBorder(borderTitle));
092:                addQualifyTableNamesCheckBox(result, 0, 0);
093:                addDeleteRefActionCheckBox(result, 0, 1);
094:                addDeleteActionComboBox(result, 0, 2);
095:                addUpdateRefActionCheckBox(result, 0, 3);
096:                addUpdateActionComboBox(result, 0, 4);
097:                return result;
098:            }
099:
100:            private void addQualifyTableNamesCheckBox(JPanel panel, int col,
101:                    int row) {
102:                GridBagConstraints c = new GridBagConstraints();
103:                c.gridx = col;
104:                c.gridy = row;
105:                c.anchor = GridBagConstraints.WEST;
106:                // i18n[SQLScriptPreferencesPanel.qualifyCheckboxLabel=Qualify table names in scripts with schema]
107:                String cbLabelStr = s_stringMgr
108:                        .getString("SQLScriptPreferencesPanel.qualifyCheckboxLabel");
109:                // i18n[SQLScriptPreferencesPanel.prefsToolTip=Table names appear in scripts as SCHEMA.TABLE]
110:                String cbToolTipText = s_stringMgr
111:                        .getString("SQLScriptPreferencesPanel.qualifyCheckboxToolTip");
112:                qualifyTableNamesCheckBox = new JCheckBox(cbLabelStr);
113:                qualifyTableNamesCheckBox.setToolTipText(cbToolTipText);
114:                panel.add(qualifyTableNamesCheckBox, c);
115:            }
116:
117:            private void addDeleteRefActionCheckBox(JPanel panel, int col,
118:                    int row) {
119:                GridBagConstraints c = new GridBagConstraints();
120:                c.gridx = col;
121:                c.gridy = row;
122:                c.anchor = GridBagConstraints.WEST;
123:                //i18n[SQLScriptPreferencesPanel.deleteRefActionCheckboxLabel=Add delete 
124:                //referential action to the FK definition]
125:                String cbLabelStr = s_stringMgr
126:                        .getString("SQLScriptPreferencesPanel.deleteRefActionCheckboxLabel");
127:                // i18n[SQLScriptPreferencesPanel.deleteRefActionToolTip=Append ON DELETE ...]
128:                String cbToolTipText = s_stringMgr
129:                        .getString("SQLScriptPreferencesPanel.deleteRefActionToolTip");
130:                deleteReferentialActionCheckbox = new JCheckBox(cbLabelStr);
131:                deleteReferentialActionCheckbox.setToolTipText(cbToolTipText);
132:
133:                deleteReferentialActionCheckbox
134:                        .addActionListener(new ActionListener() {
135:                            public void actionPerformed(ActionEvent e) {
136:                                boolean enabled = deleteReferentialActionCheckbox
137:                                        .isSelected();
138:                                deleteActionLabel.setEnabled(enabled);
139:                                deleteActionComboBox.setEnabled(enabled);
140:                            }
141:                        });
142:
143:                panel.add(deleteReferentialActionCheckbox, c);
144:            }
145:
146:            private void addUpdateRefActionCheckBox(JPanel panel, int col,
147:                    int row) {
148:                GridBagConstraints c = new GridBagConstraints();
149:                c.gridx = col;
150:                c.gridy = row;
151:                c.anchor = GridBagConstraints.WEST;
152:                //i18n[SQLScriptPreferencesPanel.updateRefActionCheckboxLabel=Add update 
153:                //referential action to the FK definition]
154:                String cbLabelStr = s_stringMgr
155:                        .getString("SQLScriptPreferencesPanel.updateRefActionCheckboxLabel");
156:                // i18n[SQLScriptPreferencesPanel.updateRefActionToolTip=Append ON UPDATE ...]
157:                String cbToolTipText = s_stringMgr
158:                        .getString("SQLScriptPreferencesPanel.updateRefActionToolTip");
159:                updateReferentialActionCheckbox = new JCheckBox(cbLabelStr);
160:                updateReferentialActionCheckbox.setToolTipText(cbToolTipText);
161:
162:                updateReferentialActionCheckbox
163:                        .addActionListener(new ActionListener() {
164:                            public void actionPerformed(ActionEvent e) {
165:                                boolean enabled = updateReferentialActionCheckbox
166:                                        .isSelected();
167:                                updateActionLabel.setEnabled(enabled);
168:                                updateActionComboBox.setEnabled(enabled);
169:                            }
170:                        });
171:
172:                panel.add(updateReferentialActionCheckbox, c);
173:            }
174:
175:            private void addDeleteActionComboBox(JPanel panel, int col, int row) {
176:                GridBagConstraints c = new GridBagConstraints();
177:                c.gridx = col;
178:                c.gridy = row;
179:                c.insets = new Insets(5, 25, 0, 0);
180:                c.anchor = GridBagConstraints.WEST;
181:
182:                JPanel subpanel = new JPanel();
183:
184:                //i18n[SQLScriptPreferencesPanel.deleteActionLabel=Action to take on delete:]
185:                String cbLabelStr = s_stringMgr
186:                        .getString("SQLScriptPreferencesPanel.deleteActionLabel");
187:                deleteActionLabel = new JLabel(cbLabelStr);
188:                deleteActionLabel.setHorizontalAlignment(JLabel.LEFT);
189:
190:                deleteActionComboBox = new JComboBox();
191:                DefaultComboBoxModel model = new DefaultComboBoxModel(
192:                        new String[] { "NO ACTION", "CASCADE", "SET DEFAULT",
193:                                "SET NULL" });
194:                deleteActionComboBox.setModel(model);
195:                subpanel.add(deleteActionLabel);
196:                subpanel.add(deleteActionComboBox);
197:                panel.add(subpanel, c);
198:            }
199:
200:            private void addUpdateActionComboBox(JPanel panel, int col, int row) {
201:                GridBagConstraints c = new GridBagConstraints();
202:                c.gridx = col;
203:                c.gridy = row;
204:                c.insets = new Insets(5, 25, 0, 0);
205:                c.anchor = GridBagConstraints.WEST;
206:
207:                JPanel subpanel = new JPanel();
208:
209:                //i18n[SQLScriptPreferencesPanel.updateActionLabel=Action to take on update:]
210:                String cbLabelStr = s_stringMgr
211:                        .getString("SQLScriptPreferencesPanel.updateActionLabel");
212:                updateActionLabel = new JLabel(cbLabelStr);
213:                updateActionLabel.setHorizontalAlignment(JLabel.LEFT);
214:
215:                updateActionComboBox = new JComboBox();
216:                DefaultComboBoxModel model = new DefaultComboBoxModel(
217:                        new String[] { "NO ACTION", "CASCADE", "SET DEFAULT",
218:                                "SET NULL" });
219:                updateActionComboBox.setModel(model);
220:                subpanel.add(updateActionLabel);
221:                subpanel.add(updateActionComboBox);
222:                panel.add(subpanel, c);
223:            }
224:
225:            private Border getTitledBorder(String title) {
226:                CompoundBorder border = new CompoundBorder(new EmptyBorder(10,
227:                        10, 10, 10), new TitledBorder(title));
228:                return border;
229:            }
230:
231:            private void loadData() {
232:                qualifyTableNamesCheckBox.setSelected(_prefs
233:                        .isQualifyTableNames());
234:                deleteReferentialActionCheckbox.setSelected(_prefs
235:                        .isDeleteRefAction());
236:                deleteActionComboBox.setEnabled(deleteReferentialActionCheckbox
237:                        .isSelected());
238:                deleteActionComboBox.setSelectedIndex(_prefs.getDeleteAction());
239:                updateReferentialActionCheckbox.setSelected(_prefs
240:                        .isUpdateRefAction());
241:                updateActionComboBox.setEnabled(updateReferentialActionCheckbox
242:                        .isSelected());
243:                updateActionComboBox.setSelectedIndex(_prefs.getUpdateAction());
244:
245:            }
246:
247:            private void save() {
248:                _prefs.setQualifyTableNames(qualifyTableNamesCheckBox
249:                        .isSelected());
250:                _prefs.setDeleteRefAction(deleteReferentialActionCheckbox
251:                        .isSelected());
252:                _prefs.setUpdateRefAction(updateReferentialActionCheckbox
253:                        .isSelected());
254:                int action = deleteActionComboBox.getSelectedIndex();
255:                _prefs.setDeleteAction(action);
256:                action = updateActionComboBox.getSelectedIndex();
257:                _prefs.setUpdateAction(action);
258:                SQLScriptPreferencesManager.savePrefs();
259:            }
260:
261:            /* (non-Javadoc)
262:             * @see net.sourceforge.squirrel_sql.client.util.IOptionPanel#applyChanges()
263:             */
264:            public void applyChanges() {
265:                save();
266:            }
267:
268:            /* (non-Javadoc)
269:             * @see net.sourceforge.squirrel_sql.client.util.IOptionPanel#getPanelComponent()
270:             */
271:            public Component getPanelComponent() {
272:                return this;
273:            }
274:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.