Source Code Cross Referenced for FullNameDialog.java in  » Mail-Clients » columba-1.4 » org » columba » addressbook » gui » dialog » contact » 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 » Mail Clients » columba 1.4 » org.columba.addressbook.gui.dialog.contact 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // The contents of this file are subject to the Mozilla Public License Version
002:        // 1.1
003:        //(the "License"); you may not use this file except in compliance with the
004:        //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
005:        //
006:        //Software distributed under the License is distributed on an "AS IS" basis,
007:        //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
008:        //for the specific language governing rights and
009:        //limitations under the License.
010:        //
011:        //The Original Code is "The Columba Project"
012:        //
013:        //The Initial Developers of the Original Code are Frederik Dietz and Timo
014:        // Stich.
015:        //Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
016:        //
017:        //All Rights Reserved.
018:
019:        package org.columba.addressbook.gui.dialog.contact;
020:
021:        import java.awt.BorderLayout;
022:        import java.awt.GridLayout;
023:        import java.awt.event.ActionEvent;
024:        import java.awt.event.ActionListener;
025:        import java.awt.event.KeyEvent;
026:
027:        import javax.swing.BorderFactory;
028:        import javax.swing.JButton;
029:        import javax.swing.JComponent;
030:        import javax.swing.JDialog;
031:        import javax.swing.JLabel;
032:        import javax.swing.JOptionPane;
033:        import javax.swing.JPanel;
034:        import javax.swing.JTextField;
035:        import javax.swing.KeyStroke;
036:        import javax.swing.SwingConstants;
037:
038:        import org.columba.addressbook.util.AddressbookResourceLoader;
039:        import org.columba.core.gui.base.ButtonWithMnemonic;
040:        import org.columba.core.gui.base.LabelWithMnemonic;
041:        import org.columba.core.gui.base.SingleSideEtchedBorder;
042:
043:        import com.jgoodies.forms.builder.DefaultFormBuilder;
044:        import com.jgoodies.forms.layout.FormLayout;
045:
046:        /**
047:         * A dialog for editing a contact's full name.
048:         */
049:
050:        public class FullNameDialog extends JDialog implements  ActionListener {
051:            private JLabel titleLabel;
052:
053:            private JTextField namePrefixTextField;
054:
055:            private JLabel fornameLabel;
056:
057:            private JTextField firstNameTextField;
058:
059:            private JLabel middlenameLabel;
060:
061:            private JTextField middleNameTextField;
062:
063:            private JLabel lastnameLabel;
064:
065:            private JTextField lastNameTextField;
066:
067:            private JLabel suffixLabel;
068:
069:            private JTextField nameSuffixTextField;
070:
071:            private JButton okButton;
072:
073:            private JButton cancelButton;
074:
075:            private boolean success = false;
076:
077:            public FullNameDialog(JDialog frame) {
078:                super (frame, AddressbookResourceLoader.getString("dialog",
079:                        "contact", "edit_fullname"), true);
080:
081:                initComponents();
082:                layoutComponents();
083:
084:                pack();
085:                setLocationRelativeTo(null);
086:            }
087:
088:            public boolean getResult() {
089:                return success;
090:            }
091:
092:            /**
093:             * @return Returns the firstNameTextField.
094:             */
095:            public JTextField getFirstNameTextField() {
096:                return firstNameTextField;
097:            }
098:
099:            /**
100:             * @return Returns the lastNameTextField.
101:             */
102:            public JTextField getLastNameTextField() {
103:                return lastNameTextField;
104:            }
105:
106:            /**
107:             * @return Returns the middleNameTextField.
108:             */
109:            public JTextField getMiddleNameTextField() {
110:                return middleNameTextField;
111:            }
112:
113:            /**
114:             * @return Returns the namePrefixTextField.
115:             */
116:            public JTextField getNamePrefixTextField() {
117:                return namePrefixTextField;
118:            }
119:
120:            /**
121:             * @return Returns the nameSuffixTextField.
122:             */
123:            public JTextField getNameSuffixTextField() {
124:                return nameSuffixTextField;
125:            }
126:
127:            protected void layoutComponents() {
128:                JPanel mainPanel = new JPanel();
129:                mainPanel.setBorder(BorderFactory.createEmptyBorder(12, 12, 12,
130:                        12));
131:
132:                FormLayout layout = new FormLayout(
133:                        "right:default, 3dlu, default:grow", "");
134:
135:                DefaultFormBuilder b = new DefaultFormBuilder(layout, mainPanel);
136:                b.setRowGroupingEnabled(true);
137:
138:                getContentPane().setLayout(new BorderLayout());
139:                getContentPane().add(mainPanel, BorderLayout.CENTER);
140:
141:                b.append(titleLabel);
142:                b.append(namePrefixTextField);
143:
144:                b.append(fornameLabel);
145:                b.append(firstNameTextField);
146:
147:                b.append(middlenameLabel);
148:                b.append(middleNameTextField);
149:
150:                b.append(lastnameLabel);
151:                b.append(lastNameTextField);
152:
153:                b.append(suffixLabel);
154:                b.append(nameSuffixTextField);
155:
156:                JPanel bottomPanel = new JPanel(new BorderLayout());
157:                bottomPanel.setBorder(new SingleSideEtchedBorder(
158:                        SwingConstants.TOP));
159:
160:                JPanel buttonPanel = new JPanel(new GridLayout(1, 2, 10, 0));
161:                buttonPanel.setBorder(BorderFactory.createEmptyBorder(12, 12,
162:                        12, 12));
163:                bottomPanel.add(buttonPanel, BorderLayout.EAST);
164:
165:                cancelButton = new ButtonWithMnemonic(AddressbookResourceLoader
166:                        .getString(null, "cancel"));
167:                cancelButton.setActionCommand("CANCEL");
168:                cancelButton.addActionListener(this );
169:                buttonPanel.add(cancelButton);
170:                okButton = new ButtonWithMnemonic(AddressbookResourceLoader
171:                        .getString(null, "ok"));
172:                okButton.setActionCommand("OK");
173:                okButton.addActionListener(this );
174:                buttonPanel.add(okButton);
175:
176:                getRootPane().registerKeyboardAction(this , "CANCEL",
177:                        KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
178:                        JComponent.WHEN_IN_FOCUSED_WINDOW);
179:
180:                getRootPane().setDefaultButton(okButton);
181:                getContentPane().add(bottomPanel, BorderLayout.SOUTH);
182:            }
183:
184:            protected void initComponents() {
185:                titleLabel = new LabelWithMnemonic(AddressbookResourceLoader
186:                        .getString("dialog", "contact", "title"));
187:                namePrefixTextField = new JTextField(20);
188:                titleLabel.setLabelFor(namePrefixTextField);
189:                fornameLabel = new LabelWithMnemonic(AddressbookResourceLoader
190:                        .getString("dialog", "contact", "first_name"));
191:                firstNameTextField = new JTextField(20);
192:                fornameLabel.setLabelFor(firstNameTextField);
193:                middlenameLabel = new LabelWithMnemonic(
194:                        AddressbookResourceLoader.getString("dialog",
195:                                "contact", "middle_name"));
196:                middleNameTextField = new JTextField(20);
197:                middlenameLabel.setLabelFor(middleNameTextField);
198:                lastnameLabel = new LabelWithMnemonic(AddressbookResourceLoader
199:                        .getString("dialog", "contact", "last_name"));
200:                lastNameTextField = new JTextField(20);
201:                lastnameLabel.setLabelFor(lastNameTextField);
202:                suffixLabel = new LabelWithMnemonic(AddressbookResourceLoader
203:                        .getString("dialog", "contact", "suffix"));
204:                nameSuffixTextField = new JTextField(20);
205:                suffixLabel.setLabelFor(nameSuffixTextField);
206:            }
207:
208:            public void actionPerformed(ActionEvent event) {
209:                if (event.getActionCommand().equals("OK")) {
210:
211:                    // check if firstname, middlename or lastname contain only valid
212:                    // characters
213:
214:                    if (firstNameTextField.getText() != null) {
215:                        // contains "," comma character
216:                        if (firstNameTextField.getText().indexOf(",") != -1) {
217:                            JOptionPane.showInternalMessageDialog(this ,
218:                                    "Firstname can't contain comma character.");
219:                            return;
220:                        }
221:                    }
222:
223:                    if (middleNameTextField.getText() != null) {
224:                        // contains "," comma character
225:                        if (middleNameTextField.getText().indexOf(",") != -1) {
226:                            JOptionPane
227:                                    .showInternalMessageDialog(this ,
228:                                            "Middle name can't contain comma character.");
229:                            return;
230:                        }
231:                    }
232:
233:                    if (lastNameTextField.getText() != null) {
234:                        // contains "," comma character
235:                        if (lastNameTextField.getText().indexOf(",") != -1) {
236:                            JOptionPane.showInternalMessageDialog(this ,
237:                                    "Lastname can't contain comma character.");
238:                            return;
239:                        }
240:                    }
241:
242:                    success = true;
243:                    setVisible(false);
244:                } else if (event.getActionCommand().equals("CANCEL")) {
245:                    success = false;
246:                    setVisible(false);
247:                }
248:
249:            }
250:
251:            public String getFormattedName() {
252:                StringBuffer buf = new StringBuffer();
253:
254:                if (namePrefixTextField.getText().length() > 0) {
255:                    buf.append(namePrefixTextField.getText() + " ");
256:                }
257:
258:                if (firstNameTextField.getText().length() > 0) {
259:                    buf.append(firstNameTextField.getText() + " ");
260:                }
261:
262:                if (middleNameTextField.getText().length() > 0) {
263:                    buf.append(middleNameTextField.getText() + " ");
264:                }
265:
266:                if (lastNameTextField.getText().length() > 0) {
267:                    buf.append(lastNameTextField.getText() + " ");
268:                }
269:
270:                if (nameSuffixTextField.getText().length() > 0) {
271:                    buf.append(nameSuffixTextField.getText() + " ");
272:                }
273:
274:                return buf.toString();
275:            }
276:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.