Source Code Cross Referenced for OutputDbDialog.java in  » XML-UI » xui32 » com » xoetrope » carousel » survey » 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 » XML UI » xui32 » com.xoetrope.carousel.survey 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.xoetrope.carousel.survey;
002:
003:        import java.awt.BorderLayout;
004:        import java.awt.Dimension;
005:        import java.awt.FlowLayout;
006:        import java.awt.GridBagConstraints;
007:        import java.awt.GridBagLayout;
008:        import java.awt.Insets;
009:        import java.awt.Toolkit;
010:        import java.awt.event.ActionEvent;
011:        import java.awt.event.ActionListener;
012:        import javax.swing.*;
013:        import javax.swing.border.Border;
014:        import javax.swing.border.TitledBorder;
015:        import net.xoetrope.xui.XProject;
016:        import net.xoetrope.xui.XProjectManager;
017:
018:        /**
019:         * A dialog for configuring output database connection.
020:         *
021:         * <p> Copyright (c) Xoetrope Ltd., 2001-2006, This software is licensed under
022:         * the GNU Public License (GPL), please see license.txt for more details. If
023:         * you make commercial use of this software you must purchase a commercial
024:         * license from Xoetrope.</p>
025:         * <p> $Revision: 1.5 $</p>
026:         */
027:        //@todo show the available surveys and languages in this dialog
028:        public class OutputDbDialog extends JDialog {
029:            private static final String DEF_SURVEYNAME = "Survey1";
030:            private static final String DEF_LANGUAGE = "English";
031:            private static final String DEF_URL = "jdbc:hsqldb:hsql://localhost";
032:            private static final String DEF_DRIVER = "org.hsqldb.jdbcDriver";
033:            private static final String DEF_USERNAME = "sa";
034:            private static final String DEF_PASSWORD = "";
035:
036:            public static final int LABEL_WIDTH = 80;
037:            public static final int EDIT_WIDTH = 160;
038:            public static final int ROW_HEIGHT = 24;
039:            public static final int WIDTH = LABEL_WIDTH + EDIT_WIDTH + 30;
040:            public static final int HEIGHT = 260;
041:            public static final int BUTTON_WIDTH = 80;
042:            public static final int BUTTON_HEIGHT = 24;
043:
044:            protected JTextField surveyNameEdit;
045:            protected JTextField surveyLanguageEdit;
046:            protected JTextField dbUrlEdit;
047:            protected JTextField dbDriverEdit;
048:            protected JTextField dbUserEdit;
049:            protected JPasswordField dbPasswordEdit;
050:
051:            protected boolean okPressed;
052:
053:            public OutputDbDialog() {
054:                super ();
055:                setModal(true);
056:                okPressed = false;
057:                init();
058:            }
059:
060:            public boolean showDialog() {
061:                okPressed = false;
062:                setVisible(true);
063:                return okPressed;
064:            }
065:
066:            private void init() {
067:                Dimension labelSize = new Dimension(LABEL_WIDTH, ROW_HEIGHT);
068:                Dimension editSize = new Dimension(EDIT_WIDTH, ROW_HEIGHT);
069:                Dimension buttonSize = new Dimension(BUTTON_WIDTH,
070:                        BUTTON_HEIGHT);
071:                Dimension size = new Dimension(WIDTH, HEIGHT);
072:                setSize(size);
073:                setPreferredSize(size);
074:
075:                TitledBorder titledBorder = BorderFactory
076:                        .createTitledBorder(" Setup the database connection");
077:
078:                JPanel mainPanel = new JPanel();
079:                mainPanel.setLayout(new BorderLayout());
080:                JPanel editPanel = new JPanel();
081:                editPanel.setLayout(new GridBagLayout());
082:                JPanel bottomPanel = new JPanel();
083:                bottomPanel.setLayout(new FlowLayout());
084:
085:                // survey name
086:                JLabel surveyNameLabel = new JLabel("Survey name");
087:                surveyNameLabel.setSize(labelSize);
088:                surveyNameLabel.setPreferredSize(labelSize);
089:                surveyNameLabel.setMinimumSize(labelSize);
090:                surveyNameLabel.setHorizontalAlignment(SwingConstants.RIGHT);
091:                surveyNameEdit = new JTextField();
092:                surveyNameEdit.setSize(editSize);
093:                surveyNameEdit.setMinimumSize(editSize);
094:                surveyNameEdit.setPreferredSize(editSize);
095:
096:                // survey language
097:                JLabel surveyLanguageLabel = new JLabel("Language");
098:                surveyLanguageLabel.setSize(labelSize);
099:                surveyLanguageLabel.setPreferredSize(labelSize);
100:                surveyLanguageLabel.setMinimumSize(labelSize);
101:                surveyLanguageLabel
102:                        .setHorizontalAlignment(SwingConstants.RIGHT);
103:                surveyLanguageEdit = new JTextField();
104:                surveyLanguageEdit.setSize(editSize);
105:                surveyLanguageEdit.setMinimumSize(editSize);
106:                surveyLanguageEdit.setPreferredSize(editSize);
107:
108:                // database url
109:                JLabel dbUrlLabel = new JLabel("Database URL");
110:                dbUrlLabel.setSize(labelSize);
111:                dbUrlLabel.setPreferredSize(labelSize);
112:                dbUrlLabel.setMinimumSize(labelSize);
113:                dbUrlLabel.setHorizontalAlignment(SwingConstants.RIGHT);
114:                dbUrlEdit = new JTextField();
115:                dbUrlEdit.setSize(editSize);
116:                dbUrlEdit.setMinimumSize(editSize);
117:                dbUrlEdit.setPreferredSize(editSize);
118:
119:                // database driver
120:                JLabel dbDriverLabel = new JLabel("Database driver");
121:                dbDriverLabel.setSize(labelSize);
122:                dbDriverLabel.setPreferredSize(labelSize);
123:                dbDriverLabel.setMinimumSize(labelSize);
124:                dbDriverLabel.setHorizontalAlignment(SwingConstants.RIGHT);
125:                dbDriverEdit = new JTextField();
126:                dbDriverEdit.setSize(editSize);
127:                dbDriverEdit.setMinimumSize(editSize);
128:                dbDriverEdit.setPreferredSize(editSize);
129:
130:                // database user
131:                JLabel dbUserLabel = new JLabel("Username");
132:                dbUserLabel.setSize(labelSize);
133:                dbUserLabel.setPreferredSize(labelSize);
134:                dbUserLabel.setMinimumSize(labelSize);
135:                dbUserLabel.setHorizontalAlignment(SwingConstants.RIGHT);
136:                dbUserEdit = new JTextField();
137:                dbUserEdit.setSize(editSize);
138:                dbUserEdit.setMinimumSize(editSize);
139:                dbUserEdit.setPreferredSize(editSize);
140:
141:                // database password
142:                JLabel dbPasswordLabel = new JLabel("Password");
143:                dbPasswordLabel.setSize(labelSize);
144:                dbPasswordLabel.setPreferredSize(labelSize);
145:                dbPasswordLabel.setMinimumSize(labelSize);
146:                dbPasswordLabel.setHorizontalAlignment(SwingConstants.RIGHT);
147:                dbPasswordEdit = new JPasswordField();
148:                dbPasswordEdit.setSize(editSize);
149:                dbPasswordEdit.setMinimumSize(editSize);
150:                dbPasswordEdit.setPreferredSize(editSize);
151:
152:                // setup the default values
153:                surveyNameEdit.setText(DEF_SURVEYNAME);
154:                surveyLanguageEdit.setText(DEF_LANGUAGE);
155:                dbUrlEdit.setText(DEF_URL);
156:                dbDriverEdit.setText(DEF_DRIVER);
157:                dbUserEdit.setText(DEF_USERNAME);
158:                dbPasswordEdit.setText(DEF_PASSWORD);
159:
160:                JButton buttonOk = new JButton("Save");
161:                buttonOk.setSize(buttonSize);
162:                buttonOk.setPreferredSize(buttonSize);
163:                buttonOk.setMinimumSize(buttonSize);
164:                buttonOk.addActionListener(new ActionListener() {
165:                    public void actionPerformed(ActionEvent e) {
166:                        okPressed = true;
167:                        OutputDbDialog.this .setVisible(false);
168:                    }
169:                });
170:
171:                JButton buttonCancel = new JButton("Cancel");
172:                buttonCancel.setSize(buttonSize);
173:                buttonCancel.setPreferredSize(buttonSize);
174:                buttonCancel.setMinimumSize(buttonSize);
175:                buttonCancel.addActionListener(new ActionListener() {
176:                    public void actionPerformed(ActionEvent e) {
177:                        okPressed = false;
178:                        OutputDbDialog.this .setVisible(false);
179:                    }
180:                });
181:
182:                GridBagConstraints c = new GridBagConstraints();
183:                c.insets = new Insets(1, 1, 1, 1);
184:
185:                // survey name
186:                c.gridx = 0;
187:                c.gridy = 0;
188:                editPanel.add(surveyNameLabel, c);
189:                c.gridx = 1;
190:                c.gridy = 0;
191:                editPanel.add(surveyNameEdit, c);
192:
193:                // survey langauge
194:                c.gridx = 0;
195:                c.gridy = 1;
196:                editPanel.add(surveyLanguageLabel, c);
197:                c.gridx = 1;
198:                c.gridy = 1;
199:                editPanel.add(surveyLanguageEdit, c);
200:
201:                // db url
202:                c.gridx = 0;
203:                c.gridy = 2;
204:                editPanel.add(dbUrlLabel, c);
205:                c.gridx = 1;
206:                c.gridy = 2;
207:                editPanel.add(dbUrlEdit, c);
208:
209:                // db driver
210:                c.gridx = 0;
211:                c.gridy = 3;
212:                editPanel.add(dbDriverLabel, c);
213:                c.gridx = 1;
214:                c.gridy = 3;
215:                editPanel.add(dbDriverEdit, c);
216:
217:                // db user
218:                c.gridx = 0;
219:                c.gridy = 4;
220:                editPanel.add(dbUserLabel, c);
221:                c.gridx = 1;
222:                c.gridy = 4;
223:                editPanel.add(dbUserEdit, c);
224:
225:                // db password
226:                c.gridx = 0;
227:                c.gridy = 5;
228:                editPanel.add(dbPasswordLabel, c);
229:                c.gridx = 1;
230:                c.gridy = 5;
231:                editPanel.add(dbPasswordEdit, c);
232:
233:                bottomPanel.add(buttonOk);
234:                bottomPanel.add(buttonCancel);
235:                mainPanel.add(editPanel, BorderLayout.CENTER);
236:                mainPanel.add(bottomPanel, BorderLayout.SOUTH);
237:                editPanel.setBorder(titledBorder);
238:                add(mainPanel);
239:                pack();
240:
241:                Dimension screenSize = Toolkit.getDefaultToolkit()
242:                        .getScreenSize();
243:                Dimension dialogSize = getSize();
244:                setLocation((screenSize.width - dialogSize.width) / 2,
245:                        (screenSize.height - dialogSize.height) / 2);
246:            }
247:
248:            public String getSurveyName() {
249:                return surveyNameEdit.getText();
250:            }
251:
252:            public String getSurveyLanguage() {
253:                return surveyLanguageEdit.getText();
254:            }
255:
256:            public String getDbUrl() {
257:                return dbUrlEdit.getText();
258:            }
259:
260:            public String getDbDriver() {
261:                return dbDriverEdit.getText();
262:            }
263:
264:            public String getDbUser() {
265:                return dbUserEdit.getText();
266:            }
267:
268:            public String getDbPassword() {
269:                return dbPasswordEdit.getText();
270:            }
271:
272:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.