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


001:        package net.sourceforge.squirrel_sql.plugins.sqlparam.gui;
002:
003:        /*
004:         * Copyright (C) 2007 Thorsten Mürell
005:         *
006:         * This program is free software; you can redistribute it and/or
007:         * modify it under the terms of the GNU General Public License
008:         * as published by the Free Software Foundation; either version 2
009:         * of the License, or any later version.
010:         *
011:         * This program is distributed in the hope that it will be useful,
012:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
014:         * GNU General Public License for more details.
015:         *
016:         * You should have received a copy of the GNU General Public License
017:         * along with this program; if not, write to the Free Software
018:         * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
019:         */
020:        import java.awt.BorderLayout;
021:        import java.awt.Component;
022:
023:        import javax.swing.JCheckBox;
024:        import javax.swing.JPanel;
025:        import javax.swing.JTextField;
026:        import javax.swing.event.DocumentEvent;
027:        import javax.swing.event.DocumentListener;
028:
029:        import net.sourceforge.squirrel_sql.client.gui.BaseInternalFrame;
030:        import net.sourceforge.squirrel_sql.client.gui.IOkClosePanelListener;
031:        import net.sourceforge.squirrel_sql.client.gui.OkClosePanel;
032:        import net.sourceforge.squirrel_sql.client.gui.OkClosePanelEvent;
033:        import net.sourceforge.squirrel_sql.fw.gui.GUIUtils;
034:        import net.sourceforge.squirrel_sql.fw.util.StringManager;
035:        import net.sourceforge.squirrel_sql.fw.util.StringManagerFactory;
036:
037:        import com.jgoodies.forms.builder.PanelBuilder;
038:        import com.jgoodies.forms.layout.CellConstraints;
039:        import com.jgoodies.forms.layout.FormLayout;
040:
041:        /**
042:         * The dialog to ask the user for a value.
043:         * 
044:         * @author Thorsten Mürell
045:         */
046:        public class AskParamValueDialog extends BaseInternalFrame {
047:            private static final long serialVersionUID = 3470927611018381204L;
048:
049:            private static final StringManager stringMgr = StringManagerFactory
050:                    .getStringManager(AskParamValueDialog.class);
051:
052:            private OkClosePanel btnsPnl = new OkClosePanel();
053:            private JTextField value = new JTextField();
054:            private JCheckBox quote = new JCheckBox();
055:            private String parameter = null;
056:            private String oldValue = null;
057:
058:            private boolean done = false;
059:            private boolean cancelled = false;
060:
061:            /**
062:             * Creates the dialog.
063:             * 
064:             * @param parameter The name of the parameter to replace.
065:             * @param oldValue The old value of the parameter to provide as a default.
066:             */
067:            public AskParamValueDialog(String parameter, String oldValue) {
068:                //i18n[sqlparam.inputParameterValues=Please input the parameter values]
069:                super (stringMgr.getString("sqlparam.inputParameterValues"),
070:                        true);
071:                this .parameter = parameter;
072:                this .oldValue = oldValue;
073:
074:                setDefaultCloseOperation(DISPOSE_ON_CLOSE);
075:                GUIUtils.makeToolWindow(this , true);
076:
077:                final JPanel content = new JPanel(new BorderLayout());
078:                content.add(createMainPanel(), BorderLayout.CENTER);
079:                setContentPane(content);
080:                btnsPnl.makeOKButtonDefault();
081:                btnsPnl.getRootPane().setDefaultButton(btnsPnl.getOKButton());
082:                pack();
083:            }
084:
085:            /**
086:             * @return <code>true</code> if the dialog is done
087:             */
088:            public boolean isDone() {
089:                return done;
090:            }
091:
092:            /**
093:             * If the user doesn't want to input a value, he hits the close
094:             * button. The this method returns true.
095:             * 
096:             * @return <code>true</code> if the dialog was cancelled by the user.
097:             */
098:            public boolean isCancelled() {
099:                return cancelled;
100:            }
101:
102:            /**
103:             * Sets the value of the dialog.
104:             * 
105:             * @param defaultValue the value to set as a default in this dialog.
106:             */
107:            public void setValue(String defaultValue) {
108:                value.setText(defaultValue);
109:            }
110:
111:            /**
112:             * Gets the value of the input field in this dialog.
113:             * 
114:             * @return The value for the parameter.
115:             */
116:            public String getValue() {
117:                return value.getText();
118:            }
119:
120:            /**
121:             * Returns if quotes around the value are needed.
122:             * 
123:             * @return <code>true</code> if quoting is needed.
124:             */
125:            public boolean isQuotingNeeded() {
126:                return quote.isSelected();
127:            }
128:
129:            private void updateCheckbox() {
130:                boolean isNumber = false;
131:
132:                try {
133:                    Float.parseFloat(value.getText());
134:                    isNumber = true;
135:                } catch (NumberFormatException nfe) {
136:                    isNumber = false;
137:                }
138:
139:                if (isNumber) {
140:                    quote.setSelected(false);
141:                    quote.setEnabled(true);
142:                } else {
143:                    quote.setSelected(true);
144:                    quote.setEnabled(false);
145:                }
146:            }
147:
148:            private Component createMainPanel() {
149:                value.setColumns(20);
150:                value.setText(oldValue);
151:                value.getDocument().addDocumentListener(new DocumentListener() {
152:                    public void changedUpdate(DocumentEvent e) {
153:                        AskParamValueDialog.this .updateCheckbox();
154:                    }
155:
156:                    public void insertUpdate(DocumentEvent e) {
157:                        AskParamValueDialog.this .updateCheckbox();
158:                    }
159:
160:                    public void removeUpdate(DocumentEvent e) {
161:                        AskParamValueDialog.this .updateCheckbox();
162:                    }
163:                });
164:                updateCheckbox();
165:                btnsPnl.addListener(new MyOkClosePanelListener());
166:
167:                final FormLayout layout = new FormLayout(
168:                // Columns
169:                        "right:pref, 8dlu, left:min(100dlu;pref):grow",
170:                        // Rows
171:                        "pref, 6dlu, pref, 6dlu, pref, 6dlu, pref, 6dlu, pref, 3dlu, pref, 3dlu, pref");
172:
173:                PanelBuilder builder = new PanelBuilder(layout);
174:                CellConstraints cc = new CellConstraints();
175:                builder.setDefaultDialogBorder();
176:
177:                int y = 1;
178:                builder.addSeparator(title, cc.xywh(1, y, 3, 1));
179:
180:                y += 2;
181:                //i18n[sqlparam.valueFor=Value for {0}]
182:                builder.addLabel(stringMgr.getString("sqlparam.valueFor",
183:                        parameter), cc.xy(1, y));
184:                builder.add(value, cc.xywh(3, y, 1, 1));
185:
186:                y += 2;
187:                //i18n[sqlparam.quoteValues=Quote Values]
188:                builder.addLabel(stringMgr.getString("sqlparam.quoteValues"),
189:                        cc.xy(1, y));
190:                builder.add(quote, cc.xywh(3, y, 1, 1));
191:
192:                y += 2;
193:                builder.addSeparator("", cc.xywh(1, y, 3, 1));
194:
195:                y += 2;
196:                builder.add(btnsPnl, cc.xywh(1, y, 3, 1));
197:
198:                return builder.getPanel();
199:            }
200:
201:            /**
202:             * Cancels the dialog.
203:             */
204:            public void cancel() {
205:                done = true;
206:                cancelled = true;
207:                dispose();
208:            }
209:
210:            /**
211:             * Confirms the dialog.
212:             */
213:            public void ok() {
214:                done = true;
215:                dispose();
216:            }
217:
218:            private final class MyOkClosePanelListener implements 
219:                    IOkClosePanelListener {
220:                /**
221:                 * Callback for the ok key.
222:                 * 
223:                 * @param evt the event
224:                 */
225:                public void okPressed(OkClosePanelEvent evt) {
226:                    AskParamValueDialog.this .ok();
227:                }
228:
229:                /**
230:                 * Callback for the close key.
231:                 * 
232:                 * @param evt the event
233:                 */
234:                public void closePressed(OkClosePanelEvent evt) {
235:                    AskParamValueDialog.this .cancel();
236:                }
237:
238:                /**
239:                 * Callback for the cancel key.
240:                 * 
241:                 * @param evt the event
242:                 */
243:                public void cancelPressed(OkClosePanelEvent evt) {
244:                    AskParamValueDialog.this.cancel();
245:                }
246:            }
247:
248:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.