Source Code Cross Referenced for EmailAddress.java in  » IDE-Eclipse » ui-examples » org » eclipse » ui » examples » propertysheet » 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 » IDE Eclipse » ui examples » org.eclipse.ui.examples.propertysheet 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*******************************************************************************
002:         * Copyright (c) 2000, 2006 IBM Corporation and others.
003:         * All rights reserved. This program and the accompanying materials
004:         * are made available under the terms of the Eclipse Public License v1.0
005:         * which accompanies this distribution, and is available at
006:         * http://www.eclipse.org/legal/epl-v10.html
007:         *
008:         * Contributors:
009:         *     IBM Corporation - initial API and implementation
010:         *******************************************************************************/package org.eclipse.ui.examples.propertysheet;
011:
012:        import java.util.Vector;
013:
014:        import org.eclipse.ui.views.properties.IPropertyDescriptor;
015:        import org.eclipse.ui.views.properties.IPropertySource;
016:        import org.eclipse.ui.views.properties.PropertyDescriptor;
017:
018:        /**
019:         * Example IPropertySource is editable and whose childern properties are itself not editable.
020:         * The values of "userid" and "mailserver" are parsed from setting "email"
021:         */
022:        public class EmailAddress implements  IPropertySource {
023:
024:            //Property-Value
025:            private String userid;
026:
027:            private String domain;
028:
029:            //Default Property-Value
030:            private static final String USERID_DEFAULT = MessageUtil
031:                    .getString("unknownUser"); //$NON-NLS-1$
032:
033:            private static final String DOMAIN_DEFAULT = MessageUtil
034:                    .getString("unknownDomain"); //$NON-NLS-1$
035:
036:            //Property unique keys
037:            public static final String P_ID_USERID = "EmailAddress.userid"; //$NON-NLS-1$
038:
039:            public static final String P_ID_DOMAIN = "EmailAddress.domain"; //$NON-NLS-1$
040:
041:            //Property display keys
042:            public static final String P_USERID = MessageUtil
043:                    .getString("userid"); //$NON-NLS-1$
044:
045:            public static final String P_DOMAIN = MessageUtil
046:                    .getString("domain"); //$NON-NLS-1$
047:
048:            //Property-Descriptors
049:            private static Vector descriptors;
050:
051:            static {
052:                descriptors = new Vector(2, 2);
053:                //non-editable child properties --> provide no editors
054:                descriptors.addElement(new PropertyDescriptor(P_ID_USERID,
055:                        P_USERID));
056:                descriptors.addElement(new PropertyDescriptor(P_ID_DOMAIN,
057:                        P_DOMAIN));
058:            }
059:
060:            /**
061:             * EmailAddress Default Constructor
062:             */
063:            public EmailAddress() {
064:                super ();
065:            }
066:
067:            /**
068:             * Convience EmailAddress constructor.
069:             * Calls setEmailAddress() to parse emailAddress
070:             * @param emailAddress java.lang.String, in the form userid@domain
071:             * @throws java.lang.IllegalArgumentException, if does not subscribe to form
072:             */
073:            public EmailAddress(String emailAddress)
074:                    throws IllegalArgumentException {
075:                super ();
076:                setEmailAddress(emailAddress);
077:
078:            }
079:
080:            /**
081:             * Returns the descriptors
082:             */
083:            private static Vector getDescriptors() {
084:                return descriptors;
085:            }
086:
087:            /**
088:             * Returns the domain
089:             */
090:            private String getDomain() {
091:                if (domain == null)
092:                    domain = DOMAIN_DEFAULT;
093:                return domain;
094:            }
095:
096:            /* (non-Javadoc)
097:             * Method declared on IPropertySource
098:             */
099:            public Object getEditableValue() {
100:                return this .toString();
101:            }
102:
103:            /* (non-Javadoc)
104:             * Method declared on IPropertySource
105:             */
106:            public IPropertyDescriptor[] getPropertyDescriptors() {
107:                return (IPropertyDescriptor[]) getDescriptors().toArray(
108:                        new IPropertyDescriptor[getDescriptors().size()]);
109:            }
110:
111:            /** 
112:             * The <code>EmailAddress</code> implementation of this
113:             * <code>IPropertySource</code> method returns the following properties
114:             *
115:             * 	1) P_USERID returns String, values before "@"
116:             *	2) P_DOMAIN returns String, values after "@"
117:             *
118:             * Observe the available properties must always equal those listed
119:             * in the property descriptors
120:             */
121:            public Object getPropertyValue(Object propKey) {
122:                if (propKey.equals(P_ID_USERID))
123:                    return getUserid();
124:                if (propKey.equals(P_ID_DOMAIN))
125:                    return getDomain();
126:                return null;
127:            }
128:
129:            /**
130:             * Returns the userid
131:             */
132:            private String getUserid() {
133:                if (userid == null)
134:                    userid = USERID_DEFAULT;
135:                return userid;
136:            }
137:
138:            /* (non-Javadoc)
139:             * Method declared on IPropertySource
140:             */
141:            public boolean isPropertySet(Object property) {
142:                return false;
143:            }
144:
145:            /* (non-Javadoc)
146:             * Method declared on IPropertySource
147:             */
148:            public void resetPropertyValue(Object property) {
149:                return;
150:            }
151:
152:            /**
153:             * Sets the domain
154:             */
155:            private void setDomain(java.lang.String newDomain) {
156:                domain = newDomain;
157:            }
158:
159:            /**
160:             * Parses emailAddress into domain and userid. Throws SetPropertyVetoException
161:             * if emailAddress does not contain an userid and domain seperated by '@'.
162:             *
163:             * @param emailAddress the email address
164:             * @throws IllegalArgumentException
165:             */
166:            private void setEmailAddress(String emailAddress)
167:                    throws IllegalArgumentException {
168:                if (emailAddress == null)
169:                    throw new IllegalArgumentException(MessageUtil
170:                            .getString("emailaddress_cannot_be_set_to_null")); //$NON-NLS-1$
171:                int index = emailAddress.indexOf('@');
172:                int length = emailAddress.length();
173:                if (index > 0 && index < length) {
174:                    setUserid(emailAddress.substring(0, index));
175:                    setDomain(emailAddress.substring(index + 1));
176:                    return;
177:                }
178:                throw new IllegalArgumentException(
179:                        MessageUtil
180:                                .getString("invalid_email_address_format_should_have_been_validated")); //$NON-NLS-1$
181:            }
182:
183:            /** 
184:             * The <code>Address</code> implementation of this
185:             * <code>IPropertySource</code> method 
186:             * defines the following Setable properties
187:             *
188:             *	1) P_USERID, expects String
189:             *	2) P_DOMAIN, expects String
190:             */
191:            public void setPropertyValue(Object name, Object value) {
192:                if (name.equals(P_ID_USERID)) {
193:                    setUserid((String) value);
194:                    return;
195:                }
196:                if (name.equals(P_ID_DOMAIN)) {
197:                    setDomain((String) value);
198:                    return;
199:                }
200:            }
201:
202:            /**
203:             * Sets the userid
204:             */
205:            private void setUserid(String newUserid) {
206:                userid = newUserid;
207:            }
208:
209:            /**
210:             * The value as displayed in the Property Sheet.
211:             * @return java.lang.String
212:             */
213:            public String toString() {
214:                StringBuffer strbuffer = new StringBuffer(getUserid());
215:                strbuffer.append('@');
216:                strbuffer.append(getDomain());
217:                return strbuffer.toString();
218:            }
219:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.